Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
vignesh_kamath
Explorer
For Use cases involving Standard ABAP CDS Views, which may require custom ODATA implementation for SAPUI5 consumption.

In usual scenarios Std. ABAP CDS Views are consumed as KPI/Smart Business App.

But you may come across situations wherein CDS View is consumed as Design Studio App through Fiori (Query Browser), and there will be challenges to extend or build custom UI5/ODATA for the same.

This blog intends to address this challenge.

Note: this blog is meant for systems with SAP Netweaver 7.4 or less (For NW 7.5 its best to auto-generate the ODATA using HANA Studio and use Annotations).

Performance of ODATA service would depend on data load.

Prerequisites

  • You have installed Eclipse IDE/HANA Studio on your local machine

  • You have installed ABAP Development Tools in Eclipse IDE/HANA Studio.

  • You have access to ABAP Netweaver 7.4 on HANA.

  • You have created ABAP Project in eclipse to connect to ABAP Netweaver 7.4 system.

  • You have required HANA authorizations in place to access Standard ABAP CDS View.


Open Hana Stuido> ABAP Perspective> Look for the CDS View in the package that you have imported to your workspace-



In this example we are working on C_FUTUREACCTRBLS which is a parameter based CDS view.

Double click on the CDS, and look for parameters.



You can use these parameters for implementing & testing ODATA service.

Check data preview with above parameters,





Click OK, to check data available in this view for the specified parameters.


Click on "Number of Entries" Button, we you get data count.



For ODATA implementation to fetch data based on these parameters, we perform the following implementation-

Go to SEGW-

Create New Project- ZDEMO_CDS_VIEW,

Import DDIC structure as shown below-




Click Next.

then select Columns you require for display of data-

then select key fields (for this example we select all).

then Save, Generate runtime objects


ReDefine the Get_EntitySet method for DPC_EXT Class as below (As shown yellow highlighted)-

Use below code for the method-
  method CDSSETSET_GET_ENTITYSET.  

DATA LV_CURRENCY TYPE VDM_V_DISPLAY_CURRENCY VALUE 'USD'.

SELECT * FROM cfutureacctrbls( P_DisplayCurrency = @LV_CURRENCY,
P_ExchangeRateType = 'M',
P_NetDueInterval1InDays = '30',
P_NetDueInterval2InDays = '60',
P_NetDueInterval3InDays = '90',
P_NetDueInterval4InDays = '120' )
INTO TABLE @DATA(lt_data).
* UP TO 100 ROWS.

MOVE-CORRESPONDING lt_data to ET_ENTITYSET.
endmethod.

Save, Generate Runtime Object. (During activation you will get warnings, ignore it, as we are using Open SQL query to access CDS View, we get these warnings)

Now go to TCode- /IWFND/GW_CLIENT

test your odata service, with the entity set created.



Check the count-



This can be further extended, by passing the parameters as odata filter variable, as per your requirements (iv_filter).

UI5 Application to consume this ODATA service can be made using simple Table/List controls.

- vigneshkamath@boaweb.com
1 Comment
Labels in this area