Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

15159

Page 1 of 3

KB Help

Rate It: Knowledge Base Home View Document Average Rating: (1 Rating)

Working with COBOL Sources in PowerCenter


Content
COBOL files are ASCII or EBCDIC fixed-width files that can contain text and/or binary data. You may have COBOL source code files , which describe the structure of the data, and COBOL data files , which contain the actual data. If your COBOL files come from a mainframe, they are in EBCDIC format. If your COBOL files come from a Windows machine, they are in ASCII format. The Designer can only import COBOL file definitions from source files that have a specific layout. Your COBOL source file may already have the proper COBOL file layout, or you may have a COBOL copybook, which contains only the fields and datatypes used in the COBOL file. The Designer cannot directly import COBOL copybooks (.cpy files) as sources. After you import the source files, the Designer looks for COBOL records such as REDEFINES and OCCURS, and creates a target table for each record. This article includes a case study to illustrate how to import source definitions, create target tables, and make mappings with a COBOL source file that has both REDEFINES and OCCURS. This article also includes examples of COBOL file layout, target tables, and some basic COBOL terminology so you can work with your COBOL files effectively.

Importing COBOL Source Files


Your COBOL source code files may be on a mainframe or on a machine local to the Designer. If your COBOL source files are already on a local machine, you can import them in the Source Analyzer by selecting Source > Import COBOL files. When you have COBOL source code files on a mainframe, you need to FTP the files onto a local machine so the Designer can read the files as source definitions. When you FTP COBOL source files from a mainframe, transfer it in ASCII mode so you won't see unreadable characters. Check your FTP documentation to see how to transfer files in ASCII mode. When the Designer imports a COBOL source file, it looks for a specific COBOL file layout, which includes the identification division, environment division, data division, and procedure division. Your COBOL source file may already be a complete COBOL program with the proper COBOL layout, or it may be a COBOL copybook, which is the portion of a COBOL program that describes the structure of the data. The Designer cannot read a COBOL copybook because the copybook does not have the proper COBOL file layout. You can insert the copybook into a template that has the COBOL format. Your COBOL data files may also be on a mainframe or a remote machine. You can FTP your COBOL data files to a machine local to the Informatica Server when you run a session.

Example
This example illustrates how to import a COBOL source file that is on a Windows machine. The sample COBOL source file is called sales.cbl. Sales.cbl has the proper COBOL layout and uses two COBOL records supported by PowerCenter: REDEFINES and OCCURS. To import a COBOL source file: 1. 2. 3. Open the Designer, connect to a repository, select a folder, and select Tools > Source Analyzer. Choose Source > Import COBOL File. Click the drop down file list and select the location of the file.

The source file sales.cbl looks like this: environment division. select SALES-FILE assign to "fname". data division. file section. fd SALES-FILE. 01 SALES-REC. 03 HDR-DATA. 05 HDR-REC-TYPE PIC X. 88 HEADER-REC VALUE 'H'. 88 DETAIL-REC VALUE 'D'. 88 TRAILER-REC VALUE 'T'. 05 HDR-STORE PIC 9(2). 03 BODY-DATA. 05 BODY-STORE-NAME PIC X(30). 05 BODY-STORE-ADDR1 PIC X(30). 05 BODY-STORE-CITY PIC X(30). 03 DETAIL-DATA REDEFINES BODY-DATA. 05 DETAIL-ITEM PIC 9(9). 05 DETAIL-DESC PIC X(30). 05 DETAIL-PRICE PIC 9(4)V99. 05 DETAIL-QTY PIC 9(5). 05 SUPPLIER-INFO OCCURS 4 TIMES. 10 SUPPLIER-CODE PIC XX.

http://psv23cmsmas1:7000/whitepapers/1/Pages/15159.aspx

6/29/2011

15159

Page 2 of 3

10 SUPPLIER-NAME PIC X(8). working-storage section. procedure division. Stop run. Notice that COBOL files have a period at the end of each line. Incorrect COBOL syntax can lead to parser errors. For more about COBOL file syntax, refer to article 15301 (Preparing COBOL Copybooks for use with PowerCenter) and article 15169 (Mainframe Basics).

Create Target Definitions with COBOL Source Files


After you import your source definition, you create target tables in the Target Designer. You can create target tables by dragging the source definition from the navigator into the Target Designer workspace. When you drag the source into the Target Designer, the Target Designer automatically creates a target table for your COBOL source definition. The Target Designer also creates a target table and a primary-foreign key relationship for each REDEFINES and OCCURS. REDEFINES and OCCURS are COBOL syntax that allow the user to organize the structure of the data easily. The Designer also creates a generated column ID (GCID) for each OCCURS.

REDEFINES
The REDEFINES clause allows you to specify a different PICTURE clause or a different data name for a previously defined data item. For example, suppose you sometimes want to refer to the decimal portion of the data, sometimes the whole number portion, and other times you need to refer to the entire number. You can use the REDEFINES clause as shown below. 01 03 03 05 05 Data-Group Numeric Item PIC9(5)V99. Numeric-Split Redefines Numeric-Item. Numeric-Whole-Portion PIC 9(5). Numeric-Decimal-Portion PIC 9(2).

