Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

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:

 

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!

4 Comments