Skip to end of metadata
Go to start of metadata

UPLOAD

UPLOAD is obsolete function module for uploading data from a file in SAP server.

 CALL FUNCTION 'UPLOAD'
  IMPORTING
   CODEPAGE                      = ' '
    FILENAME                      =  filename
    FILETYPE                       =  'DAT'
    ITEM                              = ' '
*   FILEMASK_MASK                 = ' '
*   FILEMASK_TEXT                 = ' '
*   FILETYPE_NO_CHANGE            = ' '
*   FILEMASK_ALL                  = ' '
*   FILETYPE_NO_SHOW = ' '
*   LINE_EXIT  = ' '
*   USER_FORM  = ' '
*   USER_PROG  = ' '

*   SILENT                        = 'S'
* EXPORTING
*   ACT_FILENAME                  =
*   ACT_FILETYPE                  =
*   FILESIZE      =
*   CANCEL     =
  TABLES
    DATA_TAB                              = lt_datatab
 EXCEPTIONS
   CONVERSION ERROR               = 1
   INVALID_TABLE_WIDTH           = 2
   INVALID_TYPE                          = 3
   NO_BATCH                               = 4
   UNKNOWN_ERROR                  = 5
   GUI_REFUSE_FILETRANSFER   = 6
   OTHERS                                     = 7 .

So we will be using the method ` GUI_UPLOAD` of the class `CL_GUI_FRONTEND_SERVICES`. Now in 4.6, while using FM UPLOAD, a pop-up used to appear, prompting you to get/locate the path of the file. To get the same functionality in GUI_UPLOAD use code as below-   

DATA : lt_file_table TYPE filetable.
DATA : lw_file  TYPE file_table.
DATA : l_rc TYPE i.
DATA : BEGIN OF lt_itab OCCURS 0 ,            
                  l_c1 TYPE string,      
            END OF lt_itab.
DATA : l_action TYPE i.
DATA  filename_new TYPE string .
MOVE filename to filename_new.

CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING      
     DEFAULT_FILENAME              = file
CHANGING      
     FILE_TABLE                            = lt_file_table
     RC                                            = l_rc      
     USER_ACTION                      = l_action.

IF l_action NE 9.
READ TABLE  lt_file_table INTO lw_file INDEX 1.
filename_new = lw_file-filename.

CALL METHOD cl_gui_frontend_services=>gui_upload
IMPORTING
    FILENAME                             = filename_new
    FILETYPE                               = 'ASC'
    HAS_FIELD_SEPARATOR      = 'X'
*    HEADER_LENGTH        = 0
*    READ_BY_LINE                  = 'X'
*    DAT_MODE                  = ' '
*    CODEPAGE                       = ' '
*    IGNORE_CERR                   =
*    REPLACEMENT                     = '#'
*    CHECK_BOM                                 = ' '
*    VIRUS_SCAN_PROFILE         =
*    NO_AUTH_CHECK                = ' '
  EXPORTING
*    FILELENGTH                  =
*    HEADER                  =
  TABLES
    DATA_TAB                       = lt_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
    OTHERS                                       = 17.     

ENDIF.

Note :- If UPLOAD has filetype as 'DAT', then in GUI_UPLOAD make filetype = 'ASC' and put HAS_FIELD_SEPARATOR = 'X'. Same applies for WS_UPLOAD.

  • No labels