cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

RAP Action update Entity even on fail

AbapForEver
Discoverer
0 Kudos
799

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.

 

 

Accepted Solutions (0)

Answers (1)

Answers (1)

MioYasutake
SAP Champion
SAP Champion
0 Kudos

@AbapForEver 
How about commenting out the following line?

APPEND CORRESPONDING #( <reg> ) TO failed-zentity.
AbapForEver
Discoverer
0 Kudos

dont work, If has  Warning or Error message the RAP Framework do the rollback.... I see the source code...