Using GUI Upload to upload file in SAP ABAP

Here is the use of GUI Upload Function Module...
Uploading a file using SAP ABAP programming using SAP Function Module GUI_DOWNLOAD.

REPORT  ZGUI_UPLOAD2 NO STANDARD PAGE HEADING.

DATA: BEGIN OF ITAB OCCURS 1,

        LINE(255) TYPE C,

      END OF ITAB.

DATA: V_FILE TYPE STRING.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME DEFAULT

'C:\Documents and Settings\Administrator\Desktop\ZCALL_TRAN_XD01.TXT'.

V_FILE = P_FILE.

CALL FUNCTION 'GUI_UPLOAD'

  EXPORTING

    FILENAME                      = V_FILE

    FILETYPE                      = 'ASC'

  TABLES

    DATA_TAB                      = ITAB

 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.

IF SY-SUBRC <> 0.

 MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

  LOOP AT ITAB.

    WRITE:/ ITAB-LINE.

  ENDLOOP.

ENDIF.



Popular posts from this blog

ALV with field catalog merge

SAP ABAP real-time Interview Questions with answers

Using GUI Upload in SAP ABAP