Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP RESTFul Programming Model - value help, transfer multiple fields?

5,134

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,
6 REPLIES 6

0 Kudos
2,269

I forgot to mention that my scenario is on an OnPremise system ABAP Platform 2020 where the "traditional" EPM model metadata are available.

Jelena_Perfiljeva
Active Contributor
2,269

Hi Christian, I'm not an expert on this but suspect your question is not necessarily RAP related. It sound rather like a general "return of multiple values by value help in CDS views". Searched in Google but not much coming up, unfortunately. I know this was an option in classic ABAP but am wondering if CDS calls for a different design... Also RAP is kind of still "work in progress", afaik, so that could be part of it as well.

Maybe carine.tchoutouodjomo could help?

0 Kudos
2,269

Hi Jelena,

thanks for your comment. This may in fact apply to the previous "ABAP PROGRAMMING MODEL FOR SAP FIORI" as well, but I thought the design of annotation usage could have been adapted for the new model.
And indeed, for the time being I put this under "lessons learned" and will link master data types for which I want a value help on the visible key in the app.

Jelena_Perfiljeva
Active Contributor
2,269

Another note: it looks like you have a wrong RAP tag assigned. There is an "official" ABAP RAP tag where I see some SAP folks answering questions but the tag used in your question takes me to what looks like a custom "user" tag. I'd suggest to fix that to get better response.

0 Kudos
2,269

Hi Jelena,

thanks for the hint. I found this "official" tag now. Unfortunately I have no idea how I can reassign this. When I google for this, there is tons of information for how to subscribe to a tag, but the need to change or amend tags seemingly did not occur so far.

Mikhail_Minakov
Explorer
0 Kudos
2,269

Actually, additionalBinding is doing exact what you need, transfering the additional values dynamically from ValueHelp View together with the key field value. If you want to avoid restrictions of ValueHelp filter use "usage: #RESULT" attribute:

additionalBinding:[{ localElement: 'CompanyCode', element: 'CompanyCode', usage: #RESULT }]