‎2007 Sep 04 2:59 AM
‎2007 Sep 04 3:36 AM
Hello Srinivas
BAPIs <b>must not</b> have exceptions because they are primarily intended for remote-access (RFC) to SAP business objects. If a BAPI would raise an exception the RFC connection will break down.
Therefore all BAPIs collect the messages and return them usually in a TABLES parameter RETURN (of structure BAPIRET2).
In order to evaluate the succesful calling of a BAPI add the following coding:
" call BAPI ... ==> return messages in TABLES parameter RETURN
" Returned messages are stored in itab lt_return
LOOP AT lt_return TRANSPORTING NO FIELDS
WHERE ( type CA 'AEX' ). " abort, error, dump
EXIT.
ENDLOOP.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
DESTINATION '<rfc destination>'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
DESTINATION '<rfc destination>'.
ENDIF.Please note that some BAPI do not return any messages at all in case of success.
Finally, in order to retrieve RFC failures add the following standard exceptions to the BAPI call, e.g.:
CALL FUNCTION 'BAPI_USER_CREATE1'
DESTINATION '<rfc destination>'
...
EXCEPTIONS
system_failure = 1 MESSAGE ld_rfc_msg
communication_failure = 2 MESSAGE ld_rfc_msg.Regards
Uwe
‎2007 Sep 04 3:36 AM
Hello Srinivas
BAPIs <b>must not</b> have exceptions because they are primarily intended for remote-access (RFC) to SAP business objects. If a BAPI would raise an exception the RFC connection will break down.
Therefore all BAPIs collect the messages and return them usually in a TABLES parameter RETURN (of structure BAPIRET2).
In order to evaluate the succesful calling of a BAPI add the following coding:
" call BAPI ... ==> return messages in TABLES parameter RETURN
" Returned messages are stored in itab lt_return
LOOP AT lt_return TRANSPORTING NO FIELDS
WHERE ( type CA 'AEX' ). " abort, error, dump
EXIT.
ENDLOOP.
IF ( syst-subrc = 0 ).
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
DESTINATION '<rfc destination>'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
DESTINATION '<rfc destination>'.
ENDIF.Please note that some BAPI do not return any messages at all in case of success.
Finally, in order to retrieve RFC failures add the following standard exceptions to the BAPI call, e.g.:
CALL FUNCTION 'BAPI_USER_CREATE1'
DESTINATION '<rfc destination>'
...
EXCEPTIONS
system_failure = 1 MESSAGE ld_rfc_msg
communication_failure = 2 MESSAGE ld_rfc_msg.Regards
Uwe