View previous topic :: View next topic
|
Author |
Message |
shymala
New User
Joined: 26 Jul 2018 Posts: 5 Location: india
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
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 |
|
|
shymala
New User
Joined: 26 Jul 2018 Posts: 5 Location: india
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
|