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

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.

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

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

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

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

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

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