cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Add subtotal in RAP unmanaged query

rammel_sapdev
Participant
0 Kudos
1,584

Hi,

I have been doing some research on how to do this. I saw that this is very implement with managed query (via CDS views) using aggregate CDS annotations (only for oData v2 read-only apps).

https://help.sap.com/docs/abap-cloud/abap-rap/annotating-aggregate-functions-in-cds

However, it doesn't seem to be working when I do the same thing via an unmanaged query. I have also tried playing around with the UI.presentationvariant annotations but no luck, it is also working only for managed queries.

I have also tried implementing the logic from the link below in my unmanaged query provider class, but there seems to be a problem and is resulting to a dump.

https://help.sap.com/docs/abap-cloud/abap-rap/implementing-aggregations-in-unmanaged-query

The dump is caused by the incorrect select query.

 

 SELECT (lv_req_elements) FROM /dmo/travel

 WHERE (lv_sql_filter)

 GROUP BY (lv_grouping)

 ORDER BY (lv_sort_string)

 INTO CORRESPONDING FIELDS OF TABLE @lt_travel_response

 OFFSET @lv_offset UP TO @lv_max_rows ROWS.

 

The LV_REQ_ELEMENTS variable from io_request->get_requested_elements( ) only contains the BOOKING_FEE field.

The LV_GROUPING variable from io_request->get_aggregation( )->get_grouped_elements( ) is empty even though I specified the groupBy annotation in the PresentationVariant.

The LV_SORT_STRING variable from io_request->get_sort_elements( ) is also empty. 

Does anybody know whether the @Aggregation.Default and presentationVariant is released for unmanaged query oData v2? 

    presentationVariant: [{
        sortOrder: [{
            by: 'Agency_ID',
            direction: #ASC
        }],
       groupBy : [ 'Agency_ID' ],
       totalBy : [ 'Agency_ID' ],
       total : [ 'Booking_Fee' ],
        visualizations: [{
            type: #AS_LINEITEM
        }]
    }]

@Andre_Fischer , just wondering if you have any thoughts on this? Thanks! 

Accepted Solutions (0)

Answers (1)

Answers (1)

SerhiiMartynkov
Product and Topic Expert
Product and Topic Expert

Hi rammel_sapdev,

It seems like person in this topic have somehow relevant issue as you, so it may indeed mean that they are not released. Have you considered to use Custom Logic in Query Provider? 

If you need aggregation functionalities in your unmanaged query, you might need to implement the logic within your query provider class. This would involve building the aggregation logic manually within your code.