on 2024 Jul 18 10:42 AM
Hi experts,
I want to hide parameters with conditions.
You can see the attachment image below :
Example: hide parameter element Company (P_Company) when ReportID equals 'API1' or 'TB'.
Please help me. Thanks and best Regards
Daroi
Hi @Phuhs,
It is possible to hide parameters with conditions. For instance, if we take an action with two parameters, we can hide one of them for Type='API1'.
Add boolean field "Param1IsHidden" to abstract entity. This field will be used to hide a parameter "Param1" using the annotation "@UI.hidden: #(Param1IsHidden)".
@EndUserText.label: 'Abstract Entity for Parameters'
define abstract entity ZMHL_A_Parameter
{
@UI.hidden: #(Param1IsHidden)
Param1 : abap.char(10);
@UI.hidden: true
Param1IsHidden : abap_boolean;
Param2 : abap.char(10);
}
Then go to behavior definition and define function "GetDefaultsForAction" for the action to get value for boolean field "Param1IsHidden". The name of this function should star with "GetDefaultsFor...." and it will be called before the popup is shown to get default values for parameters.
action Action parameter ZMHL_A_Parameter result [1] $self
{ default function GetDefaultsForAction; }
Implement the corresponding method "getdefaultsforaction" in the class. There you can select all necessary data by keys and then give true or false value to field "Param1IsHidden" to hide or show corresponding parameter "Param1" in popup.
METHOD getdefaultsforaction.
READ ENTITY IN LOCAL MODE zmhl_i_header
FIELDS ( type ) WITH CORRESPONDING #( keys )
RESULT DATA(lt_result).
result = CORRESPONDING #( keys ).
LOOP AT result ASSIGNING FIELD-SYMBOL(<fs_result>).
<fs_result>-%param-param1ishidden = COND #( WHEN lt_result[ %tky = <fs_result>-%tky ]-type = 'API1'
THEN abap_true
ELSE abap_false ).
ENDLOOP.
ENDMETHOD.
Don't forget to add the function "GetDefaultsForAction" to projection behavior definition.
use action action;
use function GetDefaultsForAction;
Best Regards,
Maryia
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
66 | |
10 | |
8 | |
7 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.