2007 Dec 28 11:10 AM
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.
2007 Dec 28 11:20 AM
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 .
2007 Dec 28 11:16 AM
Hi,
Declare the internal table with type Database table name.
Eg:
Data:itab like kna1 occurs 0 with header line.
2007 Dec 28 11:20 AM
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 .
2007 Dec 28 11:27 AM
But how could i use it for excel sheet. I want to upload the full excel sheet.
2007 Dec 28 11:38 AM
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.
2007 Dec 28 11:38 AM
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.
2007 Dec 28 12:00 PM
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.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |