Consultor Eletrônico



Kbase P88027: How to set a Dynamics SDO query that cannot be modified by the filter
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/12/2004
Status: Unverified

GOAL:

How to manipulate Dynamics queries

GOAL:

How to manipulate the query of a Dynamic SDO with the available functions and API calls.

GOAL:

How to preserve an SDO query that has been modified by the Filter.

GOAL:

Modifying an SDO query with the Toolbar filter can lose the WHERE clause.

GOAL:

How to permanently set an SDO query

FACT(s) (Environment):

Dynamics

FIX:

There are several different ways that Dynamics SDO queries can be changed using API's and function calls. Which method
is chosen depends on the result that is required, the property that needs to be set, and whether the new query should
be preserved.

To begin with the QueryString property is the primary query property.  When opening the SDO query, QueryString is used.
If QueryString is blank, then the QueryWhere property is used, and if QueryWhere is blank the BaseQuery property is used. The following is a list of API's that can be used to manipulate the dynamic SDO query. The SDO used in the examples
below has a design time base query of:

FOR EACH FOR EACH Order NO-LOCK,
EACH Customer OF Order NO-LOCK,
EACH Salesrep OF Order NO-LOCK
The API's are being executed from the super procedure of a dynamic viewer having obtained the handle of the source SDO. But these could also be used in an InitializeObject override in the SDO Data Logic Procedure.


In addition to the basic query manipulation API's (See solution P86287) there are additional properties that are primarily for
use when Filter functionality is available on the toolbar.  For example with the BrowseToolbar. In these cases the user can
override the base query using the filter functionality, and any query manipulation done with the basic API's can be lost. To
make such manipulation more permanent, the following properties and associated API's are available:

updateAddQueryWhere
manualAddQueryWhere
manualAssignQuerySelection
manualSetQuerySort

For the last three it is useful to set these after modifying the base query functionality with one of the query manipulation API's.
For example, after setting AddQueryWhere, set the manualAddQueryWhere property with the same values.



updateAddQueryWhere - Updates the QueryString, QueryWhere and ManualAddQueryWhere properties.
RUN updateAddQueryWhere IN h_SDO
(INPUT 'Customer.custnum GT 10', INPUT 'Customer.custnum').

Results in QueryString and QueryWhere properties of:
FOR EACH Order NO-LOCK,
EACH Customer OF Order WHERE (Customer.custnum GT 10) NO-LOCK,
EACH Salesrep OF Order NO-LOCK

and a manualAddQueryWhere property of:
Customer.custnum GT '10' + CHR(3)+ CHR(3) + AND

updateAddQueryWhere only supports applying a single WHERE clause.  But it can be
called many times, overwriting the WHERE clause each time.





manualAddqueryWhere - Updates the manualAddQueryWhere property.
cManualAddQueryWhere = "customer.name begins 'B'" +
CHR(3) + "customer" + CHR(3) + "" +
CHR(4) +
"customer.name begins 'C'" + CHR(3) + "customer" + CHR(3) + "OR".

DYNAMIC-FUNCTION(setmanualAddqueryWhere IN h_SDO,
cManualAddQueryWhere).

Results in a manualAddqueryWhere property of:
customer.name begins 'B' + CHR(3) + customer + CHR(3) +
CHR(4) customer.name begins 'C' + CHR(3) + customer + CHR(3) + OR



This would preserve the SDO query as:
FOR EACH Order NO-LOCK,
EACH Customer OF Order WHERE
(customer.name begins 'B') OR (customer.name begins 'C') NO-LOCK,
EACH Salesrep OF Order NO-LOCK




manualAssignQuerySelection - Updates the manualAssignQuerySelection property.
cMAQS = "customer.name" + CHR(3) + "B" + CHR(3) + "BEGINS"
+ CHR(4) +
"customer.custnum" + CHR(3) + "1473" + CHR(3) + "="
+ CHR(4) +
"customer.salesrep" + CHR(3) + "BBB" + CHR(3) + "=".
DYNAMIC-FUNCTION(setmanualAssignQuerySelection IN h_SDO,
cMAQS).

Results in a manualAssignQuerySelection property of:
customer.name + CHR(3) + B + CHR(3) + BEGINS + CHR(4) +
customer.custnum + CHR(3) + 1473 + CHR(3) + = + CHR(4) +
customer.salesrep + CHR(3) + BBB + CHR(3) + =

This would preserve the SDO query as:
FOR EACH Or.der NO-LOCK,
EACH Customer OF Order WHERE
(customer.name BEGINS 'B') AND
(customer.custnum = '1473') AND
(customer.salesrep = 'BBB') NO-LOCK,
EACH Salesrep OF Order NO-LOCK




manualSetQuerySort - Updates the manualSetQuerySort property.
DYNAMIC-FUNCTION(setmanualSetQuerySort IN h_SDO,"Customer.Address").

Results in a manualSetQuerySort property value of:
Customer.Address..