if first time
move input-data to output-data(1:ws-length ) ,, ws-length is length of each field
if curr-field = prev-field
and not first time
compute ws-length1 = ws-length1 + ws-length
move input-data to output-data(ws-length1)
continue ( read the next record)
like this ...
I thought from the pseudo code that you had some idea of where you were going with that.
This is a normal MOVE:
MOVE the-source-field TO the-target-field
The whole of the-source-field will be move to the whole of the-target-field. If the-target-field is bigger than the-source-field, it will be "padded" with trailing blanks. If it is shorter, the data will be truncated, from the right.
This is a MOVE with reference-modification:
MOVE the-source-field ( start-position : length-required ) TO the-target-field ( another-start-position : another-length-required )
This allows you to move any part of the-source-field to any part of the-target-field, depending on the values for the start positions and the lengths.
Whether you need reference-modification for your source field depends on how you have defined your data, but:
MOVE the-source-field ( 1 : length-of-input-record ) TO the-target-field
Will do for the move for the first record of a group, as it will initialise the unused part of the-target-field, by the padding to trailing blanks.
For your subsequent MOVEs, the-source-field stays the same, but the-target-field has to now be modified:
MOVE the-source-field ( 1 : length-of-input-record ) TO the-target-field ( length-so-far +1 : length-of-input-record )
If you use reference-modification, try to give everything good names. Don't use a literal 1, but define a value in working-storage with a descriptive name. Do the calculation "outside" of the reference modification (the +1).
Although this is the "modern" way to do it, that does not mean you have to make it more unclear/difficult to follow later.