MVSFORUMS.com A Community of and for MVS Professionals
View previous topic :: View next topic
Author
Message
rkarthik22 Beginner Joined: 27 Sep 2008 Posts: 24 Topics: 9
Posted: Thu Feb 11, 2010 11:12 am Post subject: remove leading zeroes and left shift the values
Hi Kolusu,
http://www.mvsforums.com/helpboards/viewtopic.php?t=8788
Here is the thread , where you discussed about removing the leading zeroes and left shift the values of a field.
Here is the sort card.
Code:
//STEP0100 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0000107218
0000107768
0000107768
0000107652
0000107652
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC OVERLAY=(1,10,JFY=(SHIFT=LEFT,PREBLANK=C'0',LENGTH=10))
/*
But, while i ran the job, with my sample inputs, i got the following output...
Code:
input:
100
50
1
00100
4
025
01000
005000
Code:
Output i got:
1
5
1
1
4
25
1
5
Which is wrong.
Expected output should be:
Code:
100
50
1
100
4
25
1000
5000
Can you please help me to get the correct output.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Thu Feb 11, 2010 12:29 pm Post subject:
rkarthik22 ,
Use the following DFSORT JCL. I am going to correct the other topic also
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
100
50
1
00100
4
025
01000
005000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(1,6,JFY=(SHIFT=RIGHT))),
IFTHEN=(WHEN=INIT,OVERLAY=(1,6,ZD,M10,LENGTH=6)),
IFTHEN=(WHEN=INIT,OVERLAY=(1,6,JFY=(SHIFT=LEFT)))
//*
_________________ 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: Thu Feb 11, 2010 4:01 pm Post subject:
Here's a slightly simpler way to do it with DFSORT:
Code:
SORT FIELDS=COPY
OUTREC OVERLAY=(1,6,UFF,M10,LENGTH=6,
1:1,6,JFY=(SHIFT=LEFT))
_________________ 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
rkarthik22 Beginner Joined: 27 Sep 2008 Posts: 24 Topics: 9
Posted: Sun Feb 14, 2010 10:48 am Post subject: Re:
Thank you very much Kolusu/Frank.
Both works.
You both are great.
After removing the leading zeroes i want to add '.00' at the end of each field value (but not for the values - 'spaces', '<', '>')
Field length is 14 bytes.
Input values:
Code:
100
spaces
50
1
100
<
4
25
1000
>
5000
Expected output:
Code:
100.00
spaces
50.00
1.00
100.00
<
4.00
25.00
1000.00
>
5000.00
'<' and '>' are not junk values. They are valid values.
Can any one of you please help.
thanks for your valuable time.
Back to top
kolusu Site Admin Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
Posted: Mon Feb 15, 2010 11:41 am Post subject:
rkarthik22 ,
Use the following DFSORT JCL
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
100
50
1
100
<
4
25
1000
>
5000
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,14,SS,EQ,C'>',OR,1,14,SS,EQ,C'<',OR,
1,14,CH,EQ,C' '),OVERLAY=(1:1,14)),
IFTHEN=(WHEN=NONE,OVERLAY=(1,14,UFF,M10,LENGTH=14,
1:1,14,JFY=(SHIFT=LEFT,TRAIL=C'.00')))
//*
_________________ Kolusu
www.linkedin.com/in/kolusu
Back to top
rkarthik22 Beginner Joined: 27 Sep 2008 Posts: 24 Topics: 9
Posted: Sat Feb 20, 2010 11:31 am Post subject: Re:
Great Kolusu!!!
It works....
It also removes leading zeroes additionally...
Code:
Example input:
100
<
50
>
spaces
0078
<
95
030
O/P:
100.00
<
50.00
>
spaces
78.00
<
95.00
30.00
Thank you very much...
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