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

Removing Trainling and leading Zeros


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dp33770

New User


Joined: 04 Jul 2007
Posts: 91
Location: Hyderabad

PostPosted: Thu Jan 13, 2011 12:57 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jan 13, 2011 1:15 pm
Reply with quote

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
View user's profile Send private message
Pons

New User


Joined: 25 May 2007
Posts: 61
Location: Coimbatore

PostPosted: Sun Jan 16, 2011 7:35 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Jan 17, 2011 12:06 am
Reply with quote

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
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Remove leading zeroes SYNCSORT 4
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
No new posts How to display the leading zeros of a... DB2 7
No new posts Removing date values lines/records fr... SYNCSORT 2
Search our Forums:

Back to Top