From 1e4ce8e33e7519c1a6e016fbf9bc32cd2d955edf Mon Sep 17 00:00:00 2001 From: "b.santos" Date: Mon, 7 Jul 2025 17:34:03 +0000 Subject: [PATCH] Enviar arquivos para "src" --- src/zbp_demo_abap_rap_ro_m.clas.abap | 20 +++ ...bp_demo_abap_rap_ro_m.clas.locals_imp.abap | 124 ++++++++++++++++++ src/zbp_demo_abap_rap_ro_m.clas.xml | 18 +++ 3 files changed, 162 insertions(+) create mode 100644 src/zbp_demo_abap_rap_ro_m.clas.abap create mode 100644 src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap create mode 100644 src/zbp_demo_abap_rap_ro_m.clas.xml diff --git a/src/zbp_demo_abap_rap_ro_m.clas.abap b/src/zbp_demo_abap_rap_ro_m.clas.abap new file mode 100644 index 0000000..8207782 --- /dev/null +++ b/src/zbp_demo_abap_rap_ro_m.clas.abap @@ -0,0 +1,20 @@ +*********************************************************************** +* +* RAP BO provider (i. e. ABAP behavior pool/ABP) +* for a RAP demo scenario +* +* See more information in the CCIMP include (local types tab in ADT). +* +********************************************************************** +"!

Behavior implementation for RAP demo scenario (managed BO)

+"! The class represents a RAP BO provider (i. e. an ABAP behavior pool/ABP) for a RAP demo scenario +"! (managed RAP BO with external numbering). +CLASS zbp_demo_abap_rap_ro_m DEFINITION PUBLIC ABSTRACT FINAL FOR BEHAVIOR OF zdemo_abap_rap_ro_m. + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS ZBP_DEMO_ABAP_RAP_RO_M IMPLEMENTATION. +ENDCLASS. diff --git a/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap b/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap new file mode 100644 index 0000000..0826a5c --- /dev/null +++ b/src/zbp_demo_abap_rap_ro_m.clas.locals_imp.abap @@ -0,0 +1,124 @@ +*********************************************************************** +* +* RAP BO provider (i. e. ABAP behavior pool/ABP) +* for a RAP demo scenario +* +* - RAP scenario: managed RAP BO, external numbering +* - Data model: Consists of a root entity and one child entity. The BDEF +* defines the behavior for these two entities which are connected via +* a CDS composition relation. The definitions in the BDEF determine +* which methods must be implemented in this ABAP behavior pool (ABP). +* +* ----------------------------- NOTE ----------------------------------- +* This simplified example is not a real life scenario and rather +* focuses on the technical side by giving an idea how the communication +* and data exchange between a RAP BO consumer, which is a class +* in this case, and RAP BO provider can work. Additionally, it shows +* how the methods for non-standard RAP BO operations might be +* self-implemented in an ABP. The example is is intentionally kept +* short and simple and focuses on specific RAP aspects. For this reason, +* the example might not fully meet the requirements of the RAP BO contract. +* +* The code presented in this class is intended only to support the ABAP +* cheat sheets. It is not intended for direct use in a production system +* environment. The code examples in the ABAP cheat sheets are primarily +* intended to provide a better explanation and visualization of the +* syntax and semantics of ABAP statements, not to solve concrete +* programming tasks. For production application programs, you should +* always work out your own solution for each individual case. There is +* no guarantee for the correctness or completeness of the code. +* Furthermore, there is no legal responsibility or liability for any +* errors or their consequences that may occur when using the the example +* code. +* +*********************************************************************** + +CLASS lhc_root DEFINITION INHERITING FROM cl_abap_behavior_handler. + PRIVATE SECTION. + + METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION + IMPORTING REQUEST requested_authorizations FOR root RESULT result. + + METHODS multiply_by_2 FOR MODIFY + IMPORTING keys FOR ACTION root~multiply_by_2. + + METHODS det_add_text FOR DETERMINE ON SAVE + IMPORTING keys FOR root~det_add_text. + + METHODS val FOR VALIDATE ON SAVE + IMPORTING keys FOR root~val. + +ENDCLASS. + +CLASS lhc_root IMPLEMENTATION. + + METHOD get_global_authorizations. + ENDMETHOD. + + METHOD multiply_by_2. + + "Retrieving instances based on requested keys + READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE + ENTITY root + FIELDS ( field3 field4 ) WITH CORRESPONDING #( keys ) + RESULT DATA(result) + FAILED failed. + + "If read result is initial, stop further method execution. + CHECK result IS NOT INITIAL. + + "Multiply integer values by 2 + MODIFY ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE + ENTITY root + UPDATE FIELDS ( field3 field4 ) WITH VALUE #( FOR key IN result ( %tky = key-%tky + field3 = key-field3 * 2 + field4 = key-field4 * 2 ) ). + ENDMETHOD. + + METHOD det_add_text. + + READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE + ENTITY root + FIELDS ( field2 ) WITH CORRESPONDING #( keys ) + RESULT DATA(lt_res). + + "If read result is initial, stop further method execution. + CHECK lt_res IS NOT INITIAL. + + "field2 is changed + MODIFY ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE + ENTITY root + UPDATE FIELDS ( field2 ) + WITH VALUE #( FOR key IN lt_res ( %tky = key-%tky + field2 = |{ key-field2 }_#| ) ). + + ENDMETHOD. + + METHOD val. + + READ ENTITIES OF zdemo_abap_rap_ro_m IN LOCAL MODE + ENTITY root + FIELDS ( field3 ) WITH CORRESPONDING #( keys ) + RESULT DATA(lt_res). + + "If read result is initial, stop further method execution. + CHECK lt_res IS NOT INITIAL. + + LOOP AT lt_res ASSIGNING FIELD-SYMBOL(). + IF -field3 > 1000. + APPEND VALUE #( %tky = -%tky + %fail-cause = if_abap_behv=>cause-disabled + ) + TO failed-root. + + APPEND VALUE #( %tky = -%tky + %msg = new_message_with_text( + severity = if_abap_behv_message=>severity-error + text = 'Validation failed!' ) + ) TO reported-root. + ENDIF. + ENDLOOP. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/zbp_demo_abap_rap_ro_m.clas.xml b/src/zbp_demo_abap_rap_ro_m.clas.xml new file mode 100644 index 0000000..919f460 --- /dev/null +++ b/src/zbp_demo_abap_rap_ro_m.clas.xml @@ -0,0 +1,18 @@ + + + + + + ZBP_DEMO_ABAP_RAP_RO_M + E + Behavior implementation for RAP demo scenario (managed BO) + 06 + 1 + X + X + X + ZDEMO_ABAP_RAP_RO_M + + + +