Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Removing Trainling and leading Zeros

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dp33770

New User


Joined: 04 Jul 2007
Posts: 92
Location: Hyderabad

PostPosted: Thu Jan 13, 2011 12:57 pm    Post subject: Removing Trainling and leading Zeros
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: 6968
Location: porcelain throne

PostPosted: Thu Jan 13, 2011 1:15 pm    Post subject:
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    Post subject: Reply to: Removing Trainling and leading Zeros
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

Site Director


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

PostPosted: Mon Jan 17, 2011 12:06 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am
No new posts editting the file by inserting zeros ... pramodrsingh DFSORT/ICETOOL 9 Mon Aug 21, 2017 5:58 pm
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts Removing Extra Spaces in a comma sepa... Puspojit DFSORT/ICETOOL 3 Tue Sep 13, 2016 7:46 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us