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: 

update Z table

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Using modify will create new records if they don't exist and update existing records. I don't think that UPDATE will create new records.

MODIFY zsd_stock FROM TABLE i_zsd_stock.

Regards,

Rich Heilman

former_member181962
Active Contributor
0 Kudos

Hi Praneth,

Use insert or modify statement instead.

Regards,

Ravi

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

0 Kudos

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

0 Kudos

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

0 Kudos

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.