Application Development and Automation 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: 

Using custom logic in BOPF Query called from OData Service

Sougata
Active Contributor
0 Kudos
1,942
  • SAP Managed Tags:

Hi Experts,

Here's the scenario:

We have used Annotations in a CDS View to generate the BOPF object and also the OData model.

We then have implemented a custom Query in BOPF. We then ran the generated OData in Gateway Client but the custom Query is not called by the system? However in the case of Create, Update, Deep Create the OData framework calls the BOPF framework.

So we created a new Gateway model and exposed the CDS view via SADL but it still will not call the BOPF custom Query when we perform a GET_ENTITYSET.

In the SADL option, we can redefine the READ methods but we thought it would make more sense to have all the CRUD processing logic in BOPF - any pointers where we are going wrong, how can we get the OData framework to READ data from BOPF framework?

We are on SAP_ABA Release 750 SP6.

Thanks,

Sougata.

11 REPLIES 11

maheshpalavalli
Active Contributor
1,027
  • SAP Managed Tags:

How did you generate the odata service? via CDS view or reference source in the odata segw project?

Sougata
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

Hi Mahesh

We tried both options and it did not call the custom query in either.

Regards.

maheshpalavalli
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

Hi Sougata Chatterjee,

I am not sure if a config or code change will make the SADL layer to call the BOPF query instead of CDS view. But What I can suggest is to redefine the MPC_EXT read query for that entity and call the BOPF query method manually, which will be an easy task,( the only workaround that I can think of ).

Thanks & Best Regards,

Mahesh

Sougata
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

Hi Mahesh

The problem is that we want to use the OData service that was generated via the CDS annotation @OData.publish: true

As a result we are unable to redefine anything in that model, it's cannot be viewed in SEGW.

Thanks

Sougata.

0 Kudos
1,027
  • SAP Managed Tags:

Then you can try using the reference odata source instead of generating the odata service.

Sougata
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

That way the Create/Update/Create_Deep_Entity does not seem to work with the BOPF business entity but instead it calls the generated SADL classes. As a result there is no other option than to redefine the above methods of the SEGW model which we want to avoid as we want to code the business logic only in the BOPF layer but the integration between the CDS consumption views, OData and BOPF does not seem to work (or probably we don't know yet how to integrate it seamlessly).

1,027
  • SAP Managed Tags:

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources.

Now coming to your question, I am talking about CDS view as the referenced source in the SEGW project. Many of the standard objects are created like that only and guess what it still calls the generated BOPF object that's why they gave referenced source feature where we will give our cds consumption view as the reference. Then the system will take care of diverting CRUD operations to CDS view(BOPF) internally unless if you redefine something like your read method. Again, I am only suggesting this as I am not aware of if we can provide dpc_ext kind of class for the OData generated from cds consumption view. You can check the behavior standard BP object in s4hana which does similar things.

BTW any reason you cannot use the logic directly in cds view to manipulate the read?

Thanks

Mahesh

Sougata
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

No because it is too complex to do it in the CDS view.

Yes we are using CDS view as referenced source in the SEGW project.

And no, it does not call the BOPF CRUDs even if nothing is Redefined in the SEGW.

Probably we are missing some @object.Model annotations in the CDS view.

Thanks.

1,027
  • SAP Managed Tags:

Hi Sougata Chatterjee, Ideally it is supposed to call the bopf automatically. I hope you are using objectmodel transactionalproceesingdelegated true annotation along with all other crud annotations in the consumption cds view.?

Sougata
Active Contributor
0 Kudos
1,027
  • SAP Managed Tags:

Hi Mahesh

Yes we have the annotations and it seems to call the deep entity in the BOPF framework when passed a deep structure but any idea how do we customise the create deep in this framework? Same goes for reads - how to customise the GET_ENTITYSET of the BOPF?

Thanks

Sougata.

0 Kudos
1,027
  • SAP Managed Tags:

Hi Sougata Chatterjee,

I hope now you are using the referenced source in the odata service. yeah i think it will call create deep method, if you want to customize that you need to redefine and i think it will be a tedious task, if you can tell your requirement it would be easier for me to comment.

In some std. objects, I saw sap redefining the common get entity/entityset and expand entity/entityset and writing a common logic to populate some additional details.

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_ENTITYSET

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITY

/IWBEP/IF_MGW_APPL_SRV_RUNTIME~GET_EXPANDED_ENTITYSET

There you can check if the iv_entityset is your entity then you can skip calling the cds view call and write your own logic.

Thanks,

Mahesh