Application Development and Automation 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: 
Read only

Is there any function to upload

Former Member
0 Likes
755

Hi,

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

Thanks.

deniz.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
701

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

Hi,

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

Thanks.

deniz.

5 REPLIES 5
Read only

Former Member
0 Likes
701

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

Read only

Former Member
0 Likes
702

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

Read only

Former Member
0 Likes
701

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

Read only

Former Member
0 Likes
701

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

Read only

Former Member
0 Likes
701

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