0

Currently we consume an S4HANA odata service in SCP using cloud sdk. As recommended , We currently use VDM generation approach to generate VDM class.

Now we identified that the S4HANA ODATA service is extendable. customers extend the service and adds new attributes to the entry.

We need to bring the extended attributes and process them through our business logic and place them on SCP data base

Please share guideline for this. How to achieve this? Since VDM generation is design time activity, we are not able to influence it at runtime as ours is multitenant SCP application and S4HANA service is extended by some customers based on their individual requirements

Thanks Apoorv

1 Answers1

0

For the purpose of accessing extended attributes of S/4HANA OData service, you can make use of the accessors(getters and settors) on customFields available on the VdmEntity. Here is an example:

final List<BusinessPartner> businessPartnerList =
            new DefaultBusinessPartnerService().getAllBusinessPartner().execute(destination);
        final Set<String> customfieldNames = businessPartnerList.get(0).getCustomFieldNames();
        for( BusinessPartner bp : businessPartnerList ) {
            customfieldNames.forEach(s -> bp.getCustomField(s));

        }

To set a value to a custom field, use for e.g:

businessPartnerList.get(0).setCustomField("ShoeSize",9);

You can read more about it in this tutorial.

MatKuhr
  • 505
  • 4
  • 13
Ksivakumar
  • 188
  • 1
  • 7
  • Thanks. Question is that VDM generation is design time activity which is only performed once before delivering the multitenant applciation . Customers adds extension fields (specific to customer). It will not be avilable in VDM structure correct? or we are saying that cloud sdk takes care of it and some generic code can be written to tackle all future extension fields added by customer . can you please confirm once more ? – Apoorv Bhargava Jul 22 '20 at 08:23
  • 1
    Yes, when the customer adds extension fields to an S/4 HANA OData service for which a VDM was already generated, these fields would not be available in the VDM structure directly. But, you can still access them using the accessors on `customFields`, this would help in tackling any future extension fields added by the customer. Please refer to this [tutorial](https://developers.sap.com/tutorials/cloudsdk-extensibility-type-safe-expand.html#733d48a5-1d28-46b1-af4e-f4dbe6cc7c47) for details. – Ksivakumar Jul 22 '20 at 15:44