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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable length files

Status
Not open for further replies.

mjurjovec

Programmer
Nov 27, 2000
1
0
0
US
I have a question regarding variable length files. I am converting a master file into 3 seperate files to use in DB2. The master file is a variable length file. The fixed length section contains customer information. Each customer can have multiple orders, depending on the number specified in the customer section of the fill:

05 NUM-ORDER PIC 99
05 ORDER-HEADER OCCURS 0 TO 99 TIMES DEPENDING ON NUM-ORDER

The problem I am having is that each order can have 0 to 25 detail lines. This would be a depending on clause, but what would the syntax look like? The field it depends on is part of the order data:

05 NUM-ORDER PIC 99
05 ORDER-HEADER OCCURS 0 TO 99 TIMES DEPENDING ON NUM-ORDER
10 ORDER-HEADER-DATA
10 ORDER-HEADER-NUM-DETAIL
10 ORDER-HEADER-DETAIL OCCURS 0 TO 25 TIMES DEPENDING ON
ORDER-HEADER-NUM-DETAIL????????

How do I declare an array inside of an array like this?
An help would be more than appreciated.
 
Declaring an array within an array always gives me the creeps; it quickly takes up massive amounts of memory, and referencing to each of the order detail fields with double indexes isn't very legible either.
I don't know what you want with this 2-dimensional array, but if you are planning on declaring a file description with it i would rather suggest the use of multiple record types, i.e. an order-record with order-information, and order-detail records for the detail lines. Add a field record-type to distinguish them and preferably some order-key-information, too (convenient for sorting purposes).

Good luck !
 
Multiple record types definately sounds like the answer to this. I am not sure if it is the case on all versions of cobol, but from what I have seen, occurs depending is invalid and not allowed within another occurs depending on.

s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top