Page 1 of 1
increase working storage Variable length in cobol
Posted: Sat Apr 27, 2024 8:11 pm
by Karthik G
Hi
This was asked in the interview, "If I increase working storage Variable length in cobol, What need to change in jcl".
My answer was there should not be any change. Interviewer said, "Think again". But didn't really told me the answer. What's your answer, please let me know.
Re: increase working storage Variable length in cobol
Posted: Sun Apr 28, 2024 4:48 am
by zum13
Hello.
Well, I'm presuming that the variable they are talking about changing would affect the length of a record, so the LRECL of the file would have to be altered accordingly.
Re: increase working storage Variable length in cobol
Posted: Wed May 01, 2024 11:58 am
by Karthik G
But in that it should be part of output variable definitions also, not only of working-storage, right?
Re: increase working storage Variable length in cobol
Posted: Wed May 01, 2024 6:08 pm
by zum13
One of the common practices I've seen repeatedly is the situation where the record declaration in the FILE SECTION is essentially treated as a dummy that simply defines the record length. The declarations of the individual fields in the record are defined within WORKING STORAGE (usually as a copybook) and the record is written from there. For example,
Code: Select all
FD OUTPUT-FILE
RECORDING MODE V
BLOCK CONTAINS 0 RECORDS
LABEL RECORDS ARE STANDARD
RECORD IS VARYING IN SIZE FROM 1 TO 200
DEPENDING ON WA-RECORD-LENGTH.
01 OUTPUT-RECORD PIC X(200).
Records would then be written from WORKING STORAGE using the "WRITE record FROM ws-field" form of the WRITE statement.
Since the question was about what effect changing a variable definition would have on JCL and "none" is the wrong answer, then I assume that the change being referenced would be one that affects the record length. If the program is coded as above, then four changes are needed:
- the change to the referenced variable in the WORKING STORAGE record definition;
- the "RECORD IS VARYING IN SIZE" clause to specify the new maximum record length;
- the "dummy" record definition in the FILE SECTION;
- the LRECL of the file.
If the individual fields in the record are defined in the FILE SECTION then amending the record layout to extend the record will automatically change the record length (and the "WRITE record" form of the WRITE statement will be in use). For a fixed length record the "RECORD IS VARYING IN SIZE" would not be present.
Of course, if you were amending the record to use some existing FILLER space that would not affect the record length, then yes, there would be no changes to JCL required.
Re: increase working storage Variable length in cobol
Posted: Sat May 04, 2024 4:38 pm
by Karthik G
Thanks zum13 for that explanation. This is really helpful. If this is the situation then yes, a change in working-storage can make a difference in the LRECL, not sure if this is what interviewer has thought of. If yes, should have given some background of the question.
Re: increase working storage Variable length in cobol
Posted: Sat May 04, 2024 5:28 pm
by zum13
In an interview situation, there's no harm in asking the interviewer questions. If that was the extent of the question that they asked, then my response would be "it depends on what the variable is used for" and then ask what context the variable is being used in. Sometimes, the reason for asking a question is to make sure the right question is asked in response.