07-04-2006 1:15 PM
Hi All!
I am updating a table as below :
UPDATE zsd_stock FROM TABLE i_zsd_stock.
But my z table is not getting updated.The Z table is empty right now.Any specific things to take care of before updating.
Please advise..
Regards
Praneeth
07-04-2006 1:36 PM
Hi Praneeth,
DATA : i_zsd_stock TYPE STANDARD TABLE OF zsd_stock WITH HEADER LINE.
*UPDATE Will work only if records are present in DB table and you are
*Updating some values for a particular record
UPDATE zsd_stock FROM TABLE i_zsd_stock.
Use MODIFY or INSERT.
*It inserts records present in internal table
INSERT zsd_stock FROM TABLE i_zsd_stock.
*MODIFY works both as UPDATE and INSERT
*If no record present it inserts the records in internal table(Same as INSERT)
*If record present in the DB table it updates the values for that record(Same as UPDATE)
MODIFY zsd_stock FROM TABLE i_zsd_stock.
<b>So its best to use MODIFY statement.</b>
Regards,
Arun Sambargi.
07-04-2006 1:16 PM
07-04-2006 1:18 PM
07-04-2006 1:19 PM
Hi Praneeth,
Use MODIFY statement rather than UPDATE statement.
<b>IF I_ZSD_STOCK[] IS NOT INITIAL.
MODIFY ZSD_STOCK FROM TABLE I_ZSD_STOCK.
ENDIF.</b>
Thanks,
Vinay
07-04-2006 1:24 PM
Hi,
You have to use modify statement,
MODIFY <zsd_stock> FROM TABLE <i_zsd_stock>.
And also try putting the following statement after modify statement if above statement doen't work.
COMMIT WORK.
Regs,
Venkat Ramanan N
07-04-2006 1:36 PM
Hi Praneeth,
DATA : i_zsd_stock TYPE STANDARD TABLE OF zsd_stock WITH HEADER LINE.
*UPDATE Will work only if records are present in DB table and you are
*Updating some values for a particular record
UPDATE zsd_stock FROM TABLE i_zsd_stock.
Use MODIFY or INSERT.
*It inserts records present in internal table
INSERT zsd_stock FROM TABLE i_zsd_stock.
*MODIFY works both as UPDATE and INSERT
*If no record present it inserts the records in internal table(Same as INSERT)
*If record present in the DB table it updates the values for that record(Same as UPDATE)
MODIFY zsd_stock FROM TABLE i_zsd_stock.
<b>So its best to use MODIFY statement.</b>
Regards,
Arun Sambargi.
07-04-2006 1:39 PM
Hi praneeth,
1. Use logic like this.
2. I assume , the
internal table i_zsd_stock
contains some records,
which need to be put/add/edit in database table ZSD_STOCK.
<b>
3. Loop at i_zsd_stock.
MODIFY ZSD_STOCK FROM i_zsd_stock.
Endloop.</b>
4. MODIFY statement
will AUTOMATICALLY
ADD/UPDATE/EDIT RECORDS in the database table,
based upon the primary key combination,
found or not found, in the database table.
regards,
amit m.
07-04-2006 1:54 PM
Hi All!
My requirement is to append values to the already existing table lines and not to edit any of the earlier lines just to append to the already available lines.Is it possible through modify and insert as suggested by you all.
Please advise.
Regards
Praneeth
07-04-2006 1:56 PM
Then I would say to use INSERT. But if there is a record that exists which has the same key as one that you are trying to INSERT, then the INSERT will fail. MODIFY will not fail, but it will update the record with any change. If you know that you will never want to write records with a previous used key, then INSERT is ok to use.
Regards,
Rich Heilman
07-04-2006 1:59 PM
Hi again,
1. Is it possible through modify and insert as suggested by you all.
Dont worry.
MODIFY Statement
WILL AUTOMATICALLY TAKE CARE OF THIS.
(No need to use different syntax/statement
for INSERT or UPDATE)
2.
Modify statement
will AUTOMATICALLY
INSERT / UPDATE
based upon the primary key combination
if found / not found
in the database table.
3. If the primary key is found, then edit will be done,
otherwise insert will be done,
automatically.
regards,
amit m.