How do we code a MOVE statement with variable length records in a VSAM file?

Document ID : KB000012339
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

How do we code a MOVE statement with variable length records in a VSAM file?

Environment:
CA Easytrieve Report Generator, release 11.6
Answer:

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 '  '                               
  ...                                      
Additional Information:

This will prevent the moving of data that is not part of the current record in a VSAM file.