Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving a fixed length field to a variable length field 2

Status
Not open for further replies.

hugheskbh

Programmer
Dec 18, 2002
37
US
Hi,

I need to move a 200 byte fixed length field to a variablel length field in Cobol. Can someone help me with an example?
Also, how would I know the length of the variable length field. In other words, the last character of the fixed length field needs to be the length of the variable field.
If anyone can help me, please do so.

Thanks
 
hugheskbh-

OK. I think I understand. The input is a fixed length record containing one field. The output is a variable length record containing the contents of each input record with trailing spaces eliminated. The target OS is some version of IBM mainframe.

Here's some pseudo code that outlines how I'd approach it:

1. Read the input record.
2. Determine the length of the field. I'd use INSPECT REVERSE (see thread 858815)
3. The output file should be set up roughly as:
Code:
FD OUTPUT-FILE 
   RECORD IS VARYING IN SIZE 
   DEPENDING ON OUTPUT-RECORD-LENGTH. 

01  OUTPUT-REC. 
    02 EACH-BYTE 
       OCCURS 1 TO 200 TIMES 
       DEPENDING ON OUTPUT-RECORD-LENGTH    PIC X.
4. Move the length of the input field from step 2 to OUTPUT-RECORD-LENGTH (defined somewhere in WORKING-STORAGE perhaps).
5. Move the input record to the output record using reference modification as outlined in my first post.
6. Write the output record.
7. Repeat until end of file.
 
I know nothing about mainframes.
No text file utilities in the OS like the unix's sed command ?
sed 's! *$!!' /path/to/input > output
 
nope. a lot harder to do anything at all. (Give me back my AS400!!!)


Even the code from 3gm may not work depending on the COBOL Version used, and offcourse that the DD definition must also be correct.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Tom,

I just thrundled ahead at the keyboard while thinking for a Q&D solution, and changed from a perform varying to a perform until just last-minute. Obviously never actualy compiled it, or looked at it close enough.
Sorry for the confusion I may have caused. :-(

Thnx for the pointer.
TonHu
 
It worked. I used 3gm suggestions and it looks good.
Thanks for all of your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top