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

updating database table

Former Member
0 Likes
2,034

Hi,

Can we update the database table directly using UPDATE statementor is there any function module to update the database table?

11 REPLIES 11
Read only

Former Member
0 Likes
1,407

UPDATE statement will work in your case.

Also add the statement COMMIT WORK after it to confirm the database update.

Read only

Former Member
0 Likes
1,407

Hi,

You can directly use the update statement to the table.

ex:


UPDATE  dbtab      FROM wa.

Thanks,

Sriram Ponna.

Edited by: Sriram Ponna on Feb 4, 2008 5:05 PM

Read only

0 Likes
1,407

you can update dbtab directly by using update..this is syntax

· UPDATE dbtab FROM wa. or

UPDATE (dbtabname) FROM wa.

· UPDATE dbtab FROM TABLE itab. or

UPDATE (dbtabname) FROM TABLE itab.

plz reward if useful

keep rockin

vivek

Read only

Former Member
0 Likes
1,407

Hi,

update spfli from wa_spfli.

plzz reward points i f it helps.

Read only

Former Member
0 Likes
1,407

UPDATE dbtab SET s1 ... sn.

UPDATE dbtab. or

UPDATE *dbtab. or

UPDATE (dbtabname) ... .

UPDATE dbtab FROM TABLE itab. or

UPDATE (dbtabname) FROM TABLE itab.

Updates values in a database table (see Relational database ). You can specify the name of the database table either directly in the form dbtab or at runtime as contents of the field dbtabname . In both cases, the table must be known to the ABAP/4 Dictionary . If you specify the name of the database table directly, the program must also contain an appropriate TABLES statement. Normally, lines are updated only in the current client. Data can only be updated using a view if the view refers to a single table and was created in the ABAP/4 Dictionary with the maintenance status "No restriction".

Reward if helpful,

Trinath

Read only

0 Likes
1,407

Hi,

When do we use a function module or bdc to update the database table

Read only

0 Likes
1,407

Hi,

BDC is used for mass data upload and Functionl Modules or BAPI are used to update the transaction data or any other data.

Thanks,

Sriram Ponna.

Read only

0 Likes
1,407

hi,

Why do we use this " In Update Task " ??

The main update technique for bundling database changes in a single database LUW is to use CALL FUNCTION... IN UPDATE TASK.

How do we Use ??

A typical R/3 installation contains dialog work processes and at least one update work process. The update work processes are responsible for updating the database. When an ABAP program reaches a COMMIT WORK statement, any function modules from CALL FUNCTION... IN UPDATE TASK statements are released for processing in an update work process. The dialog process does not wait for the update to finish. This kind of update is called asynchronous update.

What is the Use... ??

Asynchronous update is useful when response time from the transaction is critical, and the database updates themselves are so complex that they justify the extra system load

Real time scenario.

Suppose a user wants to change an entry in a database table, or add a new one. He or she enters the necessary data, and then starts the update process by choosing Save. This starts the following procedure in the ABAP program:

Firstly, the program locks the database entry against other users, using the enqueue work process (or the message server in the case of a distributed system). This generates an entry in the lock table. The user is informed whether the update was successful, or whether the lock could not be set because of other users.

If the lock is set, the program reads the entry that is to be changed and modifies it. If the user has created a new entry, the program checks whether a record with the same key values already exists.

In the current dialog work process, the program calls a function module using CALL FUNCTION... IN UPDATE TASK, and this writes the change details as an entry in table VBLOG.

When the program is finished (maybe after further dialog steps), a COMMIT WORK statement starts the final part of the SAP LUW. The work process that is processing the current dialog step starts an update work process.

Based on the information passed to it from the dialog work process, the update work process reads the log entries belonging to the SAP LUW from table VBLOG.

The update work process passes this data to the database for updating, and analyzes the return message from the database. If the update was successful, the update work process triggers a database commit after the last database change and deletes the log entries from table VBLOG.

If an error occurred, the update work process triggers a database rollback, leaves the log entries in table VBLOG, flags them as containing errors, and sends a SAPoffice message to the user, who should then inform the system administrator.

The corresponding entries in the lock table are reset by the update work process.

Creating Update Function Modules

To create a function module, you first need to start the Function Builder. Choose Tools ® ABAP Workbench, Function Builder. For more information about creating function modules, refer to the ABAP Workbench Tools documentation.

To be able to call a function module in an update work process, you must flag it in the Function Builder. When you create the function module, set the Process Type attribute to one of the following values:

Update with immediate start

Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions can be restarted by the update task in case of errors.

Update w. imm. start, no restart

Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions may not be restarted by the update task.

Update with delayed start

Set this option for low priority ("V2") functions that run in their own update transactions. These functions can be restarted by the update task in case of errors.

To display the attributes screen in the Function Builder, choose Goto ® Administration.

Defining the Interface

Function modules that run in the update task have a limited interface:

Result parameters or exceptions are not allowed since update-task function modules cannot report on their results.

You must specify input parameters and tables with reference fields or reference structures defined in the ABAP Dictionary.

We use BDC when we want to do a mass update of data (millions of records, without maunal intervention.)

Hope this is helpful, Do reward.

Read only

Former Member
0 Likes
1,407

Of course, we can upadte the standard table using the UPDATE statement from a WORK AREA.

But it is strongly recommended that we should not update the standard tables directly.

If u do so, only onle table will be updated, all other related tables won't get updated. It leads to database inconsistancy.

So, u have to use Transaction (BDC) or FM (BAPI) to update the standard tables.

Do not update by writing a UPDATE query.

Pl reward if useful

Narendra

Read only

0 Likes
1,407

Hi,

Can we use the update statement like this to update the database table mvke?

UPDATE mvke SET vmsta = gs_output1-vmsta.

Read only

0 Likes
1,407

Because of data integrity issues, it's not a good idea to do direct updates to standard SAP tables.

Rob