visual composer - paging records - using sql to get chunks of data _ scn

5
20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN http://scn.sap.com/docs/DOC-52505 1/5 Getting Started Newsletters Store Products Services & Support About SCN Downloads Industries Training & Education Partnership Developer Center Lines of Business University Alliances Events & Webinars Innovation Login Register Welcome, Guest Search the Community Activity Communications Actions Brow se 0 Tweet 1 created by Ehud Nir on Feb 17, 2014 1:26 PM, last modified by Ehud Nir on Feb 19, 2014 9:54 AM Abstract & Motivation This example shows yet another way to allow paging behavior for our application. Here it is achieved using a Data Service that returns a subset of the data: For each Next / Previous press by the user we call the data service to get the relevant chunk of rows. For example, for the input: Start index: 6 Number of records: 5 The result is a list containing the rows 6 to 10. One big advantage of this method: The application does not need to handle big amounts of data. The other benefit we see soon. Related documents: Paging records in the UI Paging records in the UI - Coding our own Web Service to get Row Numbers The application First five records: After pressing Next: The Backend - SQL Example Our data service consists of a simple SQL Query. Input parameters: @start - start index @step - number of rows Result: the requested subset of the Suppliers table. Code specifics: Step 1: The inner SELECT statement return the Suppliers data with an additional column called row , for the row number (1, 2, 3...). Step 2: The outer SELECT filters part of Step 1 result, using the input parameters @start and @step Paging records - Using SQL to get Chunks of Data Share 2 1 Like Version 1

Upload: crb1172

Post on 16-Dec-2015

214 views

Category:

Documents


0 download

DESCRIPTION

VC

TRANSCRIPT

  • 20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN

    http://scn.sap.com/docs/DOC-52505 1/5

    Getting Started Newsletters Store

    Products Services & Support About SCN Downloads

    Industries Training & Education Partnership Developer Center

    Lines of Business University Alliances Events & Webinars Innovation

    Login RegisterWelcome, Guest Search the Community

    Activity Communications Actions

    Brow se

    0 Tweet 1

    created by Ehud Nir on Feb 17, 2014 1:26 PM, last modif ied by Ehud Nir on Feb 19, 2014 9:54 AM

    Abstract & MotivationThis example shows yet another way to allow paging behavior for our application. Here it is achieved using a Data

    Service that returns a subset of the data: For each Next / Previous press by the user we call the data service to get the

    relevant chunk of rows.

    For example, for the input:

    Start index: 6

    Number of records: 5

    The result is a list containing the rows 6 to 10.

    One big advantage of this method: The application does not need to handle big amounts of data. The other benefit

    we see soon.

    Related documents:

    Paging records in the UI

    Paging records in the UI - Coding our own Web Service to get Row Numbers

    The applicationFirst five records:

    After pressing Next:

    The Backend - SQL ExampleOur data service consists of a simple SQL Query.

    Input parameters:

    @start - start index

    @step - number of rows

    Result: the requested subset of the Suppliers table.

    Code specifics:

    Step 1: The inner SELECT statement return the Suppliers data with an additional column called row, for

    the row number (1, 2, 3...).

    Step 2: The outer SELECT filters part of Step 1 result, using the input parameters @start and @step

    Paging records - Using SQL to get Chunksof Data

    Share 2 1Like

    Version 1

  • 20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN

    http://scn.sap.com/docs/DOC-52505 2/5

    against the row column.

    Modeling1. Search for the relevant data service and add it to the model.

    2. In case it is a JDBC Stored Procedure, as shown here:

    - Right click => Test Data Service.

    - Enter input value and press Text.

    - Press Add Fields to have the fields in the output port.

    3. Add a Table View from the output of the service.

    4. Add a Data Share element.

    5. Connect the Data Share to the service, edit the link to "listen" to the "*get" event (we model its triggering in later

    steps).

    6. Add two fields to the Data Share, index and step, as follows:

  • 20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN

    http://scn.sap.com/docs/DOC-52505 3/5

    7. Define the field assigns in the Mapping link. Here we pass our SQL code the starting index and number of rows:

    8. Go to the Layout Board and define the Actions for the "First" button:

    - ASSIGN to reset to the first chunk of records.

    - GET as a Custom Action to activate the data service (see in step 5 where we define the link activation event).

    9. Define the "Previous" button: Subtract the step size from the current index:

  • 20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN

    http://scn.sap.com/docs/DOC-52505 4/5

    10. Define the Enabled condition for the "Previous" button, adding the step size to the index:

    11. In quite the same way, define the "Next" button:

    That's it. This solution involved:

    A bit of SQL coding.

    A super-simple VC model.

    Benefit #2 (in addition to having No Big Data): Note how simple the modeling is comparing to the other paging

    solution:

    The Filter Operator is gone, as filtering is done on the database.

    Also gone is the Data Share.

    Possibly an additional Web Service to get the row number to rely on is gone as well - we don't need logic

    depending on row numbers here.

    Related documents:

    Paging records in the UI

    Paging records in the UI - Coding our own Web Service to get Row Numbers

    100 View s Categories: SAP Visual Composer 7.1 and Above Topics: performance, database Tags: code, sql, paging

  • 20/2/2014 Paging records - Using SQL to get Chunks of Data | SCN

    http://scn.sap.com/docs/DOC-52505 5/5

    Follow SCNSite Index Contact Us SAP Help Portal

    Privacy Terms of Use Legal Disclosure Copyright

    Average User Rating

    (0 ratings)

    0 Tweet 1Share 2 1Like

    There are no comments on this document.

    0 Comments