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

modify/update Database table with Internal table

Former Member
0 Likes
44,529

Hello, Could abyone please advice me...I'm trying to modify the database table with internal table, but its updating with new record rather modify the same...

MODIFY dbtable FROM TABLE itab.

1st line fields are key fields...

BAREA PLTYP PLAN_OPT BEGDA ENDDA VALUE_DATE

space DMP space space space 25.05.2007

space DMP space 01.04.2007 30.06.2007 25.05.2007

PERCENTAGE STATUS CNAME CDATE UNAME AEDTM

1,0000

1,0000 1 BR 07.02.2007

Thanks in advance...

10 REPLIES 10
Read only

Former Member
0 Likes
17,611

Make sure that structure of Internal table is same as Database table.

If the structures are same then, based upon the key fields it will add a new record or modify the record if the all the key fields are same

Check out if you are missing leading zeroes in any of the key fields

Read only

Former Member
0 Likes
17,611

hi,

Include transporting statement .

MODIFY dbtable FROM TABLE itab <b>transporting <fields>.</b>

Read only

Former Member
0 Likes
17,611

Hi,

Check whether entries are there in the internal table. Also check for the structure.

MODIFY dbtab FROM TABLE itab.
UPDATE dbtab FROM TABLE itab.

Check for sy-subrc.

Also check for duplicate entries.

Read only

former_member404244
Active Contributor
0 Likes
17,611

Hi,

1>First of all the structure of Internal table should be same as Database table.

use the below command

modify <dbtable> from table itab..

Regards,

nagaraj

Read only

Former Member
0 Likes
17,611

Hi,

use modify instead of update or insert

like this

modify mara from wa.

Regards

Shiva

Read only

Former Member
0 Likes
17,611

hi Database table structure and itab stucture same.

*-- internal data tables

DATA: i_yibrk_earnings TYPE STANDARD TABLE OF yibrk_earnings.

I'm using the st:

MODIFY YIBRK_EARNINGS FROM TABLE I_YIBRK_EARNINGS.

All fields are key fields: below is the test data. second row should not be created it...new values has to be modified in first one....

Fields:BAREA PLTYP PLAN_OPT BEGDA ENDDA VALUE_DATE

oldval: space DMP space space space 25.05.2007

newval:space DMP space 01.04.2007 30.06.2007 25.05.2007

Read only

0 Likes
17,611

Try this

LOOP AT I_YIBRK_EARNINGS.
 MODIFY YIBRK_EARNINGS FROM  I_YIBRK_EARNINGS.
 CLEAR I_YIBRK_EARNINGS.
ENDLOOP.

This will update table one by one, its not recommended, just check whether this works.

Read only

Former Member
0 Likes
17,611

BR,

You have to use below code

MODIFY dbtable FROM TABLE itab transporting <fields>.

Read only

Former Member
0 Likes
17,611

still it is inseting new row rather modify...even if use LOOP statement,,,,TRANSPORTING is not accepting as it has to use to modify only itab.

BAREA PLTYP PLAN_OPT BEGDA ENDDA VALUE_DATE are key fields


                                                                                BAREA PLTYP PLAN_OPT BEGDA      ENDDA      VALUE_DATE PERCENTAGE STATUS CNAME    CDATE                                                                                
DMP                                  25.05.2007    5,0000                             
       DMP            01.04.2007 30.06.2007 25.05.2007    5,0000  1      BR 07.02.2007 

Read only

0 Likes
17,611

Hi,

I got ur problem, it will modify/update only <b>when all the key field values are the same</b>.

In ur case only one field is the same and othe two are blank so it will insert a new row.

Now you try with changing the inserted row with a new values. You can understand.

BAREA PLTYP PLAN_OPT BEGDA ENDDA VALUE_DATE PERCENTAGE STATUS CNAME CDATE

DMP 01.04.2007 30.06.2007 25.05.2007 5,0000 1 BR 07.02.2007

Update this with some new CNAME and CDATE.

Hope this solves ur problem.