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

How to eliminate the SPACES in String using COBOL Program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 792
Location: Chennai, India

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

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

Moderator Emeritus


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

PostPosted: Thu Jan 31, 2008 10:28 pm
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 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 Using API Gateway from CICS program CICS 0
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
Search our Forums:

Back to Top