SAP ABAP Move File On Application Server
REPORT zmove_file.
DATA : lv_fname TYPE string,
lv_line TYPE string.
DATA lv_fname1 TYPE string.
lv_fname = '/usr/sap/to_be_processed/file01.txt'. "Source File
lv_fname1 = '/usr/sap/processed/file01.txt'. "Destination File
OPEN DATASET lv_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
OPEN DATASET lv_fname1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
DO.
READ DATASET lv_fname INTO lv_line.
IF sy-subrc = 0.
TRANSFER lv_line TO lv_fname1.
ELSE.
EXIT.
ENDIF.
ENDDO.
WRITE 'Berhasil'.
ELSE.
WRITE 'File tidak bisa dibuka'.
ENDIF.
CLOSE DATASET lv_fname1.
CLOSE DATASET lv_fname.
DELETE DATASET lv_fname.
ENDIF.
Comments
Post a Comment