Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Last active October 5, 2025 01:20
Show Gist options
  • Save IhwanID/5b78b64c2015b2482eb8647540d0a638 to your computer and use it in GitHub Desktop.
Save IhwanID/5b78b64c2015b2482eb8647540d0a638 to your computer and use it in GitHub Desktop.
Create CDS View and Expose it as OData Service
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Sales Order Data Model (Ihwan)'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
@OData.publish : true
define view entity Z100_SalesOrder_Ihwan as select from vbak
association [1..1] to I_SalesOrganization as _salesOrg on $projection.SalesOrganization = _salesOrg.SalesOrganization
association [1..1] to I_DistributionChannel as _distChannel on $projection.DistributionChannel = _distChannel.DistributionChannel
association [1..1] to I_Division as _division on $projection.Division = _division.Division
{
key vbeln as SalesOrderNo,
@ObjectModel.foreignKey.association: '_salesOrg'
vkorg as SalesOrganization,
@ObjectModel.foreignKey.association: '_distChannel'
vtweg as DistributionChannel,
@ObjectModel.foreignKey.association: '_division'
spart as Division,
audat as SalesOrderDate,
erdat as SalesOrderCreateDate,
ernam as SalesOrderCreator,
auart as SalesOrderType,
@Semantics.amount.currencyCode: 'Currency'
netwr as NetPrice,
waerk as Currency,
/*Association*/
_salesOrg,
_distChannel,
_division
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment