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: 

PERFORM ... ON ROLLBACK

Former Member
0 Kudos

Hi all,

i have some code in an user exit at the end of TO creation. I also write there some Application Log Messages. But when i throw an A Message in this user exit the Applog is empty after the transaction because the A Mesages causes an rollback. I had the idea to solve this with an perform on commit routine but this form routine is never been executed. Has anyone an idea what i have done wrong with this statement?

Thanks in advance

Steffen

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi !

If i remind correctly then the PERFORM ... ON ROLLBACK is not executed by any implicid ROLLBACK but only by an explicid ROLLBACK WORK command.

What you can try is the following code:

ROLLBACK WORK,

MESSAGE A.....

Means - do an explicid rollback befor your A or E Message.

That may help.

Regqards

Rainer

Some points would be fine if that helped a bit.

6 REPLIES 6

Former Member
0 Kudos

Hi !

If i remind correctly then the PERFORM ... ON ROLLBACK is not executed by any implicid ROLLBACK but only by an explicid ROLLBACK WORK command.

What you can try is the following code:

ROLLBACK WORK,

MESSAGE A.....

Means - do an explicid rollback befor your A or E Message.

That may help.

Regqards

Rainer

Some points would be fine if that helped a bit.

hymavathi_oruganti
Active Contributor
0 Kudos

messages type A and X automatically perform roll back

0 Kudos

Hi !

I've just checked it...

PERFORM on COMMIT is not regularly done by a A or X Type message... It's only beeing executed if the massage is "catched" - see help text as follows...

If you catch a type A message (MESSAGE) using the EXCEPTIONS..ERROR_MESSAGE addition in the CALL FUNCTION statement, a ROLLBACK WORK occurs, in which the subroutines registered using PERFORM ... ON ROLLBACK are executed.

Regards

Rainer

0 Kudos

Hi Rainer,

the bad thing is, that this user exit runs in an update task/background booking mode, so that i can't explicit use the rollback work statement, i tried this and the program dumps.

the next bad thing is, that this user exit runs in a standard SAP transaction ( LT03 ) so i can't catch the messages with the exception ERROR_MESSAGE.

Regards

Steffen

Message was edited by: Steffen Engert

0 Kudos

I solved the problem in another way:

i write all my Application Log Messages with a function module that i call with fuction destination 'NONE'

so all the Application Log Handling is in a seperate program context.

after the A-Messages is thrown in the user exit and the rollback is performed, the Application Log is on the database anyway.

here a short sample:

create Applog ( in an own RFC able function module as wrapper for BAL_LOG_CREATE 😞

CALL FUNCTION 'Z_BAL_LOG_CREATE' destination 'NONE'

EXPORTING

i_s_log = s_log_hdr

IMPORTING

E_LOG_HANDLE = log_handle

EXCEPTIONS

MISSING_LOG_HEADER = 1

LOG_HEADER_INCONSISTENT = 2

ERROR = 3

OTHERS = 4.

Add Message to Applog ( in an own RFC able function module as wrapper for BAL_LOG_MSG_ADD 😞

CALL FUNCTION 'Z_BAL_MSG_ADD' destination 'NONE'

EXPORTING

i_log_handle = log_handle

i_s_msg = s_bal_msg

EXCEPTIONS

MISSING_LOG_HANDLE = 1

MISSING_LOG_MESSAGE = 2

LOG_NOT_FOUND = 3

MSG_INCONSISTENT = 4

LOG_IS_FULL = 5

ERROR = 6

OTHERS = 7.

save Applog to database( in an own RFC able function module as wrapper for BAL_DB_SAVE 😞

CALL FUNCTION 'Z_BAL_DB_SAVE_SINGLE' destination 'NONE'

EXPORTING

i_log_handle = log_handle

EXCEPTIONS

MISSING_LOG_HANDLE = 1

LOG_NOT_FOUND = 2

SAVE_NOT_ALLOWED = 3

NUMBERING_ERROR = 4

ERROR = 5

OTHERS = 6.

throw A-MESSAGE:

message axxx(yyy).

the transaction performs a rollback but the applog is written to database anyway.

regards steffen

Message was edited by: Steffen Engert

0 Kudos

I'm suppose your solution does not work or some comments are missing. Where is the commit called for BAL_DB_SAVE? If you call it in 'Z_BAL_DB_SAVE_SINGLE', commit concerns all database interactions, so rollback will set nothing back.

regards,

Adam