# moving txt (A600) to a fld(a60/10) without cutting off txt

**URL:** <https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [February 6, 2008, 12:28am UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092 "2008-02-06T00:28:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerrit](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@Gerrit](https://techcommunity.softwareag.com/u/Gerrit)\
**Post date:** [February 6, 2008, 12:28am UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/1 "2008-02-06T00:28:31Z")

</div>

Hi, I need help. I’m currently reading a work file where there could be more than one line of text which is (A70) for a specific field.  
The problem comes in where I have to split the text into an array (a60/10).  
I have to join the text where it is being split when it reaches 60 with the next batch of txt without it creating a new index line.

01 #DETAIL-DESC (A70) (can have more than 1 line per wrkfl)  
01 #long-desc (A600)  
01 #desc (A60/10)  
end-define  
\*  
read work file 1  
move left #detail-desc to #long-desc /\* #long-desc contains 300 chars  
write #desc(1) /  
#desc(2)  
#desc(3)

Now what happens is that sometimes the txt is cut of at 60 chars on #desc(1), and #desc(2) only contains 10 chars and #desc(3) the rest.  
I want to populate #desc(2) with the rest of the Chars in #desc(3) till it reaches 60 again.

Please help.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [February 6, 2008, 1:39am UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/2 "2008-02-06T01:39:43Z")

</div>

Gerritt;

Your question needs a lot of clarification:

How was the workfile created? If there was a field with 100 characters would it be 70-30 on the first two records of the work file? Or is it 60-10-30 on the first three records?

Do you just want to concatenate ten records into a single string? (COMPRESS?)

More info would be helpful.

steve

---

<div class="post-metadata">

**Author:** ![Gerrit](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@Gerrit](https://techcommunity.softwareag.com/u/Gerrit)\
**Post date:** [February 6, 2008, 1:10pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/3 "2008-02-06T13:10:10Z")

</div>

It is a space delimeted file with a fixed length which I pull into TSO to create a work file.

The first line contains 70 characters of text and the second line 54 lines of text.

The program I wrote should split the text into fields of 60 characters long.

What I get is the following:  
Undergone heart surgery to correct narrowing or blockage of  
1 or  
2 coronary arteries with insertion of bypass graft(s).

What I should get is:

Undergone heart surgery to correct narrowing or blockage of  
1 or 2 coronary arteries with insertion of bypass graft(s).

Hope this clears things a bit.  
Thanks

---

<div class="post-metadata">

**Author:** ![Gerrit](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@Gerrit](https://techcommunity.softwareag.com/u/Gerrit)\
**Post date:** [February 6, 2008, 1:12pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/4 "2008-02-06T13:12:07Z")

</div>

It is a space delimeted file with a fixed length which I pull into TSO to create a work file.

The first line contains 70 characters of text and the second line 54 lines of text.

The program I wrote should split the text into fields of 60 characters long.

What I get is the following:  
Undergone heart surgery to correct narrowing or blockage of  
1 or  
2 coronary arteries with insertion of bypass graft(s).

What I should get is:

Undergone heart surgery to correct narrowing or blockage of  
1 or 2 coronary arteries with insertion of bypass graft(s).

Hope this clears things a bit.  
Thanks

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [February 6, 2008, 5:13pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/5 "2008-02-06T17:13:49Z")

</div>

Here is a piece of code which shows a promising approach (given time later today, i will put it all into a generalized loop). Please confirm this is what you want.

This is only a brief coding job, it can be cleaned up a bit (like defining the 60th character as something like #60 (a1) so I do not have to keep using substring.

DEFINE DATA LOCAL  
1 #INPUT (A70/1:2)  
1 REDEFINE #INPUT  
2 #STRING (A140)  
1 #OUTPUT (A60/1:3)  
1 #POS (I2)  
END-DEFINE  
\*  
MOVE  
'Undergone heart surgery to correct narrowing or blockage of '-  
‘1 or 2 coronary arteries with insertion of bypass graft(s).’  
TO #STRING  
\*  
IF SUBSTRING (#INPUT (1),60,1) = ’ ’  
MOVE #INPUT (1) TO #OUTPUT (1)  
COMPRESS SUBSTRING (#INPUT (1),61) #INPUT (2) INTO #OUTPUT (2)  
LEAVING NO SPACE  
ELSE  
EXAMINE DIRECTION BACKWARD SUBSTRING (#INPUT (1),1,60) FOR ’ ’  
GIVING POSITION #POS  
MOVE SUBSTRING (#INPUT (1),1,#POS) TO #OUTPUT (1)  
ADD 1 TO #POS  
COMPRESS SUBSTRING (#INPUT (1),#POS) #INPUT (2)  
INTO #OUTPUT (2) LEAVING NO SPACE  
END-IF  
\*  
WRITE ‘output-1:’ #OUTPUT (1) // ‘output-2:’ #OUTPUT (2)  
END

Page 1 08-02-06 06:39:04

output-1: Undergone heart surgery to correct narrowing or blockage of

output-2: 1 or 2 coronary arteries with insertion of bypass graft(s).

If you add an asterisk after the word of, here is the output:

Page 1 08-02-06 06:42:52

output-1: Undergone heart surgery to correct narrowing or blockage

output-2: of\*1 or 2 coronary arteries with insertion of bypass graft(s

In other words, the program correctly “saw” the string of\*1 as a “whole” and did not split it.

However, we did truncate the end of the string because I did not write the code yet to handle longer strings. As I said above, later today if i have the time.

steve

---

<div class="post-metadata">

**Author:** ![Gerrit](https://avatars.discourse-cdn.com/v4/letter/g/b9bd4f/32.png) [@Gerrit](https://techcommunity.softwareag.com/u/Gerrit)\
**Post date:** [February 6, 2008, 6:25pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/6 "2008-02-06T18:25:47Z")

</div>

Hi Steve. Thanks a lot!  
This was exactly what I needed.  
Thanks again  
Regards  
Gerrit.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [February 6, 2008, 8:25pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/7 "2008-02-06T20:25:01Z")

</div>

Here is a more general solution. Again, no guarantees; have not had time to really check it.

DEFINE DATA LOCAL  
1 #INPUT (A70/1:5)  
1 REDEFINE #INPUT  
2 #STRING (A350)  
1 REDEFINE #INPUT  
2 #CHAR (A1/1:350)  
1 #OUTPUT (A60/1:6)  
1 #POS (I2)  
1 #O (I2)  
1 #END (I2)  
1 #START (I2)  
END-DEFINE  
\*  
INCLUDE AASETC  
MOVE  
‘Undergone heart surgery to correct narrowing or blockage of\*’-  
‘1 or 2 coronary arteries with insertion of bypass graft(s).’-  
'Undergone heart surgery to correct narrowing or blockage of '-  
‘1 or 2 coronary arteries with insertion of bypass graft(s).’-  
'Undergone heart surgery to correct narrowing or blockage of '-  
‘1 or 2 coronary arteries.’  
TO #STRING

* * *

- initialize first “input bucket”  
COMPUTE #START = 1  
COMPUTE #END = 60

* * *

FOR #O = 1 TO 5 /\* #o represents “output bucket” number  
IF #CHAR (#END) = ’ ’  
MOVE SUBSTRING (#STRING,#START,60) TO #OUTPUT (#O)  
COMPUTE #START = #END + 1  
COMPUTE #END = #START + 59  
ESCAPE TOP  
ELSE  
EXAMINE DIRECTION BACKWARD SUBSTRING (#STRING,#START,60) FOR ’ ’  
GIVING POSITION #POS  
MOVE SUBSTRING (#STRING,#START,#POS) TO #OUTPUT (#O)  
COMPUTE #START = #START + #POS  
COMPUTE #END = #START + 59  
END-IF  
END-FOR

* * *

- fill last output bucket from last input bucket  
MOVE SUBSTRING (#STRING,#START) TO #OUTPUT (#O)
- 

WRITE #OUTPUT (\*)  
END

PAGE 1 08-02-06 09:54:44

UNDERGONE HEART SURGERY TO CORRECT NARROWING OR BLOCKAGE  
OF\*1 OR 2 CORONARY ARTERIES WITH INSERTION OF BYPASS  
GRAFT(S).UNDERGONE HEART SURGERY TO CORRECT NARROWING OR  
BLOCKAGE OF 1 OR 2 CORONARY ARTERIES WITH INSERTION OF  
BYPASS GRAFT(S).UNDERGONE HEART SURGERY TO CORRECT  
NARROWING OR BLOCKAGE OF 1 OR 2 CORONARY ARTERIES.

steve

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:49pm UTC](https://techcommunity.softwareag.com/t/moving-txt-a600-to-a-fld-a60-10-without-cutting-off-txt/76092/8 "2021-04-02T14:49:06Z")

</div>


