Users of business applications could potentially at some point require the ability to search for data using ROWID values. This article highlights and demonstrates how data can be retrieved using ROWID values.
ROWID within the SmartBusinessEntityAdapter QueryString
The simplest method would be to build a "QueryString" using a ROWID value. An example usage of a ROWID within the SmartBusinessEntityAdapter QueryString statement is given below:
It should be noted that the BusinessEntity contains ProDataSet Temp-Tables which are a representation of Database Tables (and NOT physical Database Tables). Therefore, whilst building the QueryString, it should be noted that the "rowid(……)" construct should contain the actual Database Table Name. In addition, as the QueryString is character based, it should always be remembered to use the "to-rowid" function to return a true ROWID value.
ROWID as a calculated field in the Business Entity
The following describes how we can use a ROWID Calculated Field on our Business Entity.
First, we create a Calculated field named "CustomerRowid" on our Customer Business Entity:
We specify the Data Type as "ROWID" and in the Source Field we use the statement "ROWID(Customer)".
Note: As we have tagged the Source Field as ROWID(Customer), the field value shall be populated automatically on the FILL Method, so there is no need to specify any Calculated Field Expression.
When filtering data on a Business Entity Calculated Field, we need to first determine whether we are going to be filtering Client or Server Side.
Client Side Filtering
If we perform a FetchData on our Customer Business Entity, we know that on each record returned, the calculated field shall be populated accordingly. Therefore, it is also possible to perform a Query on the data already contained within our SmartBusinessEntityAdapter.
An example usage of a ROWID within a prepopulated SmartBusinessEntityAdapter is given below:
The first section defines our SmartBusinessEntityAdapter and prepopulates the Adapter with 200 records.
The second section shows how to query our current Adapter using the "FindRowWhere" method:
The above code snippet is ideal if we know that the data we are filtering on exists within our Adapter's Dataset content.
Server Side Filtering
However, it may well be the case that we would be required to perform a Server Side Filter as we could not guarantee that the data required has of yet been retrieved. For example, our initial query could be based on our "CustomerRowid".
Performing a Server Side Query on the Calculated field "CustomerRowid" initially would fail, due to the fact, that we would be attempting to Filter on data that has not yet been initialised. Therefore, we would be required to Override our "FetchData" method to facilitate Queries on calculated fields ("CustomerRowid").
Within our CustomerDataAccess Class, we select the option to insert an override method for FecthData:
Within the "OVERRIDE PUBLIC VOID FetchData" method, we need to construct code that manipulates the Query before calling "SUPER:FetchData(INPUT poFetchDataRequest)".
The FetchData use case is given below:
The above code use-case is extracting the query expression and storing that query into a temporary string variable.
We are then checking to see if the query contains the Progress Function "TO-ROWID", if so, we know that the query is based on our Calculated Field. We subsequently proceed in replacing Progress Function "TO-ROWID" with an empty string. This is done to avoid the Query Parser parsing and segmenting "TO-ROWID" as another filter block option (e.g EQ, BEGINS). Once we have performed our pre-initial operation, we proceed by checking if the Query expression contains our "CustomerRowid" calculated field. If it does, then we manipulate the query to read as our SmartBusinessEntityAdapter QueryString example.
Note: we are basically replacing the relevant "CustomerRowid" segment of the Query.
Once we have manipulated our Query, we then simply assign the Query back into our FetchDateRequest object.
An example use case for Server Side Filtering is given below: