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

How to remove leading space of number?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Sun Nov 21, 2010 5:16 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top