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: 

Regarding saving file from one location to another location in local PC

Former Member
0 Kudos

Hi SAP Gurus,

My requirement is as follows,

I am having a file in on drive of my local PC (say C: drive),

I need to save the file to another location in same  PC (say 😧 Drive)

How can I do this,

Please suggest,

Thanks and Regards,

Pavan.

1 ACCEPTED SOLUTION

jack_graus2
Active Contributor
0 Kudos
    CALL METHOD cl_gui_frontend_services=>file_copy
      EXPORTING
        SOURCE               = file1
        DESTINATION          = file2
        OVERWRITE            = space.
Regards Jack
8 REPLIES 8

Former Member
0 Kudos

Hello Pavan

Why do u need SAP for this? If its on your PC then you can directly  cut and paste in D drive.

May be i misinterpreted your question, request you to explain it further.

Regards,

Deepti

0 Kudos

thanks

Former Member
0 Kudos

Hi,

Use the below function module to move the file from one location to other location:

      CALL FUNCTION 'ARCHIVFILE_SERVER_TO_SERVER'

        EXPORTING

          sourcepath = w_file

          targetpath = lv_tgt_file

        EXCEPTIONS

          error_file = 1

          OTHERS     = 2.

      IF sy-subrc <> 0.

        MESSAGE ID sy-msgid TYPE c_s NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

        EXIT.

      ELSE.

        DELETE DATASET w_file.

      ENDIF.

Aashish28
Contributor
0 Kudos

Hiii,

       Use Class CL_GUI_FRONTEND_SERVICES and use static method FILE_EXIST , FILE_COPY FILE_DELETE from old location .

jack_graus2
Active Contributor
0 Kudos
    CALL METHOD cl_gui_frontend_services=>file_copy
      EXPORTING
        SOURCE               = file1
        DESTINATION          = file2
        OVERWRITE            = space.
Regards Jack

amol_samte
Contributor
0 Kudos

Dear Pavan,

You want to save files using foreground or background. if it is background mode, you must have to use open dataset else u can use above solution.

Regards,

Amol.

KiranJ
Active Participant
0 Kudos

Hi,

If it is fore ground use the class CL_GUI_FRONTEND_SERVICES method to do the cut and paste.

If it is the back ground job first place the file in open server that is in AL11 to do the further steps.

Former Member
0 Kudos

Hi

This solution helpfull for ur problem..

whenever we want to  save the file  from one location to another location in same pc in this situation we can solve by using this fun. module -   F4_FILENAME .

code is below ---

CALL  FUNCTION  'F4_FILENAME'

EXPORTING

PROGRAME NAME   = SY-PROGRAMENAME

FIELD NAME             = ' T_FILE'

IMPORTING

FILE NAME                =  T_FILE.

V_FILE =  T_FILE. STRING CONVERSION

v_file is  string type and T_FILE is RLGRAP

if you are using FM> gui_download then you have to declarae the

file name   = V_FILE

IN EXPORTING PARAMETERS 

after using thses fun module you can esialy download file in any location  into same PC.

please if its helpfull for you then plz give me points.

Regards

suraj singh