2025 Sep 11 4:59 PM - edited 2025 Sep 11 4:59 PM
Hi RAP'lers,
the RAP Behaviour Implementation methods get_global_features, get_global_authorizations, get_instance_features, get_instance_authorizations have a changing parameter reported.
Is it really needed to fill this parameter? What is expected in this parameters? Where/when are they shown to the user in a Fiori Elements App?
If they should get filled, what would be the best approach?
The implementation eg in bp_demo_unmanaged_root_draft does not seem to be a sensible approach to me.
Thanks for some hints here,
Wolfgang
Request clarification before answering.
If the Travel is open → Delete button is active.
If the Travel is cancelled → Delete button is greyed out, Update button also greyed out.
No messages are shown — just proper enablement/disablement.
CLASS zbp_travel DEFINITION PUBLIC FINAL CREATE PROTECTED.
PUBLIC SECTION.
INTERFACES if_abap_behv_impl.
ENDCLASS.
CLASS zbp_travel IMPLEMENTATION.
METHOD get_instance_features.
LOOP AT keys ASSIGNING FIELD-SYMBOL(<ls_key>).
" Read status of the current Travel instance
SELECT SINGLE status
FROM ztravel
WHERE travel_id = @<ls_key>-travel_id
INTO @DATA(lv_status).
" Prepare feature result
APPEND VALUE #(
%tky = <ls_key>-%tky
%features-%delete =
COND #( WHEN lv_status = 'O' THEN if_abap_behv=>fc-o-enabled
ELSE if_abap_behv=>fc-o-disabled )
%features-%update =
COND #( WHEN lv_status = 'C' THEN if_abap_behv=>fc-o-disabled
ELSE if_abap_behv=>fc-o-enabled )
) TO result.
ENDLOOP.
" No need to fill reported here!
ENDMETHOD.
ENDCLASS.
We still have the Travel entity.
We want to control authorizations:
A user with role TRAVEL_ADMIN → full access (update + delete).
A user with role TRAVEL_VIEWER → read-only, no update or delete.
CLASS zbp_travel DEFINITION PUBLIC FINAL CREATE PROTECTED.
PUBLIC SECTION.
INTERFACES if_abap_behv_impl.
ENDCLASS.
CLASS zbp_travel IMPLEMENTATION.
METHOD get_instance_authorizations.
LOOP AT keys ASSIGNING FIELD-SYMBOL(<ls_key>).
" Check current user authorization (simplified example)
DATA(lv_is_admin) = cl_auth_check=>is_user_in_role( iv_role = 'TRAVEL_ADMIN' ).
DATA(lv_is_viewer) = cl_auth_check=>is_user_in_role( iv_role = 'TRAVEL_VIEWER' ).
" Prepare authorization result
APPEND VALUE #(
%tky = <ls_key>-%tky
%auth-%update =
COND #( WHEN lv_is_admin = abap_true THEN if_abap_behv=>auth-allowed
ELSE if_abap_behv=>auth-unauthorized )
%auth-%delete =
COND #( WHEN lv_is_admin = abap_true THEN if_abap_behv=>auth-allowed
ELSE if_abap_behv=>auth-unauthorized )
) TO result.
ENDLOOP.
" Again: leave reported empty
ENDMETHOD.
ENDCLASS.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 8 | |
| 7 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.