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: 

database table not updating

Former Member
0 Kudos

Hi all,

I am updating the database table with following syntex, but table not updating.

MODIFY ZTEST_BAR FROM TABLE I_ZTESTBAR.

Please help.

PKB

16 REPLIES 16

Former Member
0 Kudos

hi,

Make sure that the primary key fields are completely specified in the internal table, and they are in the same order/ structure with respect to the database table...

Could you just paste your internal table structure so that, it can be evaluated against your database table...

Thanks

Sharath

0 Kudos

Hi Sharath,

MANDT C 3 009

BWART C 3 103

HP_SERNR C 18 1234

SERNR C 18 26

MATNR C 18 000000119020000028

MBLNR C 10 5000101371

MJAHR N 4 2009

ZEILE N 4 0001

*WERKS C 4 *

This is structure of my internal table. inthis mandt, bwart and hp_sernr are my key fields which i am selecting from database. Only sernr field i am updating but unable to update table.

0 Kudos

did you check return code (sy-subrc)? If this is ok (=0), then maybe adding a commit work might do the job.

0 Kudos

hi,

in the internal table remove the column mandt and also check the value of the primay key fields whether they are matching with the values existing in the DB table for that particulary row and also make sure that there are no duplicate records of the same primary key in the internal table else it shall be over written.

thanks

Sharath

Former Member
0 Kudos

Hi,

Try this link may be helpful.

https://www.sdn.sap.com/irj/scn/forums

Regards,

jaya

Former Member
0 Kudos

Hi,

First remove the MANDT field from the intrenal table,

Secondly check the data type of the fileds should match the data element of the fields of the table

thirdly check the sy-subrc value

fourthly use COMMIT after modify to actually inserting the new record if it does not exit or updating the already existing record.

Pooja

Former Member
0 Kudos

Hi ,

If the change intended to a line in the internal table will lead to a duplicate entry in the table with the same primary index the values will not be inserted.The other entries which are unique would be inserted.

So please do check the entries in the internal table.

regards,

Radhika

Former Member
0 Kudos

hello,

use modify statement only in loop.

regards,

sumanth reddy

Former Member
0 Kudos

Hi , no need to give mandt field in the internal table structure .

and thyen you check in the table which is primary key and you should note that your r also giving atlease values for the key fields.

Then you check by putting bereak-point whether data is coimg to the internal table.

Thanks,

Rajendra

0 Kudos

Hi,

Try this.

LOOP AT IT_TAB.

MOVE-CORRESPONDING IT_TAB TO ZINKT001.

MODIFY ZINKT001.

CLEAR IT_TAB.

ENDLOOP.

Former Member
0 Kudos

Hi,

Hope this link helps you

[Link|]

Regards,

Rajani

Former Member
0 Kudos

Hi,

The ztable and the internal table from where u modify ztab must hv same primary key.

also the no. of fields ,the complete structure.

If for the value in key of the itab has no record in the ztable, the record gets inserted into the ztable.

and the value in key of the itab has record in the ztable, the record in ztable gets overwritten.

if modification is successful

SY-SUBRC is set to 0. u can check the return code.

SY-DBCNT gives the number of lines in the internal table.

Regards,

Mdi.Deeba Najam.

Former Member
0 Kudos

Hi,

firstly you can define internal table and work area as below:-

  • internal tables

************************************************************************

DATA : I_ZTESTBAR TYPE TABLE OF ZTEST_BAR.

************************************************************************

  • work areas

************************************************************************

DATA : I_ZTESTBAR_LINE LIKE LINE OF I_ZTESTBAR .

************************************************************************

here internal table having the same structure as that of ztable which include MANDT.

Then to update field, you can use add following code:-

*Update Ztable

************************************************************************

INSERT INTO ZTEST_BAR VALUES I_ZTESTBAR_LINE.

COMMIT WORK.

************************************************************************

Hope this works for you.

Thanks..........

Former Member
0 Kudos

hi,

Declare teh internal table as

i_ztable type standard table of ztable.

and then try to modify, this will definately work.

Thank You

Former Member
0 Kudos

hi,

Declare teh internal table as

i_ztable type standard table of ztable.

and then try to modify, this will definately work.

Thank You

Former Member
0 Kudos

First check that the if the same record is abvailable in table or not ? if the record is available with this data then it will not update it only modify the existing record...