简体   繁体   中英

Autonomous transaction analogue in ABAP

I'm trying to commit DML update in a db table while the main program is still running without committing it as there may be errors in future and there might be need to rollback it but the internal (saved) updetes should stay. Like in the Oracle autonomous transactions.

Call function starting new task or Submit and return don't work as they affect the main transaction.

Is there a way to start a nested DB LUW and commit it without interrupting the main LUW?

I am not aware of a way to do this with OpenSQL. But when you are using the ADBC framework , then each instance of the class CL_SQL_CONNECTION operates within a separate database LUW .

I would generally not recommend using ADBC unless you have to, because:

  • You are now writing SQL statements as strings, which means you don't have compile-time syntax checking.
  • You can't put variables into SQL code anymore. (OK, you can , but you shouldn't , because you are probably creating SQL injection vulnerabilities that way). You need to pass all the variables using statement->set_param .
  • You are now writing NativeSQL, which means that you might inadvertently write SQL which can't be ported to other database backends.

You can create separate function for saving your changes and you can call your function with starting new task mode like below.

  call function 'ZFUNCTION' starting new task 'SAVECHANGES'
   exporting
     param  = value.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM