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

Internal commit

Former Member
0 Likes
1,279

Hi,

Is there a way to commit a single database operation, outside the main transaction?

I want to perform a commit inside of a function module without confirm the caller program's luw

I tried to use STARTING NEW TASK, it works, but there is a session limit per user

My function module saves a access log in a Z transparent table.

This log must be always generated (even if a rollback was performed outside this FM) and can´t change the caller program flow

Thanks

Darley.

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
1,147

There was an article in the SAP Professional Journal on this very question. It recommends using Secondary Database Connections. If you start reading the ABAP help on "COMMIT CONNECTION", you'll find the information you need quite quickly. Or buy the magazine of course.

Note, however, that these are marked by SAP as "for internal use only", so they're used at own risk!

As an alternative, write a file to the appserver.

matt

8 REPLIES 8
Read only

Former Member
0 Likes
1,147

Its the sure-shot solution:

1)Make the FM RFC enabled.

2)Make all the parameters global.

3)Call the tRFC in BACKGROUND TASK.

http://abap-explorer.blogspot.com/

Read only

0 Likes
1,147

Hi Sourav.

The addition IN BACKGROUND TASK for the call function does not execute the FM. It register to be executed when the COMMIT WORK statement is executed.

If there is no commit in the caller program, my log will not be generated

Thanks.

Darley

Read only

matt
Active Contributor
0 Likes
1,148

There was an article in the SAP Professional Journal on this very question. It recommends using Secondary Database Connections. If you start reading the ABAP help on "COMMIT CONNECTION", you'll find the information you need quite quickly. Or buy the magazine of course.

Note, however, that these are marked by SAP as "for internal use only", so they're used at own risk!

As an alternative, write a file to the appserver.

matt

Read only

Former Member
0 Likes
1,147

I made a test using COMMIT CONNECTION con.

If con has the same value of de default connection, this commit complete the current LUW, exactly as the commit work statement

Read only

matt
Active Contributor
0 Likes
1,147

>

> I made a test using COMMIT CONNECTION con.

>

> If con has the same value of de default connection, this commit complete the current LUW, exactly as the commit work statement

That's why you need a second connection. But you can make the second connection to the same database as the first. Then the commits are independent.

DATA: connection_2 TYPE dbcon-con_name.

connection_2 = 'R/3*CONN2'. " The R/3* prefix says that it's a second connection to the db server
...
INSERT INTO zlogtab CONNECTION (connection_2) VALUES some_values.

COMMIT CONNECTION (connection_2).

Edited by: Matthew Billingham on Aug 14, 2008 9:27 AM

Added solution

Read only

Former Member
0 Likes
1,147

Thank you Matt.

"R/3*" Works fine.

Darley.

Read only

Former Member
0 Likes
1,147

Hi,

You can do the the update part alone another program ..

how does Submit and return work out?.. may be you can try

that and let me know the results..

Thanks

Krishnan

Read only

0 Likes
1,147

SUBMIT AND RETURN executes the program in the same session.

So, the commit affects both programs (same LUW)