KateMak
KateMak

Reputation: 1649

FD with Cobol table in FILE SECTION of program?

I have an input file that contains a name and number in the first 40 bytes, and then four different funds and fund numbers for that name. I was wondering how to create a Cobol table in my FILE SECTION to read this data. I have this but apparently it's bigger or smaller than 80 bytes? Or maybe my table is wrong?

FD  SALES-FILE                               
RECORDING MODE IS F.                     

01  SALES-RECORD.                            
    05  BROKER-REGION         PIC 9.         
    05  BROKER-CITY           PIC X(19).     
    05  BROKER-NAME           PIC X(20).     

01  SALES-BROKER-TBL.                        
    05 BROKER-TBL-DATA        OCCURS 4 TIMES.
       10  FUND-NUMBER        PIC 9(2).      
       10  PRICE-FLAG         PIC 9.         
       10  DEPOSIT-AMT        PIC 9(5)V99.   

The SALES-RECORD has 40 bytes, then the table has 10 bytes per entry and occurs 4 times, so that adds up to 80 right? Anyone know what I am doing wrong?

Upvotes: 1

Views: 3355

Answers (1)

NealB
NealB

Reputation: 16928

Try the following...

01  SALES-RECORD.                            
    05  BROKER-REGION         PIC 9.         
    05  BROKER-CITY           PIC X(19).     
    05  BROKER-NAME           PIC X(20).                                    
    05 SALES-BROKER-TBL.                        
       10 BROKER-TBL-DATA        OCCURS 4 TIMES.
          15  FUND-NUMBER        PIC 9(2).      
          15  PRICE-FLAG         PIC 9.         
          15  DEPOSIT-AMT        PIC 9(5)V99.   

If I understood correctly the broker and 4 funds all occur within the same record. So all you should have to do here is combine both record layouts into a single record.

The Broker Region, City and Name require 40 bytes, then each Broker Table row requires 10 bytes. Four of these make up the Sales Broker Table and require another 40 bytes. Together this gives you a total of 80 bytes per record.

Upvotes: 1

Related Questions