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

updation

Former Member
0 Likes
792

Hi Friends,

LOOP AT it_pa2002 INTO wa_pa2002.

Wa_pa2002-sprps = 'D'.

MODIFY it_pa2002 FROM wa_pa2002 TRANSPORTING sprps.

ENDLOOP.

UPDATE pa2002 FROM TABLE it_pa2002.

The above logic is not updating the database table properly. What could be the reason? The internal table structure and database table structure is same. The data is also coming properly to the internal table.

Thanks.

5 REPLIES 5
Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
763

Hi,

GIve the key of the internal table as same as that of the Databse table.

And laos it will be good if you can make it a SORTED table than a STANDARD table.

Regards,

Sesh

Read only

Former Member
0 Likes
763

Hi,

Modify it in this way

UPDATE pa2002 FROM TABLE it_pa2002 client specified.

Read only

Former Member
0 Likes
763

Hi,

1)create a lock object.

2) call lock object

3)update db table.

4)release lock object

Reward popints if helpful

Regards.

Srikanta Gope

Read only

former_member491305
Active Contributor
0 Likes
763

Hi,

Make sure you have given Commit work.Also what do u mean by" not updating properly". Is there No record getting updated or partial records are updated and remaining are not?...

Read only

Former Member
0 Likes
763

Dear Bharat,

It will not update as there is already an entry in the database so it will throw SY_SUBRC = 4.

1)You may be modifying the Key element.

2) Other wise if you want to modify the DB value for field SPRPS then give also a conditon in the Update and also the particular FIELD which you want to modify.

Please read this below quote from HELP file

"UPDATE <target> FROM TABLE <itab> .

The contents of the internal table <itab> overwrite the lines in the database table <dbtab> that have the same primary keys. The same rules apply to the line type of <itab> as to the work area <wa> described above.

If the system cannot change a line because no line with the specified key exists, it does not terminate the entire operation, but continues processing the next line of the internal table.

If all lines from the internal table have been processed, SY-SUBRC is set to 0. Otherwise, it is set to 4. If not all lines are used, you can calculate the number of unused lines by subtracting the number of processed lines in SY-DBCNT from the total number of lines in the internal table. If the internal table is empty, SY-SUBRC and SY-DBCNT are set to 0.

Whenever you want to overwrite more than one line in a database table, it is more efficient to work with an internal table than to change the lines one by one. "

Hope this helps you.

So do accordingly.

Thanks

Venugopal

If useful reward accordingly. it will be a long way to go ahead.