OData service for demand planning does not expose custom fields added via CDS view extension

We’ve added custom fields to demand planning forecasts through CDS view extensions (Z_DEMAND_FORECAST_EXT), and they appear correctly in SAP Fiori apps. However, when external systems query the OData service API_DEMAND_PLANNING, these custom fields are not included in the response metadata or data payload.

The CDS view extension is activated and we can see the fields in SE11. Standard fields from the base view work fine via OData. Here’s our extension structure:

@AbapCatalog.sqlViewAppendName: 'ZDEMANDEXT'
extend view I_DemandForecast with Z_DEMAND_FORECAST_EXT {
  @OData.property.name: 'CustomRegion'
  zregion_code,
  @OData.property.name: 'CustomPriority'
  zpriority_level
}

External access is blocked because our analytics tools can’t retrieve the custom regional segmentation data. Has anyone successfully exposed custom CDS fields through standard OData services on SAP 2020?

Don’t forget authorization checks. Even if the service definition is extended correctly, SAP 2020 has field-level authorization for OData services. Your API user needs S_SERVICE authorization object with sufficient access to custom fields. Also check if the CDS view has @AccessControl annotations that might be filtering out your custom fields for external API calls even though they’re visible in Fiori apps using different authorization contexts.

Also verify your service binding activation status. After extending the CDS view, you must republish the service binding in transaction /IWFND/MAINT_SERVICE. Sometimes the binding cache doesn’t pick up CDS extensions automatically. Look for the service binding object associated with API_DEMAND_PLANNING and use the ‘Activate and Maintain’ function to force a refresh of the metadata.

Create a new service definition extension object - never modify SAP standard objects directly. Use transaction SE80 or Eclipse ADT to create the extension. The naming convention is typically ZAPI_DEMAND_PLANNING_SRVD_EXT. In the extension, explicitly expose your custom fields. Then you need to rebind the service in /IWFND/MAINT_SERVICE and also check transaction /IWBEP/REG_SERVICE to ensure the extended metadata is registered in the gateway catalog. Sometimes you need to deactivate and reactivate for changes to take effect.

The issue is that CDS view extensions alone don’t automatically extend OData service definitions in SAP S/4HANA 2020. You need to work through all three layers:

1. CDS View Extension (you’ve done this correctly): Your CDS extension looks good, but ensure you’re using the correct annotation syntax for 2020. The @OData.property annotations are legacy - use @EndUserText instead:

@AbapCatalog.sqlViewAppendName: 'ZDEMANDEXT'
extend view I_DemandForecast with Z_DEMAND_FORECAST_EXT {
  @EndUserText.label: 'Custom Region'
  zregion_code as CustomRegion,
  @EndUserText.label: 'Custom Priority'
  zpriority_level as CustomPriority
}

2. OData Annotation Usage: Create a metadata extension (DDLX object) specifically for OData exposure. This is the missing piece. Create Z_DEMAND_FORECAST_EXT_MDE:

@Metadata.layer: #CUSTOMER
annotate view Z_DEMAND_FORECAST_EXT with
{
  @UI.lineItem: [{position: 100}]
  @Consumption.valueHelpDefinition: [{entity: {name: 'I_Region', element: 'Region'}}]
  CustomRegion;

  @UI.lineItem: [{position: 110}]
  CustomPriority;
}

3. Service Binding Activation: This is critical. You must extend the service definition AND republish the binding:

Step 3a - Create Service Definition Extension in Eclipse ADT:

  • Right-click on API_DEMAND_PLANNING service definition
  • Select “New” → “Service Definition Extension”
  • Name it Z_API_DEMAND_PLANNING_EXT
  • Add your custom fields explicitly:
extend service definition API_DEMAND_PLANNING {
  expose Z_DEMAND_FORECAST_EXT as DemandForecast {
    CustomRegion,
    CustomPriority
  }
}

Step 3b - Republish Service Binding:

  1. Transaction /IWFND/MAINT_SERVICE
  2. Find service API_DEMAND_PLANNING
  3. Click “SAP Gateway Client” to test current metadata
  4. Note the metadata version
  5. Click “Deactivate” then “Activate and Maintain”
  6. This regenerates the OData $metadata document
  7. Clear ICF service cache: transaction SMICM → Goto → HTTP Server Cache → Invalidate Globally

Step 3c - Verify Registration:

  1. Transaction /IWBEP/REG_SERVICE
  2. Search for API_DEMAND_PLANNING
  3. Check “System Alias” and “Service Version”
  4. Click “Load Metadata” and verify your custom fields appear in the entity type definition
  5. If fields are missing, use “Reload” button to force metadata refresh from service definition

Additional Configuration:

  • Authorization: Ensure role S_SERVICE includes your extended view Z_DEMAND_FORECAST_EXT with activity 03 (display)
  • Access Control: If your CDS view has DCL (Data Control Language), create corresponding DCL extension:
@MappingRole: true
define role Z_DEMAND_FORECAST_EXT_DCL {
  grant select on Z_DEMAND_FORECAST_EXT
    where inheriting conditions from entity I_DemandForecast;
}

Testing: Query the OData metadata to verify field exposure:


GET /sap/opu/odata/sap/API_DEMAND_PLANNING/$metadata

Look for <Property Name="CustomRegion" and <Property Name="CustomPriority" in the EntityType definition.

Then test data retrieval:


GET /sap/opu/odata/sap/API_DEMAND_PLANNING/DemandForecast?$select=ForecastID,CustomRegion,CustomPriority

The most common mistake is skipping the service definition extension (step 3a). CDS extensions and metadata annotations alone are insufficient - you must explicitly extend the service definition to expose custom fields via OData. All three layers must align for custom fields to be externally accessible.

I found the service definition in Eclipse (SRVD object API_DEMAND_PLANNING_SRVD), but I’m not clear on the syntax for extending it. Do I create a separate extension object or modify the original? And after extending the service definition, is the service binding republish in /IWFND/MAINT_SERVICE sufficient or are there additional activation steps?

CDS view extensions don’t automatically propagate to OData service definitions. You need to extend the service definition itself, not just the CDS view. Check if there’s a service definition object (SRVD) for API_DEMAND_PLANNING and create an extension for that. The OData annotations in your CDS view are ignored unless the service definition explicitly includes those fields.