Skip to Content
0
Former Member
Mar 16, 2010 at 10:46 AM

Open Dataset For Update

664 Views

Hello ABAP experts,

is it possible to read and update a file during a loop?

I try to open the file with "FOR UPDATE" and if a file record contain a customer number than this number should be immediatelly updated. But it doesn't work. Has anybody an idea what I did wrong in the following coding?

The file could be correctly opened and also the CONCATENATE works fine but the TRANSFER did not save the change in the file.

OPEN DATASET p_file FOR UPDATE IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

WRITE: 'Error when opening file: ', p_file.

ELSE.

DO.

READ DATASET p_file INTO wa_file.

IF sy-subrc NE 0.

CLOSE DATASET p_file.

EXIT.

ELSE.

  • set prefix "0301" for any customer number

IF wa_file(1) EQ '1'.

GET DATASET p_file POSITION w_pos.

CONCATENATE '0301' wa_file5(6) INTO wa_file5(10).

SET DATASET p_file POSITION w_pos.

TRANSFER wa_file TO p_file.

ENDIF.

ENDIF.

ENDDO.

ENDIF.

Best regards

CD