Showing results for 
Search instead for 
Did you mean: 

ABAP RAP MAP_MESSAGES is not triggerred when foreign entity finalize() save sequence fails

0 Kudos

I have create a custom managed RAP BO. In the interaction phase, when the action processInstance is triggered, I create a Purchase Requisition using EML MODIFY statement



"pseudo code
method processInstance "for RAP action

     MODIFY ENTITIES OF i_purchaserequisitiontp
     ENTITY purchaserequisition
                     PurReqnDescription )
     WITH VALUE #(   ( %cid                    = |My%CID_{ counter }|
                       PurchaseRequisitionType = purchaseRequisitionType
                       PurReqnDescription      = purReqnDescription ) )



The action also triggers the save sequence.

In the save phase, the foreign entity I_PurchaseRequisitionTP fails in the finalize() method and returns the error messages in the reported structure.

I want to log these error messages.

So, I declare this foreign entity in my BO behavior base definition (not in the Consumption Behavior Definition)



managed implementation in class zbp_i_pr_mass_upload unique;
strict ( 2 );
  foreign entity I_PurchaseRequisitionTP alias PurchaseRequisition;
  foreign entity I_PurchaseReqnItemTP alias PurchaseRequistionItems;

define behavior for ZI_PR_MASS_UPLOAD alias filestore
with additional save



And in my generate class from managed BO, I have explicitly redefined the MAP_MESSAGES method.



"managed RAP behaviour class implementation
"save sequence
CLASS lsc_zi_pr_mass_upload DEFINITION INHERITING FROM cl_abap_behavior_saver.
    METHODS save_modified REDEFINITION.
    METHODS map_messages REDEFINITION.

CLASS lsc_zi_pr_mass_upload IMPLEMENTATION.
  METHOD map_messages.
    CHECK reported IS NOT INITIAL.
    "logic to log the errors from foreign entity follows



When I do a test run from the UI preview, the map_message method is not triggered (even the breakpoints do not hit)

I am referring to Message Mapping | SAP Help Portal where it mentions that -

...If [map_messages is] implemented, the method is called immediately after every invocation of a saver class that has returned messages in reported. This means that the message mapping occurs before the messages are processed further by the RAP framework...


Can someone guide what am I missing?


@Andre_Fischer - Could you please guide
View Entire Topic
Active Contributor
0 Kudos


Not sure if it is too late for you or not, but here is the un-documented reason for this misbehavior that I was able to figure out by debugging the logic in standard classes.

The foreign entity you have used is I_PurchaseRequisitionTP. This is only a interface of R_PurchaseRequisitionTP. The real work happens in R_PurchaseRequisitionTP and hence the real foreign entity which will throw messages back to your calling program is R_PurchaseRequisitionTP. So, in your definition you have to use foreign entity name as R_PurchaseRequisitionTP.

Now, R_PurchaseRequisitionTP is not Released for Cloud development. Which means (assuming you are using Cloud version of ABAP), if you try to mention R_PurchaseRequisitionTP as the foreign entity, SAP won't permit that.

Thus, although, this seems like a real neat feature that SAP has provided, it is unusable on standard BOs, due to the fact that underlying implementations like R_PurchaseRequisitionTP will not be released by SAP.