|
View previous topic :: View next topic
|
| Author |
Message |
ksouren007
New User
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?
Regards,
Souren
Code'd |
|
| Back to top |
|
 |
Skolusu
Senior Member
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. |
|
| Back to top |
|
 |
ksouren007
New User
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.
| Code: |
SORT FILEDS=COPY
OUTFIL FNAMES=SORTOF1,ENDREC=1
OUTFIL FNAMES=SORTOF2,
OUTREC ITHEN=(WHEN=(1,5,CH,NE,C'<header>'),
OVERLAY=(1:1,16,UFF,M11,LENGTH=16,239X))
|
|
|
| Back to top |
|
 |
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
you need to show the job output
| Quote: |
| OUTFIL FNAMES=SORTOF2 getting statement syntax error |
The above is insufficient to sort out your issue.
What exactly are you now trying to do ?
Are you trying to write the header in a separate file ?
I doubt you have run what you have posted as I can see other syntax errors
FILEDS should be FIELDS
ITHEN should be IFTHEN
maybe this might help
| Code: |
SORT FIELDS=COPY
OUTFIL FNAMES=SORTOF1,ENDREC=1
OUTFIL FNAMES=SORTOF2,
IFTHEN=(WHEN=(1,5,CH,NE,C'<HEADER>'),
OVERLAY=(1:1,16,UFF,M11,LENGTH=16,239X))
|
Gerry |
|
| Back to top |
|
 |
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
Thanks gcichet.
Sorry for the the typos(FILEDS,ITTHEN) they are because of I didn't actually copy paste my card from mainframe, my shop doesn't let me do so.
But the problem still I'm facing is like below:
| Code: |
SORT FILEDS=COPY
OUTFIL FNAMES=SORTOF1,ENDREC=1
OUTFIL FNAMES=SORTOF2,
IFTHEN=(WHEN=(1,5,CH,NE,C'<HEADER>'),
*
OVERLAY=(1:1,16,UFF,M11,LENGTH=16,239X))
|
OUTFIL STATEMENT : SYNTAX ERROR
And yes I'm trying to create two output files this time first one with Header. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| From the sample input you showed earlier, I think you should be using the PARSE suggestion anyway, |
|
| Back to top |
|
 |
Skolusu
Senior Member
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.
| Code: |
//SYSIN DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,6,CH,NE,C'HEADER'),
BUILD=(1,16,UFF,M11,LENGTH=16))
//* |
|
|
| Back to top |
|
 |
ksouren007
New User
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!
| Code: |
//SYSIN DD *
SORT FIELDS=(1,16,CH,A)
INREC IFTHEN=(WHEN=(1,6,CH,NE,C'HEADER'),
BUILD=(1,16,UFF,M11,LENGTH=16))
SUM FIELDS=NONE
//*
|
|
|
| Back to top |
|
 |
ksouren007
New User
Joined: 30 Jun 2010 Posts: 85 Location: Toronto, ON
|
|
|
|
Skolusu,
One small question:
Can I include another 'AND' condition in my IFTHEN=WHEN card to include a numeric value check also...What I'm trying to get is somewhat as below:
INREC IFTHEN=(WHEN=(1,6,CH,NE,C'HEADER' and 1,16,FS,EQ,NUM)
Can it be included? Please advise. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
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? |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|