By default, the most of the standard APIs in Private Cloud / On-Premise installations are not active, as their service groups are not published (OData V4) or the services are not activated (OData V2).

For Warehouse physical stock service, when you try to open url https://{host}:{port}/sap/opu/odata4/sap/api_whse_physstockprod/srvd_a2x/sap/whsephysicalstockproducts/0001, you receive an error:

    ... Service group 'API_WHSE_PHYSSTOCKPROD' is not published...

Follow the instructions below in order to publish the corresponding group.

Publishing an OData V4 Service Group

  1. Go to transaction /IWFND/V4_ADMIN SAP Gateway Service Administration.
  2. Check that API_WHSE_PHYSSTOCKPROD service group is not listed in the section Service Groups, otherwise it is already published. If it is already published, you can skip this section.
  3. Open publishing dialog using the button Publish Service Groups.
  4. Fill in the required parameters.
    • System alias: usually “LOCAL”.
    • Service group ID: "API_WHSE_PHYSSTOCKPROD".
  5. Find the corresponding service group using the button Get Service Groups (F8).
  6. Select it from the results list, publish it using the button Publish Service Groups.

Once published, the OData endpoint should become available.

Using it in your Fiori SAPUI5 application

  1. Update your webapp/manifest.json file.
    1. Under "sap.app" → "dataSources", define a data source that points to the published OData V4 service. For example:
        ...
        "dataSources": {
            "warehousePhysicalStockService": {
                "uri": "/sap/opu/odata4/sap/api_whse_physstockprod/srvd_a2x/sap/whsephysicalstockproducts/0001/",
                "type": "OData",
                "settings": {
                  "odataVersion": "4.0"
                }
            }
        }
        ...
    
    1. Under "sap.ui5" → "models", create a model referencing that data source. For example:
        ...
        "models": {
            "warehouseStockModel": {
                "dataSource": "warehousePhysicalStockService",
                "settings": {
                    "groupId": "$direct",
                    "synchronizationMode": "None",
                    "operationMode": "Server"
                },
                "type": "sap.ui.model.odata.v4.ODataModel"
            }
        }
        ...
    
  2. Use the new Model in your application.
    1. Option 1, binding to a View (Declarative Approach, XML). Adjust your XML view file to consider the new model. For example:
        ...
        <Table id="myTable" items="{
            path: 'warehouseStockModel>/WarehousePhysicalStockProducts', 
            parameters: { 
                $select: 'EWMWarehouse,Product,EWMStockQuantityInBaseUnit,EWMStockQuantityBaseUnit'
            }
        }">
        ...
    
    1. Option 2, accessing the data from Controller's code (Imperative Approach, JavaScript). Adjust your controller code to read data from the new model. For example:
        ...
        const oStockModel = this.getOwnerComponent().getModel("warehouseStockModel");
        const aFilter = aHUs.map(oHU => {
            return new sap.ui.model.Filter({
                path: "HandlingUnitNumber",
                operator: sap.ui.model.FilterOperator.EQ,
                value1: oHU.HandlingUnit
            });
        });
        const oHUQIBinding = oStockModel.bindList("/WarehousePhysicalStockProducts",
            null,   // no context
            null,   // no sorters
            aFilter,
            { $select: "HandlingUnitNumber,QualityInspectionDocument" }
        );
        oHUQIBinding.requestContexts().then(aContexts => {
            aContexts.forEach(oContext => {
                console.log(oContext.getObject());
            });
        });
        ...
    

Other steps

Depending on your security policies, it is might be required to add the corresponding service to your user catalog or whitelist it. The corresponding steps are not included into this article.

Verified systems

  • SAP S/4HANA 2023

Provide feedback

If you have comments or suggestions, please feel free to: