Skip to Content

Summary

The document will give insights to two SAP standard function modules which can be used to upload / download files to / from application servers. There are few blogs on creating custom function modules to accomplish the task. Using the standard function modules will help in reducing this effort.

Data declaration:

Parameters:  p_file type sapb-sappfad.        “On presentation server
parameters : p_path type rlgrap-filename.    “On Application server

At selection-screen on value-request for p_path.
“Start to check current directory
  call function ‘/SAPDMC/LSM_F4_SERVER_FILE’
    exporting
      filemask         = ‘ ‘
    importing
      serverfile       = p_path
    exceptions
      canceled_by_user = 1
      others           = 2.

  if sy-subrc <> 0.
    p_path = p_path.
  endif.

  The above codes will popup the below screen for selecting the folder in application server:

  F4_Application server_File_Selection.png

a) Use ARCHIVEFILE_CLIENT_TO_SERVER function module to transfer file from presentation server to application server.

Code snippet:

call function ‘ARCHIVFILE_CLIENT_TO_SERVER’
      exporting
        path       = p_file
        targetpath = p_path
      exceptions
        error_file = 1
        others     = 2.

    if sy-subrc <> 0.
      message id sy-msgid type sy-msgty number sy-msgno
              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    else .
      message ‘successfully transfered’ type ‘S’.
    endif.

b) Use ARCHIVEFILE_SERVER_TO_CLIENT function module to transfer file from application server to presentation server.

Code snippet:

data : w_path type sapb-sappfad,
       w_file   type sapb-sappfad.

parameters : p_path1 type rlgrap-filename.

parameters : p_file1 type rlgrap-filename.

move p_path1 to w_path.
move p_file1 to w_file.

    call function ‘ARCHIVFILE_SERVER_TO_CLIENT’

      exporting

        path       = w_path

        targetpath = w_file

      exceptions

        error_file = 1

        others     = 2.

    if sy-subrc <> 0.

      message id sy-msgid type sy-msgty number sy-msgno

              with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    else.

      message ‘successfully transfered’ type ‘S’ .

    endif.

Conclusion

Request you to try out these function modules and get back on improvements, if any.

Cheers!

To report this post you need to login first.

2 Comments

You must be Logged on to comment or reply to a post.

  1. Suhas Saha

    Hello Ajay,

    If you check the forums you can see that this topic has been discussed in length. And tbh your blog does not add any value.

    The content is redundant & basic. Next time try to do some research before posting the content, it’ll save you the poor ratings.

    Thanks,

    Suhas

    (0) 

Leave a Reply