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 eliminate the SPACES in String using COBOL Program

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

New User


Joined: 08 May 2007
Posts: 26
Location: hyderabad

PostPosted: Thu Jan 31, 2008 12:06 pm    Post subject: How to eliminate the SPACES in String using COBOL Program
Reply with quote

I have one string with the length of 80 (X(80)). the data comming in that string might contain Spaces in any place.

I need to eliminate the spaces before the data and after the data, also i need to eliminate the spaces in between data, only one spaces should be places in between the data.

Example:

Name Pic X(80)

Data in Name like below:
' ARUN RAJPAL '
'ARUN RAJPAL '
I need output like below:
'ARUN RAJPAL '

Data in Name like below:'ARUN RAJ PAL '
I need output like below:
'ARUN RAJ PAL '

Please help me out.
Back to top
View user's profile Send private message

Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 785
Location: Chennai, India

PostPosted: Thu Jan 31, 2008 4:53 pm    Post subject:
Reply with quote

http://ibmmainframes.com/viewtopic.php?t=26561

This post might help you to start the work.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Jan 31, 2008 10:28 pm    Post subject:
Reply with quote

Hello,

Given the variety of possible input data and the requirement to ensure one space between each name component, i'd suggest defining 2 arrays (one of the input and one for the output) and looping across the input one byte at a time, moving all of the needed bytes to the output array - skipping leading, trailing and multiple-embedded spaces.
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 Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
No new posts I can not compile my program PL1 V3.R... Miguel Fernandez PL/I & Assembler 13 Tue Dec 06, 2016 8:30 pm
No new posts IMS BMP program causes 878 system abend Artemk IMS DB/DC 7 Tue Nov 22, 2016 8:26 pm


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