Skip to Content
0
Former Member
Feb 17, 2010 at 05:05 PM

edit 1st record in a file

35 Views

Hello,

I want to open a file and edit the first record. The following code does this in our 4.7 system. But the second record is shifted left 11 spaces. We are using IBM AIX Unix.

Does someone know how to resolve this problem? I could add 11 spaces to the beginning of the second record before the transfer statement. But that seems like a bad solution.

Thanks

Bruce

PARAMETERS: p_output(50) LOWER CASE OBLIGATORY

DEFAULT '/sapdata/DEV/home/gta_check_tst/BCT_test'.

*

DATA: BEGIN OF record,

part1(30),

part2(20),

END OF record.

DATA: num TYPE i.

*

OPEN DATASET p_output

FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

record = 'Control Record count'.

TRANSFER record TO p_output.

*

DO 3 TIMES.

ADD 1 TO num.

record-part1 = 'Record #'.

WRITE num TO record-part2.

TRANSFER record TO p_output.

ENDDO.

*

CLOSE DATASET p_output.

*

*EXIT.

*

  • Open the file again for updating the 1st record in the file

OPEN DATASET p_output

FOR UPDATE AT POSITION 0 IN TEXT MODE ENCODING DEFAULT.

*

record-part1 = 'Control Record count'.

WRITE num TO record-part2.

SHIFT record-part2 LEFT DELETING LEADING ' '.

TRANSFER record TO p_output.