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

Removing left spaces from a string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rajesh_mbt

New User


Joined: 27 Mar 2006
Posts: 97
Location: India

PostPosted: Tue Dec 26, 2006 12:30 pm
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: 1448
Location: Chicago, IL

PostPosted: Tue Dec 26, 2006 12:40 pm
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: 3156
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 5:34 pm
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: 1448
Location: Chicago, IL

PostPosted: Tue Dec 26, 2006 10:38 pm
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: 3156
Location: Tucson AZ

PostPosted: Tue Dec 26, 2006 10:50 pm
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 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 PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
Search our Forums:

Back to Top