Applicable Versions: 2.01.0152 Onwards



DataPA allows you to call Progress ABL functions that generate a temp table to provide data for your reports, queries and dashboard, see Can I create a query that runs a Progress function on the server to retrieve data? for details. Your business logic needs to be exposed as a function, rather than a procedure, because functions provide a consistent interface where the temp table is returned as a handle return value of the function. A procedure does not have any specific input our output parameters, so for DataPA to provide a single generic routine to cope with any procedure call is virtually impossible. The DYNAMIC-FUNCTION method in Progress gives DataPA much more flexibility, and allows the product to cope with a wide range of signatures with a single generic routine.


This does not however mean you have to change any existing business logic from a procedure to a function in order to use it from DataPA. We can simply create a wrapper procedure, that exposes your business logic as a function. For example, take the case that I have a procedure, called CreateOrders.p. The procedure has the following definitions section;


DEFINE TEMP-TABLE ttOrders LIKE Order. 


DEFINE INPUT PARAMETER iCustNum AS INTEGER NO-UNDO.
DEFINE OUTPUT PARAMETER TABLE FOR ttOrders.


The remaining code in the procedure populates the temp-table with the appropriate orders, and is not relevant to this example. If I want to call this procedure from DataPA, I can simply create a wrapper procedure that includes a function designed to call my existing procedure. For example;


DEFINE TEMP-TABLE ttOrders LIKE Order.

FUNCTION CustomerOrders RETURNS HANDLE (INPUT iCustNum AS INTEGER):
  RUN CreateOrders(INPUT iCustNum, OUTPUT TABLE ttOrders).
  RETURN TEMP-TABLE ttOrders:HANDLE.
END FUNCTION.


This code is placed in a procedure and added to the super procedure stack as in Can I create a query that runs a Progress function on the server to retrieve data?. Depending on how consistent the signatures of your business logic procedures and temp-tables are, it is possible to extend this approach to produce a number of generic functions that can call any number of business logic routines to provide data for DataPA. For example,  the following function could run any procedure that took an integer as an input parameter and returned a handle of a temp-table;


FUNCTION CustomerData RETURNS HANDLE
  (INPUT iCustNum AS INTEGERINPUT cProcedure AS CHARACTER):
  DEFINE VARIABLE returnHandle AS HANDLE NO-UNDO.
  RUN VALUE(cProcedure) (INPUT iCustNum, OUTPUT returnHandle).
  RETURN returnHandle.
END FUNCTION.