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: 

Data Upload from Excel Sheet. Two Worksheets.

Former Member
0 Kudos

Hello,

I have to upload data from excel sheet to Internal Table.

The excel sheet is having 2 worksheets.

These worksheets are to be uploaded in two Internal tables.

Is there any Function module for this?

Your help wud be appretiated.

~pranu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You need 2 excel for loading two internal tables. You can't splitting a excel file in two internal tables.

I give you an example

**&----


**

*& Form LEER_EXCEL

**&----


**

FORM leer_excel .

DATA: it_raw TYPE truxs_t_text_data, "Variable necesaria para la función

p_fichero LIKE rlgrap-filename."Tipo de fichero necesario

    • Tipo de ruta necesaria*

CONCATENATE p_file1 gt_files INTO p_fichero.

    • REPLACE '.xls' WITH '.fan' INTO p_fichero.*

    • Función que carga un ficher excel en una tabla interna*

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

    • I_FIELD_SEPERATOR =*

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_fichero

TABLES

i_tab_converted_data = gt_fichero1[]

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE i000(su)

WITH 'Error al leer el archivo Excel.'

'Compruebe que el archivo no esta abierto'

'y revise que la estructura'

'es la adecuada'.

STOP.

ENDIF.

ENDFORM. " LEER_EXCEL

3 REPLIES 3

Former Member
0 Kudos

You need 2 excel for loading two internal tables. You can't splitting a excel file in two internal tables.

I give you an example

**&----


**

*& Form LEER_EXCEL

**&----


**

FORM leer_excel .

DATA: it_raw TYPE truxs_t_text_data, "Variable necesaria para la función

p_fichero LIKE rlgrap-filename."Tipo de fichero necesario

    • Tipo de ruta necesaria*

CONCATENATE p_file1 gt_files INTO p_fichero.

    • REPLACE '.xls' WITH '.fan' INTO p_fichero.*

    • Función que carga un ficher excel en una tabla interna*

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

    • I_FIELD_SEPERATOR =*

i_line_header = 'X'

i_tab_raw_data = it_raw

i_filename = p_fichero

TABLES

i_tab_converted_data = gt_fichero1[]

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE i000(su)

WITH 'Error al leer el archivo Excel.'

'Compruebe que el archivo no esta abierto'

'y revise que la estructura'

'es la adecuada'.

STOP.

ENDIF.

ENDFORM. " LEER_EXCEL

0 Kudos

Hello,

The excel that I am getting is having 5 Worksheets.

Sheet1, sheet2, sheet3, sheet4 and sheet5.

From this excel sheet, I have to read the data from worksheet1 and worksheet 3.

I will nto be getting two excel sheets. It would have been easier otherwise .

Any Idea?

Thanks

0 Kudos

Hello,

Take a look on this: [ABAP - Upload data from Excel to Sap using OO|https://wiki.sdn.sap.com/wiki/x/xOw/]. It's a program to upload data and as you can see in this, it shows how to navigate between spreadsheets and cells.

Regards.