cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing data from the ODATA association using BTP destination integration

chandan3009
Explorer
0 Kudos

Hello all,

I am using SAP BTP destination services for setting up the ODATA integration with SAP C4C. While doing this, I do see an option to expand(include) the associations in the integration (as can be seen in below screenshot)

In above screenshot, we can see BTP destination integration do give option to enable the association for integration, however I cannot access these association while actual binding to the UI components as it was possible with the traditional AppGyver ODATA integration.

Can someone shed some light on how could I access the association data (like Activity Text or Activity Party from above example) through the Enabled ODATA collection (here ActivityCollection)?

BR, Chandan

Accepted Solutions (0)

Answers (4)

Answers (4)

chandan3009
Explorer
0 Kudos

Hello Daniel,

Sorry for late reply, With your help, I am able to use the association while creating the new Service Request to C4C.

However, I am still stuck while displaying the Service Request data. With your guidance, for a Service Request; I am able to fetch the Activity details from MemoActivityBusinessTransactionDocumentReferenceCollection, but now trying to fetch the child associations for Activity to get the Text and Party information. Below screenshot shows the data receiving from C4C:

I fetched the memo references for a service ticket. Memo subject can be fetched expanding Activity from memo reference. Now further information on Memo party and Text has to be expanded from Activity.

I am repeating a row based on the memo references (MemoActivityBusinessTransactionDocumentReferenceCollection). ActivityParty and ActivityText information is what is to be fetched and filled in respective cells in row:

BR, Chandan

2367835
Explorer
0 Kudos

Hi Chandan,

Now i am facing same issue to get data from that expand fields.

can you please suggest a way to get data from that parentNav.

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

You can start with the Object with properties UI for the Record, like here in my example:

But then instead say you want a formula, like here:

It's the same thing except as a formula ... then you can add to it all the fields you want.

I will do an example with Business Partners and post it as soon as possible (unless Marc beats me to it 🙂

chandan3009
Explorer
0 Kudos

Hello Daniel/Marc,

It is really nice to see getting replies but I am not able to access the association data using formula. Following the suggestion from Marc, I am getting 'No Suggestion' error while adding the formula (ActivityText and ActivityParty are the associations to ActivityCollection in C4C ODATA)

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

1) Formulas will give errors because they are not aware of the field, but you can still save the formula. Though there is an underlying schema understood by SAP Build Apps, the value is just a JSON object and you can set it to anything (pretty much). If you never provide a field in the current list of objects called ActivityText, yes, it will fail, but the formula editor has no idea what will be and so gives an error.

2) See my blog post today – inspired by your questions 😺 It goes against S/4HANA but I assume its all OData services in the end. I hope you have a service called ActivityText from which we can get the schema -- you don;t need to call, just makes life easier to get the schema -- https://blogs.sap.com/2023/06/11/your-guide-to-calling-s-4hana-apis-from-sap-build-apps/

chandan3009
Explorer
0 Kudos

Hello Daniel,

Your new blog is very helpful, gave me some other direction to fetch the data.

I didn't stopped seeing the No suggestion formula error but also tried by applying these formulas, but couldn't fetch the required data.

One thing that is making things different for me as compared to your blog is that, in my case; I have multiple records in the association. I have ticket display page which would show the selected ticket details. I am unable to show the ticket's past conversations. Below screenshot shows the relationships between various ODATA services (in blue), I am using to display the data:

I wish to use the data from MemoActivityTextCollection and MemoActivityPartyCollection to show the past conversation maintained on ticket in C4C

MemoActivityBusinessTransactionDocumentReferenceCollection provides me 3 memo activities linked to sample ticket, for which I need to fetch corresponding 3 PartyName and 3 Texts from MemoActivityPartyCollection and MemoActivityTextCollection respectively.

MarcHuber
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Chandan,

you need to use a formula to access the expanded data.

Let's assume you have a list item object where you display all the ActivityCollection entry and you want to display the corresponding "Text" from the expanded ActivityText, it should be a formula like repeated.current.ActivityText.results.Text

Explanation:
repeated = because in the list we repeat the items with every entry in the backend
current = we want to access the current row
ActivityText = the expanded entity you want to access
results = I checked the API (https://api.sap.com/api/memoactivity/tryout) and it seems that the data from the ActivityText is again in an object called results. If not just delete the results. part
Text = the final data object that you want to display from the ActivityText data entity. Just type in the data object that you want to use.

Best regards;
Marc

chandan3009
Explorer
0 Kudos

Hi Marc,

While creating new memo in C4C, below payload works using Postman:

{"SubjectName": "Ticket Subject","InitiatorCode": "2", // value "2" for inbound to SAP Cloud for Customer, value "3" for outbound from SAP Cloud for Customer"ActivityParty": [{"PartyID": "1000080", // customerId"PartyTypeCode": "159", // value "159" for b2c, value "147" for b2b"RoleCode": "34" // value "34" for b2c, value "49" for b2b}],"ActivityText": [{"Text": "Ticket Message 2","TypeCode": "10002"}],"ActivityBusinessTransactionDocumentReference": [{ "ParentObjectID": "9B6B537C38BB1EDE8187F3EF6766C804", "ID": "164", "TypeCode": "118", "RoleCode": "1"}]}

But I cannot send all these sample data to C4C using Build Apps in single Create Record flow for ActivityCollection. This is because Data Variable for ActivityCollection doesn't show elements to bind the data (shown in screenshot above in reply to Daniel).

In turn, if I decide to create individual call to each ODATA collection for creation, I don't see option to add custom record for Record creation. Below screenshots for other two ODATA collection which I wish to use to associate the associate data to main ActivityCollection. These shows only option to add objectID for creation:

Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos

You can access them with a formula ... the data variable can only know the top schema but does not know whether this record has 5 associated objects or 10. But you can access the entire data using a formula.

Assuming I went to this OData service:

https://services.odata.org/V4/TripPinServiceRW

And took the People entity and expanded Friends. Now I want to repeat with People and bind a text field.

If I try to bind Data item in repeat, I see the Friends but it is a list and incompatible.

But I could access all the data with a formula, for example, if I want to bind the user name of the first friend.

repeated.current.Friends[0].UserName

Hope this helps

chandan3009
Explorer

Hello Daniel,

Thanks for replying.

I have integrated C4C using the BTP destination and with this the association aren't even visible. I wish to add data to the associations while creating new record in C4C. But as can be seen in below screenshot, these association are not available to bind the data relevant elements: