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

excel sheet entries into standard database table

Former Member
0 Likes
775

hi,

can we add data from excel sheet into standard database table through ABAP program.

I want to add the data in my excel sheet into standard database table kna1 through a program. I am using function module for internal table and then getting it in table kna1.

But the error it is giving me that : the type of the database table and the internal table are not unicode convertible, Can u please tell me the solution.

1 ACCEPTED SOLUTION
Read only

former_member188829
Active Contributor
0 Likes
755

Hi,

Check this Example.

TABLES:MARA.

DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

ITAB-MATNR = '123ABCD'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

INSERT MARA FROM ITAB.

MODIFY MARA .

6 REPLIES 6
Read only

former_member188829
Active Contributor
0 Likes
755

Hi,

Declare the internal table with type Database table name.

Eg:

Data:itab like kna1 occurs 0 with header line.

Read only

former_member188829
Active Contributor
0 Likes
756

Hi,

Check this Example.

TABLES:MARA.

DATA:ITAB LIKE MARA OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

ITAB-MATNR = '123ABCD'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

INSERT MARA FROM ITAB.

MODIFY MARA .

Read only

0 Likes
755

But how could i use it for excel sheet. I want to upload the full excel sheet.

Read only

0 Likes
755

Hi Pal,

Let me share my points with u. By using type pools TRUXS our problem my be solve.

Take one internal table like your standard data base table and

one internal table for truxs like

DATA: it_raw TYPE truxs_t_text_data.

DATA: itab like mara occurs 0 with header line.

Use FM

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

  • I_FIELD_SEPERATOR =

i_line_header = 'X'

i_tab_raw_data = it_raw " WORK TABLE

i_filename = p_file

TABLES

i_tab_converted_data = it[] "ACTUAL DATA

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

Now looping that and updated to data base table.

Hope this helps you. Reply for queries, shall post the updates.

Regards.

Kumar.

Read only

0 Likes
755

Hi,

First Move that Excel Sheet Data to Internal Table Using Function Module ALSM_EXCEL_TO_INTERNAL_TABLE.

And you can insert that internal table data to Database Table Using INSERT Commannd.

Read only

0 Likes
755

Hi Yadav,

First upload Data From Excel Sheet to ITAB with Required Structure. Once the Data Comes...

And Declare another Internal Table (ITAB1) Type Database Table name.

And Use Insert Database Table From ITAB1.

Check this Example.

TABLES:MARA.

DATA:BEGIN OF ITAB OCCURS 0,

MATNR LIKE MARA-MATNR,

MBRSH LIKE MARA-MBRSH,

MTART LIKE MARA-MTART,

MEINS LIKE MARA-MEINS,

END OF ITAB.

DATA:ITAB1 LIKE MARA OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

ITAB-MATNR = '123ABCDA'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

ITAB-MATNR = '123ABCDB'. .

ITAB-MBRSH = 'C'.

ITAB-MTART = 'FERT' .

ITAB-MEINS = 'KG' .

APPEND ITAB.

LOOP AT ITAB.

MOVE-CORRESPONDING ITAB TO ITAB1.

APPEND ITAB1.

ENDLOOP.

LOOP AT ITAB1.

INSERT MARA FROM ITAB1.

MODIFY MARA .

ENDLOOP.