View previous topic :: View next topic
|
Author |
Message |
shobhit garg
New User
Joined: 09 Jan 2009 Posts: 8 Location: Pune
|
|
|
|
HI All,
Can anybody tell me ,Given the layout shown for CUSTMAST-REC, what are the correct values for 'x' and 'y' in the scenario above?
Code: |
FD CUSTMAST
RECORD IS VARYING IN SIZE
FROM x TO y CHARACTERS
DEPENDING ON RECORD-LENGTH.
01 CUSTMAST-REC.
05 CR-CUSTOMER-DATA.
10 CR-CUSTOMER-ID PIC X(10).
10 CR-ORDER-COUNT PIC 9(02).
05 CR-ORDER-DATA OCCURS 1 TO 20 TIMES
INDEXED BY CROD-INDEX.
10 CR-ORDER-DATE PIC X(08).
10 CR-ORDER-ITEM PIC X(10).
10 CR-ORDER-QTY PIC 9(05).
...
WORKING-STORAGE SECTION.
...
05 RECORD-LENGTH PIC 9(03). |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
What values for x and y did you calculate? |
|
Back to top |
|
|
shobhit garg
New User
Joined: 09 Jan 2009 Posts: 8 Location: Pune
|
|
|
|
see these are possible answers..but i dont know which one is correct ?
x=12, y=35
x=33, y=422
x=35, y=472
x=12, y=500
x=35, y=700 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
So this is a homework question?
How many bytes is CR-CUSTOMER-DATA?
How many bytes is each occurrence of CR-ORDER-DATA?
Once you figure those, simple arithmetic gives you the answers. If you can't figure them, you need to visit the manuals (link at the top of the page), find the COBOL Language Reference, and read up on DATA DIVISION fields and their lengths. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
drowning in the kitchen sink...... why not use a bit of logic ???
&LENGTH1 length of the fixed part
&LENGTH2 length of one entry of the variable part
&OCCURS1 number of minimun number of entries
&OCCURS2 number of maximum number of entries
minimun total length = &LENGTH1 + &LENGTH2 * &OCCURS1
maximum total length = &LENGTH1 + &LENGTH2 * &OCCURS2
simple math and simple logic |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Quote: |
what are the correct values for 'x' and 'y' in the scenario above? |
Actually, the 'x' needs to be no longer than the minimum length, and could be even shorter. The 'y' can be no shorter than the maximum length, and could be longer, up to the defined dataset's LRECL (minus the RDW). |
|
Back to top |
|
|
|