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

Remove leading zeroes


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Wed Aug 09, 2023 8:11 pm
Reply with quote

Is there a way to replace leading zeroes with spaces in alphanumeric field? It's a 24-byte field, but the 1st 10 characters contain the value I need to remove the leading zeroes.

Input:
Code:
0000000019
000XXXXXXX
0000000001
000OPSCARA


Output:
Code:
        19
   XXXXXXX
         1
   OPSCARA


The business hasn't decided if the result will be left or right justified, I added my output as right justified, but if they prefer left, I can handle this with the JFY parameter.

I tried the UFF parameter but got mixed results.

Any assistance would be greatly appreciated.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1247
Location: Bamberg, Germany

PostPosted: Wed Aug 09, 2023 8:39 pm
Reply with quote

A non-safe option is the following:
Code:
OPTION COPY                                                     
INREC IFTHEN=(WHEN=(1,10,FS,EQ,NUM),BUILD=(1,10,CSF)),           
  IFTHEN=(WHEN=NONE,BUILD=(1,10,JFY=(SHIFT=RIGHT,PREBLANK=C'0')))
END

Disadvantage, it will remove Nulls on the end of non digits as well. But you see what can be done.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1247
Location: Bamberg, Germany

PostPosted: Thu Aug 10, 2023 11:46 am
Reply with quote

<deleted>
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1247
Location: Bamberg, Germany

PostPosted: Thu Aug 10, 2023 12:27 pm
Reply with quote

This should work better, feel free to improve.

Code:
OPTION COPY                                             
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'''',1,10,C'''')),
  IFTHEN=(WHEN=INIT,                                   
    PARSE=(%=(ABSPOS=81,STARTAFT=C'''',ENDBEFR=UC,   
              ENDBEFR=C'1',ENDBEFR=C'2',ENDBEFR=C'3',
              ENDBEFR=C'4',ENDBEFR=C'5',ENDBEFR=C'6',
              ENDBEFR=C'7',ENDBEFR=C'8',ENDBEFR=C'9',
              ENDBEFR=C'''',FIXLEN=10),               
           %01=(SUBPOS=1,ENDBEFR=C'''',FIXLEN=10)),     
    BUILD=(%01,JFY=(SHIFT=RIGHT)))                     
END

Input:
Code:
0000000019
000XXXXXXX
0000000001
000OPSCARA
ABCDEFGHIJ
100SOME000

Output:
Code:
****** *********************
000001         19           
000002    XXXXXXX           
000003          1           
000004    OPSCARA           
000005 ABCDEFGHIJ           
000006 100SOME000           
****** *********************
Back to top
View user's profile Send private message
chillmo

New User


Joined: 31 Aug 2017
Posts: 30
Location: USA

PostPosted: Wed Aug 16, 2023 10:36 am
Reply with quote

Joerg.Findeisen, this worked perfectly.

Thanks!
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 -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
Search our Forums:

Back to Top