Dear community,
after studying code examples for value help in the ABAP RESTful Programming model, e.g. in the openSAP course on the topic abap-platform-rap-opensap/week2/unit4.md, I tried to apply this to a different data model where objects are defined with GUID keys that are then used for associating entities and could not get the value help to populate the key of an associated object when creating a new record.
Description of the problem:
In the example quoted above, there is a field CustomerID in the Travel view with a foreign key association to a Customer entity /DMO/I_Customer joined on exactly this field. The search help is put into place with the annotation
@Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Customer', element: 'CustomerID' } }]
This establishes the value help for field CustomerID which is shown on the UI of the Fiori app. When the user of the app has made a choice with the value help, the framework transfers the CustomerID value for the line of the search help view chosen by the user to the CustomerID field of the Travel object. Everything fine.
I tried to apply the concept to the "traditional" EPM model with a logistics flavor. In particular, there is a sales order header entity which has an association to a business partner entity joined on the buyer guid of the sales order header to the node_key of the business partner table. This guid is a technical key of the business partner table and is referenced as foreign key where applicable, a normal data modelling scheme.
Now, when I place a value help on CustomerID into the projection view, I see that the full record is displayed to the user, including the buyer guid, but it is the CustomerID that is transferred back. However the association from sales order header to business partner is on buyer_guid, and this field is left unchanged by applying the search help result, so you cannot populate an associated business partner for a newly created record this way. I would need this buyer_guid to be transferred as well. I looked through the documentation but could not find any way to achieve this.
The only "workaround" I see to get a search help for the associated business partner is putting buyer_guid on the UI and place the search help on that buyer_guid field, but this would be a horrible "solution".
I missed an option to direct the framework to transfer an additional field from the result record of the search help back to the entity where the search help resides. Any suggestions?
Thanks a lot in advance for any ideas,
Christian
-----------------------------
Details
Excerpt of the interface view for the sales order header:
//...
define root view entity ZI_RAP_SOH_00
as select from zrap_soh_00 as Header
composition [0..*] of ZI_RAP_SOI_00 as _Item
association [0..1] to SEPM_I_BusinessPartner as _Customer
on Header.buyer_guid = _Customer.BusinessPartnerUUID
association [0..1] to I_Currency as _Currency
on $projection.CurrencyCode = _Currency.Currency
{
key node_key as NodeKey,
so_id as SoId,
buyer_guid as BuyerGuid,
_Customer.BusinessPartner as CustomerID,
The CustomerID is supposed to be shown on the UI with a value help that allows for choosing a business partner record when creating a new sales order header object.

That's why the CustomerID was added to the interface view above. It will also be in the projection view where the value help is applied.
Excerpt of the projection view:
//..
@Search.searchable: true
@Metadata.allowExtensions: true
define root view entity ZC_RAP_SOH_00
as projection on ZI_RAP_SOH_00
{
key NodeKey,
@Search.defaultSearchElement: true
SoId,
BuyerGuid, // willbe hidden on the UI
@Consumption.valueHelpDefinition:
[{ entity: { name: 'SEPM_I_BusinessPartner',
element: 'BusinessPartner'}
// how to transfer 'BuyerGuid' of result?
// NB: additionalBinding annotation as shown in comment below
// does not work since that would just place an additional restriction // on the BuyerGuid of the *previously associated* business partner record
// instead of adopting the BuyerGuid for the chosen CustomerID
// , additionalBinding: [{ localElement: 'BuyerGuid',
// element: 'BusinessPartnerUUID'
// }]
}]
CustomerID,