cancel
Showing results for 
Search instead for 
Did you mean: 

Paging in a RAP service with complex search and a Fiori Elements app

maartenweijer
Explorer

Hi all,

We have defined a root custom entity with a query implementation class. In the root custom entity we defined all the fields we want on the output and in the class we populate those fields with the data.

This all works fine, but we see that in the Fiori Elements app a maximum of 20 records is shown. When you scroll down, the next 20 records will be retrieved from the database.

We implemented our solution based on this information:

https://help.sap.com/docs/abap-cloud/abap-rap/implementing-paging-in-unmanaged-query?version=s4_hana

Our DB search statement looks ends like this, where we fetch 20 records max with the help of the OFFSET and UP TO … ROWS.

<select statement>
INTO CORRESPONDING FIELDS OF TABLE @eta_ods_data
OFFSET @Iva_skip UP TO @Iva_max_rows ROWS.

Next to this, we also do a count to fetch the total count of all relevant records.

SELECT count(*)  into @Eva_count
FROM <select statement>

With the next 2 statements we tell the front end what to display and how many more records there are:

"Set total no. of records
io_response->set_total_number_of_records( lva_count ).
io_response->set_data( gta_final ).

In the Fiori Elements app this is all working correctly where you can handle your data retrieval  via the  SELECT statement.

But one of our development teams already faced a scenario where this was not enough. And I am already aware of an upcoming development where we will have the same situation.

After the SELECT statement also classes and function modules were used to change the output. So in the end we have more records than selected by the SELECT statement.

That means the above approach with the OFFSET is not good enough and as far as we could see we would need to fetch all the records from the DB and use the classes and function modules to determine the correct output. But the output is only showing 20 records a time max, so each time when scrolling down in the Fiori app, we need to retrieve all data again from the DB and call the classes and function modules. While this would technically work and we can determine the next 20 records from the total results, performance was not good enough. 

Is there a best practice how this be achieved on a more efficient way?

Kind regards,

Maarten Weijer

Accepted Solutions (0)

Answers (1)

Answers (1)

Dinu
Contributor
0 Kudos

Check this previously asked question: FE - List Report Growing Threshold

maartenweijer
Explorer
0 Kudos

I tried this solution by adding the line

 

@UI.presentationVariant: [{maxItems: 99, visualizations: [{ type: #AS_LINEITEM }]}]

right above "define root custom entity <name>", but it does not give the expected result. Also when I debug, the line

DATA(lva_top) = io_request->get_paging( )->get_page_size( ). 

gives back a value of 20. I cannot find the value of 99 anywhere.