Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP CDS annotation for OData boolean ?

Attila
Active Participant
0 Likes
19,619

Dear Gurus,

I would like to let SADL generate the OData service from my CDS View, and I need Edm.Boolean in the service metadata for the property/field, instead of Edm.String for the value 'X'.

Is there annotation for this purpose ?

Thank you

Attila

Dear Gurus,

I would like to let SADL generate the OData service from my CDS View, and I need Edm.Boolean in the service metadata for the property/field, instead of Edm.String for the value 'X'.

Is there annotation for this purpose ?

Thank you

Attila

8 REPLIES 8
Read only

sdebeaulieu
Participant
11,639

Hello,

https://help.sap.com/saphelp_gateway20sp12/helpdata/en/8d/89e454c2656574e10000000a44538d/content.htm

Edm.Boolean : "If the number of characters is 1 and the domain contains the strings BOOL or FLAG If the domain is one of the following: BOOLE, XFELD, XFLAG, FLAG, X, DDFLAG, CHAR1_X"

Best Regards,

Sev

Read only

Attila
Active Participant
11,639

Hello Sev,

thank You for your answer. The above is working when I have an SEGW project and my entity is based on a DDIC structure, or I manually set the Data element in the entity property. Unfortunately, this is not working in my CDS Consumption view, when I add virtual property ESSGranted:

      case ESSRole.agr_name
      when 'Z_CA_BCR_WORKSPACE_ESS' then cast ( 'X' as BOOLE_D )
      else cast ( '' as BOOLE_D ) end                 as ESSGranted

It seems SADL is not considering such.

Best regards

Attila

Read only

smarchesini
SAP Champion
SAP Champion
0 Likes
11,639

Same issue Attila

Sebastiano

Read only

jrodriguezferna
Participant
11,639

can you test that?

      cast (
           case ESSRole.agr_name
                when 'Z_CA_BCR_WORKSPACE_ESS' then 'X'
                else '' 
           end  as BOOLE_D ) as ESSGranted
Read only

0 Likes
11,639

Working!
Thanks you so much

Read only

jan_nyfeler2
Explorer
11,639

If you want to have a Edm.Boolean field from the CDS view within the SEGW project (when the CDS entity is referenzed as datasource) I think you have to change the datatype with de Model Provider Class Extension-Class (DEFINE-Method):

DATA(lo_type) = model->get_entity_type( iv_entity_name = 'YOUR_TYPE' ).
DATA(lo_prop) = lo_type->get_property(
EXPORTING
iv_property_name= 'YOUR_PROPERTY'
).
lo_prop->set_type_edm_boolean( ).
Read only

igor_muntoreanu
Participant
8,354

Make Sure that the Data Element is created as FLAG or BOOLE_D. And do the following on your CDS or Metadata Extension:
@Consumption.filter: { selectionType: #SINGLE, multipleSelections: false }
Preflg;

igor_muntoreanu_0-1732051008325.png

 

Read only

0 Likes
7,314

Brilliant! This works well! 

Empty selection filters for both "yess/no". 

Great solution.