View previous topic :: View next topic
|
Author |
Message |
dp33770
New User
Joined: 04 Jul 2007 Posts: 91 Location: Hyderabad
|
|
|
|
Hi All ,
I have a WS-PRICE variable with PIC X(19) .
can I remove its leading and trailing Zeros with use of INSPECT and other Verbs.
Input :
WS-PRICE = 000567800.011234000
Output:
WS-Result(PIC X(19)) = 567800.011234
can you guys help me in this |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
yes you can INSPECT CONVERT the leading and trailing char,
but I assume you want the remaining chars to be left justified.
if that is the case, run a two indexs
(or use reference modification - which is slower)
along the the source pic x(19) field only moving non-spaces
to the result pic x(19) field, incrementing after a move.
insure that the result field is set to all spaces before you start. |
|
Back to top |
|
|
Pons
New User
Joined: 25 May 2007 Posts: 61 Location: Coimbatore
|
|
|
|
You can also the get the index position by using tallying counter option.
INSPECT WS-PRICE TALLYING WS-TALLY1 FOR LEADING ZEROS
INSPECT WS-PRICE TALLYING WS-TALLY2 FOR TRAILING ZEROS
Move WS-PRICE (WS-TALLY1+1 : WS-TALLY1-1) TO WS-RESULT.
Picture X is always left justified. So result will be stored as left justified.
Make sure you initialized all the counter variables (WS-TALLY1 & WS-TALLY2). |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You need to make sure what you post is correct and contains no typos. . .
Lately i have fixed a few and deleted a few that you have posted because they were wrong.
Please review and re-post your "solution" and i'll delete the problem post and this reply of mine.
You should actually post only code that has worked successfully and has been posted using copy/paste and not rekeyed.. |
|
Back to top |
|
|
|