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

update/insert-databasetable

Former Member
0 Likes
732

hi all,

i have to update database table from internal table values.

pls suggest me how to update/insert databasetabel.

best regards,

ashok reddy.

7 REPLIES 7
Read only

Former Member
0 Likes
694

if you want to update a custome tABLE THEN YOU CAN USE MODIFY.

if you want to update standard table , i dont think this is the sugestable way.

Read only

Former Member
0 Likes
694

you can use

insert <dbtab> from table <itab>.

this will insert new record if primary key is new else it will modify older record with same primary key

that will do

plz reward if useful

vivek

Read only

Former Member
0 Likes
694

Hi,

You can update a database table using Modify or update statement.

Modify: It inserts one or several lines specified in source in target or overwrites the existing lines.

MODIFY target FROM source.

Eg., modify z_employee from table it_employee[].

Where z_employee is the database (custom) table & it_employee is the internal table.

Update: The statement UPDATE changes the content of one or more lines of the database table specified in target. The entries in source determine which columns of which lines are changed, and how they are changed. If no records in the target system are found, a new record will be created.

Refer

https://forums.sdn.sap.com/click.jspa?searchID=10903258&messageID=3412558

Regards

Kiran

Read only

Former Member
0 Likes
694

This code works for adding, but changing the INSERT to MODIFY will update the table if the record exists, and insert is if it doesn't.


  IF NOT ittax[] IS INITIAL.
    IF p_load = 'X'.
**      DELETE FROM ztax CLIENT SPECIFIED
**        WHERE mandt = sy-mandt.

      INSERT ztax FROM TABLE ittax.
    ENDIF.
    PERFORM display_data.
  ELSE.
    WRITE: 'No data input.  Nothing was Loaded'.
  ENDIF.

Read only

prasanth_kasturi
Active Contributor
0 Likes
694

hi

insert <dbtab> from table <itab>

insert <dbtab> from <WA>

modify <dbtab> from <wa>

insert <dbtab> from table <itab>

regards

prasanrth

Read only

Former Member
0 Likes
694

create lock entry for the table

call ENQUEUE function module to lock the entry...

and use update table...

e.g. UPDATE zcsv_crws_rec

FROM e_zcsv_crws_rec.

after successfull update DEQUEUE the corresponding entry

Read only

Former Member
0 Likes
694

Hi,

See this Link.

It will be helpful.

[Insert DataBase Table|http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3a6d358411d1829f0000e829fbfe/content.htm]

Regards,

Balakumar.G.

Reward Points if helpful.