Application Development 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: 

reg updating z table

Former Member
0 Kudos

hi all

i want to update a ztable from a internal table .

LOOP AT int_item_update.

INSERT into zinv_item values int_item_update.

MODIFY zinv_item FROM int_item_update.

ENDLOOP.

the z table has no values now.

if i use insert , first record only gets updated.

if i use modify, last recorrd gets updated.

gimme ur valuable answers please

regards

karthik

Edited by: karthikeyan palaniayya on Jan 10, 2008 7:06 AM

15 REPLIES 15

Former Member
0 Kudos

Hi u can use as following without using the Loop at Itab.

Insert ztable from table itab.

awrd points if useful

Bhupal

0 Kudos

Hi buphal

its not getting updated ,

any more suggestion plz

regards

karthik

0 Kudos

Try by giving

COMMIT WORK.

After Insert Statement.

awrd points if helpful

Bhupal

Former Member
0 Kudos

Hi karthik,

Try this...

LOOP AT int_item_update.

INSERT into zinv_item values int_item_update.

ENDLOOP.

commit work.

Regards,

Azhar

Former Member
0 Kudos

u have all the data in internal table itab which is of same type as of the ZTABLE..

then u can directly give

INSERT INTO zls_yield VALUES t_zls_yield

or

MODIFY zls_yield_share FROM TABLE t_zls_yield.

commit work.

Former Member
0 Kudos

Karthik,

use the below statement it will update all the reocrds from internal table. if the record already exists it will over write the existing values. instead of insert statement, this is the best option.

MODIFY zinv_item FROM table int_item_update

let me know if you have any questions....

former_member404244
Active Contributor
0 Kudos

Hi,

do like this.

first get data in the internal table as u did..so data is there in the internal table int_item_update.

now directly u can write this statement.

update zinv_item FROM table int_item_update.

if sy-subrc eq 0.

commi work.

endif.

"LOOP IS NOT NECESSARY"

Regards,

Nagaraj

Former Member
0 Kudos

Hi Karthikeyan,

As per the issue raised by you , it is understood that you have the same key(Primary) combination, so you are facing the problem. Even if you use the statement outside loop statement also you will face the same problem. The problem is not with the code but with the data you are trying to update. Since you are having the same key combination, the same record gets updated whenever you use MODIFY stmt. But if you use INSERT stmt, after you insert the first record, there cannot be a new record with the same key combination, so the other records cannot be inserted.

Hope this will resolve your Query.

Reward all the helpful answers.

Regards

Nagaraj T

0 Kudos

Hi nagaraj

i am having single primary key as RUN NUMBER. it is not the same value. so what i have to use?

regards

karthik

0 Kudos

Is that only the Primary Key, Didnt u put MANDT?

If ur table had MANDT also fill that one also by sy-mandt.

and then insert .

awrd points if helpful

0 Kudos

Hi Karthikeyan,

As per bhupal suggested, did u use MANDT also as primary key in ur z-table. If so , send me across ur code so that I can help you out.

Hope this will resolve your Query.

Reward all the helpful answers.

Regards

Nagaraj T

0 Kudos

Hi,

if u want to make the table as client specific then use MANDT field otherwise no need for it..

secondly if ur primary key is RUN NUMBER ,then check in ur internal table if u r gettting different values for it..If yes,then all should be updated, if no then u have add one more thing as " ACCEPT DUPLICATES".

MODIFY ZTABLE FROM TABLE ITAB ACCEPTING DUPLICATE ENTRIES...i didn't exactly rememebr the syntax,it will be like this only..

Regards,

Nagaraj

Former Member
0 Kudos

Hi,

SORT itab.

IF NOT int_item_update[] IS INITIAL.

MODIFY zinv_item FROM int_item_update.

COMMIT WORK.

ENDIF.

Former Member
0 Kudos

Hai,

Just try this.

select fieldvalues u require from table into internal table then

loop at internaltable into workarea.

modify originatable from workarea.

ex.

loop at itab_emp INTO wa_emp.

modify zemp FROM wa_emp.

endloop.

and also check that structure of the originaltable and ita_emp,wa_emp should same.

Regards.

B.Sowjanya

Edited by: Sowjanya barli on Jan 10, 2008 7:55 AM

Former Member
0 Kudos

Hi all

thanks all for ur wonderful support

Kind Regards

Karthik