admin管理员组

文章数量:1406052

I have an action in an ABAP RAP application that creates an accounting document. However, when an error occurs and I set a message in the 'reported' field, the entity's status cannot be updated with the error due to a rollback.

How can I handle an error within the action and still update the entity's data?

Example:

method action1.
... "Call BAPI
if success = abap_true.
...
else.
        APPEND CORRESPONDING #( <reg> ) TO failed-zentity.
        LOOP AT lt_return INTO DATA(ls_return) where type = 'E'.
          APPEND VALUE #( %msg = new_message( id       = ls_return-id
                                              number   = ls_return-number
                                              severity = if_abap_behv_message=>severity-error
                                              v1       = ls_return-message_v1
                                              v2       = ls_return-message_v2
                                              v3       = ls_return-message_v3
                                              v4       = ls_return-message_v4 )
                          %key = <reg>-%key )
                 TO reported-zentity.
     endloop.
endif.
....
    MODIFY ENTITIES OF zentitytp IN LOCAL MODE
           ENTITY zentity
           UPDATE FROM VALUE #( FOR reg IN regs
                                ( %tky                = reg-%tky
                                  belnr               = reg-belnr
                                  status              = reg-status
                                  %control-belnr     = if_abap_behv=>mk-on
                                  %control-status     = if_abap_behv=>mk-on ) ).
endmethod.

本文标签: abapRAP Action update Entity even on failStack Overflow