Skip to Content
0
Jan 17 at 07:24 AM

CAP: Service Consumption : Trial Balance

192 Views

Hello Experts,

I am new to CAP and have requirement to consume trial balance API ( https://api.sap.com/api/C_TRIALBALANCE_CDS/overview) for the entity C_TrialBalance. In this entity, if we see, it has a navigation property called Results and I have to consume the service as it is given in the "business documentation" of this API here. Putting the snapshot of the sample URL here:

https://sandbox.api.sap.com/s4hanacloud/sap/opu/odata/sap/C_TRIALBALANCE_CDS/C_TRIALBALANCE(P_FromPostingDate=datetime'2018-01-01T00%3A00%3A00',P_ToPostingDate=datetime'2018-12-31T00%3A00%3A00')/Results?
%24filter=Ledger%20eq%20'0L'%20and%20CompanyCode%20eq%20'1010'&%24select=CompanyCode,GLAccount,StartingBalanceAmtInCoCodeCrcy_F
,DebitAmountInCoCodeCrcy_F,CreditAmountInCoCodeCrcy_F,EndingBalanceAmtInCoCodeCrcy_F

What I did so far:-

1. Created srv->Catalog-Service.cds file with the entity definition from C_TRIALBALANCE & C_TRIALBALANCEResults entity.

2. Created srv->Catalog-Service.js file with the implementation to call READ on C_TRIALBALANCE.

3. Package.json is all in place with the destination created.

Of course, this is incomplete. I am not sure what do I write code to have the call given as in the above URL with navigation properties filtered and main entity queried with date values.

Kindly help.

Thanks & Regards

Srinivas Rao.