READ xxx INTO yyy is COBOL shorthand for READ xxx followed by MOVE 
xxx-record-area to yyy.

COBOL MOVE's (even implied moves) are *supposed* to respect the value of the 
OCCURS DEPENDING ON variable value, so this *should* work with no programmer 
intervention, but I haven't actually done exactly this so I am not positive.

To be "safe", I would tell the programmer to set up a record-length variable 
for the COBOL FILE (so that after any READ he knows the exact length of the 
record that was read) and then use  SEPARATE READ and MOVE statements that look 
like this:

READ xxx
        AT END (do endfile processing)
        NOT AT END MOVE xxx-record-area (1 : record-length-variable) TO yyy (1 
: occurs-depending-on-variable)
END-READ

That will move the shorter of the two lengths into the yyy variable, up to but 
not past the value of the occurs-depending-on-variable.

Record length variables for varying-length files are set in the RECORD clause 
of the FILE SECTION FD file entry (RECORD VARYING DEPENDING ON 
record-length-variable).

There is no way in COBOL to set up a record-length-variable in the FILE SECTION 
for a fixed-length file.  For a fixed-length file, just set up a 
WORKING-STORAGE record-length-variable binary VALUE actual-fixed-record-length.

HTH

Peter

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of John McKown
Sent: Wednesday, September 11, 2013 1:02 PM
To: [email protected]
Subject: COBOL "problem" (not really), but sort of.

A programmer came by today with a problem. He is sometimes getting a S0C4-4
abend in a COBOL program. This is a subroutine. One of the parameters
passed in is a data area, which can be of various lengths. It is defined
with an OCCURS DEPENDING ON with a data element within the area. I.e. the
first 05 level is PIC S9(5) COMP. The subroutine does a READ of a data set
into this area. This is where the abend occurs. The reason is because the
OCCURS DEPENDING ON maximum size is significantly larger than what the
caller is passing it. And the READ to the 01 is trying to pad the entire
possible 01 level with blanks.

The problem is how do I describe this to a COBOL programmer who just
doesn't "get it". He expects COBOL to _not_ pad the "non existent"
occurrences with blanks. And, if fact, to not even reference this area
wherein they would have resided, had they existed. I'm just get "deer in
headlights" looks. I'm not using the correct words, somehow.

-- 

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to