In the COBOL source file sales.cbl we imported in the previous section, we can see a REDEFINES clause in the second half of the file: 03 05 05 05 03 05 05 05 05 05 10 10 BODY-DATA. BODY-STORE-NAME PIC X(30). BODY-STORE-ADDR1 PIC X(30). BODY-STORE-CITY PIC X(30). DETAIL-DATA REDEFINES BODY-DATA. DETAIL-ITEM PIC 9(9). DETAIL-DESC PIC X(30). DETAIL-PRICE PIC 9(4)V99. DETAIL-QTY PIC 9(5). SUPPLIER-INFO OCCURS 4 TIMES. SUPPLIER-CODE PIC XX. SUPPLIER-NAME PIC X(8).

For each REDEFINES, the Designer creates a target table and a primary-foreign key relationship when you drag the source into the Target Designer. The Target Designer creates a target table called DETAIL_DATA for the REDEFINES in sales.cbl. In the above example, the Target Designer also creates a target table called SUPPLIER_INFO because of the OCCURS clause. The next section discusses the OCCURS clause in more detail.

OCCURS
The OCCURS clause specifies the number of times a field is repeated. In other words, OCCURS defines the number of entries in a table. A typical example is months in a year: 01 Month-Table 03 Month-Name Pic X(9) Occurs 12 Times The above OCCURS clause specifies that the Month table has 12 entries. For each OCCURS clause, Informatica generates proper outputs through the Normalizer to normalize the data. The Designer creates a target table, a primary-foreign key relationship, and a generated column ID (GCID) for each OCCURS. In the same COBOL source file sales.cbl, we can see an OCCURS clause near the end of the file: 03 DETAIL-DATA REDEFINES BODY-DATA. 05 DETAIL-ITEM PIC 9(9). 05 DETAIL-DESC PIC X(30). 05 DETAIL-PRICE PIC 9(4)V99. 05 DETAIL-QTY PIC 9(5). 05 SUPPLIER-INFO OCCURS 4 TIMES. 10 SUPPLIER-CODE PIC XX. 10 SUPPLIER-NAME PIC X(8). working-storage section. procedure division. Stop run. In the previous section, the Target Designer creates a target table, a primary-foreign key relationship, and a generated column ID (GCID) for the OCCUR in sales.cbl. The target table for the OCCURS in sales.cbl is called SUPPLIER_INFO.

Creating Mappings with COBOL sources

http://psv23cmsmas1:7000/whitepapers/1/Pages/15159.aspx

6/29/2011

15159

Page 3 of 3

When you create a mapping with a COBOL source file containing REDEFINES, you need to use Filter transformations to differentiate between records. A REDEFINES allows you to specify multiple PICTURE clauses for the same physical data location. Therefore, you need to use Filter transformations to separate the data into the tables created by the REDEFINES.

Example
Using the same COBOL source file (sales.cbl), you can make a mapping to filter out BODY_DATA, DETAIL_DATA, and SUPPLIER_INFO into three target tables. In sales.cbl, BODY_DATA contains store information such as store name, store address, and store city. The REDEFINES clause tells you that detail information about merchandise is in the same physical location as BODY_DATA. Detail information about the merchandise in the store includes item, description, price, and quantity. The OCCURS clause tells you that there can be four suppliers to each item. Information about the store, the items, and the suppliers are all in the same physical location in the data file. You use three Filter transformations to separate information about the store, the items, and the suppliers. Notice that at the beginning of the COBOL file, header information of the store is defined with a value of H and detail information about items is defined with a value of D. Detail information about items also includes supplier information. Supplier information has a supplier code that is not null. Using these values, the filter condition are the following: FIL_STORE_INFO : HDR_REC_TYPE='H' FIL_ITEM_INFO : HDR_REC_TYPS='D' FIL_SUPPLIER_INFO : HDR_REC_TYPE='D' AND NOT ISNULL(SUPPLIER_CODE) AND SUPPLIER_CODE !=" The filter conditions depend on the structure of your data. The filter conditions here only apply to the example file sales.cbl. You need to examine your own source file to determine filter conditions.

Creating a Session: FTP COBOL Data Files


After you make mappings with your COBOL source files, you create a session in the Workflow Manager using the Session Wizard. Your data files can be on a machine local to the Informatica Server, or they can be on a remote machine or a mainframe. If your COBOL data files are on a mainframe or on a remote machine, you need to FTP your data files. You can set FTP connections in the Workflow Manager by choosing Server Configuration-FTP connections. You can also use other FTP utilities in pre-session scripts. If your COBOL data file is on a mainframe, you need to FTP the file in binary mode. Otherwise, you might see "garbage" characters in your output. The Informatica FTP utility in the Workflow Manager automatically transfers files in binary mode. You can then specify the file type as EBCDIC in the session. If you are using another FTP utility, you need to check your FTP documentation to change the transfer mode from ASCII to binary.

Related Documents
Mainframe Basics and PowerCenter (15169) Preparing COBOL Copybooks for use with PowerCenter (15301)

Applies To

Database: VSAM Product: PowerCenter

Feedback
Did this article help you? This article resolved my issue This article did not resolve my issue This article helped but additional information was required to resolve my issue

What can we do to improve this information (2000 or fewer characters)

Submit

2010 Informatica Corporation. All rights reserved | KB is best viewed with IE and Firefox

Help

Terms of Use

Privacy Policy

http://psv23cmsmas1:7000/whitepapers/1/Pages/15159.aspx

6/29/2011

You might also like