field ( features : instance ) MandFieldInstfeat;
field ( mandatory ) MandFieldBdef;
Header object page | Item object page |
"1" is entered on header level | --> the field MandFieldInstfeat is read-only. |
"2" is entered on header level | --> the field MandFieldInstfeat is mandatory. |
METHOD get_instance_features.
" get the root node(s). In a Fiori Elements UI this
" will be just one entry. But when being called via EML or
" as an API several instances of HeaderMand can be requested
READ ENTITIES OF ZI_HEADERMand IN LOCAL MODE
ENTITY iTEMmAND BY \_HeaderMand
ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT DATA(HeaderMands).
" Read all associated child nodes and set the field MandFieldInstfeat
" to either read-only or mandatory based on the value of the field Mynumber
" in the root node
LOOP AT HeaderMands INTO DATA(HeaderMand).
READ ENTITIES OF ZI_HEADERMand IN LOCAL MODE
ENTITY HeaderMand BY \_ItemMand
ALL FIELDS
WITH VALUE #( ( %tky = HeaderMand-%tky ) )
RESULT DATA(ItemMands).
result = VALUE #( FOR ItemMand IN ItemMands
( %tky = ItemMand-%tky
%field-MandFieldInstfeat = COND #( WHEN HeaderMand-Mynumber = 2
THEN if_abap_behv=>fc-f-mandatory
ELSE if_abap_behv=>fc-f-read_only )
) ).
ENDLOOP.
ENDMETHOD.
field ( features : instance ) MandFieldInstfeat;
field ( mandatory ) MandFieldBdef;
METHOD mandatory_fields_check.
DATA permission_request TYPE STRUCTURE FOR PERMISSIONS REQUEST ZI_ITEMMand.
DATA reported_zi_itemmand_li LIKE LINE OF reported-itemmand.
DATA(description_permission_request) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_data_ref( REF #( permission_request-%field ) ) ).
DATA(components_permission_request) = description_permission_request->get_components( ).
LOOP AT components_permission_request INTO DATA(component_permission_request).
permission_request-%field-(component_permission_request-name) = if_abap_behv=>mk-on.
ENDLOOP.
" Get current field values
READ ENTITIES OF ZI_HeaderMand IN LOCAL MODE
ENTITY ItemMand
ALL FIELDS
WITH CORRESPONDING #( keys )
RESULT DATA(entities).
LOOP AT entities INTO DATA(entity).
GET PERMISSIONS ONLY INSTANCE FEATURES ENTITY ZI_ItemMand
FROM VALUE #( ( itemuuid = entity-ItemUUID ) )
REQUEST permission_request
RESULT DATA(permission_result)
FAILED DATA(failed_permission_result)
REPORTED DATA(reported_permission_result).
LOOP AT components_permission_request INTO component_permission_request.
"permission result for instances (field ( features : instance ) MandFieldInstfeat;) is stored in an internal table.
"So we have to retrieve the information for the current entity
"whereas the global information (field ( mandatory ) MandFieldBdef;) is stored in a structure
IF ( permission_result-instances[ itemuuid = entity-ItemUUID ]-%field-(component_permission_request-name) = if_abap_behv=>fc-f-mandatory OR
permission_result-global-%field-(component_permission_request-name) = if_abap_behv=>fc-f-mandatory ) AND
entity-(component_permission_request-name) IS INITIAL.
APPEND VALUE #( %tky = entity-%tky ) TO failed-itemmand.
"since %element-(component_permission_request-name) = if_abap_behv=>mk-on could not be added using a VALUE statement
"add the value via assigning value to the field of a structure
CLEAR reported_zi_itemmand_li.
reported_zi_itemmand_li-%tky = entity-%tky.
reported_zi_itemmand_li-%element-(component_permission_request-name) = if_abap_behv=>mk-on.
reported_zi_itemmand_li-%msg = new_message( id = '/DMO/CM_RAP_GEN_MSG'
number = 066
severity = if_abap_behv_message=>severity-error
v1 = |{ component_permission_request-name }|
v2 = | with semantic key: { entity-SemanticKey } | ).
APPEND reported_zi_itemmand_li TO reported-itemmand.
ENDIF.
ENDLOOP.
ENDLOOP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
34 | |
13 | |
11 | |
11 | |
10 | |
9 | |
9 | |
9 | |
8 | |
7 |