Professional Documents
Culture Documents
This document, and the software described or referenced in it, are confidential and proprietary to Ascential Software Corporation ("Ascential"). They are provided under, and are subject to, the terms and conditions of a license agreement between Ascential and the licensee, and may not be transferred, disclosed, or otherwise provided to third parties, unless otherwise permitted by that agreement. No portion of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of Ascential. The specifications and other information contained in this document for some purposes may not be complete, current, or correct, and are subject to change without notice. NO REPRESENTATION OR OTHER AFFIRMATION OF FACT CONTAINED IN THIS DOCUMENT, INCLUDING WITHOUT LIMITATION STATEMENTS REGARDING CAPACITY, PERFORMANCE, OR SUITABILITY FOR USE OF PRODUCTS OR SOFTWARE DESCRIBED HEREIN, SHALL BE DEEMED TO BE A WARRANTY BY ASCENTIAL FOR ANY PURPOSE OR GIVE RISE TO ANY LIABILITY OF ASCENTIAL WHATSOEVER. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL ASCENTIAL BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. If you are acquiring this software on behalf of the U.S. government, the Government shall have only "Restricted Rights" in the software and related documentation as defined in the Federal Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you are acquiring the software on behalf of the Department of Defense, the software shall be classified as "Commercial Computer Software" and the Government shall have only "Restricted Rights" as defined in Clause 252.227-7013 (c) (1) of DFARs. This product or the use thereof may be covered by or is licensed under one or more of the following issued patents: US6604110, US5727158, US5909681, US5995980, US6272449, US6289474, US6311265, US6330008, US6347310, US6415286; Australian Patent No. 704678; Canadian Patent No. 2205660; European Patent No. 799450; Japanese Patent No. 11500247. 2005 Ascential Software Corporation. All rights reserved. DataStage, EasyLogic, EasyPath, Enterprise Data Quality Management, Iterations, Matchware, Mercator, MetaBroker, Application Integration, Simplified, Ascential, Ascential AuditStage, Ascential DataStage, Ascential ProfileStage, Ascential QualityStage, Ascential Enterprise Integration Suite, Ascential Real-time Integration Services, Ascential MetaStage, and Ascential RTI are trademarks of Ascential Software Corporation or its affiliates and may be registered in the United States or other jurisdictions. The software delivered to Licensee may contain third-party software code. See Legal Notices (LegalNotices.pdf) for more information.
This document contains information about the Ascential DataStage TX Design Studio.
Related Documentation
The Online Library, DK Online Library, and Resource Adapters Online Library buttons on the title page of this document contain links to the documentation for all Ascential DataStage TX products. To learn more about documentation from other Ascential products as they relate to the Design Studio, refer to the following table.
Guide
Design Studio Introduction
Description
Using the Design Studio client components to define data content, define data transformation, and perform business process modeling. This is a companion book to the Design Studio Tutorial. Using the Type Designer to create and edit type trees that describe your data. Describing the Map Designer user interface and providing instruction on specifying mapping rules, configuring map sources and targets, defining map-level settings, and executing a compiled map. Using the Integration Flow Designer as a Design Studio companion and graphical facility to manage collections of related maps. Also graphically organizing these maps, based upon your requirements, into logical collections called systems. Creating component rules in the Type Designer and map rules in the Map Designer using expressions, functions, and reserved words.
iii
Conventions
Conventions
Convention
bold
Used for
Field names, button names, menu items, and keystrokes. Also used to indicate filenames, and window and dialog box names. Information that you need to enter as is. Code examples Placeholders for information that you need to enter. Do not type the greater-/less-than brackets as part of the variable. Indicators used to separate menu options, such as: Start >Programs >Ascential DataStage TX
or
<variable>
>
[A]
B A|B {}
Options in command syntax. Do not type the brackets as part of the option. Elements that can repeat. Indicator used to separate mutually-exclusive elements. Indicator used to identify sets of choices.
Contacting Support
To reach Customer Care, please refer to the information below: Call toll-free: 1-866-INFONOW (1-866-463-6669) Email: support@ascentialsoftware.com Ascential Developer Net: http://developernet.ascential.com Please consult your support agreement for the location and availability of customer support personnel. To find the location and telephone number of the nearest Ascential Software office outside of North America, please visit the Ascential Software Corporation website at http://www.ascentialsoftware.com.
iv
Contents
How to Use This Guide
Related Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv Contacting Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
Introduction
Design Studio Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii Tutorial Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xviii Help Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Menu Commands and Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Your Working Folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xx Design Studio Tutorial Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Unzipping the Ch01.exe File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi Design Studio Tutorial Solutions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxii
Chapter 1
Mapping Basics
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Used in This Chapter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Provided for Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Created for Chapter 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Contact Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Label Record . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting the Map Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exploring the ContactToLabel Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1 1-2 1-2 1-2 1-3 1-3 1-6 1-8 1-9
Contents
Link Between the Map Designer and Type Designer . . . . . . . . . . . . . . . . Viewing Components in the ContactToLabel Map . . . . . . . . . . . . . . . . . . . . . ContactToLabel Map Cards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Map Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Data Object Names in Map Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing the Map Rules on the ContactToLabel Map . . . . . . . . . . . . . . . . Using the Navigator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Building the ContactToLabel Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running the ContactToLabel Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing the ContactToLabel Map Run Results . . . . . . . . . . . . . . . . . . . . . Closing Multiple Run Results Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ContactToLabel Map Source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ContactToLabel Map Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1-14 1-15 1-17 1-19 1-20 1-20 1-21 1-22 1-23 1-24 1-24 1-25 1-26 1-27 1-27 1-28
Chapter 2
vi
Contents
Chapter 3
vii
Contents
Chapter 4
Chapter 5
Chapter 6
viii
Contents
Naming the Preferred Type Tree. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6 Creating the PreferredFile Group Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 Creating the Field Item Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8 Defining the PurchaseDate Item Properties . . . . . . . . . . . . . . . . . . . . . . . . . 6-9 Defining the Customer Group Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-10 Defining the PreferredFile Group Type. . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13 Saving and Analyzing the Preferred Type Tree . . . . . . . . . . . . . . . . . . . . . 6-16 MakePreferredData Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16 Creating the PreferredFile Output Card . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17 Creating Multiple Occurrences of Customer . . . . . . . . . . . . . . . . . . . . . . . 6-17 Creating the Map Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-18 Using the TODATETIME Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-19 Generating Customer[2] and Customer[3] Output . . . . . . . . . . . . . . . . . . 6-20 Building and Running the MakePreferredData Map . . . . . . . . . . . . . . . . . 6-20 Extracting Contacts that are Preferred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-21 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-22
Chapter 7
ix
Contents
Creating the F_MakeSalesRecord Functional Map . . . . . . . . . . . . . . . . . . . . . Using the LOOKUP Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Functional Map Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modify the F_MakeSalesRecord Functional Map . . . . . . . . . . . . . . . . . . . Generating the Output of SalesRecord . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the SORTDOWN Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the SortRegion_Descending Map . . . . . . . . . . . . . . . . . . . . . . . . . . . Optional Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the SEARCHUP Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Creating the RegionReport_SEARCHUP Map . . . . . . . . . . . . . . . . . . . . . . . . . Optional Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7-12 7-12 7-13 7-14 7-15 7-15 7-15 7-17 7-17 7-18 7-19
Chapter 8
Chapter 9
Contents
Chapter 10
Chapter 11
xi
Contents
Chapter 12
Chapter 13
Chapter 14
xii
Contents
Files Provided for Chapter 14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files You Create or Modify for Chapter 14 . . . . . . . . . . . . . . . . . . . . . . . . . Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RandomDetails.mtt Type Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Map Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RandomDetails Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generating the RandomDetails Output . . . . . . . . . . . . . . . . . . . . . . . . . . . F_MakePO2 Functional Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F_MakeDetail2 Functional Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . RandomDetails Executable Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Generating the PO2.txt Output File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing Run Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
14-1 14-2 14-3 14-4 14-4 14-4 14-5 14-5 14-6 14-6 14-7 14-7 14-8
Chapter 15
Chapter 16
Exporting a Map
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16-1
xiii
Contents
Files Used in This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Provided for Chapter 16 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files You Create or Modify for Chapter 16. . . . . . . . . . . . . . . . . . . . . . . . . XML Format for Maps and Map Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exporting the New_PO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . XML DTD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Viewing the Exported XML File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exported Map Rules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exported Map Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Exported Card Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16-1 16-1 16-2 16-2 16-3 16-3 16-4 16-4 16-5 16-5 16-6
Chapter 17
Importing a Map
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Used in This Chapter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files Provided for Chapter 17 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files You Create or Modify for Chapter 17. . . . . . . . . . . . . . . . . . . . . . . . . Importing a Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17-1 17-1 17-1 17-2 17-2 17-3
Chapter 18
Chapter 19
xiv
Contents
Files Provided for Chapter 19 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Files You Create or Modify for Chapter 19 . . . . . . . . . . . . . . . . . . . . . . . . . Scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Increment.mtt Type Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the INDEX Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . MakePO Functional Map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the COUNT Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Using the Index Value [LAST] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Chapter 20
Index
xv
Contents
xvi
Introduction
The Ascential DataStage TX Design Studio Tutorial provides a practical hands-on learning experience for the components of the Design Studio. The Introduction to the Design Studio book is a prerequisite for using this tutorial and is a part of the Online Library, which is delivered on the product CD. The concepts of using the Design Studio and terms such as mapping, type trees, and other Design Studio terminology are presented in the Introduction to the Design Studio. The exercises in this tutorial provide experience with performing basic and advanced functions using the client components of the Design Studio.
Tutorial Objectives
Introduction
Command or Event Server manages the execution of maps at run time. Run-time functions are not discussed in this tutorial. This tutorial focuses on the design-time functions performed in three of these applications: the Map Designer, the Type Designer, and the Integration Flow Designer. Due to the database-dependent nature of the Database Interface Designer, no tutorial exercises using that designer are included in this tutorial.
Tutorial Objectives
Completing this tutorial will enable you to use the Design Studio applications. You will be able to: Create and modify type trees and maps. Use functions in map rules. Include cross-referenced data in your maps. Define breaks in data. Create functional maps to process specific data transformation. Create nested functional maps. Use functions in map rules. Use functions in component rules. Associated related data. Build business rules in your data transformation. Create trace files. Export a map. Build a validation map.
xviii
Introduction
Help Overview
Help Overview
The Design Studios extensive and versatile Help system provides you with immediate assistance and reference information. There are several ways to access Help while using the Design Studio. To access Help Choose one of the following access methods: From the Help menu, choose Contents. The complete Ascential DataStage TX Help system appears.
Locate a topic in the contents. Click the Index tab to search by keyword. Click the Search tab to perform a text search. Click to browse related Help topics.
To access context-sensitive Help Choose one of the following access methods: Press F1. Right-click any window, dialog, or field and choose Help from the context menu. From the Help menu, choose Whats This Help. Click any open window, tool on the toolbar, or command on a menu. or Click Whats This? on the toolbar ( ) or in a dialog ( ) and click any menu commands, controls, tools, and toolbars.
xix
Installation
Introduction
Right-click icons in any Navigator to display their context menu. Double-click icons in any Navigator. Right-click any data object to display context menus. Right-click the light blue title bar of the input and output cards in the Map Designer to display context menus. Right-click the map rule in the Map Designer rule cell on the output card (or Rule Bar) to display its context menu.
Note Commands are available as listed above; however, most procedural information in this tutorial uses the menu access as a default method. Use the activation method most convenient for you.
Installation
This tutorial requires that the Design Studio applications be installed on your system. Ascential DataStage TX products include a simple installation program. The Design Studio applications are installed as one of the components of the installation program. Refer to the release notes for installation instructions. The files required to use the exercises in this Design Studio Tutorial are provided in the default Ascential DataStage TX installation tutorial folder. For the purposes of this document, it is assumed that the Design Studio is installed in the default installation directory on drive C. The tutorial files are provided as self-extracting zip files under the exercises and solutions folders in the install_dir\tutorial folder.
Note <install_dir> refers to the directory where your product is installed.
xx
Introduction
(where nn is the chapter number). install_dir used in this context not italicized, is the literal value, not the variable value, which would be italicized and represent the product installation location. For example, install_dir\tutorial\my_exercises\ch01 would be your unzipped working folder location for Chapter 1 exercises and install_dir\tutorial\my_solutions\ch01 would be your unzipped working folder location for Chapter 1 solutions.
xxi
Introduction
Use the Windows Explorer to navigate to the install_dir\tutorial\exercises folder and locate the Ch01.exe file. Double-click the Ch01.exe file. The WinZip Self-Extractor dialog appears with the install_dir\tutorial\my_exercises\ch01 default path in the Unzip to folder: box. You can use the default path and also specify a different path by navigating to it after clicking the Browse button or by entering the path directly in the Unzip to folder: box.
3 4
Click Unzip and then when the window appears confirming the success of the unzip operation, click OK. Click Close in the WinZip Self-Extractor dialog to exit the WinZip application. The lesson files for Chapter 1 are extracted to your install_dir\tutorial\my_exercises\ch01 working folder.
Repeat these steps to extract the contents of all the exercise chapter files.
xxii
Introduction
Note References to the folder structure into where the exercise and solutions files are unzipped will be referenced as ..\tutorial in subsequent chapters.
xxiii
Introduction
xxiv
1
Mapping Basics
In this exercise, you will open, build, and run a map in the Map Designer. You will also examine the data structure of the input and output files.
Objectives
This exercise introduces basic mapping skills used in the Map Designer. By completing the exercises for Chapter 1, you will learn how to: Identify map file types and map file name extensions. Open a map source file. Select a map in the Navigator. Expand and collapse maps in the Navigator. Expand and collapse input and output cards in the Navigator. Expand and collapse nested data objects on input and output cards. Identify map rules. Resize, dock, and float the Rule Bar. Build a map. Run a map. View the run results of a map. Identify the link between the Type Designer and the Map Designer.
1-1
Mapping Basics
Note When using Type Designer and *.OMT file is generated as a result of updating or modifying a *.MTT file generated from a previous release of Ascential DataStage TX. Note If a window appears in the Design Studio with only the title bar displayed, place the cursor on the bottom of the bar. Left-click and pull the window open for its optimum usage.
Name
Contact.txt
Description
Input data text file that contains a single contact record of information about one customer Type tree describing the contact data (input) Type tree describing the label data (output) Map source file containing the ContactToLabel map, which maps a contact to a label
Type tree
Contact.mtt
Type tree
Label.mtt
Mail.mms
Name
Label.txt
Description
Output data text file that contains a single label record produced by the ContactToLabel map
1-2
Mapping Basics
Scenario
Icon
File type
Compiled map file
Name
ContactToLabel.mmc
Description
Compiled map file generated from the build process Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files created automatically during the Save process
Map build analysis results file Map source options file Backup type tree and map files
The default behavior is to create backup files with the .bak filename extension when each type tree file or map source file is saved. Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
You have a simple Contact.txt text file consisting of one record that contains information about a customer. Using the file as input, you need to generate a mailing label for this customer.
Contact Record
The Contact.txt file (the contents of which are shown below) is a simple text file with one record containing information about a customer. The record includes the name of the contact person at the company, the company name, the address, and the phone number. This input data must be described as a file (consisting of one contact record), and as a record (consisting of multiple data fields). In the Contact.mtt type tree: The input data is a file that consists of a single contact record. The data object that represents the file containing the contact record is ContactFile. The input data is also a contact record consisting of many data fields delimited by commas. The data object that represents the contact record is Contact.
1-3
Scenario
Mapping Basics
The Type Designer is the design component used to specify, define, and manage type definitions. Type trees are maintained and created in the Type Designer, although type trees can also be created using the Type Tree Maker, the Importer Wizard in the Type Designer, and the Database Interface Designer. The type definitions of the Contact record are defined in the Contact.mtt type tree file. Type definitions define the data in a classification hierarchy and do not reflect the data structure. The type tree organizes types alphabetically (for example, AreaCode, City, Company, and so on).
The ContactFile group type represents the file that contains records of contacts. Group types contain components. A component represents a data object that is part of another data object. The Contact group type is a component of the ContactFile group. The ContactFile group represents the entire file of contact records. The Contact group represents a contact record. Multiple contact records may exist in the same file.
1-4
Mapping Basics
Scenario
The components of the Contact group type are defined in the Contact group window. Each component represents a field of the Contact record. The Contact group contains the components of the contact record in the order they appear in the data stream.
The Contact group window is displayed by double-clicking the group type in the Contact.mtt type tree window. The title bar in the group window shows the compositional hierarchy. For example, the title bar of Contact group window illustrates that Contact is a subtype of Data.
1-5
Scenario
Mapping Basics
In the Contact.txt input file, commas are used to separate (delimit) the fields. Use any text editor to view the Contact.txt input data file.
Label Record
The Label.txt output file you want to generate will consist of one mailing label. The label consists of four data fields, each on a separate line.
1-6
Mapping Basics
Scenario
The Label.mtt type tree defines the data in a classification hierarchy for the output file. The LabelFile group type represents the file that contains the label record. The component of LabelFile is the Label group, which represents the label record.
The components of the Label group type are defined in the Label group window. Each component represents a portion of the Label record. The Label group contains the components of the label record in the order they appear in the data stream. The Label.mtt type tree defines the data of the Label record, as shown in the following illustration.
1-7
Mapping Basics
From the Windows Start menu, choose Programs. Choose Ascential DataStage TX n.n > Design Studio > Map Designer, where n.n represents the version number. The Startup window appears with the default startup option Open an existing map source file selected.
Click OK. The Open dialog appears. Navigate to your Chapter 1 working folder: ..\tutorial\my_exercises\ch01. Select the Mail.mms map source file and click Open. The Map Designer opens and the Mail.mms map source file is displayed in the main window and the Navigator.
4 5
1-8
Mapping Basics
Note The installation program adds an entry for the Map Designer to the Ascential DataStage TX program folder. If you do not see the Ascential DataStage TX program on the Start menu, contact your system administrator.
1-9
Mapping Basics
A map defines input and output specifications. The ContactToLabel map uses the Contact.txt input file and produces the Label.txt output file.
Each input and output card represents one data object, identified by selecting a type from a type tree. A card may represent an object in a row, a row in a record, the entire record, or the entire file. Each card specifies a type tree and a type as part of the card definition. This type, and the type tree that contains it, is the link between the
1-10
Mapping Basics
Type Designer and the Map Designer that defines the structure and properties of the data in the card. Input cards represent input data. Output card represent output data and contains the map rules that transform that data. Therefore, only the output card has a rule column. Each card specifies a name, a type tree and a type as part of the card definition. The name of the input card can be anything. In this case, the name of the input card is ContactFile, which describes the data object it represents. Each card represents one data object, identified by selecting a type from a type tree. The ContactFile input card specifies the Contact.mtt type tree and the ContactFile Data type (the ContactFile group type is a subtype of Data). This type, and the type tree that contains it, is the link between the Type Designer and the Map Designer that defines the structure and properties of the data in the card. The ContactFile input card contains the definition of the input for the ContactToLabel map including information such as source identification (Contact.txt file), retrieval specifics, and the behavior that should occur during processing. The ContactFile input card definition is shown below.
1-11
Mapping Basics
The Label output card defines how the output is generated. The Target specifies the output be written to the File specified for the FilePath setting. If a path is not specified for the FilePath, the map source file location is used. The settings of the Label output card, shown below, specify the output file Label.txt be written to the map source file folder, in this case ..\tutorial\my_exercises\ch01.
1-12
Mapping Basics
The Map Designer is the application in the Design Studio that specifies data transformation logic in the form of map rules. The map rules for the data objects on the Label output card specify the data transformation logic used to generate a mailing label. The compositional hierarchy of the output card defines the structure of the output data.
1-13
Mapping Basics
The Label output card represents the Label group type. The Label group contains the components that define the fields of the Label record (such as Full Name, Company, and so on). Components are listed from top to bottom in the order they appear in the data stream. The structure of the output card defines the data in a compositional hierarchy.
The Label output card #1 in the ContactToLabel map specifies the Label group type and the Label.mtt type tree as the link between the Map Designer and the Type Designer.
1-14 Design Studio Tutorial
Mapping Basics
In the Navigator, map source files can be expanded to view all of the maps they contain. Maps can be expanded to view the input and output cards. Icons that display a plus sign (+) may be expanded. Icons that display a minus sign (-) may be contracted. In the List view of the Navigator, the ContactToLabel map can be expanded to view the input and output cards.
1-15
Mapping Basics
Position the cursor on the right edge of the Navigator and resize by dragging.
The List view of the Navigator is the default view. If you are not viewing the Navigator in List view, click the List tab. Click the plus sign (+) to the left of the ContactToLabel map icon. The names of the input and output cards appears. The input and output cards may also be expanded to view all of the input and output cards.
Expand the Input Cards. The input card #1 named ContactFile appears. Expand the Output Cards. The output card #1 named Label appears.
1-16
Mapping Basics
1-17
Mapping Basics
The output card #1 Label appears in the To window. The To window represents the output data to which you are mapping. The output card #1 Label is displayed in the To window. The output card Label represents the Label group type defined in the Label.mtt type tree. In the To window, the Label type on the output card #1 Label is currently expanded to display the map rules on the data objects contained in the Label card. To expand the icon in the ContactFile input card
1 2
Click the plus sign (+) to the left of the ContactFile group type to display its components. Expand the Contact group type to view its components.
Note The Contact group type has a component range of (s), indicating a minimum of 0 (zero) occurrences and a maximum of some unknown number. Data objects with a range of (0:s) are shown the data object name followed by (s) on the cards. The Contact type appears as Contact (s) because of this component range.
Component ranges are defined in the Type Designer. The component range of the Contact group type is defined in the Contact.mtt type tree. There are an unknown number of contact records (represented by the Contact group type) that exist in the file of contacts (represented by the ContactFile group type).
1-18
Mapping Basics
Map Rules
Click the minus sign (-) to the left of the Label group type to hide its components. The components of the Label group are contracted.
Map Rules
Map rules are used in output cards of a map to define how output data is built. Map rules are required for output data generation. If there is no map rule, there is no output data. Each output card has a rule column in which you enter map rules. Each map rule begins with an equal sign (=), followed by an expression. A map rule is an expression that evaluates to data. An expression is any valid combination of literals, data object names, operators, functions, and map names. The expression in a map rule generates the desired data. Map rules are entered in the Rule Bar. Portions of the map rule are visible in the rule cell on the output card.
You edit and view the map rule in the Rule Bar, which can be docked or floated.
1-19
Map Rules
Mapping Basics
The default position of the Rule Bar is docked beneath the menu bar. If the Rule Bar is not visible, you can view the Rule Bar. You can resize, dock, or float the Rule Bar. To view the Rule Bar
1
From the View menu, choose Rule Bar. The Rule Bar is docked beneath the menu bar (or shown in the last position).
Position the cursor beneath the docked Rule Bar until splitter cursor appears. Drag the cursor until the entire map rule is visible.
1-20
Mapping Basics
Map Rules
To show or hide the Navigator From the View menu, select Navigator. A check mark appears next to Navigator on the View menu indicating that the Navigator is displayed. To hide the Navigator when it is displayed, select Hide from the context menu of the Navigator or repeat step 1 to clear the Navigator selection from the View menu. To dock or float the Navigator
1 2
Right-click the top border of the Navigator. From the context menu, select Allow Docking. If a check mark is displayed next to the Allow Docking command on the context menu, the Navigator can be docked.
1-21
Mapping Basics
After selecting Allow Docking, you can toggle between a docked window and a floated window by double-clicking the top border of the Navigator.
Note The Rule Bar can also be docked or floated. Experiment with moving, docking, and floating the Rule Bar.
1-22
Mapping Basics
From the Map menu, choose Build. Or click (Build map) on the toolbar.
The message Building a map appears briefly in a message box, which closes automatically.
Results
If no errors occur, executing the Build command generates the following files in the same folder as the map source file: ContactToLabel.mmc (compiled map file) ContactToLabel.mme (map build analysis results file) Build results of a map provide information on errors and warnings that occur during the map build process. Use Windows Explorer to view the files generated during the build process.
1-23
Mapping Basics
Select the ContactToLabel map in the Navigator. Run the map using one of the following methods:
From the Map menu, choose Run. Click (Run map) on the toolbar.
The Command Server dialog appears. The Command Server dialog displays the map name, the map execution, the total number of input objects found, and the total number of output objects built. These statistics are shown to indicate progress and results.
Results
Executing the Run command generates the Label.txt output text file.
1-24
Mapping Basics
Select the ContactToLabel map in the Navigator. View the run results using one of the following methods:
From the Map menu, choose Run Results. Click (View run results) on the toolbar.
Click OK. Each data source and target appears in its own window.
1-25
Mapping Basics
Tip
To quickly view all run results of a map, press Ctrl + Shift and click (View run results).
Select the map in the Navigator. Click (Close all run results).
Note The (Close all run results) tool is available on the toolbar only when the corresponding map is selected in the Navigator and run results windows are displayed.
1-26
Mapping Basics
Summary
The position of the run results windows is retained for each map. The next time the run results are viewed, the run results windows appear in the same position. The mapname.mopt file contains map-specific options. The .mopt file is created in the map folder when the map is saved. You can close multiple data windows at once. To close all data windows
1
Summary
The Mail.mms map source file contains the ContactToLabel map. Input cards define the source of the map. Output cards define the target of the map.
1-27
Summary
Mapping Basics
The Contact input card on the ContactToLabel map represents the Contact group type. Therefore, the structure of the input card is the same as the structure of the Contact group type as defined in the Contact group window. In the Type Designer In the Map Designer
The Contact group window contains the components of the Contact record in the order they appear in the data stream.
The Contact input card definition specifies the Contact.mtt type tree and the Contact Data type. The Contact type defines the structure and properties of the data in the card. The specification of the Contact type, and the Contact.mtt type tree that contains it, is the link between the Type Designer and the Map Designer that defines the structure and properties of the data in the card.
Mapping Basics
Summary
The Label group type defines the components of the Label record. The components of the Label group type are arranged in the order they appear in the data stream. The Label output card on the ContactToLabel map represents the Label group type. For that reason, the structure of the Label output card is the same as the structure of the Label group type as defined in the Label group window. In the Type Designer In the Map Designer
The Label group window contains the components of the Label record in the order they appear in the data stream.
The Label output card definition specifies the Label.mtt type tree and the Label Data type. The Label type defines the structure and properties of the data in the card. The specification of the Label type and the Label.mtt type tree that contains it is the link between the Type Designer and the Map Designer that defines the structure and properties of the data in the card.
1-29
Summary
Mapping Basics
1-30
2
Modifying the Contact Type Tree
The ContactToLabel map introduced in Chapter 1 uses a single Customer record to generate a single mailing label. The Contact.mtt type tree represents the input data. The Customer record in Chapter 1 did not have a middle name or initial. In this exercise, you modify the input Contact.mtt type tree to add a definition for the middle name field.
Objectives
This exercise modifies an existing type tree and introduces component ranges. By completing the exercises for Chapter 2, you will learn how to use the Type Designer to: View and understand type properties. View associated input data file. Open and close group windows components. Modify a type tree to create a new data field. Add a component to a group type. Add a component range to an optional component. Access Help for a field in a dialog. Analyze and save a type tree.
2-1
Name
Contact.mtt
Description
Type tree describing the contact data (input). Input data text file that contains multiple contact records of information about customers.
Text file
FullContact.txt
Name
Contact.mtt
Description
Type tree describing the contact data (input). Type tree analysis message file created when a type tree is analyzed. Backup type tree file created when the type tree is saved.
Text file
Contact.dbe
Contact.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
2-2
Scenario
Scenario
You have a Contact text file consisting of multiple records that contain information about a customer. Using the file of multiple records as input, you need to generate one mailing label for each contact record in the input data. The input data contains optional data objects; the records of some customers contain middle names or initials. You need to modify the type tree that represents the input data to contain a middle name field.
FullContact Record
The FullContact.txt file is a file of an unknown number of records that contain information about customers. The records include the name of the contact person at the company, the company name, the address, and the phone number. The middle name is optional. Use any text editor to view the FullContact.txt text input data file. This input data can be described as a file consisting of multiple contact records with each contact record consisting of many data fields.
The type definitions of the Contact input record file, without consideration of the middle name or initial, are defined in the Contact.mtt type tree. You will modify the Contact.mtt type tree to include the type definition of the middle name field.
2-3
Label Output
The output data is a file of mailing labels. We want to generate one label for every contact record in the input. The labels will consist of four data fields, each on a separate line. The labels should look like the following:
James P. Adams ABC Co. 29 Frankford Rd Bloomington, IL 60525 Maria B. Miller Conrad Corp 1234 Smith St Buffalo Grove, CA 60089 Fred A. Smith Sand Inc. Beach Street Pismo Beach, FL 33321
From the Windows Start menu, choose Programs. Choose Ascential DataStage TX n.n > Design Studio > Type Designer, where n.n represents the version number. The Startup dialog appears with the default startup option Open an existing type tree file selected.
Click OK. The Open dialog appears. Navigate to your Chapter 2 working folder: ..\tutorial\my_exercises\ch02. Select the Contact.mtt type tree file and click Open. The Type Designer opens and the Contact.mtt type tree file is displayed in the type tree window.
4 5
2-4
In the type tree window, double-click the Contact group type. The Contact group window opens.
2-5
An uncomplicated way to close a group window is to use the standard Windows upper left corner window controls.
2-6
Type Properties
Double-click the green icon in the left side of the group window title bar.
Type Properties
The properties and definitions of all data objects are defined in the type tree. The properties and definition of each data object in the input data, and each data object in the output data, must be defined in a type tree to achieve the desired data transformation. In the type tree window, the color of the icon in the type tree provides a visual indication for the Class of the data object. Category icons are red. Group icons are green. Item icons are blue.
In the type tree window, select the Contact group type. Click (Properties) on the toolbar.
The Properties for Contact Data window appears. The Properties window may be sized, docked, or floated as needed. The default position of the Properties window for new type trees is docked. The title bar for docked windows is not displayed. To view the title bar, undock the window.
2-7
The properties of the Contact group type describe the properties of each contact record. The properties in the Properties for Contact Data window define the Contact data object.
Value
Sequence Explicit
Description
Each component of this group is validated sequentially. The format of this group relies on syntax to separate components. Each component can be identified by its position, or by a delimiter in the data. Delimiters appear for missing components.
2-8
Components of Contact
Property
Component Syntax
Value
Delimited
Description
The syntax of the Contact group is delimited, where a delimiter in the data separates each component. The literal comma (,) delimiter separates (delimits) the components of each contact record. A terminator is a syntax object that appears at the end of a data object. Defining the terminator as literal identifies the terminator as a known constant value. The value of the literal terminator of the Contact group is <NL> (new line character). This non-platform specific terminator specifies a new line. For example, for the Contact record on Windows, the <NL> new line character represents a carriage return character followed by a line feed character. For the Contact record on a UNIX system, the <NL> new line character represents a line feed character.
Delimiter
Literal
Terminator
Literal
Value
<NL>
Components of Contact
The Contact group window defines the components of the Contact input data. The components of the Contact group type define the data objects for the contact records in the order they appear in the data stream. In the Contact group window composition hierarchy shown below, there is not a data definition for the Middle Name Field.
2-9
Classification Hierarchy
Classification Hierarchy
The classification hierarchy shown in the Contact.mtt type tree window illustrates that the First and Last item types are subtypes of Name. The Name item type is a subtype of the Field item type. We could also express this classification hierarchy by saying that First Name and Last Name are subtypes of Field. Two type names separated by a space, such as First Name, indicate a classification subtype relationship.
2-10
Classification Hierarchy
In the Contact.mtt type tree window, select the Name item type. From the Type menu, choose Add. The confirmation dialog appears.
Click Yes. A new type is added as a subtype of Name. The new type is highlighted in the type tree with the default name NewType1.
2-11
Classification Hierarchy
4 5
In the type tree window, enter Middle as the name of the new type. Press Enter. The new type name Middle appears and the Name type is selected. The Properties window, displaying the properties of Name, also appears.
2-12
Classification Hierarchy
In the type tree window, select the Middle type. From the Type menu, choose Properties. The Properties window appears. (If the Properties window is already open, the properties are updated for the selected type.)
3 4
Click the plus sign (+) to expand the Item Subclass property. Expand the Size (content) property.
The size of an item includes separators and signs, but not initiator, terminator, release, or pad characters. The Min property defines the minimum number of bytes of the item. The Middle Name Field has a minimum size of 1 byte. The Min value of 1 was inherited from the Name type. The property was inherited from the selected Name type when the Middle type was created as a subtype of Name.
Tip
For information on the values for specific type properties, access Help on any type property by right-clicking the property in the Properties window and selecting Help from the context menu.
2-13
In the type tree window, double-click the Contact group type. The Contact group window appears. Resize, move, and arrange windows to view the Contact group window and the type tree window. If the Properties window is still open, move it or close it as needed. Drag the Middle type from the type tree window to the correct position in the Contact group window. This position is determined by the data structure.
2-14
The Middle Name Field type name appears in the component cell.
2-15
Component Ranges
The component range of a data object defines the number of consecutive occurrences of that component. If a component range is other than the default (1:1), it appears in the group window after the component name in parenthesis. The component rule bar appears on group and category windows. The component rule bar is used to specify the component range and component rules for the selected component in the window. You can enter text in the component rule bar or drag objects from type trees into component rules. For detailed information on component rules, see the Type Designer Reference Guide. The Middle Name Field is an optional component. Optional components must have 0 as the minimum component range value. The range for Middle Name Field is (0:1), indicating a minimum of zero occurrences and a maximum of one occurrence. To enter a component range for Middle Name Field
1
In the Contact group window, select the Middle Name Field component. The Middle Name Field component name appears in the component rule bar.
2-16
From the Component menu, choose Set Range. The Set Range dialog appears with the default component range of (1:1).
Click OK. The optional component range of (0:1) appears next to Middle Name Field.
5 6
Close the Contact Data group window to save the addition of the Middle component. When prompted for confirmation, click Yes to save changes.
2-17
Summary
stream. The analysis indicates if something in your data definition may prevent accurate data mapping.
Note The type tree analyzer checks your data definitions for logical consistency, but does not compare your definitions to your actual data.
Logical analysis addresses the integrity of the relationships that you define. Structural analysis addresses the integrity of the underlying database. Typically, you should not encounter structural analysis errors. To analyze and save the Contact.mtt type tree
1
With current focus on the Contact type tree window, from the Tree menu, choose Analyze > Logic Only. The Analyze Tree (Logic Only) window appears showing the results of the analysis.
2 3
Summary
The contact records for each customer may include a middle name. The data object that represents the middle name must be defined in the Contact.mtt type tree. The data object that represents the middle name field already exists in the Label.mtt type tree as the FullName Field. The map rule for FullName Field provides the logic for building the FullName on output. The Contact.mtt type tree was modified to add the Middle item type.
2-18
Summary
The Middle item type was added as a component to the Contact group type. Spaces in type name indicate a subtype relationship in a classification hierarchy. The type name Middle Name Field indicates that Middle is a subtype of Name, and Name is a subtype of Field. The optional component range of (0:1) was added to the Middle Name Field item type. The Contact.mtt type tree was analyzed and saved.
2-19
Summary
2-20
3
Modifying the Mail.mss Map Source File
The ContactToLabel map introduced in Chapter 1 used a single customer record to generate a single mailing label. In this exercise, you copy the ContactToLabel map to a new name in the same Mail.mms map source file. You map multiple records that may contain the optional middle names to multiple labels. After you complete the exercises in this chapter, the Mail.mms map source file will contain the original ContactToLabel map and the new ContactToFullLabel map. The ContactToFullLabel map uses the FullContact.txt as the data source, and generates the Label.txt output file.
Objectives
This exercise copies an input card to create a new map, and introduces map rules and functions. By completing the exercises for Chapter 3, you will learn how to use the Map Designer to: Copy an existing card to a new map. Create an output card. Use the What's This Help. Create a functional map using the Functional Map Wizard. Enter and edit map rules. Use the IF function to evaluate a conditional expression.
3-1
Name
FullContact.txt
Description
Input data text file that contains multiple contact records of information about customers. Type tree describing the contact data (input). Type tree describing the label data (output). Map source file you opened in Chapter 1.
Type tree
Contact.mtt
Type tree
Label.mtt
Mail.mms
Name
Label.txt
Description
Output data text file that contains multiple label records produced by the ContactToLabel map. Output data text file generated by the ContactToLabel map. Compiled map file generated from the build process.
Text file
FullLabel.txt
ContactToFullLabel.mmc
3-2
Scenario
Icon
File type
Name
Description
Map build analysis results file generated from the build process. Type tree analysis message file created when a type tree is analyzed. Map options file created automatically during the Save process. Backup type tree files and map source files are created automatically during the Save process.
Map build ContactToFullLabel.mme analysis results file Type tree analysis message file Map source options file Backup type tree and map files *.dbe
Mail.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this tutorial.
Scenario
You have a file that consists of multiple records containing information about your customers. This source data is the FullContact.txt text file. The FullContact.txt file of records contains optional data objects; the records of some customers contain middle names or middle initials. Using the FullContact.txt file of multiple records as input, you want to generate one mailing label for each contact record in the input data. The data object on the Label output card in the ContactToLabel map represents a single label. The value of the Type Name on this Label output card is Label. The Label group type represents a single label. The output card Type Name must be changed to the data object that represents the output file of label records. The data object that represents the entire file of label records is LabelFile. The map rules on the Label output card specify the logic for generating the mailing labels. These map rules must be modified to conditionally include the middle name or initial in the generated mailing labels.
3-3
From the Windows Start menu, choose Programs. Choose Ascential DataStage TX n.n > Design Studio > Map Designer, where n.n represents the version number. The Startup dialog appears with the default startup option Open an existing map source file selected.
Click OK. The Open dialog appears. Navigate to your Chapter 3 working folder: ..\tutorial\my_exercises\ch03. Select the Mail.mms map file and click Open. In the Navigator, select the #1 ContactFile input card in the ContactToLabel map. From the Card menu, choose Copy. The Copy Card dialog appears. For the Into fields:
4 5 6 7
Leave Mail.mms in the File field. Enter ContactToFullLabel for the Map field.
Note Copying a card to a new map automatically copies the input card and generates the new map at the same time. The ContactToFullLabel map does not exist, so it will be created.
3-4
10 Enter ContactFile as the name of the new input card in the 11 Click OK.
The ContactToFullLabel map is created in the Mail.mms map. The ContactFile input card exists in the new ContactToFullLabel map.
Tip
Use the button to access a description for each field in a dialog. Click , and then click the field for which you want information.
In the Navigator, double-click the ContactToFullLabel map to select it. The title bar of the Map Designer displays the ContactToFullLabel map name.
3-5
In the ContactToFullLabel map, select the To window. From the Card menu, choose New. The Add Output Card dialog appears. For the CardName, enter LabelFile.
3-6
(browse).
The Setting and Value columns in the input and output card dialogs can be resized. Position splitter cursor over the column divider and drag to the desired size. To navigate in the output card, use the Tab key to move the cursor from field to field or use the mouse to move your insertion cursor.
(browse).
3-7
3-8
8 9
Click OK to close the Select Type dialog. For the Target, the default File is correct.
Note The Target is the destination of the output data after it is built by the map.
10 For the FilePath, enter FullLabel.txt.
3-9
Note The target output file name is entered (not selected) because it does not exist and will be generated by the map.
11 Click OK.
On the #1 LabelFile output card, expand LabelFile. Expand Label. The only available (white) rule cell is on the output Label.
3-10
Note The Label data object has a component range of (s), which indicates some unknown number of Labels. The component range of (s) appears on cards next to the type name.
applications, and so on. Think of an executable map as the main map, the top-level map. Executable maps are compiled and run. In the Navigator, the icon for an executable map is blue .
Functional Map: A functional map is referenced by another map through a map rule. A functional map maps just a portion of the entire data. Data sources and targets are not specified in the input and output cards of functional maps. Functional maps are not compiled and run. In the Navigator, the icon for a functional map (or an incomplete executable map) is gray .
Functional Maps
A functional map is like a sub-routine; it maps a portion of data at a time. A functional map takes one or more input objects and generates one output object. The use of functional maps is very common. Almost every executable map created will use at least one functional map. A functional map and the executable map that calls it must be in the same map source file (.mms). To map a group in the input to a different group in the output, use a functional map. The presence of an output component with a range of more than one is one determining factor of when to use a functional map.
Note The Label data object component range of (s) indicates the number of Label(s) to be created is based on the number of Contact(s).
Another important factor in determining when to use a functional map is when you want to transform the data: mapping from one or more types to a different type. For the ContactToFullLabel map, we want to map from the First Name Field, Middle Name Field, and Last Name Field to the FullName Field. We know we need to use a functional map because: The number of a certain output group, Label, that we want to create is based on the occurrences of some input data, Contact. The types are different types (First Name Field, Middle Name Field, and Last Name Field to FullName Field).
3-12
The map is a functional map (F_ is a conventional prefix for functional map names). The F_MakeLabels functional map name describes the function of the functional map (to make labels).
Parentheses follow the functional map name. The input data object (Contact group type) that is necessary to create one occurrence of the output object is positioned in these parentheses. In the rule cell of the Label group type, the syntax to call a functional map is:
The syntax of a functional map expression is similar to the syntax of a function. The inputs and the output of a functional map are data objects.
3-13
The input arguments of a functional map are the objects necessary to create one occurrence of the output object where the map rule is. The input argument of the functional map that will build a label for each contact record is the data object that represents a single contact, the Contact group type. The output of the functional map is the single data object to be generated. The output argument of the functional map is the data object that represents a single label, the Label group type. To enter the map rule to call the functional map
1
On the ContactFile input card, locate the Contact group type. This is the data object that represents the single contact.
Tip
Expand the ContactFile group type to see the nested Contact group type.
On the output card, position the cursor in the rule cell corresponding to the Label group type. This is the data object that represents a single label. Enter the required equal sign (=) and F_MakeLabels (the name of the functional map to be generated) and open and close parentheses (). F_MakeLabels is a practical name that identifies the map as a functional map (the use of the F_ prefix) and describes the purpose (to make labels). The text appears in the Rule Bar.
3-14
By default, color-coding is enabled for the Rule Bar. When colorcoding is enabled, each element of a map rule has a different color. Elements of map rules include: Syntax Type Name Map Name Literal Number Reserved (Words and Symbols) Comment
4
From the #1 Contact File input card, drag the Contact group type to the Rule Bar between the parentheses.
Press Enter to commit the map rule. The map rule for the Label group type appears in the Rule Bar and in the rule cell on the output card.
3-15
specifies: F_MakeLabels is the name of the functional map. The input data object is Contact, which is a component of ContactFile.
In the ContactToFullLabel map on the LabelFile output card for the Label group type, put current focus on the map rule for the Label group type (this is the data object that requires additional processing). This map rule calls the functional map:
=F_MakeLabels(Contact:ContactFile)
3-16
From the Rules menu, choose Functional Map Wizard. The Functional Map Wizard dialog appears.
Select the Out output card and click the Edit button.
3-17
In the Card Attributes dialog, assign a meaningful name to the output card. Shown below, the name of the functional map output card is changed to LabelsOut in the Card Name field.
5 6
Click OK to close the Card Attributes dialog for the output card. Edit the input card and assign a meaningful name: ContactsIn. The green face icon ( ) indicates successful functional map type tree and type selections.
3-18
Note Placing the curser on the Tree name will show you with the entire tree file path.
7
Click Create. The F_MakeLabels functional map is created. The contents of the Functional Map Wizard dialog are automatically cleared after a functional map is successfully created.
Click Close.
On the Composition tab of the Navigator, functional maps appear underneath the executable map that calls it.
3-19
Select the F_MakeLabels functional map in the Navigator. Select Company Field in the input card. Drag Company Field from the input card into the rule cell of Company Field on the output card.
3-20
The equal sign (=) and the Company Field:ContactsIn data object name appear in the rule cell. (They will appear in the Rule Bar after the map rule is committed.)
Place current focus in the Rule Bar or the rule cell and press Enter to commit the map rule.
3-21
Note When dragging a data object into a rule cell, the equal sign is automatically inserted.
Position the cursor at top of the column until the splitter appears. Drag the splitter until the column is the desired size.
3-22
Select the object Street Field on the input card. Drag it into the rule cell for Street Field on the output card. Place current focus in the Rule Bar or the rule cell and press Enter to commit the map rule.
The map rule is committed after you press Enter. The equal sign (=) and the Street Field:ContactsIn object name appear in the rule cell for Street Field.
A comma and a space should appear between the city and state, and another space should appear between the state and zip code. The CityStateZip Field should look like this:
Bloomington, IL 60525
The map rule entered for the CityStateZip Field is a text concatenation, including the City, State, and ZipCode fields from ContactsIn, spaces, and a comma. To concatenate text, use the plus sign (+). Literal text values must be enclosed in quotation marks (" ").
3-23
Note Syntax errors in the Rule Bar are indicated with underlines. While the map rule is under construction it is normal to see underlines.
Select City Field on the input card. Drag City Field into the rule cell of CityStateZip Field. =City Field:ContactsIn appears in the Rule Bar. Click in the Rule Bar to the right of City Field:ContactsIn and type a space. This space is entered to improve readability. Spaces can be entered around object names and operators and do not affect the evaluation of the rule.
This instruction requires four spaces: After the + to improve readability After the comma in the quotation marks to enter a literal comma and a literal space Before the + to improve readability After the + to improve readability
5 6 7 8
Drag the State Field from the input card up into the Rule Bar. Type + " " + (this adds a literal space between State and Zip Code). Drag ZipCode Field up into the Rule Bar. Press Enter to commit the map rule. The map rule for CityStateZip Field should look like this:
3-24
PRESENT Function
The PRESENT function checks for the presence of an object. If the object is present, the function returns TRUE. If the object is not present, the function returns FALSE. The syntax of the PRESENT function is:
PRESENT (object_to_look_for)
IF Function
This function evaluates a conditional expression, returning one value if true, another if false. There are three arguments in the IF function. The first argument is a condition. If it is TRUE, the second argument is performed. If it is FALSE, the third argument is performed. The syntax of the IF function is:
IF (test_this, result_if_true [, result_if_false])
3-25
The braces that surround the third argument [, result_if_false] indicate that the comma and the third argument are optional.
First Name Field:ContactsIn + " " + Middle Name Field:ContactsIn + " " + Last Name Field:ContactsIn, First Name Field:ContactsIn + " " + Last Name Field:ContactsIn)
Select the rule cell next to FullName Field. From the Rules menu, choose Insert Function. The Insert Function dialog appears. Select the IF function in the Functions list.
3-26
Tip
4
Placing current focus in the Functions list and typing the letter I jumps directly to the I functions. Click Insert. =IF( ) appears in the Rule Bar. The cursor is positioned between the parentheses, ready for the first argument of the function.
5 6 7
Click Close to close the Insert Function dialog. To make the rule easier to read, enter a few spaces after the opening parenthesis (. Insert the PRESENT function and close the Insert Function dialog. =IF( PRESENT( ) ) appears in the Rule Bar. The cursor is positioned between the parentheses, ready for the first argument of the PRESENT function.
8 9
To improve readability, type a few spaces next to the PRESENT function, before the opening parenthesis (. Drag the Middle Name Field from the ContactsIn input card into the Rule Bar, between the parentheses of the PRESENT function. comma (,) and a space.
3-27
Note Underlines in map rules indicate syntax errors. Check the syntax of the map rule if you see underlines in your map rule.
Drag First Name Field from the input card into the Rule Bar after the command and space just typed. Type + " " + Type a space after the plus sign (+). This space is required.
4 5
Drag Middle Name Field into the Rule Bar. Type + ". " + This period and space provide the literal period (.) to follow the middle initial and the space that separates the middle initial from the last name.
Type a space after the plus sign (+). This space is required. Drag Last Name Field into the Rule Bar.
Type a comma and a space after the Last Name Field:ContactsIn and before the closing parenthesis ).
3-28
Drag First Name Field into the Rule Bar, after the space just typed. Type + " " + Type a space after the plus sign (+). This space is required. Drag Last Name Field into the Rule Bar. Press Enter. When finished, the map rule should look like this:
4 5
The map rule can be formatted so that it is more easily read. If desired, create a new line in the Rule Bar where you want one. New lines may be entered outside of object names, and outside of literals enclosed in quotation marks. Adding a new line within quotation marks is not valid.
Note How a new line is entered depends on the Commit rules with setting. The Enter key is the default commit key. The Commit rules with setting in the Tools > Options dialog defines the commit key. This tutorial assumes Enter is the commit key.
3-29
Place the cursor where you want to create a new line in the Rule Bar. Press Ctrl + Enter. As needed, add spaces after new lines and between commas to improve readability.
The same map rule can be more easily read with the addition of some new lines, and spaces.
Note Non-printable characters are not displayed in the Rule Bar, but appear in the rule cell on the To window as .
In the Navigator, select the Mail map source file. From the File menu, choose Save.
Design Studio Tutorial
3-30
In the Navigator, select the ContactToFullLabel map. From the Map menu, choose Build. The message Building a map appears briefly in a message box, which closes automatically.
If build errors occur the Organizer window appears automatically. For help in resolving errors, see the Map Designer Reference Guide. To view map build errors
1 2 3
In the Organizer window, click the Build Results tab. Fix the errors, if any. Build the map again.
In the Navigator, select the ContactToFullLabel map. From the Map menu, choose Run. The Command Server window appears. The Command Server window shows the map execution progress, the total number of input objects found (3841 contact record fields), and the total number of output objects built (1801 labels).
3-31
Results
Executing the Map > Run command generates the FullLabel.txt output text file.
Select the ContactToFullLabel map in the Navigator. Click (View run results) on the toolbar.
To view only the output, clear the check box next to #1 ContactFile.
3-32
Click OK.
The results window for the #1 LabelFile output card on the ContactToFullLabel map appears. Note that the middle initials appear in the output file where needed, and that Mary Jones of McCormick Enterprises has no middle name.
3-33
Summary
Check the output results in the Map Designer and in the destination directory using Explorer.
Summary
The Mail.mms map source file contains the original ContactToLabel map. You copied this ContactToLabel map to create a new map named ContactToFullLabel. The ContactToFullLabel map has the same cards as the ContactToLabel map. You edited the #1 LabelFile output card so the data object represented by this card is the entire file of labels: the LabelFile group type. The Label group type is a component of LabelFile. You created a map rule that called the F_MakeLabels functional map. You used the Functional Map Wizard to automatically create a functional map.
The map rules to generate labels with an optional middle name were entered on the objects on the output card of the functional map. These map rules used the IF and the PRESENT functions.
The rules on the #1 LabelFile output card became unresolved due to the difference in data structure. The unresolved rules appear automatically on the Organizer window on the Unresolved Rules tab. These may be reused if needed, but you deleted them and redefined the required map rules on a functional map.
3-34
Summary
The ContactToFullLabel specifies FullContact.txt as the data source, and generates the Label.txt output file. Optionally, the ContactToFullLabel output card was edited to generate the FullLabel.txt output file. The ContactToFullLabel map was saved, built, and run. The results of the map were viewed.
3-35
Summary
3-36
4
Using the UNIQUE Function
The ContactToFullLabel map created in Chapter 3 maps a file of multiple contact records to a file of multiple labels. After analyzing the output, it is clear that some of the contact records in the address file occur multiple times.
Objectives
This exercise copies and modifies an existing map, and introduces the UNIQUE function. By completing the exercises for Chapter 4, you will learn how to: Modify an existing map. Copy an input card to create a new map. Copy an input card to an output card. Edit card settings. Use the UNIQUE function to avoid creating duplicate records.
4-1
Name
FullContact.txt
Description
Input data text file that contains multiple contact records of information about customers Type tree describing the contact data (input) Type tree describing the label data (output) Map source file you opened in Chapter 1
Type tree
Contact.mtt
Type tree
Label.mtt
Mail.mms
Name
unique.txt
Description
Output data text file containing unique records (no duplicates) Compiled map file that creates a file of unique records Map build analysis results file generated from the build process Work file for input card #1 in the UniqueContacts map Type tree analysis message file created when a type tree is analyzed
Compiled map file Map build analysis results file Input card #1 work file Type tree analysis message file
UniqueContacts.mmc
UniqueContacts.mme
UniqueContacts.I01
*.dbe
4-2
Scenario
Icon
File type
Map build analysis results file Map source options file Backup type tree and map files
Name
*.mme
Description
Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Mail.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
The FullContact.txt file that contains your customer records contains duplicate records. You must generate an output file that contains only the unique contact records. The output file containing only the unique records can then be used as the input file to generate the label file.
Open the Mail.mms map source file. Copy the ContactFile input card in the ContactToFullLabel map to a new map named UniqueContacts. This is the name of the map to which you want to copy the selected card. Because there is no UniqueContacts map in Mail.mms, a new map by that name will be created.
4-3
Enter ContactFile as the name of the new input card in the Name field.
Click OK. The UniqueContacts map is created with the ContactFile input card.
4-4
To copy the ContactFile input card to an output card using the Navigator
1 2
Expand the UniqueContacts map in the Mail.mms map source file in the List view of the Navigator. Expand Input Cards for the UniqueContacts map to display the ContactFile input card in the Navigator.
Click the #1 ContactFile card, then press Ctrl and drag #1 ContactFile to Output Cards.
4-5
Editing a Card
Click Yes to confirm that you want to copy the card as an output card. A new card appears in the Navigator under Output Cards named #1 ContactFile_1.
Editing a Card
The newly created #1 ContactFile_1 output card should be renamed to represent the output it generates. In the Edit Output Card dialog, change the setting to direct the output of the UniqueLabels map to a text file named unique.txt. To rename the #1 ContactFile_1 output card and change the Target > FilePath
1 2
In the Navigator, select the #1 ContactFile_1 output card. Edit the card using one of the following methods:
or
4-6
Editing a Card
Right-click the #1 ContactFile_1 card in the Navigator and select Edit from the context menu.
Click OK.
When the data objects are expanded on the ContactFile input card and the UniqueContactsFile output card, the cards should look like this:
4-7
Editing a Card
In this map, you want to map only the unique contact records. Use the UNIQUE function, which evaluates a series of objects, belonging to some type. The UNIQUE function returns the unique data objects in that series. The syntax of the UNIQUE function is:
UNIQUE (series_whose_unique_objects_you_want)
Expand the objects on the output card until Contact is displayed. Insert the UNIQUE function for the Contact data object on the UniqueContactsFile output card. UNIQUE ( ) appears in the Rule Bar. Drag Contact from the input card into the Rule Bar between the parentheses. Press Enter to commit the map rule. Build and run the map. View the run results. The input file FullContact.txt and the output file unique.txt appear in separate windows. The UNIQUE function eliminated duplicate contact records in the output file.
3 4 5 6
4-8
Summary
Save the Mail.mms map source file to retain changes to the UniqueContacts map.
Summary
The Mail.mms map source file now contains three executable maps and one functional map.
Map Name
ContactToLabel ContactToFullLabel F_MakeLabels UniqueContacts
Type of map
Executable Executable Functional Executable
Target = File
Contact.txt FullContact.txt n/a unique.txt
Output Generated
A single mailing label. A file containing multiple mailing labels. A mailing label record for each contact record. A file containing only the unique contact records (duplicate records were not generated).
The UniqueContacts map was created when the ContactFile input card was copied from the ContactToFullLabel map.
4-9
Summary
When created, the UniqueContacts map contained only the ContactFile input card that was copied from the ContactToFullLabel map. The ContactFile input card was copied to the output card. Copying the input card to an output card enabled the input data to be mapped. The UNIQUE function was added to the map rule for the Contact data object. The output of the map was the unique.txt file, which contained only the unique records (no duplicate records).
4-10
5
Using the EXTRACT Function
The ContactToFullLabel map in the Mail.mms map source file can be modified to extract only the Florida addresses.
Objectives
This exercise modifies an existing map and introduces the EXTRACT function. By completing the exercises for Chapter 5, you will learn how to: Modify an existing map. Use the right-click context menu to edit a card. Use the EXTRACT function to extract data for which a specified condition is true. Copy a map.
5-1
Name
unique.txt
Description
Input data text file that contains multiple contact records of information about customers Type tree describing the contact data (input) Type tree describing the label data (output) Map source file containing three executable and one functional map
Type tree
Contact.mtt
Type tree
Label.mtt
Mail.mms
Name
FloridaContacts.txt
Description
Output data text file containing contact records with Florida addresses Compiled map file that creates a file of unique records from Florida Map build analysis results file generated from the build process Type tree analysis message file created when a type tree is analyzed Map build analysis results file generated from the build process Map options file created automatically during the Save process
FloridaLabels.mmc
FloridaLabels.mme
Type tree analysis *.dbe message file Map build analysis results file Map source options file *.mme
Mail.mopt
5-2
Scenario
Icon
File type
Backup type tree and map files
Name
*.bak
Description
Backup type tree files and map source files are created automatically during the Save process
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
From the FullContact.txt input file, you need to generate a list of labels for the Florida addresses only.
Open the Mail.mms map source file. Make the ContactToFullLabel map the active map by selecting it in the Navigator.
Note The title bar displays the name of the active map.
From the Map menu, choose Copy to copy the ContactToFullLabel map to the FloridaLabels map. In the Copy as field, enter FloridaLabels as the name of the new map.
Tip
5-3
5-4
Tip
The input file is defined by the value of the Source > FilePath setting on the ContactFile input card.
The output file is defined by the value of the Target > FilePath setting on the LabelFile output card.
5-5
The EXTRACT function has two arguments: The first argument is the series to be evaluated: objects_to_extract The second argument is the condition: condition_to_evaluate EXTRACT returns the data objects of the first argument if a corresponding evaluation of the second argument is TRUE. For our purposes, the objects are extracted from the contact records. The condition to evaluate is whether the state is Florida. In the FloridaLabels map, the map rule containing the call for the functional map is on the Label data object.
Note The map rules are shown in a floating Rule Bar.
5-6
To use the EXTRACT function in the call to the F_MakeLabels functional map
1 2
Display the map rule for the Label data object on the FloridaLabelFile output card. Click in the Rule Bar between the open parenthesis and Contact:ContactFile.
Insert the EXTRACT function. EXTRACT( ) appears in the map rule. The underline in the map rule indicates a syntax error (the map rule is incomplete, so you can ignore the indicator at this point).
Because we want to extract from the contact records, the first argument of the EXTRACT function is the Contact:ContactFile data object.
4 5 6
For this reason, delete the close parenthesis before Contact:ContactFile. Type a comma after Contact:ContactFile to enter the second argument of the EXTRACT function. Drag State Field from the input card into the Rule Bar after the comma.
5-7
The second argument of the EXTRACT function requires a condition. Our condition is whether a state is Florida.
7 8
To extract the contact records that have a state equal to Florida, enter ="FL" The first ) closes the EXTRACT function. Type ) to complete the map rule.
Note Map rule syntax requires a close parenthesis for every open parenthesis.
9
Press Enter to commit the map rule. With a floated Rule Bar, the map should look like this:
5-8
Summary
The unique.txt input file and the FloridaContacts.txt output file are displayed in separate windows. Each label that was generated has the value FL for the State Field. Two records contain Florida addresses.
12 Save the Mail.mms map source file.
Optionally, copy the FloridaLabels map to a different name. Modify the EXTRACT map rule to extract a different state.
Note Close all maps, type trees, and text files.
Summary
The Mail.mms map source file now contains the FloridaLabels executable map. The FloridaLabels executable map was created as a copy of the ContactToFullLabel map. You changed the source of the input card. You defined a new target for the output card. You defined a map rule to extract the contact records for Florida addresses. The FloridaLabels.txt file was generated with two Florida addresses.
Note Close all maps, type trees, and text files.
5-9
Summary
5-10
6
Using the OR Function With a Lookup File
You need to generate labels for only the preferred customers in the address file.
Objectives
This exercise introduces creating type trees and the concept of creating a lookup file. By completing the exercises for Chapter 6, you will learn how to: Create a type tree that represents preferred customers. Change type properties in the Properties window. Use type inheritance for creating subtypes. Define group types as Explicit or Implicit. Define terminators and delimiters. Index the output object to generate a specific number of occurrences. Use the TODATETIME function to convert a text literal to a date format. Generate a lookup file of preferred customers as output of a map.
6-1
Name
FullContact.txt
Description
Input data text file that contains multiple contact records of information about customers Map source file
Mail.mms
Type tree
Contact.mtt
Type tree describing the contact data (input) Type tree describing the label data (output)
Type tree
Label.mtt
Name
MakePreferredData.mmc
Description
Compiled map that generates the preferred customer lookup file Compiled map that generates the label file containing only preferred customers Input data file containing a list of preferred customers. This file is created as an output of the MakePreferredData map Type tree describing the lookup file listing preferred customers
ContactToFullLabel.mmc
Text file
Lookup.txt
Type tree
Preferred.mtt
6-2
Scenario
Icon
File type
Text file
Name
PreferredLabels.txt
Description
Output data file containing labels for preferred customers produced by the PreferredLabels map Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Type tree analysis message file Map build analysis results file Map source options file
*.dbe
*.mme
*.mopt
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
You need to create a file containing the names of preferred customers. You can then use this lookup file to determine whether a contact is a preferred customer, and generate labels for preferred customers only.
6-3
The data structure of this lookup file must be defined in a type tree.
The type tree for the lookup file must have item types for: Company Field ID Field PurchaseDate Field The type tree for the lookup file must have the following group types: Customer - represents customer records PreferredFile - represents the file containing customer records
6-4
created as subtypes of Field. These types inherit the properties of Field. The PurchaseDate type can also be created as a subtype of Field, although the Item Subclass property must be Date. These item types have Class = Item, Partitioned = No, and the default Order subtypes = Ascending. The table below displays the properties of the item types, their interpretations, minimum content size, and maximum content size.
Type Name
Field Company ID PurchaseDate
Item Subclass
Text Text Text Date & Time
Interpret as
Character Character Character Character
Min. Size
0 0 0
Max. Size
The Field types share common properties. They are: Subclass = Text Interpret as = Character Size (content) > Min = 0 Size (content) > Max = <none>
Note The PurchaseDate item type has a different Item Subclass and no minimum size.
From the File menu, choose New. A new type tree with the TypeTree1 default name is created.
The type tree window is displayed with a root type of ROOT. The ROOT type has a red icon, indicating ROOT is a category type. A category type is used for organizing other types in a type tree. The root category type of a type tree is named ROOT by default. You may change this name to any name suitable for your purpose.
6-5
Right-click the ROOT type in the type tree window and choose Properties from the context menu. The Properties window appears. For the Name property, enter Data. Press Enter (or click anywhere else to save the property change).
2 3
Before populating the type tree, save it to establish the name of the type tree file.
or
Click
Navigate to your current working folder: ..tutorial\my_exercises\ch06. By default, the file is named TypeTree1.mtt. In the File name field, enter Preferred to change the name of the type tree.
Note The .mtt extension is automatically added to the filename.
Click Save. The Preferred.mtt name of the type tree file is displayed in the title bar of the type tree window.
6-6
Next, create the group types. Generally, the order in which types are created does not matter. For this tutorial, however, please follow these steps. Create the group types Customer and PreferredFile. The Customer group type represents the contact records. The PreferredFile group type represents the file that contains these records. To create the Customer group type
1
From the Type menu, choose Add. The confirmation dialog appears.
Click Yes to add a new type. The new type is created with the default name NewType1.
Note Use the Properties window to view and change the type properties as required.
4
Change the Name of the type to Customer by typing it in the Name field.
Note If the NewType1 name is selected in the type tree window, typing any other name replaces NewType1.
6-7
Change the Class to Group by selecting the Group class from the Class drop-down list. The confirmation dialog appears.
Click Yes to change the class of the Customer type from Category to Group. The green color of the icon in the type tree window indicates the Customer type is a group type.
Select the Data root type before creating the PreferredFile group type. The default Group Subclass > Format property of Implicit is correct for the PreferredFile group type.
6-8
Add a new item type as a subtype of the Data root type. Change the properties of the new type in the Properties window:
Change the Name to Field. Change the Class to Item. The default Item Subclass is Text.
Add the Company, ID, and PurchaseDate item types as subtypes of Field.
The Company Field and ID Field item types are correctly defined as text items.
Display the PurchaseDate item type properties. For the Item Subclass property, select Date & Time.
6-9
For the Item Subclass > Format property, click The Date Time dialog appears. For the Date format, select YYMMDD.
(browse).
Click OK.
6-10
To generate one record per line, records must be terminated with a <NL>. Each field in the record is delimited with forward and backward slashes /\. The Component Syntax must be Delimited. The Delimiter > Value must be defined with the literal delimiters. The explicit format relies on syntax to separate components. Each component of the record can be identified by the /\ delimiter in the data. The Customer group type must be defined with Format = Explicit.
Note To access help on any type property, put focus on that property in the Properties window and press F1.
Double-click the Customer type in the type tree window. The Customer group window appears. Drag the components from the type tree window to the Customer group window.
Arrange the components of Customer Data in the order they appear in the data: Company Field, ID Field, and then PurchaseDate Field. Close and save the Customer group window.
6-11
Display the Customer group type properties. For the Type Syntax > Terminator property, select Literal. For the Value, click Select the NL symbol. The Description of New Line appears on the status line. Click the Insert button. <NL> appears in the Value field of the Symbols dialog. Click OK. The Terminator > Value = <NL>. (browse).
For the Component Syntax property, select Delimited. For the Delimiter property, select Literal.
6-12
For the Delimiter > Value, enter the literal forward and backward slashes /\.
Note The literal delimiter text does not require quotation marks.
6-13
Open the PreferredFile group window. Drag the Customer group type to the PreferredFile group window. Expand the Customer group type to view the nested components.
6-14
Right-click the Customer group type in the PreferredFile group window and select Set Range from the context menu.
Click OK. The range (s) appears after the Customer component name.
6-15
MakePreferredData Map
MakePreferredData Map
You have created the Preferred.mtt type tree to describe the preferred customer data. Now you must create, build, and run a map to generate that data. The Mail.mms map source file is provided. You can easily add another map to this map source file. To create the MakePreferredDate map
1 2 3 4
Open and select the Mail.mms map source file in the Map Designer Navigator. From the Map menu, choose New. In the Create New Map dialog, enter MakePreferredData in the New map name field. Click OK.
6-16
MakePreferredData Map
Note An input card is not required for the MakePreferredData map because the output is generated from text literals entered in the map rules (and not from a data source defined in the input card).
6-17
MakePreferredData Map
To generate a specific number of occurrences of the Customer group type, you can index Customer on the output card. When indexed, the object name on the output card refers to a particular occurrence of that data object. The index of the occurrence appears in square brackets immediately after its name. After you have indexed an item output, you can enter a map rule for it. You need to generate three occurrences of the Customer records in the output of the MakePreferredData map. To index the Customer group type
1
On the PreferredFile output card, right-click the Customer(s) group type and choose Add Index from the context menu. Another occurrence of the Customer group type appears, followed by the index number in square brackets [1 ].
Index the Customer group type two more times to generate three records.
6-18
MakePreferredData Map
For the Company Field component of Customer, enter the literal company names enclosed in quotation marks. For the ID Field component, enter the literal text enclosed in quotation marks. For the PurchaseDate Field, you must enter the literal text for the date and convert this to a date time format using the TODATETIME function. (For detailed instructions about this, refer to "Using the TODATETIME Function" .) To enter =NONE for the Customer(s) group type, from the Rules menu, choose Insert NONE if Empty.
{date_time_format_string} ] )
The text_to_convert is the text literal date you enter in the map rule. The date_time_format_string specifies the date time format.
The default format for the date_time_format_string is CCYYMMDDHH24MMSS. The text literal of "010322" does not match the default date time format. Therefore, you must specify the format of YYMMDD.
In the PreferredFile output card #1 map rule for the PurchaseDate Field, insert the TODATETIME function. =TODATETIME () appears in the Rule Bar In the parentheses, enter:
The text_to_convert A comma (,) The date_time_format_string enclosed in quotation marks " "
6-19
MakePreferredData Map
The map rule for the first occurrence of the PurchaseDate Field is:
=TODATETIME ("010322","yymmdd")
6-20
The CardName should describe the input. Name the card LookupFile. The TypeTree must describe the input. Select the Preferred type tree. The Type must represent the data object of the card. Select Preferred File Data.
Edit a setting on the output card to generate the PreferredLabels.txt. Modify the map rule that generates the functional map to use the OR function. The OR function evaluates a series of conditions and returns TRUE if at least one condition evaluates to TRUE, otherwise returns FALSE. You can use the OR function when you want to test if one of a series of conditions is true. In this case, you want to test if the Company Field in the Contact group (which is a component of ContactFile) is equal to the Company Field in the Customer group (a component of LookupFile). Your map rule should look like this:
6-21
Summary
Note To view help on any function, place current focus on that function in the Insert Function dialog and press F1.
The run results of the modified ContactToFullLabel map show two input files (FullContact.txt and lookup.txt) and one output file (PreferredLabels.txt).
Summary
You created the MakePreferredData map to generate the lookup.txt file. You modified the ContactToFullLabel map by adding an input card to use the preferred.txt, changing the filename of the output file.
6-22
Summary
The call for the functional map uses the OR function and the EXTRACT function to generate a list of labels for preferred customers only.
6-23
Summary
6-24
7
Using Cross-Referenced Data
This chapter explains how to decide which function to use when cross-referencing data, and how to use that function. A map example using each of these functions is provided.
Objectives
This chapter defines how to cross-reference data from another source and incorporate it into the output. By completing the exercises for Chapter 7, you will learn how to: Create group types to represent records. Create group types to represent files of records. Add components to group types. Define component ranges. Use the LOOKUP function to locate an object in a list that is not organized in any particular order. Use the SORTDOWN function to locate an object in a list that is in descending order. Use the SEARCHUP function to locate an object in a list that is in ascending order. [Optional] Use the SORTUP function to locate an object in a list that is in ascending order. [Optional] Use the SEARCHDOWN function to locate an object in a list that is in descending order.
7-1
Name
Region.txt
Description
Cross-reference data file containing a list of zip codes and the region to which each belongs Input cross-reference data file containing a list of zip codes and the region to which each belongs. The records in this file are sorted in descending order. Input cross-reference data file containing a list of zip codes and the region to which each belongs. The records in this file are sorted in ascending order. Input data file containing a series of unique contacts Type tree describing the contact data (input) Incomplete type tree describing the region lookup file item types (input) and region report item types (output)
Text file
Region_desc.txt
Text file
Region_asc.txt
Text file
unique.txt
Type tree
Contact.mtt
Type tree
Customer.mtt
Name
Customer.mms
Description
Map source file containing the RegionReport map that creates a file of sales records
7-2
Icon
File type
Compiled map file Text file
Name
CreateRegionFile.mmc
Description
Compiled map file that generates a file of zip codes and regions Cross-reference data file containing a list of zip codes and the region to which each belongs [Optional] Compiled map file that generates a file of zip codes and regions sorted in descending order Output data file produced by the SortRegion_Descending map Compiled map file that generates a file of zip codes and regions sorted in ascending order Output data file produced by the SortRegion_Ascending map Compiled map file that generates a region report file of customer contacts, company name, and region Output data file produced by the RegionReport map [Optional] Compiled map file that generates a region report file of customer contacts, company name, and region Output data file produced by the RegionReport_SEARCHUP map Compiled map file that generates a region report file of customer contacts, company name, and region [Optional] Output data file produced by the RegionReport_SEARCHDOWN map Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process
Region.txt
RegionReport.mmc
RegionReport.txt
Type tree analysis message file Map build analysis results file
*.dbe
*.mme
7-3
Scenario
Icon
File type
Map source options file Backup type tree and map files
Name
*.mopt *.bak
Description
Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
You have the unique.txt file of unique contacts. This data is not in any particular sequence. The geographical region information is not contained in this input file. You need to generate a cross-reference region.txt file that contains records identifying the name of each customer contact, their company, and their geographical region. You need to generate the regionreport.txt file that contains the contact name, company name, and the region.
7-4
Region Data
The data is a file you will generate as an output of the Customer map. You want to generate the region.txt file to contain the zip code
7-5
and the region for each record. This data file is delimited with two spaces between fields.
60525 60089 33321 60012 19444 44444 North West South North West South
Properties of Record
The record data is presented sequentially. The Group Subclass = Sequence. The format of the data relies on syntax to separate components. Each component can be identified by its position, or by a delimiter in the data. The Group Subclass > Format = Explicit. The Format > Component Syntax = Delimited. Components are separated by two spaces. For the Delimiter > (browse) and use the Symbols Value, enter <SP><SP> or click dialog. The location of the delimiter in the region.txt file is between the data objects, therefore the Delimiter > Location = Infix. An infix delimiter appears between each component. The properties for the Record group type should be as follows:
7-6
Components of Record
Define ZipCode Field and Region Field as components of Record.
7-7
Properties of RegionRecordsFile
Define the properties of RegionRecordsFile. The RegionRecordsFile group type has a Format of Implicit. The group has no syntax property that distinguishes one component from another.
Component of RegionRecordsFile
Define the Record group type as a component or RegionRecordsFile. Define the component range of Record. It is unknown how many records are in the data.
7-8
Output Types
Output Types
You need to generate an output file that consists of sales records. Create the group types that represent this data. Create the SalesRecord group type to represent these records. Create the Report group type to represent the file that contains the records. Each sales record contains the contact person, the company name, and the region. The Contact Field, Company Field, and Region Field item types represent these fields in each sales record.
7-9
The F_MakeSalesRecord functional map to use the two data sources (the customer contact and the lookup record data) to create the sales record where the zip code in the region lookup file is equal to the zip code in the contact file.
The CreateRegionFile map has no input card. The CreateRegionFile map has a single output card.
Name the ouput card RegionFile. Enter map rules in the output card to generate the region.txt data file. Define the Type and the TypeTree for the output card.
Index six records. Enter literal values on the output card to generate a cross-reference file that contains zip codes and their corresponding geographical region.
Note You learned how to index an output in Chapter 6. For more information about indexing an output, see the Map Designer Reference Guide.
7-10
Build and run this map to generate the region.txt output file.
7-11
The LOOKUP function returns the first object in the series if a corresponding evaluation of the condition is TRUE. The syntax of the LOOKUP function is:
LOOKUP (series_to_search, condition_to_evaluate)
The map rule for the SalesRecord object on the output card is:
=F_MakesSalesRecord (Contact:ContactFile, LOOKUP (Record:RegionLookupFile, ZipCode Field:Record:RegionLookupFile = ZipCode Field:Contact:ContactFile ))
For the SalesRecord executable map, place current focus on the map rule for the SalesRecord component on the output card.
Enter the map rule to generate the F_MakesSalesRecord functional map using the LOOKUP function:
=F_MakeSalesRecord (Contact:ContactFile, LOOKUP (Record:RegionLookupFile, ZipCode Field:.:RegionLookupFile = ZipCode Field:.:ContactFile))
3 4
From the Rules menu, choose Functional Map Wizard. [Optional] In the Functional Map Wizard dialog, edit the card names to provide meaningful names.
7-13
5 6
7-14
The item_series_to_sort is the record containing the zip code and region.
7-15
Copy the new SortRegion_Descending input card #1 to an output card in the same SortRegion_Descending map. Name the new output card SortRegionLookupFile.
Define the SortRegionLookupFile output card to generate the region_desc.txt file. The SortRegion_Descending map uses the SORTDOWN function and sorts the output in descending order and should look like this:
7-16
Optional Exercise
Build and run the SortRegion_Descending map. The run results are sorted in descending order.
Optional Exercise
Create a SortRegion_Ascending map and use the SORTUP function to generate results in ascending order. Use the region_asc.txt file as the data source of the input card.
7-17
The SEARCHUP function has three arguments: The first argument is the object to get that is related to the ordered series, which is in ascending order: object_to_get The second argument is the ascending ordered series of objects: ordered_series_to_search The third argument is the members of the series that are compared to the second argument: object_to_compare
Note For the SEARCHUP function to work properly, the second argument ordered_series_to_search must be in ascending order.
Modify the input card #2 RegionLookupFile to use the region_asc.txt as the data source. Modify the map rule that calls the functional map to use the SEARCHUP function instead of LOOKUP function:
=F_MakeSalesRecord ( Contact:ContactFile , SEARCHUP ( Record:RegionLookupFile , ZipCode Field:.:RegionLookupFile , ZipCode Field:.:ContactFile ) )
Build and run the RegionReport_SEARCHUP map. The run results are displayed.
7-18
Optional Exercise
Copy the RegionReport executable map in the Customer.mms map source file to create the new RegionReport_SEARCHDOWN executable map. Modify the input card #2 RegionLookupFile to use the region_desc.txt as the data source. Modify the map rule that calls the functional map to use the SEARCHDOWN function instead of LOOKUP function. Modify the output card to generate the RegionReportDOWN.txt.
Note Close all maps, type trees, and text files.
7-19
7-20
8
Using the CHOOSE Function
This chapter explains how to decide which function to use when cross-referencing data, and how to use that function. A map example using each of these functions is provided.
Objectives
This chapter defines how to locate an object in a certain position in a series. By completing the exercises for Chapter 8, you will learn how to: Use the CHOOSE function to locate an object in a certain position in a series.
Name
prizes.txt
Description
Input data file containing a list of the prizes for each place
8-1
Icon
File type
Text file
Name
winners.txt
Description
Input data file containing the list of winners in order based on the prize won Type tree describing the winner data (input), the prize data (input) and the congratulation data (output)
Type tree
Raffle.mtt
Name
Raffle.mtt
Description
Type tree describing the winner data (input), the prize data (input) and the congratulation data (output) Source map file containing the RaffleCongrats map, which creates a file of records congratulating each winner and listing the prize won Compiled map file that generates a text file containing a message for each winner and lists the prize won Output data file produced by the RaffleCongrats map Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Raffle.mms
RaffleCongrats.mmc
Text file
Congratulate.txt
Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
*.dbe
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solution folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this tutorial.
8-2
Scenario
Scenario
You have the results of a raffle drawing. The winners.txt file lists the winners in the raffle. The first person in the file won first place, the second person won second place, and so on. The winners.txt file lists the winners in order; Helen is the first prizewinner, Florence is second, and so on:
Helen Florence Karen Glenn Betty Robert Toby
The prizes.txt file lists the raffle prizes and the place a winner must achieve in order to receive that prize. Here is the prizes.txt file:
Hot tub, 4 Couch, 6 Stereo, 3 Dog bone, 7 House, 1 Set of luggage, 5 Car, 2
You need to generate a file that notifies each winner of his or her prize, and have the output file appear like this:
Congratulations, prizewinner1! Congratulations, prizewinner2! You have won PRIZE X. You have won a PRIZE Y.
8-3
The CHOOSE function has two arguments and selects an object from a series. The first argument is the series of prize objects to choose from: from_these_objects The second argument is the index number of the object chosen: pick_the_nth_one
8-4
Create the PrizeRecord group type to represent the data in the prizes.txt file. Define the components of PrizeRecord. The contents of the prizes.txt file show that two components are required: Prize and Place. The Prize Field and Place Field item types exist in the Raffle.mtt.
8-5
Define the Winner item type as a component of WinnerFile. Define the component range of Winner.
Define the components of the CongratulationsRecord group type. There is text, the winner's name, more text, and the prize won.
8-6
Raffle Map
Raffle Map
Create a map source file called Raffle that uses the prizes and winner files as inputs.
8-7
Raffle Map
Create the RaffleCongrats executable map to use two input cards. Sources for these cards are: The source of input card #1 PrizesFile is the prizes.txt input data file that contains a list of the prizes for each place. The source of input card #2 WinnersFile is the winners.txt input data file that contains the list of winners in order based on the prize won. The RaffleCongrats executable map has one output card that specifies creation of the F_Congratulate functional map. The data target for output card #1 CongratulationsFile is the Congratulate.txt file. The map rule on the CongratulationsRecord data object specifies creation of the F_Congratulate functional map and uses the CHOOSE function.
Use the Functional Map Wizard to create the F_Congratulate functional map. For the map rules on the F_Congratulate functional map enter the text literals that compose the congratulations message. Remember to include the punctuation as text literals.
8-8
Summary
Build and run the RaffleCongrats executable map. The results show that each winner is matched with a prize.
Summary
You modified a type tree by creating group types to represent records, and files of records. You defined components and component ranges. You created a functional map and created a map rule using the CHOOSE function to select a prize for a winner based on the winner position in the winners.txt file.
8-9
Summary
8-10
9
Data Breaks By Object Count
Physical characteristics of data include delimiters and established values of fixed length objects. These physical characteristics are used to determine where data objects begin and end. If the data has delimiters or is of a fixed length, these characteristics can be defined in the type properties in the Type Designer. If data is not of fixed length or it does not contain delimiters, other methods are required to define a break in the data. Breaks in data can be also determined when: The count of a certain object reaches a specific value. or When the value of a certain item changes.
Objectives
This exercise uses the first method to define logical breaks in the data. By completing the exercises for Chapter 9, you will learn how to: Count objects to determine breaks in the data. Dock or float the Rule Bar and Navigator window. Create a new type tree using the Merge Type command.
9-1
Name
Address.txt
Description
Input data file containing multiple contacts Type tree describing the contact and label data
Type tree
Address.mtt
Name
app.txt
Description
Output data file of records where each record contains the names of four companies from the input. Type tree describing the contact data (input) as sets of up to four contact records and the company file (output). Map source file containing the CompanyMap map, which creates a file of records where each record contains the names of four companies from the input. Compiled map generated from the CompanyMap executable map in the Company.mms map source file. Type analysis message generated from the type tree analysis.
Type tree
Address2.mtt
Company.mms
CompanyMap.mmc
*.dbe
9-2
Icon
File type
Map build analysis results file Map source options file Backup type tree and map files
Name
*.mme
Description
Map build analysis results file generated from the build process. Map options file created automatically during the Save process. Backup type tree files and map source files are created automatically during the Save process.
*.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
As shown in the illustration, the AddressFile data source contains multiple ContactSets. Each ContactSet contains four Contacts. The CompanyFile data target contains multiple Records. Within each Record, there are four Company fields. You want to map the Company field of one Contact in the ContactSet to one of the Company fields in Record.
9-3
Define a specific number of data objects as a single data object. Use the Type Designer to define the address file in terms of ContactSets, and use a component rule on the Contact component of ContactSet. Define the company file of records. Use the Map Designer to create a map that maps the AddressFile to the CompanyFile. Create a functional map to map a single ContactSet to a single Record. Defining a specific number of data objects as a single data object enables each set of four contacts to be recognized as a single data object. This allows you to map each set of four contacts to a single record in the output.
Open the address.mtt type tree. Create a new type tree called Address2.mtt and name the root Data. Arrange the type tree windows so that both windows can be viewed.
9-4
4 5
Select Contact in address.mtt. Select Type > Merge and click in the Address2.mtt type tree window. In the Merge Type dialog, the To tree field displays Address2.mtt.
9-5
6 7
Click Merge. Click Close. The new Address2.mtt type tree now contains only the Contact object and the fields that are its components.
8 9
Close address.mtt. In the Address2.mtt, create two new group types ContactSet and NewContactFile as sequence group types with an implicit format and no syntax.
10 Add the Contact group type as a component to ContactSet. 11 Define a component range for Contact.
9-6
9-7
The argument objects_to_count is the number of Contact records in the ContactSet. The $ in a component rule is shorthand notation for the current object. COUNT ($) is the same as COUNT (Contact (s)). The component rule on the Contact component of ContactSet ensures that a ContactSet contains up to four Contacts:
COUNT ($) <= 4
If the number of Contacts in the file is not divisible by four, the last Contacts are still considered a ContactSet, because the component rule allows for sets with less than four. To enter the component rule, use the Insert Function command to insert the COUNT function, use the ($) shorthand notation for the current object, enter the less than and equal sign operators (<=), and the count value of 4. To add a component rule to Contact
1
In the ContactSet group window, set current focus on the Contact group type by clicking in the rule cell next to the Contact group.
9-8
3 4
Enter the ($) shorthand notation to indicate the objects_to_count are the Contact records. Enter the less than and equal sign operators (<=) and the count value of 4.
This diagram illustrates how the transformation server behaves as it proceeds through the data:
9-9
The output type CompanyFile consists of Record(s). A Record consists of four Company fields. Create the CompanyFile group and add Record as a component. Define the component range for Record.
Tip
You can also copy the CompanyFile group type from the Address.mtt type tree.
Conrad Corp Hooks and Hangers Andromeda Co. Sand Inc. ABC Co. Channel 7 News Any Co. Brackman's Inc Johnson Systems.
In the output data, Record has an explicit, fixed format. Each Record contains the same number of characters of data.
9-10
In the output data, each Company field in Record is padded to take up a fixed size of 25 characters. To account for this use of Company Field, some changes need to be made to its type definition by defining a pad character. By specifying a pad character of a space (<sp>), which will be used to pad Company to a fixed length of 25 characters whenever Company Field is used in a fixed group. Therefore, when Company Field is used in Record for the output, it will be padded to 25 characters. When Company Field is used in Contact (a delimited group) it will be of a variable length according to the data it contains.
9-11
9-12
The CompanyFile output card specifies the CompanyFile Data type in the Address2.mtt type tree and generates the company.txt file.
9-13
Enter the map rule for the Record data object on the CompanyFile output card to specify generation of the F_RecordMap function map.
Use the Functional Map Wizard to generate the F_RecordMap function map.
Tip
The Navigator window shown below and the Rule Bar shown previously are floated. Right-click in the area under the title bar as shown to dock or float the Navigator or Rule Bar window.
In the F_RecordMap function map, the Company field of each Contact is mapped to the Company field in the Record.
Build and run the map. Note that each Record in the output file consists of four Company fields from the input.
9-14
Summary
Summary
You learned how to count objects to determine breaks in the data.
9-15
Summary
9-16
10
Data Breaks By Value
Breaks in data can be determined when the value of a certain item changes. A break in the data pattern can be recognized when the value of a certain item type changes. This change in the value of a certain field determines the end of one object and the beginning of the next object.
Objectives
The input file contains a specific number of purchase orders. You want to generate a file that contains a field that gives the count of the purchase orders in the input file. By completing the exercises for Chapter 10, you will learn how to: Determine if the value of a certain item changes to determine breaks in the data. Identify and eliminate a type tree analysis error message about distinguishability by using a component rule to find the last record. Use the COUNT function in a map rule to count the number of items in an input file. Use the index value [LAST] in a component rule to refer to the last occurrence of that object. Use $ shorthand notation in a component rule.
10-1
Name
cntrl.txt
Description
Input data file containing multiple purchase order records Type tree describing the purchase order data
Type tree
control.mtt
Name
countpo.txt
Description
Output data file that contains the number of number of purchase orders in the input data Compiled map file that generates a text file containing the number of purchase orders Map source file containing the MakeCountFile executable map Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process
Compiled map file Map source file Type tree analysis message file Map build analysis results file Map source options file
MakeCountFile
Control.mms
*.dbe
*.mme
*.mopt
10-2
Icon
File type
Backup type tree and map files
Name
*.bak
Description
Backup type tree files and map source files are created automatically during the Save process
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
10-3
Open and analyze the Control.mtt type tree. The analysis results display in the Analysis Results window.
The purchase order is decribed by the PO group type. We know that one purchase PO can be distinguished from the next purchase order PO by the value of the purchase order number.
In a component rule, the index value [LAST] refers to the last occurrence of that object.
10-4
Open the PO Data group window. Place current focus on the component rule cell for the Record component of PO. Press the Alt key and drag the PO# item type from the type tree window to the component rule bar. Enter a colon (:) after PO#. Press Alt and drag the Record group type from the type tree window into the component rule.
6 7 8 9
Enter a space, an equal sign (=), and another space. Drag the PO# Field item type as a component of the Record item type. Enter the index value [LAST]. Press Enter to commit the component rule.
10-5
Note Shading in a component rule that is under construction is an indication of syntax error. Completing and committing a valid component rule eliminates this shading.
Data Handling
The first record is processed and the component rule is validated as true or false.
Note The index value [LAST] is interpreted as [1] when no previous occurrences exist.
The first Record in the PO file, the component rule is interpreted as: Is PO# Field:Record[1] = PO# Field:Record[1]? Is PO# Field:Record[1] = PO# Field:Record[LAST]? Is 12345 = 12345?
10-6
The second record is then processed: Is PO# Field:Record[2] = PO# Field:Record[LAST]? Is 12345 = 12345? The following diagram shows how the component rule is evaluated for the first four records in the data. As a result, the first three records are determined to make up a single PO.
10-7
Summary
You want the map to generate a file that contains just one field that gives the count of the purchase orders in the input file. Build and run the MakeCountFile map. View the run results. The content of the countpo.txt indicates there are two (2) purchase orders.
Summary
You learned to determine a break in the data when the value of a certain item changed. You also learned to eliminate a type tree analysis error message about distinguish ability by using a component rule to find the last record.
10-8
11
Partitioning Types To Simplify Map Rules
This chapter defines how to partition types to simplify map rules. Partitioning is a method of subdividing data objects into mutually exclusive subtypes. Data that can be divided into mutually exclusive subtypes can be partitioned. Partitioning is required when components are randomly or partially ordered. You may decide to use partitioning in a type tree to build additional logic into the definition of the data. You may also use partitioning to simplify the rules needed in your map.
Objectives
This exercise uses a single input file to generate multiple output files using partitions and attributes. By completing the exercises for Chapter 11, you will learn how to: Partition to simplify map rules. Identify partitions in map rules and component rules. Use the identifier attribute to distinguish record types. Generate multiple output files from a single input file. Use the CURRENTDATE function. View type properties in the Map Designer. View component numbers in the group window.
11-1
Use the multiply (*) and divide (/) operators. Calculate percentages of Customer and Distributor records in an input file.
Name
Deliver.txt
Description
Input data file multiple records of different types Invoice, Forecast, and PO Type tree describing the input data (file of Records) and the activity report output data
Type tree
Deliver.mtt
Name
Acct.txt
Description
Output data file for accounting that contains the invoice records in the input data Output data file for the order entry department that contains the forecast and PO records in the input data Output data file that contains an activity report with statistics about the records in the input data Map source file containing the ActivityReport and OrdersByDepartment maps
Text file
Order.txt
Text file
Report.txt
Deliver.mms
11-2
Scenario
Icon
File type
Compiled map file Compiled map file
Name
ActivityReport.m cc OrdersByDept.m cc
Description
Compiled map file that creates the activity report Compiled map file that creates the two department files: a file of invoices (to send to an accounting department) and a file of purchase orders and forecasts (to send to the order entry department) Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
*.dbe
*.mme
*.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
A file contains a collection of records in no particular order. The source of each record may be one of three kinds of business partners: customers, suppliers, or distributors. In addition, each record originates in one of three different applications: a forecast, purchase order, or invoice application. A particular field in each record indicates the business partner it came from and another field indicates the associated application. You want to create three different output files: A file of invoices to send to an accounting department. A file of purchase orders and forecasts to send to an order entry department.
11-3
Scenario
A report on the activity of customers, suppliers, and distributors for the MIS department. Using the Type Designer, you need to modify the type tree to: Define the data file of records. Partition the different kinds of records and define the activity report. Using the Map Designer, you need to to create one map source file with: An executable map with two output cards:
Output card #1 to generate a file for the accounting department Output card #2 to generate a file for the order entry department file.
indicates Qualifier Field is a component of the ACME group type. Type names separated by angle brackets (<>) indicate a partition relationship.
Qualifier Field:ACME<>Collection
indicates Qualifier Field is a component of the ACME group type and ACME is a partition of the Collection group type.
11-4
The deliver.txt input text file consists of records in random order. This file of records is defined as the Collection group type.
11-5
Open the group window and place current focus on the component to which you want to assign the identifier attribute. From the Component menu, choose Identifier. The identifier attribute appears next to the component name.
Using the Type Designer, assign the identifier attribute ( ) to the ApplicationID Field component in the following three group windows: Forecast Record Data PO Record Data Invoice Record Data
11-6
On the next level of partitioning, the types can be distinguished by the first component. For example, the first component of a Distributor Forecast record is Distributor Partner, and the first component of a Customer Forecast record is Customer Partner.
11-7
11-8
The Partner group type is the first component of each record. It is partitioned by Customer, Distributor, and Supplier, and then by specific companies. The component rules on each companys partner type provide the values for each field. The component rule makes ACME customer record distinguishable from the Bob record. The partner types are distinguished by their different first component Customer Partner, Distributor Partner or Supplier Partner.
In the Distributor Partner Data group window, the Qualifier Field is component 1 and PartnerID Field is component 2.
11-10
In the Distributor Forecast Record Data group window, when Distributor Partner is expanded, the nested component numbers are shown.
From the Tools menu, choose Options. The Options dialog appears. Select Group Window. The group windows options appear. Enable the Show component number check box. Click OK.
3 4
11-11
11-12
The type name appears in the rule cell with the partition (<>) and component (:) separators: =Invoice<>Record:Collection.
11-13
Drag Forecast records from the input card to the rule cell for Forecast on the output card. Do the same for PO. In this file, Invoice records are not desired, so enter =NONE in that rule cell.
Build and run the OrdersByDept executable map to generate the two output files: Acct.txt and Orders.txt.
11-14
On the output card, right-click the Date Field data object and choose Properties from the context menu. View the Format property to confirm the MMDDYY format of the generated date. Close the properties window.
Use the COUNT function to count the following records: #CustomerPOs #CustomerForecasts #DistributorPOs
=COUNT ( Customer<>PO<>Record:Collection ) =COUNT ( Customer<>Forecast<>Record:Collection ) =COUNT ( Distributor<>PO<>Record: Collection ) ( Distributor<>Forecast<>Record:Collection )
For the %CustomerPOs and %DistributorPOs data objects, enter map rules to calculate the percentages of Customer and Distributor records in the entire input file.
11-15
Use the multiply (*) operator to multiply the data object by 100. For example:
100 * #CustomerPOs Field:Report
multiplies the #CustomerPOs Field component of Report by 100. Use the divide operator (/). For example:
=100 * #DistributorPOs Field:Report / COUNT ( PO<>Record:Collection )
divides the count of the PO records by (100 times the number of #DistributorPOs Field in Report). %CustomerPOs %DistributorPOs
=100 * #CustomerPOs Field:Report / COUNT ( PO<>Record:Collection ) =100 * #DistributorPOs Field:Report / COUNT ( PO<>Record:Collection )
The Report.txt contains statistics about the records in the input data.
Note Close all maps, type trees, and text files.
11-16
Summary
Summary
In the Deliver.mtt type tree, the record types are partitioned for six different types of records:
You used two executable maps to generate three output files. You used arithmatic operators with data objects to calcuate percentages.
11-17
Summary
11-18
12
Mapping Optional Inputs
Some data objects are not always present in the input file.
Objectives
This exercise maps optional input data objects. By completing the exercises for Chapter 12, you will learn how to: Map optional inputs. Use category types to organize related types.
Name
Sts.txt
Description
Input data file containing weather and human statistics on states in the United States Type tree describing the input data (file of statistics by state) and the output data (file of state populations)
Type tree
States.mtt
12-1
Scenario
Name
Output.txt
Description
Output data file that holds records for each state containing the state ID and the population for that state Map source file containing the Master map, which creates the state population file from the state statistics file Compiled map file that generates the Output.txt file Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
States.mms
Compiled map file Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
States.mmc
*.dbe
*.mme
*.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
A data file of statistics on states in the United States may include population density, median household income, average summer temperature, average winter temperature, and average yearly rainfall. You need to generate a file that contains only the population statistics.
12-2
Input Data
Input Data
The input data is provided in the Sts.txt file. This file contains weather and human statistics on states in the United States:
Midwest:OH/257,3738/74,31,37:IL/,4285/76,26,33:IN/142,3687/75,29,39 Mountain:MT/5,3130/68,19,11:ID/8,2953/75,29,11:WY/3,3353/70,26,15 Plains:MN/48,3635/73,12,25:IA/,3549/74,20,33:MO/67,3458/78,32,35
The diagram shows how the data objects within a Region are organized. A Region consists of a RegionID, and a series of States. Each State consists of a StateID, Human, and Weather statistics.
The statistics for population density and household income are within each Human data object. The statistics for average summer temperature, average winter temperature, and average yearly rainfall are within each Weather data object.
You need to extract each StateID and corresponding Population. You need to generate an output file that consists of a series of StatePops, each containing a StateID and the state Population.
OH,257*IL,196*
12-3
Component Ranges
Component Ranges
The default component range is (1:1), indicating a minimum of one occurrence and a maximum of one occurrence. When the component ranges vary from this default, you must define accurate component ranges. The Region Input Data group type is a component of UnitedStates Input Data. Define the component range to indicate some unknown number of files.
12-4
Component Ranges
The Region Input Data group type components are: The RegionID item type. The State group type. The number of states is unknown. Define the component range of State.
The components of the State group type are: The StateID item type. The Human group type. The Weather group type. The Human component of State is optional. Define the component range of (0:1) to indicate a minimum of zero occurrences and a maximum of one occurrence of this data.
The components of the Human group type are also optional. Indicate these as optional components.
12-5
Component Ranges
In the input data, optional components may not be present. The Region Input Data is an Explicit group type. The colon (:) delimiter explicitly identifies the states within each region.
12-6
Component Ranges
View the State type properties to see that fields within each state are delimited with a forward slash (/).
The Human group type is a component of State. The components of Human are separated by a comma delimiter.
12-7
12-8
To generate each StatePop in the output, create the F_MapState functional map. The map rule to generate the StatePop group type specifies two input data objects: State and Population. Generate StateID only if StateID data is present in the input data. Generate Population output data only if Population Statisitic is present in the input data. The map rule for the StatePop is:
=F_MapState ( StateID:State:Region:USData , Population Statistic:Human:State:Region:USData )
For the F_MapState functional map, drag StateID and Population Statistic from the input card to create the map rules for StateID Input and Population Statistic Input data objects.
12-9
Summary
The output.txt output file shows that a StatePop was not created for the states having no Population Statistic. For example, IL had no Population Statistic, and no IL data was created in the output.
Summary
You learned how to indicate optional input by using component ranges. The default component range (1:1) is assumed and does not display. Only component ranges with values other than (1:1) display in group windows and on map cards. The delimiter identified missing data.
12-10
13
Mapping Multiple Files to One File
This chapter defines how to map two input files into one output file.
Objectives
This chapter uses two input files to create one output file. By completing the exercises for Chapter 13, you will learn how to: Map two input files (one header and one detail file) into one output file. Use ellipses to shorten object names in component rules. Use nested functional maps.
Name
Header.txt
Description
Input data file containing header records
13-1
Icon
File type
Text file
Name
Detail.txt
Description
Input data file containing detail records in sets by PO Type tree describing both files of the input data (file of header records and file of detail records) and the output data (file of purchase orders)
Type tree
TwoFiles.mtt
Name
PO.txt
Description
Output data file that contains POs made up of a header record and multiple detail records Map source file containing the Executable map Compiled map file that creates the PO.txt output file based on the input data in the header file and detail file Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
TwoFiles.mms
CreatePO.mmc
Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
*.dbe
*.mme
*.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
13-2
Scenario
Scenario
You have a header file made up of header records. Each header record includes a customer number, an account number, a purchase order number, and a date. You also have a detail file made up of detail records. The detail records include a purchase order number, an item ID, a quantity, and a unit price. You need to create an output file made up of purchase orders. Each PO has a header and a set of details. The Detail.txt detail input file is sorted to correspond with the data in the header file. The first header record goes with the first set of detail records, the second header record goes with the second set of detail records, and so on. The input data is shown below. The arrows indicate how each Header Record corresponds to a particular set of Detail Records:
7000 PO#175 Oct-04-97 aa533,100 aa022,40 aa045,15 4500 aa011,10 PO#100 May-14-97
Using Ellipses
When the Use ellipses option is enabled, object names used in component rules (Type Designer) and map rules (Map Designer) are abbreviated to the shortest unique object name. Some object names may not include ellipses, because the shortest unique name is the entire name.
13-3
Using Ellipses
Note The ellipses appear in component rules in the Type Designer group window, and in map rules in the Map Designer.
From the Tools menu, choose Options. In the Options dialog, select Group Window. Enable the Use ellipses check box.
From the Tools menu, choose Options. In the Options dialog, select Rule Bar. Enable the Use ellipses check box.
13-4
The Use Ellipses option does not affect object names that already exist in component or map rules; it only affects object names that are entered after the option is enabled.
Use control-break logic to identify how the sets are organized: when the PO# changes, a new set begins. Use the index value [LAST] to refer to the occurrence of the last header record.
13-5
13-6
Output PO
The PO Output Data group type describes the PO.txt output file. There is one Header record and some unknown number of Detail records.
CreatePO Input
Both input files are defined in the TwoFiles.mtt type tree. Name input card #1 HeaderFile. The Type for input card #1 is Header File Input Data.
13-7
Name input card #2 DetailSet. The Type for input card #2 is Detail File Input Data.
13-8
The arguments to the F_MakePO functional map are a Header Record, and the corresponding DetailSet. Pick the DetailSet whose index matches the Header Records index. For example, when Header Record #2 is used, the CHOOSE function retrieves DetailSet #2 as well.
=F_MakePO (Header Record:HeaderFile, CHOOSE ( DetailSet:DetailFile, INDEX ( Header Record:HeaderFile )))
Use the CHOOSE function and the INDEX function to choose the detail set in the detail file that corresponds with the same header record in the header file.
Use the Functional Map Wizard to create the F_MakePO functional map.
13-9
For the Detail records in the F_MakePO functional map: Use another functional map call to create the F_MakeDetail functional map to get one detail record from the detail set.
=F_MakeDetail ( Detail Record:DetailSet )
Use the Functional Map Wizard to create the F_MakeDetail functional map.
13-10
View the CreatePO executable map in Composition view in the Navigator to see the nested map composition.
Summary
The two input files generated one output file. You used nested functional maps to use the corresponding detail and header records. In the functional map F_MakePO, the Header information in the output is mapped from the Header in the input. The Detail information is mapped from the Detail records, by using another functional map: F_MakeDetail. The PO.txt output file shows that the transformation server matched the header with its corresponding detail set.
Note Close all maps, type trees, and text files.
13-11
Summary
13-12
14
Detail Records Not Sorted by PO
In Chapter 13, the detail records in the Detail.txt file were in the same order as the corresponding header records in the Header.txt file. Your data may be in random order and not be sorted or organized into sets.
Objectives
This exercise associates randomly ordered detail records with the correct header record. By completing the exercises for Chapter 14, you will learn how to: Associate randomly sorted detail records with header records. Use the EXTRACT function to extract a detail record from the detail file when the PO# of the detail record is equal to the PO# of the header record. Close all run results windows at the same time.
14-1
Icon
File type
Text file
Name
RandomDetails.txt
Description
Input data file containing multiple detail records, sorted in random order Input data file containing header records Type tree describing the file of header records and the output data (file of purchase orders) Type tree describing the detail input data file (file of randomly sorted detail records)
Text file
Header.txt
Type tree
TwoFiles.mtt
Type tree
RandomDetails.mtt
Name
PO2.txt
Description
Output data file of details and associated header records Map source file containing the RandomFiles executable map Compiled map file that generates a list of PO from randomly ordered detail and header record input files Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process. Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
RandomDetails.mms
RandomDetails.mmc
Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
*.dbe
*.mme
*.mopt
*.bak
14-2
Scenario
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Note The Tools > Options > Rule Bar > Use Ellipses option is disabled in the example map rules shown in this chapter. Disable or enable this option as you prefer.
Scenario
You have the detail records and header records in two input files. The order of the records in the files is random.
Note The Detail.txt detail input file is not sorted to correspond with the data in the header file.
Each header record includes a customer number, an account number, a purchase order number, and a date. You also have a detail file made up of detail records. The detail records include a purchase order number, an item ID, a quantity, and a unit price. You need to create an output file made up of purchase orders. Each PO has a header and a set of details. The detail file is not organized into sets of detail records. For example, the detail records for purchase order number 144 are scattered throughout the file. The randomly sorted RandomDetails.txt input data file looks like:
175 175 100 144 175 144 aa533 aa045 aa011 aa097 aa022 aa045 100 15 10 25 40 10 2.35 3.70 6.90 4.32 2.25 5.60
14-3
RandomDetails Input
Both input files are defined in the TwoFiles.mtt type tree. Name input card #1 HeaderFile. The Type for input card #1 is Header File Input Data.
14-4
Name input card #2 DetailSet. The Type for input card #2 is Detail File Input Data.
14-5
Use the Functional Map Wizard to create the F_MakeDetail2 functional map.
14-6
After you run the RandomDetails executable map, from the Map menu, choose Run Results. The Run Results dialog appears. Click OK. The data files associated with the two input cards and the output card display in separate run results windows.
With current focus in the Navigator window on the RandomDetails executable map (map must be selected), from the Map menu, choose Close All Run Results. For quick command access, click and click (View run results)
Tip
14-7
Summary
The position of the windows associated with map source files is stored in a mmsname.mopt file. The RandomDetails.mopt file stores the position and run results window information.
Summary
Randomly ordered detail records were associated with header records by identifying matching purchase order numbers. The F_MakePO2 functional map processed the header records in the header file and the detail file. On the output card of the F_MakePO2 functional map, the map rule for the Detail called the F_MakeDetail2 functional map. This nested functional map used the EXTRACT function to extract records where the purchase order number in the detail file equaled the purchase order number in the header record.
Note Close all maps, type trees, and text files.
14-8
15
Creating a Trace File
The trace file is a text file that records the progress during the execution of a map. You can choose to trace the input data, the output data or both. The trace file is a debugging aid used to diagnose invalid data or incorrect type definitions.
Objectives
This exercise creates a trace file that can be used for debugging purposes. By completing the exercises for Chapter 15, you will learn how to: Create a trace file. View the trace file on the Trace tab on the Organizer window. View the trace file in a separate window. Understand the contents of a trace file. Change the trace file settings.
15-1
Name
Detail.txt
Description
Input data file containing multiple detail records Input data file containing multiple header records Type tree describing the detail and header data Type tree describing the output data Map source file containing the Executable map
Text file
Header.txt
Type tree
TwoFiles.mtt
Type tree
Math.mtt
New_POS.mms
Name
Output.txt
Description
Output data file of purchase orders Compiled map file that generates a trailer with summary information about the items in the purchase order Map build analysis results file generated from the build process Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process
Executable.mmc
Map build analysis results file Type tree analysis message file Map build analysis results file
Executable.mtr
*.dbe
*.mme
15-2
Scenario
Icon
File type
Map source options file Backup type tree and map files
Name
*.mopt
Description
Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
You want more information on your data validation.
Trace File
When input data is traced, the trace file provides a step-by-step account of the data objects found, the reason the data is found to be invalid, sizes and counts of data objects, and the data object position in the data stream. When output data is traced, the trace file specifies the objects that are built and the output objects that evaluate to NONE. A trace file of input messages contains a message for each input data object that shows: The level of the object in the card. The offset of the data object in the data stream. The length of the data object. The component number of the data object. The index of the component. A portion of the actual data. The name of the type to which it belongs. For input data tracing, a message exists in the trace file for each input data object indicating whether the data object is valid. If the data is invalid, the message indicates the reason the data is invalid.
15-3
Trace File
The trace file is created as specified after the map is compiled and executed. The default name of the trace file is the executable map name, plus the file name extension .mtr. The default location of the trace file is the map execution directory. A specific name and location of the trace file can be defined in the Map Settings dialog. For example, if your executable map name is RegionReport, the trace file is RegionReport.mtr. After you run a map, the trace file can be viewed on the Trace tab in the organizer window or with any text editor.
Open the New_POS map source file. Select the Executable map in the Navigator. From the Map menu, choose Settings. Right-click MapTrace and choose Expand All to view the map trace settings. For the ContentTrace > Switch setting, choose ON. Click OK. Build and run the Executable map. The trace file is created.
If you ran a map and got a message that an input was invalid, turn on the input trace only. If you got a message that an output was invalid, turn on the output trace only.
15-4
Select the Executable map in the Navigator. On the toolbar, click window. (Organizer) to view the Organizer
Click the Trace tab on the Organizer window and size the window as needed.
The input data trace messages are at the beginning of the file.
15-5
Right-click the Trace tab on the Organizer window. From the context menu, choose Float In Main Window. The Trace file appears in a separate window.
Data Validation
Data validation occurs at item, group, and card object levels.
15-6
Data Validation
The first data item in the Header.txt file is the customer number (in this case customer number 4500) as described by Customer# Field item type in the TwoFiles.mtt.
Trace Message
Level 2
Description
The level of an object indicates the position of the data object with respect to the entire card object. A card object has Level 0; a component of the card object has Level 1, and so on. The Customer# Field Data item type is a Level 2 because it is a component of the Header Record, which is a Level 1. In this example, HeaderFile is Level 0.
Offset 0
The offset of the data object in the data stream. No offset for Customer# Field Data.
len 6
The length of the data object. Customer# Field Data has a size length of 6 bytes.
15-7
Data Validation
Trace Message
comp 1 of 4
Description
The component number. Customer# Field Data is the first of four components of the Header group type.
#1
The index of the component. This is the first occurrence of Customer# Field Data.
The DI number is not used for debugging purposes and may be ignored. Same offset information. A portion of the actual data. Customer number is 4500 (and two pad spaces).
The name of the type to which it presumably belongs. Customer# Field Data type. The X number is not used for debugging purposes and may be ignored.
Group Validation
A group is valid if the syntax is valid and all of its components are valid. A group is validated component-by-component. A component is valid if its type is valid, its component range is valid, and, if the component has a rule, the rule evaluates to TRUE.
Note When a component rule is evaluated, any invalid data used in a component rule is evaluated with a value of NONE.
After all of the components of a group have been found, a message in the trace file indicates that the group itself was found. For example, the Header group type trace message:
(Level 1: Offset 0, len 32, comp 1 of 1, #1, DI 00000005:) Data at offset 0 ('4500 kes11 1') was found to be of TYPE X'0006' (Header Record Input Data)
Invalid Data
The trace message for Header File Input Data (the Type defined for input card #1) is:
(Level 0: Offset 0, len 102, comp 1 of 0, #1, DI 00000010:) Data at offset 0 ('4500 kes11 1') was found to be of TYPE X'0004' (Header File Input Data).
The message following this card object appears after all of the messages for the objects within that card:
INPUT 1 was valid. End of Validation messages for INPUT CARD 1.
Invalid Data
When a data object does not match the definition of the type to which it presumably belongs, it could be invalid. Following are possible reasons for an invalid data object: Item value is not in restriction list Item failed the presentation test Item is the wrong size Data object has the wrong delimiter Data object has the wrong terminator Data object failed the component rule Group is missing a required component Group contains one or more invalid component(s) See the Map Designer Reference Guide for details on invalid data.
Summary
Trace files should be used only for debugging purposes because the trace process impacts performance. Information in trace files can help you debug input data, output data, and type property definitions.
15-9
Summary
15-10
16
Exporting a Map
Exporting a map source file enables you to store map definitions in xml format in a repository directory. The resulting xml file contains information on map settings, card settings, and map rules.
Objectives
This chapter exports the New_POS map source file. By completing the exercises for Chapter 16, you will learn how to: Export a map source file.
Name
Detail.txt
Description
Input data file containing multiple detail records
16-1
Exporting a Map
Icon
File type
Text file
Name
Header.txt
Description
Input data file containing multiple header records Type tree describing the detail and header data Type tree describing the output data Map source file containing the Executable map
Type tree
TwoFiles.mtt
Type tree
Math.mtt
New_POS.mms
Name
New_POS.xml
Description
XML file generated with the Map > Export command that includes detailed information about the map
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this tutorial.
16-2
Exporting a Map
Open the New_POS map source file. In the Navigator, select the Executable map. The active map name displays on the title bar. From the Map menu, choose Export. The Export Map(s) to an XML file dialog appears with the active map name in the File name field.
To export to the current folder, click Select. The Maps exported successfully confirmation message appears.
Click OK. The resulting New_POS.xml file can be opened with a text editor.
Note To view the exported xml file in a browser, you must use the mapsettings.dtd and the mms.dtd files provided in the install_dir\mapimportexport\dtd folder.
XML DTD
The mapsettings.dtd and the mms.dtd files are required to view the exported xml file in a browser. These *.dtd files are provided in the install_dir\mapimportexport\dtd folder. Export maps to this install_dir\mapimportexport\dtd location or copy these dtd files to the export map location. To export the New_POS map to be opened in a browser
1 2
Open the New_POS map source file. In the Navigator, select the Executable map. The active map name displays on the title bar. From the Map menu, choose Export. The Export Map(s) to an XML file dialog appears with the active map name in the File name field.
For the Save in field, navigate your file system to specify the Design Studio install_dir\mapimportexport\dtd folder.
16-3
Exporting a Map
Click OK. The resulting New_POS.xml file can be opened with a browser.
16-4
Exporting a Map
16-5
Summary
Exporting a Map
Summary
The exported xml open document interface is useful for: Storing and retrieving map definitions in a repository. Printing map definitions. Global impact analysis. Converting business rules from other sources to map rules. Documentation. Exported maps also provide an alternate format for storing map definitions in XML format in version control systems. The mapsettings.dtd and the mms.dtd files are required to view the exported XML file in a browser.
Note Close all maps, type trees, and text files.
16-6
17
Importing a Map
The xml files generated with the Map > Export command can be imported into the Map Designer to create a map source file.
Objectives
This chapter imports a map source xml file. By completing the exercises for Chapter 17, you will: Create a map source file from an xml file.
Name
New_POS.xml
Description
Map source XML file
17-1
Importing a Map
Importing a Map
Name
TwoFiles.mtt
Description
Type tree describing the detail and header data Type tree describing the output data Map source file
Type tree
Math.mtt
New_POS.mms
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Importing a Map
The XML file can be imported into the Map Designer to create a map source file. If you want to view the map source file, the import location should contain the associated type trees. To import the New_POS.xml file
1 2
Open the Map Designer. From the Map menu, choose Import. The Import Map(s) from an XML File dialog appears. For the Look in field, navigate your file system to the location of the New_POS.xml file. Select the New_POS.xml file. The New_POS file name appears in the File name field. Click Select. The Save As dialog appears. Enter New_POS in the File name field.
3 4
17-2
Importing a Map
Summary
Click Select. The Ascential DataStage TX Map Designer view confirmation dialog appears.
Click No when prompted to view the map source file. The map is imported.
Note To view the map source file, the associated type trees must be present where specified in the map cards.
If the type trees are not in the directory specified in the map cards, errors occur. In this example, the type trees are defined to be in the same directory. The type trees are provided in the solutions file.
Summary
The xml file containing map source file details can be imported into the Map Designer to create a map source file. Associated type trees must be located in the import directory to avoid errors.
17-3
Summary
Importing a Map
17-4
18
Mapping Invalid Data
Invalid data can be rejected from the input data file by using the REJECT function. This rejected data can be then mapped to an error file to provide useful information that identifies errors in the input data.
Objectives
This chapter maps invalid data using the REJECT function. By completing the exercises for Chapter 18, you will view a working map that: Maps invalid data. Uses the restart attribute. Uses the REJECT function to create an error output file.
18-1
Name
Names.txt
Description
Input data file containing customer information Type tree describing the input customer data Type tree describing the output error data Type tree describing the output error data Map source file containing the MyCustomers map
Type tree
MyCustomers.mtt
Type tree
Errors.mtt
Type tree
CustomerErrors.mtt
Name
Names.txt
Description
Input data file containing customer information Type tree describing the output error data Type tree describing the output error data Type tree describing the input customer data Map source file containing the MyCustomers map
Type tree
Errors.mtt
Type tree
CustomerErrors.mtt
Type tree
MyCustomers.mtt
MyCustomers.mms
18-2
Icon
File type
Compiled map file
Name
MyCustomers.mmc
Description
Compiled map file that generates a trailer with summary information about the items in the purchase order Output data file of summary information about the customers in the input file Output data file containing the rejected data from the customer input file Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Text file
Cust_summary.txt
Text file
Errors.txt
Map build analysis results file Map source options file Backup type tree and map files
*.mme
*.mopt
*.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this tutorial.
18-3
Restart Attribute
This BadData item type is used to map an invalid customer. The ErrorReport group type contains a Header and some unknown number of BadData items as components.
Restart Attribute
The restart attribute is used to identify valid data objects that contain objects in error.
18-4
The restart attribute is assigned to components of group types in the Type Designer. The restart attribute allows you to continue processing your input data when a data object of a component is invalid. To map invalid data of a particular object, assign the restart attribute. Errors are ignored for invalid data object during validation. You can then map the invalid data using error functions. During data validation, the restart attribute identifies a "start over" point when an unidentified foreign object (UFO) is encountered in the data. All unrecognized data is considered an error of the type with the restart attribute assigned. The restart attribute is used during validation to mark both UFOs and existing data objects in error, which are ignored when mapping input to output.
18-5
18-6
Summary
Summary
Mapping invalid data provides mechanisms to identify and isolate invalid input data. Use the restart attribute to allow invalid data to be processed. Use the error functions to identify the invalid data. The Error Handling category on the Insert Function dialog identifies the error handling functions you can use to map invalid data.
18-7
Summary
18-8
19
Incrementing Output Data
Output objects can be incremented. There are three methods of incrementing the position of an output object.
Objectives
This chapter provides an overview of the three methods of incrementing the position of an output object. By completing the exercises for Chapter 19, you run maps that: Increment output objects using the INDEX function. Increment output objects using the COUNT function. Increment output objects using the index value [LAST].
19-1
Name
Header.txt
Description
Input data file containing header records Input data file containing detail records in sets by PO. This file is located in the ..\tutorial\ my_exercises\ch19 folder Type tree describing both files of the input data (file of header records and file of detail records) and the output data (file of purchase orders) Map source file containing the Executable map, which creates the output file based on the input data in the header file and detail file
Text file
Detail.txt
Type tree
Increment.mtt
Name
Executable_UsingCOUNT.mmc
Description
Compiled map file that generates the CountOutput.txt file Output data file that contains indexed purchase orders with a header record, multiple detail records, and a trailer record Compiled map file that generates the LastOutput.txt file Output data file that contains indexed purchase orders with a header record, multiple detail records, and a trailer record
CountOutput.txt
Executable_UsingLAST.mmc
LastOutput.txt
19-2
Scenario
Icon
File type
Compiled map file Text file
Name
ExecutableUsingINDEX.mmc
Description
Compiled map file that generates the IndexedOutput.txt file Output data file that contains indexed purchase orders with a header record, multiple detail records, and a trailer record Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
IndexedOutput.txt
Map build analysis results file Map source options file Backup type tree and map files
*.mme
*.mopt *.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
Scenario
You have a Header file and a Detail file. These files are to be mapped to a PO file. In the header of each PO in the output, there is a field whose value increments by one for each PO. In the first PO, it has the value 1; in the second PO, it has the value 2; and so on. The Increment map source file contains three maps using three different methods of incrementing output.
19-3
The IndexOfPO item type is the last component of the Header group type.
The File Output Data group type contains the PO group type, whose components are the Header and the Detail group type (whose components are the fields in the output file):
19-4
The map rule uses the CHOOSE function for the details, the INDEX function for the header records, and the INDEX function for the current purchase order (indicated with the shorthand notation of $).
19-5
Build and run the ExecutableUsingINDEX executable map. In the IndexedOutput.txt file generated by the ExecutableUsingINDEX map, the IndexOfPO increments by one for each PO.
19-6
Summary
Output objects can be incremented by counting, using the index value LAST, or by using the INDEX function.
19-7
Summary
19-8
20
Creating a Validation Map
Validation maps provide a method of confirming your input type definitions are accurate. Validation maps are used when you are developing type trees.
Objectives
This chapter provides an overview of creating a validation map. By completing the exercises for Chapter 20, you will learn to: Create a map to validate your type definitions.
Name
Contact.txt
Description
Input data text file that contains a single contact record of information about one customer
20-1
Icon
File type
Type tree
Name
Contact.mtt
Description
Type tree describing the contact data
Name
Contact.txt
Description
Input data text file that contains a single contact record of information about one customer Type tree describing the contact data
Type tree
Contact.mtt
Contact.mms
Map source file containing the Contact map, which maps a contact to a contact to validate the type definitions Compiled map file that generates the ContactOutput.txt file Output data file that contains indexed purchase orders with a header record, multiple detail records, and a trailer record Type analysis message generated from the type tree analysis Map build analysis results file generated from the build process Map options file created automatically during the Save process Backup type tree files and map source files are created automatically during the Save process
Contact.mmc
ContactOutput.txt
Type tree analysis message file Map build analysis results file Map source options file Backup type tree and map files
*.dbe
*.mme
*.mopt *.bak
Copies of the files created during the exercises are provided for all chapters in the install_dir\tutorial\solutions folder. The structure and use of these files is described in "Design Studio Tutorial Solutions" on page xxii in the Introduction section of this document.
20-2
Scenario
Scenario
A validation map can be created to validate your input and output type definitions.
Create the ContactRecordOut output card. Map each input item to the corresponding output item by dragging it from the input card to the output card.
20-3
Summary
Build and run the map. Compare your output file to your input file. The number of input objects and output objects should match exactly.
If your output type definitions need changing, use a different type and use the same method of comparision.
Summary
Confirming type definitions is simple with a validation map. Use different type definitions as required.
20-4
Index
Symbols
$ 98 .mtt file extension 66 mapping invalid 181 data breaks 91 by change in data value 101 by counting objects 94 delimiters infix 76 docking Navigator 121
A
Analyzing a type tree structure 218 Ascential Developer Net iv
E
errors build 331 executable map definition of 311 exporting map 161 EXTRACT function 56
B
breaks in data by counting objects 94 build command 122 building a map 122 errors 331
C
card settings exporting 165 CHOOSE function 83 Close All Run Results command 127 command access xix component rule 98 concatenating text in a map rule 324 control-break logic using to define data 91 COUNT function 107 using in a component rule 98 cross-reference file defining 64 Customer Care iv Customer Care, telephone iv
F
function inserting into a map rule 326 Functional map creating 138 functional map automatically creating 316 definition of 312 referencing in a map rule 713 when to use 311 Functional Map Wizard using 316 functions CHOOSE 83 COUNT 107 EXTRACT 56 IF 325 INDEX 195 LOOKUP 712
D
data
Index-1
Index
PRESENT 325 REJECT 181 SEARCHDOWN 719 SEARCHUP 717 SORTDOWN 716 TODATETIME 619 UNIQUE 48
G
group validation 158
H
Help xix
I
identifier attribute on a component 116 IF function 325 incrementing output objects 191 index in a component rule 105 LAST 104 on an output card 618 INDEX function 195 infix delimiter 76 inheritance of type properties 64 Insert Function command 326 invalid data mapping 181
definition of 119 Map Designer command access xix Map rule definition of 320 entering 320 map rule concatenating text in 324 definition of 119 formatting appearance 330 map rules exporting 164 map settings exporting 165 mapping invalid data 181 maps building errors 331 exporting 161 functional 713 importing 172 Merge Type command 94
N
Navigator docking 121 window 121
O
output objects incrementing 191
P L
lookup file defining 64 LOOKUP function 712 partitioned types mapping 1112 partitioning types to simplify map rules 111 PRESENT function 325 properties inheriting 64
M
Map rule definition of 320 entering 320 map building 122 executable definition of 311 functional 316 definition of 312 rule
R
REJECT function 181 restart attribute 181 Rule map definition of 320 entering 320 rule map
Index-2
Index
definition of 119 rule bar creating new line in 330 run results 125 command 332 viewing 332
S
SEARCHDOWN function 719 SEARCHUP function 717 shorthand notation in a component rule $ 98 SORTDOWN function 716 Structure analyzing in type definitions 218
T
text concatenating in a map rule 324 entering in a map rule 324 TODATETIME function 619 trace file 151, 153 viewing 155 Type creating groups 67 definitions analyzing 218 type inheritance 64 partitioned mapping 1112
U
UNIQUE function 48
V
viewing run results 125, 332 trace file 155
W
wizard using the Functional Map Wizard 316
X
XML format for maps and map rules 162
Index-3
Index
Index-4