Mtok
Mtok

Reputation: 1630

Where does gui_upload uploads the files?

Simply, where does gui_upload function uploads the files in Application Server. How can I find the location of them, or is there any tcode that I can find last uploaded files or search by name ?

Thanks.

Upvotes: 1

Views: 4895

Answers (3)

slynx
slynx

Reputation: 21

I can confirm both previous answers. If you'd like to upload a text/csv file for example to an application server, you can use the following code.

Using GUI_UPLOAD to actually read the provided input file to an internal table:

lv_filename = p_filebp.
CLEAR lt_data_tab.

IF NOT lv_filename IS INITIAL.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = lv_filename
    TABLES
      data_tab                = lt_data_tab
    EXCEPTIONS
      file_open_error         = 1
      OTHERS                  = 17.

  IF sy-subrc <> 0.
    EXIT.
  ENDIF.
ENDIF.

Check if there was data in the text file, and has been transferred into the internal table correctly. If so, upload it to a file on the application server. You can provide a path yourself where you want to see this uploaded:

READ TABLE lt_data_tab INDEX 1.
IF sy-subrc <> 0.
  WRITE: / 'No data in input file.'.
ELSE.
  CONCATENATE '/interfaces/' sy-sysid '/CRM_ACTIVITIES/' sy-datum '_INPUT.CSV' INTO p_serinp.

  OPEN DATASET p_serinp FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

  IF sy-subrc NE 0.
    EXIT.
  ENDIF.

  LOOP AT lt_data_tab.
    TRANSFER lt_data_tab TO p_serinp.
    CLEAR lt_data_tab.
  ENDLOOP.

  CLOSE DATASET p_serinp.

  IF sy-subrc = 0.
    CLEAR gd_error_text.

    CONCATENATE 'Download to file: ' p_serinp ' is finished.'
    INTO gd_error_text SEPARATED BY space.

    WRITE: / gd_error_text.
  ENDIF.
ENDIF.

Keep in mind that, using the OPEN DATASET statement, you can write files anywhere on your network. That if at least you got the required authorizations.

Transaction AL11 can be used to explore the existing folders and files on your SAP system.

Upvotes: 1

Bryan Anthony Abrams
Bryan Anthony Abrams

Reputation: 72

I don't have an ABAP stack on hand but I believe what you're looking for is the command OPEN DATASET, or something along those lines. This handles reading and writing files on the application server. The files that are processed via OPEN DATASET can be found with transaction AL11.

Upvotes: 0

Kush Kashyap
Kush Kashyap

Reputation: 116

gui_upload function does not upload file to the Application server. it just reads a file from the presentation layer into an internal table. You will then need to use some other function to write this internal table to a file on the application server.

Hope this helps.

Upvotes: 4

Related Questions