Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
Hi,
I have a requirement as below for which I would need advise:
Requirement:
Code:
I/P File FB/LRECL=255
Header<blank----spaces>
99999999<blank-----spaces> ---*digits would be less than 16
888888<blank-----spaces> bytes of varied length.
7777777<blank----spaces>
I would like to have my ouput file as: <FB LRECL=255>
Code:
Header<blank-----spaces>
----16th bytes-------|----rest blank spaces|
0000000099999999<blank----spaces> ---*Leading zeroes would be
0000000000888888<blank----spaces> inserted but overall numeric
0000000007777777<blank----spaces> part's length would be 16.
Can someone please help in achieving this through sort?
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
without code tags it is impossible to provide you with a solution.
Is your data like this?
Code:
HEADER
----+----1----+----2----+----3----+----4----+
99999999 SOME OTHER DATA1
888888 SOME OTHER DATA2
7777777 SOME OTHER DATA3
or like this
Code:
HEADER
----+----1----+----2----+----3----+----4----+
99999999 SOME OTHER DATA1
888888 SOME OTHER DATA2
7777777 SOME OTHER DATA3
If it is case # 1 then it is quite simple. USE OVERLAY treating the first 16 bytes as UFF and use M11 edit mask with a length of 16
If the data looks like case # 2 then you need to parse the data using ENDBEFR=C' ' and then build the record treating the first 16 bytes as UFF and use M11 edit mask with a length of 16 and appending the rest of the data.
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
Thanks Kolusu the first option went fine with me. Tried the below sortcard and it worked.
Code:
OUTREC OVERLAY=(1:1,16,UFF,M11,LENGTH=16,239X)
But I have a header part also for which I am trying the below sortcard but it is failing with OUTFIL FNAMES=SORTOF2 getting statement syntax error. Not being able to figure out why.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
ksouren007,
Why are you trying to split the header into a separate file? Is it because the UFF is translating that zeros? You could have avoided that by using an IFTHEN statement.
Is your intention to just copy the first 16 bytes and then pad with spaces for the rest of 255 bytes? Don't you need the data from byte 17 onwards?
If you indeed want only the first 16 bytes other than the header record , you can simply use the following. This will leave the header record as is but pad the numeric values with leading zeroes.
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
Thankls Skolusu..It worked perfectly!!
Yes the OUTREC IFTHEN was not working and UFF was prefixing the header with zeroes so I tried putting them in a seperate file.
Also I wont need the bytes beyond 16th position but wanted to initialize them as spaces so used that 239X.
Your sort card worked great, I just added a line to remove duplicates also.
Thanks for your help once again!
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Why don't you describe what it is that you want to do. Show a sample input file and expected output from that sample input. If you want to know what field-types you can use NUM with, why don't you look at the manual?