In file section of a COBOL program, I have the following line.Record varying from 122 to 160 depending on WS00_RECORD_LENGTH. How would the value of WS00_RECORD_LENGTH found out? Where will it be?

Questions by VIRUPAKSH

Showing Answers 1 - 8 of 8 Answers

soumya_dev

  • Mar 1st, 2006
 

In this line you have to defined WS00_RECORD_LENGTH as S9(4) comp.

And when you write the statement:

READ FILE-NAME

this variable automatically get the record length in this variable.

  Was this answer useful?  Yes

rfl

  • Dec 2nd, 2006
 

FILE  SECTION.                                                  
FD  THE-FILE RECORD IS VARYING  DEPENDING ON REC-LENGTH.        

01  THE-RECORD  PICTURE X(5000) .                                
WORKING-STORAGE  SECTION.                                        
01  REC-LENGTH  PICTURE 9(5)  COMPUTATIONAL.                    
01  SAVED-RECORD PICTURE X(5000).                                
PROCEDURE DIVISION.                                              
* Read a record of unknown length.                              
    READ THE-FILE.  
    DISPLAY REC-LENGTH.                            
* or use REC-LENGTH to access the right amount of data:
    MOVE THE-RECORD (1:REC-LENGTH) TO SAVED-RECORD.                                                                  

  Was this answer useful?  Yes

Usually, W00_RECORD_LENGTH would be part of the record definition somewhere within the first 122 bytes of the record (it could not be in the variable portion of the record.) When creating such a record, you would have to determine the value it should have yourself, depending on how much of the variable 38 bytes is appropriate.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions