Skip to Content
0
Jan 09 at 09:38 PM

RAP managed BO with unmanaged save: parameter "failed" is unknown

138 Views

I have implemented managed BO with unmanaged save in BTP ABAP trial environment.

Behavior definition

managed implementation in class zbp_person_m unique;
strict;
with draft;

define behavior for ZI_PERSON_M alias Person
with unmanaged save

Behavior implementation

CLASS lsc_zi_person_m DEFINITION INHERITING FROM cl_abap_behavior_saver.

  PROTECTED SECTION.

    METHODS save_modified REDEFINITION.

ENDCLASS.

CLASS lsc_zi_person_m IMPLEMENTATION.

  METHOD save_modified.
    ...
  ENDMETHOD.

ENDCLASS.

For unmanaged save, existence of data saving logic is expected (such as function modules or classes). My doubt is, how to handle errors in saver class when the existing logic raises an exception.

CL_ABAP_BEHAVIOR_SAVER~SAVE_MODIFIED has changing parameters reported and failed, so at the first glance we should be good if we set these parameters in case of an error.

  methods SAVE_MODIFIED
    importing
      !CREATE type DATA
      !UPDATE type DATA
      !DELETE type DATA
    changing
      !REPORTED type DATA optional
      !FAILED type DATA optional .

However, if I try to set "failed" parameter, the compiler says "Field FAILED-PERSON is unknown".

failed-does-not-exist.png

I have implemented save_modified as follows to see what happens if I just set "reported".

  METHOD save_modified.
    IF update-person IS NOT INITIAL.
*        "Set failed keys
*        APPEND VALUE #( %is_draft = if_abap_behv=>mk-off
*                        personuuid = update-person[ 1 ]-PersonUUID )
*               TO failed-person.

      "Set message
      APPEND VALUE #( %key = update-person[ 1 ]-%key
                      %is_draft = if_abap_behv=>mk-off
                      personuuid = update-person[ 1 ]-PersonUUID
                      %element-FirstName = if_abap_behv=>mk-on
                      %msg = new_message(
                               id       = 'ZRAP_MSG_YASU2122_2'
                               number   = 002
                               severity = if_abap_behv_message=>severity-error
                             ) )
             TO reported-person.

      RETURN.
    ENDIF.

As a result, the screen pops up error message, but at the same time, "Object saved" message is emitted. So obviously we need "failed" parameter as well.

saved-message.png

Why "failed" parameter is unknown in the save_modified method although the super class has the same parameter?

Attachments

saved-message.png (41.0 kB)