‎2008 Mar 12 2:08 PM
Hi gurus,
I have duplicate records in my internal table.I need to update these duplicate records into ztable.I created Ztable with out having the key value.I put only MANDT as key value , all other fields are non key values.I need to insert these duplicate records into Ztable.
When i am using insert statement it inserts only the last record. I am snding my piece of code here. Please any one suggest me on this.
loop at t_ltap into s_ltap.
wa_tab-lgort = s_ltap-lgort.
wa_tab-wdatu = s_ltap-wdatu.
wa_tab-matnr = s_ltap-matnr.
wa_tab-maktx = s_ltap-maktx.
wa_tab-nsola = s_ltap-nsola.
wa_tab-text = s_ltap-text.
append wa_tab to it_tab.
clear wa_tab.
endloop.
loop at it_tab into wa_tab.
insert ztab_ltap from wa_tab.
endloop.
Thanks in Advance....
Thanks and Regards
siri......
‎2008 Mar 12 2:13 PM
Hi,
Try this piece of code for inserting.
loop at t_ltap into s_ltap.
wa_tab-lgort = s_ltap-lgort.
wa_tab-wdatu = s_ltap-wdatu.
wa_tab-matnr = s_ltap-matnr.
wa_tab-maktx = s_ltap-maktx.
wa_tab-nsola = s_ltap-nsola.
wa_tab-text = s_ltap-text.
append wa_tab to it_tab.
clear wa_tab.
clear it_tab.
endloop.
loop at it_tab into wa_tab.
insert ztab_ltap from wa_tab ACCEPTING DUPLICATE KEYS
endloop.
Thanks,
Sriram Ponna.
‎2008 Mar 12 2:25 PM
Hi sriram,
When i give accepting duplicate keys it gives the error.
please check it and suggest me please.
Thanks in advance
Thanks and Regards
siri...
‎2008 Mar 12 2:29 PM
Hi,
what is the error you are getting?
Please refer to the example code:
TABLES SCUSTOM.
SCUSTOM-ID = '12400177'.
SCUSTOM-NAME = 'Robinson'.
SCUSTOM-POSTCODE = '69542'.
SCUSTOM-CITY = 'Heidelberg'.
SCUSTOM-CUSTTYPE = 'P'.
SCUSTOM-DISCOUNT = '003'.
SCUSTOM-TELEPHONE = '06201/44889'.
INSERT INTO SCUSTOM VALUES SCUSTOM.
Thanks,
Sriram Ponna.
‎2008 Mar 12 2:34 PM
Hi sriram,
When i wrote u r code like ,
insert ztab_ltap from wa_tab accepting duplicate keys.
the error comes as '.' required after wa_tab.
Please check it out and suggest me..
Thanks and Regards
Siri...
‎2008 Mar 12 2:42 PM
Hi,
Accepting duplicates will not work with area, that is the reason it is throwing an error:
Try like this :
loop at t_ltap into s_ltap.
wa_tab-lgort = s_ltap-lgort.
wa_tab-wdatu = s_ltap-wdatu.
wa_tab-matnr = s_ltap-matnr.
wa_tab-maktx = s_ltap-maktx.
wa_tab-nsola = s_ltap-nsola.
wa_tab-text = s_ltap-text.
append wa_tab to it_tab.
clear wa_tab.
endloop.
INSERT <ztablename> FROM TABLE it_tab.
Thanks,
Sriram Ponna.
‎2008 Mar 12 2:42 PM
‎2008 Mar 12 2:19 PM
Hi Abinava,
Maybe you can add a numeric field (i.e. NUMC10) as key field in your Z table together with MANDT.
In your program you build a counter and increase it per each register in it_tab.
The insert statemanet should no cause errors with this.
Reward points if useful
Roger
‎2008 Mar 12 2:21 PM