cancel
Showing results for 
Search instead for 
Did you mean: 

csn file in the Cloud Programming Model - S/4 Hana Cloud API

10-02-2019 3:14 PM
kevin_hu Active Participant
3601 views 4 comments Go to solution
0 Likes
SAP Managed Tags
Subscribe

Hi,

I was following this tutorial

https://developers.sap.com/tutorials/cap-cloudsdk-1-mock-service.html

Just wondering in Step 3, how the file "API_BUSINESS_PARTNER.json" is generated/acquired. I checked the api.sap.com but could not find it with the same format.

Also my understand is this file is the csn file which is parsed from service cds, am I right?

dj.adams dj.adams.sap

0 Likes

Accepted Solutions (1)

Accepted Solutions (1)

dhem
Advisor
Advisor

Hey Kevin,

There's a package called "@sap/edm-converters" in SAP's public npm registry (https://npm.sap.com).

To install it, first add an .npmrc file to your project with the following line:

@sap:registry=https://npm.sap.com

Then you should be able to run "npm i -D @sap/edm-converters".

Finally, you should be able to run "npx convert_edm", which should print the tools usage.

Hope that helps!

Dennis

kevin_hu
Active Participant

Download the edmx file from api.sap.com

install edm-converters.

run the command line

To generate CSN file from an EDMX File:

 * Windows: $homedir>./node_modules/@sap/edm-converters/lib/edmToCsn/bin/edmx2csn.cmd -i ${input_folder}/metadata.xml -o ${output_folder} -f 
 * Linux: $homedir>./node_modules/@sap/edm-converters/lib/edmToCsn/bin/edmx2csn.sh -i ${input_folder}/metadata.xml -o ${output_folder} -f 

Got the csn json file, do a cds compile and it works perfect.

Check the Readme for more info

./node_modules\@sap\edm-converters\lib\edmToCsn\README.md

Thanks

santosh_kumar97
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi Dennis,

i am getting below error while generating csn file out of edmx .

npx convert_edm edmxV40ToJsonV40 --input abcd.edmx

ERROR - MISSING: com.sap.vocabularies.Common.v1 /sap/opu/odata/IWFND/CATALOGSERVICE;v=2/Vocabularies(TechnicalName='%2FIWBEP%2FVOC_COMMON',Version='0001',SAP__Origin='LOCAL')/$value

ERROR - Could not convert document: Missing referenced documents

Answers (1)

Answers (1)

vLeonkev
Product and Topic Expert
Product and Topic Expert

Hi Kevin,

The CDS module produces such files out of CDS files, but as the format of CSN is standardized, you are free to compose such files in any manual or automatic way, and also reuse files as in this case - downloading from github.

See: CSN format and cds.parse

Consuming S/4HANA Service is described here.

You can also download the EDMX-file you want to consume and use @sap/edmx2csn node module to generate the CSN-file.

Best