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
18,103

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
SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Kudos

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

nabheetscn
Active Contributor
0 Kudos

Hi Ajay

Suhas has pointed it out rightly. Please take care of this thing.

Thanks

Nabheet

Jelena_Perfiljeva
Active Contributor
0 Kudos
PLEASE DO NOT USE THESE FUNCTION MODULES! Both are not released to the customers.

There is no need for an FM to replace basic OPEN DATASET command for application server. And for presentation server use CL_GUI_FRONTEND_SERVICES which existed since 1998.

Not sure why but a link to this blog was posted in 2019. Posting a warning to those who stumble upon this.
christian_brhl
Explorer
0 Kudos
I found this blog helpful and think it is fine if it stays since there is nothing wrong with being redundant (except when it come to employment ;>] ).  I prefer using FM "ARCHIVFILE_CLIENT_TO_SERVER" to transfer a file from the presentation to application server easiy as opposed to the open data set where one has to mess with tables and what not.

As far being not released I could not care less since are thousands of such FMs in SAP.

The FM "ARCHIVFILE_CLIENT_TO_SERVER" uses another FM "SCMS_UPLOAD" (also not released) that is used in over 30 SAP objects.  In the unlikely case that SAP removes "ARCHIVFILE_CLIENT_TO_SERVER" I can always change to the open dataset or one of the FMs in the SCMS function group.

Again, thanks for posting.

 
Labels in this area