Adding leading Zero to output value



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Adding leading Zero to output value

Postby rjambu » Tue Mar 01, 2011 10:59 pm

I am trying to add leading zero to a alphanumeric value o/p.
not working as expected

//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=04),
%01=(ENDBEFR=X'6A',FIXLEN=05)),

BUILD=(%00,%01,UFF,M11,)
/*


i/p:
----+----

1212¦1000
1213¦R001
1214¦XXXX

o/p should be :
----+----

121201000
12130R001
12140XXXX

I need the 2nd columns should be having leading zero (5 char length ) in the answerset


when i Use the below code i get the correct answer for numeric data alone,
But doesnt work for alphanuberic values.

is there any solution for this ?

Thanks,
JRS
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding leading Zero to output value

Postby Frank Yaeger » Tue Mar 01, 2011 11:34 pm

Going by your example, it appears all you need to do is overlay the 5th column with a 0 so you could use these DFSORT control statements:

  OPTION COPY             
  INREC OVERLAY=(5:C'0')   


If your requirement is really more complicated than that, please show an example of your input records and expected output records that show the actual complexity of what you're trying to do, and explain the rules for getting from input to output.
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Adding leading Zero to output value

Postby rjambu » Wed Mar 02, 2011 1:08 am

Hi Frank,

I tried using the bleow code

//SYSIN DD *
OPTION COPY
INREC OVERLAY=(5:C'0'),
PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=04),
%01=(ENDBEFR=X'6A',FIXLEN=05)),
BUILD=(%00,%01)
/*
//

Gives syntax error, Donno wheather i used ur code in right place!
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding leading Zero to output value

Postby Frank Yaeger » Wed Mar 02, 2011 2:11 am

Sigh. You DON'T NEED PARSE to overlay one character in position 5 - you just need OVERLAY like this:

//SYSIN DD *
  OPTION COPY             
  INREC OVERLAY=(5:C'0')
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1079
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 15 times

Re: Adding leading Zero to output value

Postby rjambu » Wed Mar 02, 2011 7:43 pm

Hi Frank,

i tried with the overlay removing the parse from JCL, Not sure how to change the existing code to overlay


//SORTIN DD DSN=A.B.SRC_IN,DISP=SHR
//SORTOUT DD DSN=A.B.TGT_OUT,
// UNIT=DISK,SPACE=(TRK,(1,2),RLSE),
// DCB=(LRECL=302,BLKSIZE=0,RECFM=FB),
// DISP=(NEW,CATLG,DELETE)
//SYSSORT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(5:C'0'),(%00=(ENDBEFR=X'6A',FIXLEN=04),
%01=(ENDBEFR=X'6A',FIXLEN=05)),
BUILD=(%00,%01)
/*

Can you help me in this

Thanks
JRS
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding leading Zero to output value

Postby NicC » Wed Mar 02, 2011 8:15 pm

why are you not using Frank's code as supplied? He has given a complete solution. Why your ENDBEFR, FIXLEN & BUILD?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Adding leading Zero to output value

Postby enrico-sorichetti » Wed Mar 02, 2011 8:24 pm

most probably the initial requirement was not properly defined/described!
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 3006
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 165 times

Re: Adding leading Zero to output value

Postby rjambu » Wed Mar 02, 2011 9:16 pm

Hey Guys Sorry for not giving the correct source scenario,

Here is the new CSV i/p data that I get.

1st column comes blank
2nd column with 4 char length
3rd column Blank data
4th Column contain City
5th Column Contain State code


Source data Required O/p Data

¦1340¦¦Scranton¦PA --01340----Scranton-------PA
¦2140¦¦ Cleveland¦OH --02140----Cleveland------OH
¦R000¦¦Chicago¦IL --0R000----Chicago--------IL
¦X990¦¦¦ --0X990---------------------


In the o/p file layout, I represent the spaces as ‘-’ , the o/p needs the exact same layout as this will be used by a cobol PGM that will use this layout.

That is the reason I used the PARSE statement.


Before the requirement to add Zero before the 2nd column the JCL code looked like this and worked fine :

//SORTIN DD DSN=A.B.C,DISP=SHR
//SORTOUT DD DSN=A.B.C,
// UNIT=DISK,SPACE=(TRK,(1,2),RLSE),
// DCB=(LRECL=28,BLKSIZE=0,RECFM=FB),
// DISP=(NEW,CATLG,DELETE)
//SYSSORT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*
//SYSIN DD *
SORT FIELDS=COPY
INREC PARSE=(%00=(ENDBEFR=X'6A',FIXLEN=02),
%01=(ENDBEFR=X'6A',FIXLEN=05),
%02=(ENDBEFR=X'6A',FIXLEN=04),
%03=(ENDBEFR=X'6A',FIXLEN=15),
%04=(ENDBEFR=X'6A',FIXLEN=02)),
BUILD=(%00,%01,%02,%03,%04)
/*

thx
JRS
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Adding leading Zero to output value

Postby NicC » Wed Mar 02, 2011 10:40 pm

Are the ¦s actually in the data? Probably best if you show the data as it is - cut'n'paste and use code tags so that we cn see the real alignment.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Adding leading Zero to output value

Postby rjambu » Wed Mar 02, 2011 10:53 pm

Here is the Source data and the required o/p data


Source data

¦1340¦¦Scranton¦PA
¦2140¦¦ Cleveland¦OH
¦R000¦¦Chicago¦IL
¦X990¦¦¦


Required O/p Data

  01340    Scranton       PA
  02140    Cleveland      OH
  0R000    Chicago        IL
  0X990                   


Thanks JRS
rjambu
 
Posts: 27
Joined: Tue Feb 08, 2011 7:59 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post