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
 
Removing left spaces from a string

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

New User


Joined: 27 Mar 2006
Posts: 95
Location: India

PostPosted: Tue Dec 26, 2006 12:30 pm    Post subject: Removing left spaces from a string
Reply with quote

Hi
Please explain me how to remove leading spaces in a variable.
ex
A = ' 124050'
Where A is x(18).

I want A shouls contain as 'welcom' with out any space in front oi it.
Back to top
View user's profile Send private message

priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Tue Dec 26, 2006 12:40 pm    Post subject: Re: Removing spaces from a string
Reply with quote

rajesh_mbt,

Althoguh your given examples doesnt make sense... but hopefully this is what you are looking for:-

Code:
INITIALIZE WS-LEN-LEAD-SPACE.
INSPECT WS-STRING TALLYING WS-LEN-LEAD-SPACE FOR LEADING SPACES.
COMPUTE WS-LEN-ACTUAL-STR = 18 - WS-LEN-LEAD-SPACE.

MOVE WS-STRING (WS-LEN-LEAD-SPACE+1: WS-LEN-ACTUAL-STR) TO WS-EDITED-STRING.


Code above would remove leading spaces from the WS-STRING and WS-EDITED-STRING would contain rest of the data with spaces padded behind.
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 5:34 pm    Post subject:
Reply with quote

Would not a JUSTIFY LEFT work?
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Tue Dec 26, 2006 10:38 pm    Post subject: Re: Removing left spaces from a string
Reply with quote

Quote:
Would not a JUSTIFY LEFT work?

Hey Bill... Would "JUST LEFT" strip the "spaces" ahead... I doubt ...
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 10:50 pm    Post subject:
Reply with quote

Yea, I think you're right...I guess I don't use justify enough to remember.... icon_cry.gif
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 Removing the period or dot from the v... gopinak COBOL Programming 6 Wed May 09, 2018 1:53 pm
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm
No new posts Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 9 Thu Dec 14, 2017 3:52 pm

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