CRITICAL
Rule Definition
BAPIs must not cause program terminations, they can only return a message (type A: termination message) in the return parameter. Messages of type E (error) and A (termination) cannot be output in the program, otherwise the BAPI will not be processed correctly and control may not be given back to the calling program.
Remediation
You must create a parameter named Return for every BAPI. This parameter returns exception messages or success messages to the calling program.
Violation Code Sample
FUNCTION BAPI_PO_GETDETAIL.
...
SELECT SINGLE * FROM EKKO WHERE EBELN EQ PURCHASEORDER.
IF SY-SUBRC NE 0.
RAISE INCORRECT_PURCHASEORDER.
ENDIF.
...
ENDFUNCTION.
Fixed Code Sample
FUNCTION BAPI_PO_GETDETAIL.
...
SELECT SINGLE * FROM EKKO WHERE EBELN EQ PURCHASEORDER.
IF SY-SUBRC NE 0.
PERFORM FILL_BAPIRETURN TABLES RETURN
USING 'E'
'W5'
'107'
PURCHASEORDER.
EXIT.
ENDIF.
...
ENDFUNCTION.
Reference
http://help.sap.com/saphelp_utilities472/helpdata/en/a5/3ec9b64ac011d1894e0000e829fbbd/content.htm
Related Technologies
Technical Criterion
Programming Practices - Unexpected Behavior
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.