IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

COBOL Fundamentals : file structure


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
shobhit garg

New User


Joined: 09 Jan 2009
Posts: 8
Location: Pune

PostPosted: Wed Mar 11, 2009 5:00 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 11, 2009 5:05 pm
Reply with quote

What values for x and y did you calculate?
Back to top
View user's profile Send private message
shobhit garg

New User


Joined: 09 Jan 2009
Posts: 8
Location: Pune

PostPosted: Wed Mar 11, 2009 5:13 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 11, 2009 5:30 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Wed Mar 11, 2009 5:34 pm
Reply with quote

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
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Wed Mar 11, 2009 6:15 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top