Application Development and Automation 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: 
Read only

Move a File into an archive folder in application server .

Former Member
0 Likes
4,606

Hi All ,

Is there any FM or BAPI that can transfer File from one folder in to other in application server ??.

I have to move a file into an archive folder after processing it and i am trying with READ DATASET and TRANSFER DATASET.

But using this i am not able to transfer entire data from one file to other as READ DATAST cant read data in to Internal table .

Is there any sample code available so that can move entire records from one file to another file using READ DATASET and TRANSFER DATASET ..??

Thanks in Advance ..

Regards ,

Sijin K P.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,569

Sijin,

You can use ARCHIVFILE_SERVER_TO_SERVER for your purpose but this one limits the size of file paths to 70 characters.

IF your filenames are longer than that, better to use Transfer dataset line by line and then delete dataset...sample code below...


* You must be having the contents of your source file into an internal table, suppose gt_data.

OPEN DATASET lv_tgt_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc IS NOT INITIAL.
       "raise error
    ENDIF.

    LOOP AT gt_data INTO lv_data.               "source file data table
      TRANSFER lv_data TO lv_tgt_filename.
    ENDLOOP.

    CLOSE DATASET lv_tgt_filename.

    DELETE DATASET gv_source_filename.          "remove original file

BR,

Diwakar

6 REPLIES 6
Read only

Former Member
0 Likes
2,569

Hi

I don't know why you can't use an internal table or READ DATASET and TRANSFER DATASET, so I believe you can try to use the ftp command, see demo program RSFTP008

Max

Read only

Lukas_Weigelt
Active Contributor
0 Likes
2,569

Why not use READ/TRANSFER Dataset with an xstring instead of an internal table? Never failed me 😮

Read only

Former Member
0 Likes
2,569

Create an external command in SM49/SM69 for mv unix command(if your application server is on Unix) , then call the external command via FM SXPG_COMMAND_EXECUTE.

Hope this is what you were looking for.

Read only

Former Member
0 Likes
2,570

Sijin,

You can use ARCHIVFILE_SERVER_TO_SERVER for your purpose but this one limits the size of file paths to 70 characters.

IF your filenames are longer than that, better to use Transfer dataset line by line and then delete dataset...sample code below...


* You must be having the contents of your source file into an internal table, suppose gt_data.

OPEN DATASET lv_tgt_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    IF sy-subrc IS NOT INITIAL.
       "raise error
    ENDIF.

    LOOP AT gt_data INTO lv_data.               "source file data table
      TRANSFER lv_data TO lv_tgt_filename.
    ENDLOOP.

    CLOSE DATASET lv_tgt_filename.

    DELETE DATASET gv_source_filename.          "remove original file

BR,

Diwakar

Read only

0 Likes
2,569

Hi All ,

Thanks for reply ,

Mainly focussing on how to read data from file in to internal table using READ DATASET ,

Please share some code for this ...

Regards,

Sijin K P.

Read only

0 Likes
2,569

Sijin,

Why don't you just SEARCH.

Enough posts available.

BR,

Diwakar