MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
arungr Beginner Joined: 12 Feb 2005 Posts: 16 Topics: 4
Posted: Wed Mar 21, 2007 2:14 am Post subject: Remove leading Zeroes
Hello,
Below is the requirement
File 1
Code:
003145,0986,2006-01-18, ,007894
000784,4564,2006-02-10, ,032891
We have to get in File 2 by removing all leading zeroes and spaces
File 2
Code:
3145,986,2006-01-18,,7894
784,4564,2006-02-10,,32891
It can be done in COBOL or SORT. Could anybody help me on this??
Thanks,
Arun.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Wed Mar 21, 2007 1:45 pm Post subject:
Try this DFSORT JCl
Code:
//STEP0010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
003145,0986,2006-01-18, ,007894
000784,4564,2006-02-10, ,032891
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC OVERLAY=(01:01,06,SQZ=(SHIFT=LEFT,PREBLANK=C'0',LENGTH=06),
08:08,04,SQZ=(SHIFT=LEFT,PREBLANK=C'0',LENGTH=04),
13:13,10,SQZ=(SHIFT=LEFT,PREBLANK=C' ',LENGTH=10),
24:24,10,SQZ=(SHIFT=LEFT,PREBLANK=C' ',LENGTH=10),
35:35,06,SQZ=(SHIFT=LEFT,PREBLANK=C'0',LENGTH=06))
OUTFIL BUILD=(1,80,SQZ=(SHIFT=LEFT,PAIR=APOST))
/*
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
Frank Yaeger Sort Forum Moderator Joined: 02 Dec 2002 Posts: 1618 Topics: 31 Location: San Jose
Posted: Wed Mar 21, 2007 2:50 pm Post subject:
Kolusu,
Thanks for calling my attention to this one. I missed it because I don't usually look at this topic.
Your solution works for the example shown, but it won't work if there are trailing zeros. For example, if the input records were:
Code:
003100,0906,2006-01-18, ,007804
000780,4500,2006-02-10, ,032800
the output should be:
Code:
3100,906,2006-01-18,,7804
780,4500,2006-02-10,,32800
but your solution would give:
Code:
31,96,2006-01-18,,784
78,45,2006-02-10,,328
Arun,
Here's a DFSORT job that will handle the trailing zeros:
Code:
//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SORTIN DD *
003100,0906,2006-01-18, ,007804
000780,4500,2006-02-10, ,032800
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(41:C'*')),
IFTHEN=(WHEN=INIT,
BUILD=(1,7,JFY=(SHIFT=LEFT,PREBLANK=C'0'),
8,5,JFY=(SHIFT=LEFT,PREBLANK=C'0'),
13,10,C',,',
35,7,JFY=(SHIFT=LEFT,PREBLANK=C'0'),80:X)),
IFTHEN=(WHEN=INIT,
BUILD=(1,80,SQZ=(SHIFT=LEFT,PREBLANK=C'*')))
/*
Note that z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) is required in order to use DFSORT's JFY and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:
www.ibm.com/servers/storage/support/software/sort/mvs/peug/ _________________ Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
arungr Beginner Joined: 12 Feb 2005 Posts: 16 Topics: 4
Posted: Wed Mar 21, 2007 10:08 pm Post subject:
Kolusu/Frank Yaeger,
Thanks very much. Frank's solution is working for me.
-Arun.
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum