05-17-2006 7:33 PM
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
05-18-2006 5:39 AM
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.
05-18-2006 5:39 AM
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.
05-18-2006 5:42 AM
05-18-2006 5:55 AM
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
05-18-2006 7:43 AM
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
05-18-2006 9:18 AM
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
11-09-2006 11:18 AM
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