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
 

 

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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts To trim spaces in a pipe delimited da... Nish84 COBOL Programming 16 Mon Oct 10, 2016 1:54 pm


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