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 what is meaning of the number in dcl Martylin PL/I & Assembler 2 Thu Mar 09, 2017 7:18 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts GDG version number PANDU1 JCL & VSAM 4 Sat Mar 04, 2017 8:28 pm
No new posts Remove junk values in a file and rite... KP1125 DFSORT/ICETOOL 2 Wed Jan 25, 2017 9:58 pm
No new posts Sort Card to Remove Duplicate records... raj4neo SYNCSORT 2 Wed Jan 25, 2017 4:44 am


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