SAP ABAP中的OData枚举类型

问题描述 投票:0回答:1

oData V4支持枚举类型。我需要有关如何在经典ABAP编程的odata模型的模型类中定义枚举类型的建议吗?谢谢。

具有枚举类型的元数据示例:

edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
<edmx:DataServices>
<Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="com.sap.icd.odata4.example">
<EnumType Name="XXXX" IsFlags="false" UnderlyingType="Edm.Int32">
<Member Name="WEEKLY" Value="0"/>
<Member Name="BIWEEKLY" Value="1"/>
<Member Name="SEMI_MONTHLY" Value="2"/>
<Member Name="MONTHLY" Value="3"/>
</EnumType>
<EntityType Name="Create">
<Key>
<PropertyRef Name="id"/>
</Key>
<Property Name="id" Type="Edm.String"/>
<Property Name="Country" Type="Edm.String"/>
<Property Name="Town" Type="com.sap.icd.odata4.example.XXXX"/>
<Property Name="startDay" Type="Edm.String"/>
<Property Name="description" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="container">
<EntitySet Name="ViewSet" EntityType="com.sap.icd.odata4.example.View"/>
<EntitySet Name="EventSet" EntityType="com.sap.icd.odata4.example.AreaEvent"/>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>  ```
enums odata sap abap odata-v4
1个回答
0
投票

枚举在ABAP since 7.51中可用,并且可以用关键字BEGIN OF ENUM定义:

TYPES:
  BEGIN OF ENUM occurrence,
    WEEKLY,
    BIWEEKLY,
    SEMI_MONTHLY,
    MONTHLY,
  END OF ENUM occurrence.

DATA periodicity type occurrence.

periodicity = weekly.

cl_demo_output=>display( periodicity ).
© www.soinside.com 2019 - 2024. All rights reserved.