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

remove the gap b/w 2 fields


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
shymala

New User


Joined: 26 Jul 2018
Posts: 5
Location: india

PostPosted: Thu Aug 02, 2018 12:05 pm
Reply with quote

I need to concatenate 2 fields in my o/p file.
as of now I am getting the o/p as

{12345678} {1:1234:456}
I have a gap in b/w these 2 fields because of varying length of field1 the actual o/p should be
{12345678}{1:1234:456}

the important thing here is field 1 will be having varying length. say for example
{123}
{12345}
the 1st field length is 16 characters.

can anyone help me in solving this problem

Read more: ibmmainframes.com/about66753.html#ixzz5N049e3gy
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Aug 02, 2018 1:32 pm
Reply with quote

Find the first space (INSPECT). Move the data before that position to a new variableand use reference modification to move the data from (that posiiton +1) to a new variable. STRING the 2 values together.
I do not know if you can reference modification to define the destination of a string but if you can then you could simply use the current variable by moving the second part one byte to the left.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Aug 02, 2018 6:03 pm
Reply with quote

Quote:
I do not know if you can reference modification to define the destination of a string but if you can then you could simply use the current variable by moving the second part one byte to the left.
Yes, COBOL allows reference modification for the sending and receiving variables in a MOVE statement so this could work.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


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

PostPosted: Thu Aug 02, 2018 7:31 pm
Reply with quote

The link attached in your post has the solution already , Reread what RahulG31 has posted and modify slightly to include another filed and follow the same. The same approach is what Nic too saying above.
However, if you have DB2 in the program then you can use below query to get it easily.
Code:
select  concat(strip(:variable-1),strip(:variable-2))
        into :concat-var
from sysibm.sysdummy1
Back to top
View user's profile Send private message
shymala

New User


Joined: 26 Jul 2018
Posts: 5
Location: india

PostPosted: Fri Aug 03, 2018 2:24 pm
Reply with quote

Hi All,

The case is I am writing the data to header file of length 100 characters and the 1st field is varying . so I need to have a count and move that in a proper way.

Is there any other option apart from reference modification.
Like concatenate option in cobol not in JCl if so please provide me the example.
Does Trim option works for this situation.

Thanks
Shymala
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Aug 03, 2018 2:32 pm
Reply with quote

You have been given a perfectly good response that will work. Re-stating your requirement does not change the response.
Why not write a little program to test out TRIM? Or read the manual.
As you seem to not be able to try recommended answers or try things out for yourself there is little point in continuing this topic. Locked.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Remove leading zeroes SYNCSORT 4
No new posts How to remove block of duplicates DFSORT/ICETOOL 8
No new posts To Remove spaces (which is in hex for... JCL & VSAM 10
No new posts How to remove spaces in between. SYNCSORT 12
Search our Forums:

Back to Top