Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

can't we use GUI_UPLOAD and scshedule in background

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

former_member194669
Active Contributor
0 Kudos

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.

2 REPLIES 2

former_member194669
Active Contributor
0 Kudos

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.

former_member125661
Contributor
0 Kudos

NO. You cannot use GUI_UPLOAD in background It is meant to upload file from the presentation server only.

Use open data set - command to upload the file from the application server.