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: 

Is there any function to upload

Former Member
0 Kudos

Hi,

Is there any function to upload a txt file in background into itab?

Thanks.

deniz.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

I guess for presentation server it is not possible as there is active presentation server when program runs in background...whereas for Appplication server this can be done using OPENDATASET....CLOSEDATASET.

Pooja

5 REPLIES 5

Former Member
0 Kudos

hi,

CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
    filename                      =  'D:\FILEINTERFACE\file.TXT'
*    FILETYPE                      = 'ASC'
     has_field_separator           = 'X'
*    HEADER_LENGTH                 = 0
*    READ_BY_LINE                  = 'X'
*    DAT_MODE                      = ' '
*    CODEPAGE                      = ' '
*    IGNORE_CERR                   = ABAP_TRUE
*    REPLACEMENT                   = '#'
*  IMPORTING
*    FILELENGTH                    =
*    HEADER                        =
    TABLES
      data_tab                      = t_kna1
*  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.
  ENDIF.                               " IF SY-SUBRC <> 0

Thanks

Sharath

Former Member
0 Kudos

Hi,

I guess for presentation server it is not possible as there is active presentation server when program runs in background...whereas for Appplication server this can be done using OPENDATASET....CLOSEDATASET.

Pooja

Former Member
0 Kudos

Hi,

use this function module...

FILE_READ_AND_CONVERT_SAP_DATA: Uploads the file from either presentation or application server into an internal table

CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'

EXPORTING

i_filename = 'c:\temp\filename.txt'

  • I_SERVERTYP = C_APPLICATION_SERVER

  • I_FILEFORMAT =

I_FIELD_SEPERATOR = 'X'

  • I_LINE_HEADER =

  • IMPORTING

  • E_BIN_FILELENGTH =

  • TABLES

  • I_TAB_RECEIVER =

EXCEPTIONS

FILE_NOT_FOUND = 1

CLOSE_FAILED = 2

AUTHORIZATION_FAILED = 3

OPEN_FAILED = 4

CONVERSION_FAILED = 5

OTHERS = 6.

IF sy-subrc <> 0.

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

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

ENDIF.

Regards

Kiran

Former Member
0 Kudos

Hi,

call function GUI_UPLOAD .

This uploads text file into internal table.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

  • I_LINE_HEADER =

i_tab_raw_data = t_tab

i_filename = 'C:\1312\cust.xls'

TABLES

i_tab_converted_data = t_cust

EXCEPTIONS

conversion_failed = 1

OTHERS = 2

.

IF sy-subrc <> 0.

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

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

ENDIF.

This uploads excel(.xls) file into internal table

Former Member
0 Kudos

Hi Deniz,

To upload file in the back ground we use gui_upload function module. The examples are shown in the wiki. The link is shown below

https://www.sdn.sap.com/irj/scn/wiki.

Hope I have resolved your issue.

Regards,

Abdur Rafique