‎2006 Jan 10 12:35 PM
Hello Guru's!!
I want to Insert the TABLE values of two Internal tables of Different Business Units...(Bu_zknvh & Au_Zknvh) into table Zknvh
Currently following is the CODE.. but I cant see both the Business Units data at once in the TABLE..
*... Insert Zknvh from Bu_zknvh..................
INSERT ZKNVH FROM TABLE BU_ZKNVH.
MESSAGE I002(ZM) WITH TEXT-006 SY-DBCNT.
IF SY-SUBRC <> 0 OR BU IS INITIAL.
ROLLBACK WORK.
MESSAGE E001(ZM) WITH TEXT-003.
ELSE.
COMMIT WORK.
ENDIF.
For this second internal table
I have tried using the code ..
insert into Zknvh values au_zknvh
but it inserts only one ROW.... I want to append this table with all the values of au_zknvh but it shows me an ERROR MESSAGE:: ZKNVH is not an INTERNAL TABLE ..
*... Insert ZKNVH from Table Au_zknvh...............
INSERT zknvh From table au_zknvh.
MESSAGE i002(zm) WITH text-006 sy-dbcnt.
IF sy-subrc <> 0 OR bu IS INITIAL.
ROLLBACK WORK.
MESSAGE e001(zm) WITH text-003.
ELSE.
COMMIT WORK.
ENDIF.
Please help me Thanx in advance
Preethu
‎2006 Jan 10 12:47 PM
Hi,
You can achieve it in following way.
append lines of itab1 to itab.
append lines of itab2 to itab.
Kindly reward points if it helps.
‎2006 Jan 10 12:49 PM
I believe both the internal tables are of the same same structure ...right ?
Can't you move the contents of both itabs to one and do the insert in one shot..?
if yes, use the following...
move the 2nd itab data to the first
append lines of au_zknvh to bu_knvh.
*... Insert Zknvh from Bu_zknvh..................
INSERT ZKNVH FROM TABLE BU_ZKNVH.
MESSAGE I002(ZM) WITH TEXT-006 SY-DBCNT.
IF SY-SUBRC <> 0 OR BU IS INITIAL.
ROLLBACK WORK.
MESSAGE E001(ZM) WITH TEXT-003.
ELSE.
COMMIT WORK.
ENDIF.
Thanks,
Renjith
‎2006 Jan 10 12:57 PM
Hi renjith..
you are true both the ITABs have the same structure.. I also need the code to move both Itabs at one shot..
Could you also write me the code of Moving the 2nd itab into 1st itab without Duplicating.. please..
Thanx in advance..
‎2006 Jan 10 1:00 PM
Hi preethu,
1. one shot is not possible.
2. do u want to update database table ?
3. then
4.
Loop at itab1.
modify dbtab from itab1.
endloop.
Loop at itab2.
modify dbtab from itab2.
endloop.
regards,
amit m.
‎2006 Jan 10 1:01 PM
Do this to remove duplicate entries after combining both itabs...
append lines of au_zknvh to bu_zknvh.
sort bu_zknvh.
Delete adjacent duplicates from bu_zknvh comparing all fields.
Also while doing the insert add the "accepting duplicate keys " addition...check the F1 on Insert to see the help
Thanks,
Renjith.
‎2006 Jan 10 1:04 PM
Hi
You should check your tables if you want to know if there are records with the same keys.
APPEND LINE OF AU_ZKNVH TO BU_ZKNVH.
INSERT ZKNVH FROM BU_ZKNVH.
You can use the option ACCEPTING DUPLICATE KEYS if you don't know the dump for duplicate keys:
INSERT ZKNVH FROM BU_ZKNVH ACCEPTING DUPLICATE KEYS.
Max