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 Sequence number add in SORT pshongal SYNCSORT 3 Fri Sep 02, 2016 3:32 pm
No new posts Casting a Binary Number to Numeric in... Bob Steinkraus Java & MQSeries 6 Tue Aug 09, 2016 5:58 pm
No new posts Remove Special Characters from Mainfr... Rodger Zhang All Other Mainframe Topics 6 Wed Jul 06, 2016 1:12 am
No new posts GDG vsersion number change Raghu navaikulam JCL & VSAM 5 Fri May 27, 2016 4:49 pm
No new posts CPU time Vs Number of records Nileshkul JCL & VSAM 5 Mon May 09, 2016 4:05 pm


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