how to suppress the zero in sort utility

Created on May 11, 2021, 1:05 p.m. - by Michael, Nicholas


I want to remove the leading zeroes in the number.

For example, I have an input file. 

00015
00220
07000

and the output file should be,
15
220
7000
 
Can anyone please suggest?


Comments (6)

Parker, Paul
May 12, 2021, 4:23 p.m.

try this code, let me know if you have any issue

INREC BUILD=(1,5,ZD,EDIT=(IIIII))           
OUTREC BUILD=(1,5,JFY=(SHIFT=LEFT))  


Matthew, Marry
May 15, 2021, 4:59 a.m.

Try this,

//STEP1     EXEC PGM=ICEMAN                         
//SYSOUT   DD SYSOUT=*                             
//SORTIN   DD *                                     
00015
00220
07000                                        
//SORTOUT  DD SYSOUT=*                             
//SYSIN    DD    *                                 
  OPTION COPY                                       
  INREC BUILD=(1,5,ZD,EDIT=(IIIII))           
  OUTREC BUILD=(1,5,JFY=(SHIFT=LEFT))             
/* 


Andrew, Brian
May 15, 2021, 5:09 a.m.

You can do it by SORT utility also, see below example

//STEP0050 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                       
11,   12.50                           
11,  120.60                           
11, 1000.80                           
//SORTOUT  DD SYSOUT=*             
//SYSIN    DD *                       
  OPTION COPY                           
  OUTREC FIELDS=(1,11,SQZ=(SHIFT=LEFT))
/*


Michael, Nicholas
May 15, 2021, 5:16 a.m.

Thank you Matthew 

I used the below SORT utility and got the expected result.

//STEP1 EXEC PGM=SORT                 
//SYSOUT   DD SYSOUT=*                 
//SORTIN   DD *                       
   15
  220
 7000                           
//SORTOUT  DD SYSOUT=*             
//SYSIN    DD *                       
  OPTION COPY                           
  OUTREC FIELDS=(1,5,SQZ=(SHIFT=LEFT))
/*


Parker, Paul
May 16, 2021, 2:49 a.m.

Your question and the solution are different. Initially, you wanted to remove the leading Zeros but your solution will remove the spaces. Please provide your requirements clearly.


Srinivasan, Panneer Selvam
May 16, 2021, 3:09 a.m.

You can do it in a single step as below -

OPTION COPY                                   
  INREC BUILD=(1,5,ZD,EDIT=(IIIII))   
  OUTREC BUILD=(1,5,SQZ=(SHIFT=LEFT))     


Copyright 2020 by ibmmainframer. All Rights Reserved.