IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Inserting Leading zeroes through Sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Thu Oct 03, 2013 8:01 pm
Reply with quote

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
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Oct 04, 2013 3:35 am
Reply with quote

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
View user's profile Send private message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Fri Oct 04, 2013 11:47 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Fri Oct 04, 2013 12:45 pm
Reply with quote

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

Code:

SORT FILEDS=COPY


FILEDS should be FIELDS


Code:
OUTREC ITHEN=(WHEN


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
View user's profile Send private message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Fri Oct 04, 2013 1:37 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 04, 2013 1:39 pm
Reply with quote

From the sample input you showed earlier, I think you should be using the PARSE suggestion anyway,
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Fri Oct 04, 2013 6:13 pm
Reply with quote

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
View user's profile Send private message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Fri Oct 04, 2013 6:36 pm
Reply with quote

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
View user's profile Send private message
ksouren007

New User


Joined: 30 Jun 2010
Posts: 85
Location: Toronto, ON

PostPosted: Fri Oct 04, 2013 8:12 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Oct 04, 2013 10:02 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top