Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Open Dataset For Update

Former Member
0 Kudos

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

2 REPLIES 2

SuhaSaha
Advisor
Advisor
0 Kudos

What is the use of the GET / SET DATASET statements ? Why do you use them ?

Former Member
0 Kudos

Hi,

I'm not sure if you can update immediately. What u can do is upload the file in an internal table. Make the necessary changes in the internal table. Then download the fle on the server with the same name. U can delete the file before downloading it again, else it overwrites the existing file (whatever way u want it to be).

Regards

Jaspreet