03-26-2010 11:19 AM
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?
03-26-2010 11:30 AM
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.
03-26-2010 11:31 AM
03-26-2010 11:31 AM
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
03-26-2010 11:59 AM
its not recommended to use update stmt to update SAP standard table..
03-26-2010 12:06 PM
Don't use update statement to directly update the database table. This will lead to inconsistent data.
03-26-2010 1:40 PM
Really bad idea - have you considered the effect on other tables like BSID?
Rob