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

Plz check my code...

Former Member
0 Likes
1,128

Hi gurus,

I am trying to insert the internal table data into Ztable.

I am sending my piece of code.Please check it out and suggest me is there any modifications required..

In that internal table i have duplicate records..Those duplicates are not inserted..

My piece of code is...

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 ztab_ltap from table it_tab accepting duplicate keys.

or

loop at it_tab into wa_tab.

insert ztab_ltap from wa_tab ..

modify ztab_ltap from wa_tab. .

endloop.

I tried out these two types of insert statements.

suppose i have 6 reords, in those recorde the 3 recorde have same lgort ,wdatu, and different matnr..

Remaining 3 recorde have same lgort ,wdatu , and the Matnr are same as above matnrs.

When i am running this code in database table the last record only inserted.

I need to insert 6 record.

Please can any one suggest me on this.

Thanks in Advance

Help ful answers will be rewarded...

Thanks and Regards

Siri..

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,105

Use commit work

ex:

insert ztab_ltap from table it_tab accepting duplicate keys.

COMMIT WORK.

9 REPLIES 9
Read only

Former Member
0 Likes
1,105

Hi,

What are the primary key fields of your ztable?

Based on your primary key and foreign key fields records will get inserted....

Read only

0 Likes
1,105

Hi murali ,

I put only Lgort is the primary key first time.Then also it will be same..

After that i change the primary key as mandt..Even though it will be same..

Please suggest me how to do..

Thanks and Regards

Siri...

Read only

Former Member
0 Likes
1,105

Hi

instead of this code...

{

loop at it_tab into wa_tab.

insert ztab_ltap from wa_tab ..

modify ztab_ltap from wa_tab. .

endloop.

}

you can directly insert the records into ztab_ltap from it_tab by using

modify ztab_ltap from it_tab

Read only

Former Member
0 Likes
1,105

Hi,

Try it

loop at it_tab into wa_tab.

append ztab_ltap .

endloop.

Regards

Read only

Former Member
0 Likes
1,106

Use commit work

ex:

insert ztab_ltap from table it_tab accepting duplicate keys.

COMMIT WORK.

Read only

0 Likes
1,105

Hi shaik,

I am using commit work stmt also . Its not working

Please suggest me..

thanks and Regards

Siri..

Read only

0 Likes
1,105

Hi,

if u are using standard data elements its not possible to insert the dupicate records

Read only

0 Likes
1,105

Hi Rajesh,

Thanks for giving valuable suggestion.. Its working fyn...

I rewarded u...

Regards...

Siri...

Read only

Former Member
0 Likes
1,105

Hi,

Try

MODIFY ztab_ltap FROM TABLE wa_tab.