There are many scenarios where you have either your own OData service or want to integrate with another SAP OData service. For those cases, you can generate your own OData client as described in the following.
Download the service specification file for SAP S/4HANA Cloud Workforce Timesheet service and SAP SuccessFactors Employee Central Time Off service from the SAP Business API Hub and put it into the resources/service-specs
.
In this directory, you will also find the service mapping file, which contains some extra configuration for the generated service(s), like the directory name and service path for the service.
Note As it's described in the License, OData clients for SAP S/4HANA and SAP SuccessFactors should not be made available as open source because it is subject to SAP intellectual property.
To generate the OData clients, run the following npm script:
npm run generate
Once this is completed you should find your generated OData clients in the src/generated
. We will use this code for OData requests to SAP S/4HANA and SAP SuccessFactors.
The script runs the following command:
npx generate-odata-client -c generator-config.json
In your package.json
, you have already installed the @sap/cloud-sdk-generator
.The command runs the generator with configuration option -c
which points to generator-config.json
. We specify input and output directories along with some other options for the generation in the file.
The generator creates clients for all service definitions found in the input directory. The options given in the config are applied to each individual service. To find out more about the options run:
npx generate-odata-client -h
The options are described in the documentation.