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: 788
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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