Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Inefficient BUILD - VB records paddin... Daniel Prosser SYNCSORT 6 Thu Dec 14, 2017 3:52 pm
No new posts The same REXX program doesnt work for... jackzhang75 CLIST & REXX 5 Wed Dec 06, 2017 2:51 am
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts Calling IKJEFT01 program from Rexx upendrasri CLIST & REXX 8 Wed Nov 15, 2017 4:27 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us