Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

can't we use GUI_UPLOAD and scshedule in background

Hi,

I have a program which uploads a comma delimted text file and updates custom table.

.It works fine in when I run online but when I schedule it background it fails.

I used GUI_UPLOAD to upload the text file.

*----------------------------------------------------------------------*
FORM file_upload.


  CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
  filename = file
* FILETYPE = 'ASC
* has_field_separator = ','   <-- Comment this
* HEADER_LENGTH = 1
* READ_BY_LINE = 'X'
* IMPORTING
* FILELENGTH =
* HEADER = 'X'
  TABLES
  data_tab = i_datatab
  EXCEPTIONS
  file_open_error = 1
  file_read_error = 2
  no_batch = 3
  gui_refuse_filetransfer = 4
  invalid_type = 5
  no_authority = 6
  unknown_error = 7
  bad_data_format = 8
  header_not_allowed = 9
  separator_not_allowed = 10
  header_too_long = 11
  unknown_dp_error = 12
  access_denied = 13
  dp_out_of_memory = 14
  disk_full = 15
  dp_timeout = 16.

  LOOP AT i_datatab INTO x_datatab .
    IF sy-tabix GT '1'.

      SPLIT x_datatab-line AT ',' INTO wa_tab-zdate
    wa_tab-empid wa_tab-lname wa_tab-fname wa_tab-cycle wa_tab-branch
    wa_tab-job wa_tab-phase wa_tab-pdept wa_tab-ptype wa_tab-zhour .

      APPEND wa_tab TO i_tab.
    ENDIF.

  ENDLOOP.

Former Member
replied

fm GUI_UPLOAD will not work in background

you need to use

lv_filename = <input file path> " app server path
 
 open dataset lv_filename for input in text mode encoding default.
    if sy-subrc = 0.
      do.
        read dataset lv_filename into gs_input-wa_string.
        if sy-subrc eq 0.
          append gs_input to gt_input.
        else.
          exit.
        endif.
      enddo.
      close dataset lv_filename.
    endif.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question