Professional Documents
Culture Documents
Working With COBOL Source
Working With COBOL Source
Page 1 of 3
KB Help
Rate It: Knowledge Base Home View Document Average Rating: (1 Rating)
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).
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.
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.
Related Documents
Mainframe Basics and PowerCenter (15169) Preparing COBOL Copybooks for use with PowerCenter (15301)
Applies To
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
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