Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to remove leading space of number?

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

New User


Joined: 21 Sep 2008
Posts: 4
Location: pune

PostPosted: Sun Nov 21, 2010 4:35 pm    Post subject: How to remove leading space of number?
Reply with quote

Hi,

I want to remove the leading space from 1 variable which has
PIC clause S9(16)V99.

Ex.
i/p is -145.35
then it is coming as ' -145.35'
Here I want to remove the leading space from this variable.

Please suggest.
Thanks in advance.
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Sun Nov 21, 2010 5:16 pm    Post subject: Reply to: How to remove leading space of number?
Reply with quote

Move the variable to a WS Edit Pattern and bump through it -

Code:

03  WS-VARIABLE-V99 PIC S9(16)V99 VALUE -145.35.
03  WS-VARIABLE REDEFINES WS-VARIABLE-V99 PIC S9(18).
03  WS-PATTERN PIC Z(18).
03  WS-SUB PIC 9(08) COMP.

MOVE WS-VARIABLE TO WS-PATTERN.

IF  WS-PATTERN (1:) NOT = SPACES
    MOVE 1 TO WS-SUB
    PERFORM UNTIL WS-SUB > LENGTH OF WS-PATTERN
        IF  WS-PATTERN (WS-SUB:1) NOT = SPACE
            DISPLAY 'VARIABLE (WITH SPACES REMOVED) IS ===> ', WS-PATTERN (WS-SUB:)
            MOVE LENGTH OF WS-PATTERN TO WS-SUB
        END-IF
    ADD 1 TO WS-SUB
    END-PERFORM
ELSE
    DISPLAY 'VARIABLE IS ALL ZEROS - PLEASE INVESTIGATE'
END-IF.

There are probably other ways to do this.

Bill
Back to top
View user's profile Send private message
deepali33

New User


Joined: 21 Sep 2008
Posts: 4
Location: pune

PostPosted: Mon Nov 22, 2010 11:35 am    Post subject: Reply to: How to remove leading space of number?
Reply with quote

Hi Bill,

Thanks a lot for the solution.
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 SMTP the current generation number of... Jyothi Kulunde JCL & VSAM 4 Thu May 04, 2017 4:08 pm
No new posts VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am
This topic is locked: you cannot edit posts or make replies. Need help in estimating space of unlo... ashek15 IMS DB/DC 12 Fri Apr 07, 2017 5:11 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts Edit large number of datasets (QSAM) zh_lad TSO/ISPF 3 Tue Apr 04, 2017 6:08 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us