cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Accessing Product Description in Value Help Using sap/api_product/srvd_a2x/sap/product/0002 API

Nicolaas
Explorer
0 Likes
328

Hi SAP Community,

I'm working on an SAP CAP (Cloud Application Programming) project where I need to access product descriptions in a value help for a product using the OData API https://{host}:{port}/sap/opu/odata4/sap/api_product/srvd_a2x/sap/product/0002. However, I'm encountering an issue when implementing the search help for the product description, and I need some guidance.

To access the external API I've defined an index.cds file under /srv/external. In this file I have included the following entity projects:

namespace external;

@readonly
entity Product                               as
    projection on PRODUCT_0002.Product {
        key Product,
            BaseUnit,
            _ProductDescription  : redirected to ProductDescription,
    }

@readonly
entity ProductDescription                         as
    projection on PRODUCT_0002.ProductDescription {
        key Product,
        key Language,
            ProductDescription,
    }

In my service definition I've included the project following entities:

using {external as externalServices} from './external';

    entity Product                as projection on externalServices.Product;
    entity ProductDescription     as projection on externalServices.ProductDescription;

In the annotation for the fiori application I have included:

annotate service.x with {
    product @(
        Common.Label : '{i18n>product}',
        Common.ValueList : {
            $Type : 'Common.ValueListType',
            CollectionPath : 'ProductDescription',
            Parameters : [
                {
                    $Type : 'Common.ValueListParameterInOut',
                    LocalDataProperty : product_Product,
                    ValueListProperty : 'Product',
                },
            ],
        },
        Common.ValueListWithFixedValues : false,
    )
};

In the console I get the following error:

    message: 'Error during request to remote service: Unspecified provider error occurred. See Error Context and Call Stack.',
    code: 'ERR_BAD_REQUEST',
    config: {
      timeout: 0,
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      method: 'get',
      baseURL: 'https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata4/sap/api_product/srvd_a2x/sap/product/0002',
      proxy: false,
      url: "/Product(Product='undefined')?$expand=_ProductDescription($filter=Language%20eq%20'undefined')",
      data: undefined
    },

What am I missing here?

Thank you in advance for your time!

==== update 10/04/25 ====

I think I might have missed something on providing the right context. In the JS implementation of service X I use the mashup package from SAP.

x-service.js

  this.on('READ', Product, handleMashupRequest);
handleMashupRequest is implemented in utils.js
const MashupHandler = require("@sap/external-service-mashup/src/handle-mashups");

// Centralized handler for mashup operations
const handleMashupRequest = async (req, next) => {
  const handler = new MashupHandler();
  return handler.handle(req, next);
};<p>Nicolaas</p>

Accepted Solutions (0)

Answers (0)