How do we code a MOVE statement with variable length records in a VSAM file?
FILE VSAMFILE VS
..other field definitions... DEFINE WS-WHOLE-REC W 100 A (large enough for the longest record) JOB ... MOVE VSAMFILE VSAMFILE:RECORD-LENGTH + TO WS-WHOLE-REC ...rest of program...
The above code will ensure that the record length for that particular record is used for the move to the working storage field used for processing this data. Please add a WS-WHOLE-REC = ' ' before reading the next record.
To pad out the WS-WHOLE-REC field, please code:
MOVE VSAMFILE VSAMFILE:RECORD-LENGTH + TO WS-WHOLE-REC FILL ' ' ...
This will prevent the moving of data that is not part of the current record in a VSAM file.