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
 
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: 2504
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 add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm
No new posts PARSE GDG name to separate generation... Abid Hasan SYNCSORT 2 Sun Feb 11, 2018 3:40 pm
No new posts Increment number for every group of r... srajendran2 DFSORT/ICETOOL 7 Thu Nov 09, 2017 10:31 pm
No new posts The TS7720 is out of cache space. Rex Montemayor All Other Mainframe Topics 2 Mon Sep 25, 2017 7:18 am
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

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