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

Replace each space in cobol string with a substring.


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

Active User


Joined: 06 Apr 2021
Posts: 123
Location: argentina

PostPosted: Sat Mar 23, 2024 2:53 am
Reply with quote

Hello to all.

How to remove spaces within a string in COBOL, and for each space removed, replace it with the string XXXX. That is, the characters to the right of the removed space should be retained, they just need to be moved to the right.


my requirement is:


original string
Code:
123 456 789



changed string

Code:
123xxxx456xxxx789



do you have any clue? in jcl I can use Outrec and insert the substring but in cobol I did not reach the desire result yet.

Thanks
Code'd for you
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1255
Location: Bamberg, Germany

PostPosted: Sat Mar 23, 2024 4:51 am
Reply with quote

Ali_gezer wrote:
in jcl I can use Outrec and insert the substring but in cobol I did not reach the desire result yet.

JCL does not have an OUTREC keyword.
Back to top
View user's profile Send private message
Phrzby Phil

Senior Member


Joined: 31 Oct 2006
Posts: 1042
Location: Richmond, Virginia

PostPosted: Sat Mar 23, 2024 8:32 am
Reply with quote

My turn to say: With 123 posts starting 3 years ago, you must know by now that no one is going to help you until you post (using code tags) your attempted solution, along with the input and output from your latest test.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3053
Location: NYC,USA

PostPosted: Fri Mar 29, 2024 6:03 am
Reply with quote

You can use reference modification in COBOL.. move one by one byte to output field and once you hit the space move hardcoded 'xxxx' and continue to advance one byte to move to output field until end of record.

Does this hint help?
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 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
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Substring number between 2 characters... DFSORT/ICETOOL 2
Search our Forums:

Back to Top