View previous topic :: View next topic
Author
Message
chillmo New User Joined: 31 Aug 2017Posts: 39 Location: USA
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
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1334 Location: Bamberg, Germany
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
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1334 Location: Bamberg, Germany
<deleted>
Back to top
Joerg.Findeisen Senior Member Joined: 15 Aug 2015Posts: 1334 Location: Bamberg, Germany
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
chillmo New User Joined: 31 Aug 2017Posts: 39 Location: USA
Joerg.Findeisen, this worked perfectly.
Thanks!
Back to top
Please enable JavaScript!