Customizing Data Download with TOP, ORDER BY, and UNION
Customize data downloads using TOP, ORDER BY, and UNION SQL operations.
By default, the internally generated download SQL statement, based on the
synchronization parameters, includes only the '=' operator. For
example:
SELECT * FROM entity a WHERE a.x = :x and a.y = :y
SAP Mobile Platform
allows customization of the download data SQL through SAP Mobile WorkSpace
to support:
Where clause operators other than '='. For example, ( > , <
, < > , != , > =, < =, ! > , ! <, and so on).
Joining multiple entities using ‘UNION’, ‘TOP’ and ‘ORDER BY’
keywords in the customized SQL, and supporting them in the download-data SQL.
Define synchronization parameters and customized data download SQL
in SAP Mobile WorkSpace using the desired SQL operations. For example,
“TOP”, “>=”, <=” and “ORDER BY”, and deploy the MBO package to
SAP Mobile Server.
For example, the Employee MBO contains three synchronization parameters: topNum,
salary, and startDate along with other attributes. From the Synchronization tab in
the Properties view, you could select Customized download data
and enter this SQL
statement:
SELECT TOP :topNum x.*FROM Employee x WHERE x.start_date >= :startDate
AND x.salary <= :salary ORDER BY x.emp_lname
create a native device application, and specify the synchronization parameters
values to download data to the device. For example:
This downloads the top five records where start_date >= 1989/07/01 and salary
<= 50000.00 to the device. There are 43 records in the sampledb that match the
query:
SELECT x.* FROM Employee x WHERE x.start_date >= ‘1989-07-01’ AND
x.salary <= 50000.00 ORDER BY x.emp_lname
Note: TOP and ORDER BY should always be used together:
Using TOP without ORDER BY results in undetermined returned values.
Using ORDER BY without TOP adds no value since it does not change the data
set to be downloaded.