2025 Apr 08 10:22 AM - edited 2025 Apr 08 10:24 AM
I am attempting to show/hide UI facets using only ABAP CDS annotations with Fiori Element App Preview from eclipse (ADT). Our S/4 HANA on-premise 2023 system components.
In the CDS projection view, I create a virtual element. Any boolean type other than 'abap_boolean' gives a deprecrated warning: 'Data Element xfeld is deprecated. Use Data Element ABAP_BOOLEAN instead', so we use abap_boolean.
@EndUserText.label: 'Hide Section 1'
@UI.hidden: true
virtual hideSection1IsEnabled: abap_boolean,
In the metadata extension, we attempt to reference the virtual element but are given error 'Annotation value "hideSection1IsEnabled" must be of type 'Boolean'.@EndUserText.label: 'Hide Section 1' @ui.hidden: true virtual hideSection1IsEnabled: abap_boolean,
@UI.facet: [
{
parentId: 'Section1',
id: 'SubSection1',
type: #FIELDGROUP_REFERENCE,
label: 'Sub Section 1',
targetQualifier: 'DetailsGroup',
hidden: 'hideSection1IsEnabled'
},__PRESENT
Request clarification before answering.
The annotation for dynamically hiding a header facet is as follows:
{
hidden: #('editActionIsEnabled'),
label: 'Credit Limit Consumption',
id: 'CreditLimitChartHeader',
targetQualifier: 'CreditLimitChart',
targetElement: '_CREDITLIMITDETAILS',
type: #CHART_REFERENCE,
purpose: #HEADER
}https://sapui5.hana.ondemand.com/#/topic/ca00ee45fe344a73998f482cb2e669bb
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I saw that in the documentation but it was unclear how to implement it using ABAP cds annotations. I think that 'editActionIsEnabled' refers to a xml property defined as Edm.Boolean. (https://github.com/SAP/open-ux-tools/blob/a5a6a14936119a90905d73d4dfacbf8672d09e93/packages/odata-se...). I created this post to hopefully get a solution that works as a ABAP CDS annotation. If it requires js or xml based development that will be done in BAS / outside of our ABAP system so be it. Hopefully as RAP and clean core add-ons become more popular more functionality becomes available through ABAP cds annotations.
@ui.facet: [{
parentId: 'Section1',
id: 'SubSection1',
type: #FIELDGROUP_REFERENCE,
label: 'Sub Section 1',
targetQualifier: 'DetailsGroup',
//hidden: 'hideSection1IsEnabled'
}]extend via manifest.json(say a details page):-
"sap.ui.controllerExtensions": {
"sap.suite.ui.generic.template.ObjectPage.view.Details": {
"controllerName": "<controller_name>"
}
}in the actual controller after rendering:-
onAfterRendering: function () {
var oView = this.getView();
var oModel = oView.getModel(); // Assuming you use default model
var oContext = oView.getBindingContext();
// Read the field `hideSection1IsEnabled`
var bHideSection = oModel.getProperty("hideSection1IsEnabled", oContext);
// Get the SmartForm or Section control (adjust ID)
var oSection = oView.byId("SubSection1"); // Use actual section ID
if (oSection) {
oSection.setVisible(!bHideSection); // Hide or show based on logic
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
ADT expects a literal value(true/false), not reference.
To show/hide UI facets dynamically, I think custom logic at UI5 can be done.
Thanks,
Arun
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.