Klasse CL GUI FRONTEND SERVICES, Methode GUI UPLOAD

Aus SAP-Wiki
Wechseln zu: Navigation, Suche

Die Methode GUI_UPLOAD lädt Daten vom Frontend/PC hoch zu SAP.

Siehe auch Vorlage Upload/Download Datei Frontend.

Coding für Binärdatei, z. B. PDF

*&---------------------------------------------------------------------*
*&      Form  UPLOAD_PDF
*&---------------------------------------------------------------------*
*       Upload PDF-Datei
*----------------------------------------------------------------------*
form upload_pdf  using    piv_pdf        type file_table-filename
                 changing pct_pdf        type tty_pdf
                          pcv_pdf_laenge type i.

  data: lv_str_filename type string,
        lv_header       type xstring.

  lv_str_filename = piv_pdf.

  call method cl_gui_frontend_services=>gui_upload
    exporting
      filename                = lv_str_filename
      filetype                = 'BIN'
    importing
      filelength              = pcv_pdf_laenge
      header                  = lv_header
    changing
      data_tab                = pct_pdf
    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         = gc_11
      unknown_dp_error        = gc_12
      access_denied           = gc_13
      dp_out_of_memory        = gc_14
      disk_full               = gc_15
      dp_timeout              = gc_16
      not_supported_by_gui    = gc_17
      error_no_gui            = gc_18
      others                  = gc_19.
  if sy-subrc <> 0.
    message id sy-msgid type   sy-msgty
                        number sy-msgno
                        with   sy-msgv1
                               sy-msgv2
                               sy-msgv3
                               sy-msgv4.
  endif.

endform.                    " UPLOAD_PDF

Upload für Textdatei

*&---------------------------------------------------------------------*
*&      Form  UPLOAD_FILE
*&---------------------------------------------------------------------*
*       Upload Datei
*----------------------------------------------------------------------*
FORM UPLOAD_FILE
   using piv_FILE   TYPE RLGRAP-FILENAME
   changing pct_file type tty_file.

  Data: lv_filename type string.

  lv_filename = piv_file.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
       FILENAME                = lv_filename
*      FILETYPE                = 'ASC'
*      HAS_FIELD_SEPARATOR     = SPACE
*      HEADER_LENGTH           = 0
*      READ_BY_LINE            = 'X'
*      DAT_MODE                = SPACE
*      CODEPAGE                = SPACE
*      IGNORE_CERR             = ABAP_TRUE
*      REPLACEMENT             = '#'
*      VIRUS_SCAN_PROFILE      =
*    IMPORTING
*      FILELENGTH              =
*      HEADER                  =
    CHANGING
      DATA_TAB                = pct_FILE
    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
      NOT_SUPPORTED_BY_GUI    = 17
      ERROR_NO_GUI            = 18
      OTHERS                  = 19.

  if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

ENDFORM.                    " UPLOAD_FILE

Web-Links