cancel
Showing results for 
Search instead for 
Did you mean: 

How to upload file to app server using file upload UI element

Former Member
0 Kudos

Hi experts,

File content is XSTRING after using file upload UI element to upload a local .txt file, then how can I transfer the XSTRING content to application server and realize the file copy between local work station to application server?

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

You can use function module ARCHIVFILE_CLIENT_TO_SERVER to upload files. Note SE37 will capitalize your filename and path, but you can set a breakpoint in the FM and change the ijnput parameters back to lower-case if necessary.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> You can use function module ARCHIVFILE_CLIENT_TO_SERVER to upload files. Note SE37 will capitalize your filename and path, but you can set a breakpoint in the FM and change the ijnput parameters back to lower-case if necessary.

You can not use ARCHIVFILE_CLIENT_TO_SERVER within Web Dynpro ABAP. It uses SCMS_UPLOAD with the importing parameter FRONTEND hardcoded to 'X'. This will cause the upload from the client to occur with an RFC call to SAPFTP. This RFC call will try to connect via the SAPGUI with the SAPFTP option - which will fail in Web Dynpro ABAP since there is of course no connection to the SAPGUI.

Former Member
0 Kudos

HI,

This is the piece of code to upload file to app server.

data lv_output_length type i.

data ls_solix type solix-line.

data lt_solix_tab type table of solix-line.

data lv_filename type string.

data lv_docnum type doknr.

*write a temp file on app server

  • 1. create File name of the uploaded file on app server

concatenate '/usr/sap/' sy-sysid sy-uname sy-datum into lv_filename.

*2. convert xstring to binary : pass the XSTRING received from UI Upload element

call function 'SCMS_XSTRING_TO_BINARY'

exporting

buffer = lv_filesource " this is the XSTRING of the file u want to upload

importing

output_length = lv_output_length

tables

binary_tab = lt_solix_tab.

  • 3. write the file

if not lt_solix_tab is initial.

open dataset lv_filename for output in binary mode.

loop at lt_solix_tab into ls_solix.

transfer ls_solix to lv_filename.

endloop.

close dataset lv_filename.

endif.

The file <Lv_filename> will be created on the app server.

Thanks,

Abhishek

Edited by: abhishek sinha on Aug 22, 2009 10:10 AM

Former Member
0 Kudos

Thanks, the code works, but is it possible to use text mode instead of binary mode to transfer the file to app server? Since if using binary mode the text file being transfered to the server is added many # at the end.

Former Member
0 Kudos

You can look at the various possibilities using the F1 help on OPEN DATASET command. And it is possible to use the text mode to write data on app server.

Since you already have XSTRING convert it to the format you want and then use OPEN DATSET to upload.

Thanks,

Abhishek