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: 

Updating a table using update

Former Member
0 Kudos

Hello,

I have to update the BSEG table using the following update stmt.

UPDATE BSEG SET BUPLA = W_BUPLA

WHERE BUKRS = W_BUKRS

AND BELNR = W_BELNR

AND GJAHR = W_GJAHR

AND BUPLA EQ SPACE

AND QSSKZ NE SPACE .

For one invoice update ( i.e. one belnr value ) i can run the above stmt and it works fine. But if i have multiple invoice values saved in in internal table say it_invoice and i want to run a sinlge update for all invoice nos in it_invoice, keeping the other paramaters like w_bukrs, w_gjahr same, how do i do it?

6 REPLIES 6

Former Member
0 Kudos

Not sure why you're directly updating a database table...not a good practice...but...

You can loop at an internal table and (slowly) do what you're doing here, moving the table columns to the w_whatever work area.

For mass updates, I'd probably use MODIFY dtab from itab statement, but that would require some changes in your approach.

former_member632458
Participant
0 Kudos

HI,

Use commit statement after Update.

Regards,

Rajesh S

Former Member
0 Kudos

It is as simple as it looks like

UPDATE BSEG FROM TABLE it_invoice

  • Updating the database table according to a where condition

UPDATE BSEG SET BUPLA = W_BUPLA

WHERE BUKRS = W_BUKRS

AND BELNR = W_BELNR

AND GJAHR = W_GJAHR

AND BUPLA EQ SPACE

AND QSSKZ NE SPACE .

Edited by: Bhanu Malik on Mar 26, 2010 12:31 PM

Former Member
0 Kudos

its not recommended to use update stmt to update SAP standard table..

0 Kudos

Don't use update statement to directly update the database table. This will lead to inconsistent data.

Former Member
0 Kudos

Really bad idea - have you considered the effect on other tables like BSID?

Rob