cancel
Showing results for 
Search instead for 
Did you mean: 

CAP: Service Consumption : Trial Balance

Srinivas-Rao
Contributor
0 Kudos

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.

Srinivas-Rao
Contributor
0 Kudos

Hi gregorw carlos.roggan - Any help/pointers?

Accepted Solutions (0)

Answers (1)

Answers (1)

gregorw
Active Contributor
0 Kudos

I would suggest you download the Metadata of the service from:

/sap/opu/odata/sap/C_TRIALBALANCE_CDS/$metadata

and then follow the documentation at Consuming Services. You should notice that you're calling a View with Parameters. Maybe you get some help from Views with Parameters. I think this answer: CAP: How to properly pass parameters to a View when consumed programmatically (Node.js) should help you.