Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COBOL REDEFINE TWO RECORDS 2

Status
Not open for further replies.

cobolcobol

Programmer
Mar 13, 2003
1
CA
HOW TO DEFINE A INPUT RECORD 2 TIMES WITH 1 INPUT FILE

FOR EXAMPLE


01 SALES-REC.
05 SALES-NO-IN PIC X(5).
05 SALES-NAME-IN PIC X(20).
05 SALES-NUM-REC-IN PIC 9(3).
05 BLANK-SPACE PIC X(2).

01 SALES-REC2
05 SALES-NO-IN PIC X(5).
05 SALES-NAME-IN PIC X(20).
05 SALES-AMT-INT PIC 9(5)V99.




 
If the record descriptors are in the FILE SECTION, the redefinition is implicit. If not:
Code:
01  SALES-REC.
    05 SALES-NO-IN        PIC X(5).
    05 SALES-NAME-IN      PIC X(20).
    05 SALES-NUM-REC-IN   PIC 9(3).
    05 BLANK-SPACE        PIC X(2).
    05                    PIC X(2).
01 SALES-REC2 REDEFINES SALES-REC.
    05 SALES-NO-IN        PIC X(5).
    05 SALES-NAME-IN      PIC X(20).
    05 SALES-AMT-INT      PIC 9(5)V99.
The extra filler is not required in most compilers, but I like to put it in for documentation.

 
fd filename.

01 SALES-REC.
05 SALES-NO-IN PIC X(5).
05 SALES-NAME-IN PIC X(20).
05 SALES-NUM-REC-IN PIC 9(3).
05 BLANK-SPACE PIC X(2).

01 SALES-REC2
05 SALES-NO-IN PIC X(5).
05 SALES-NAME-IN PIC X(20).
05 SALES-AMT-INT PIC 9(5)V99.
--------------------------------------------
or

use level 66 (RENAMES)

 
Just a minor point. If you define two or more records for the same file and the record definitions are not the same length, COBOL assumes you are defininig a Variable record file. That may or may not be what was intended. If the file has fixed length records, you should be sure to include appropriate FILLER.

Regards.

Glenn
 
Hi Glenn,

It may be a minor point, but a good one. If you're not aware of it, you can spend a lot of time scratching your head, wondering why you have a VB file on your hands. A file with all those nasty binary BDW/RDWs up front.

Regards, Jack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top