Writing the file with layout



IBM's Command List programming language & Restructured Extended Executor

Writing the file with layout

Postby Suganya.Shanmugam » Thu Jan 06, 2011 2:59 pm

I have the requirement like below:
Two input files. one will have the file layout and the other will have values for that layout.
I need to read the layout and pull the values and have to write it in the output file.
for eg:
Layout of the file is
05 abc 9(5)
05 def9(8)
05 sdhf x(5)

File2 will have val for the layout mentioned above as 111112222222233333

what i need in output is in the below format
abc 11111
def 22222222
sdhf 33333
please help in coding this requirement.
Suganya.Shanmugam
 
Posts: 7
Joined: Thu Nov 11, 2010 10:57 am
Has thanked: 0 time
Been thanked: 0 time

Re: Writing the file with layout

Postby Akatsukami » Thu Jan 06, 2011 5:36 pm

I recommend that you read and process the first data set, creating and filling stems of field tag, field type, starting position, and length (although in the sample data that you present the fields are contiguous and presumably start in position 1, this may not always be the case). Then process the second data set; for each input record iterate through the stems and use the SUBSTR function and concatenation operator to create an output record.

Aside from the obvious return code checks, there are at least two potential error conditions that you have to handle:

  1. What if the data record is of a different length than the layout?
  2. What if the data are different from the field definition (i.e., the field is defined as 9(6), but the data are "ABCXYZ")?
There are likely others, but I'm not moved to do a thorough job of analysis just now.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post