Consultor Eletrônico



Kbase P131746: How to return multiple object handles from an object method in the ABL?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

How to return multiple object handles from an object method in the ABL?

GOAL:

How to set the return type of a class method to return multiple object references?

GOAL:

Is it possible to return an array of object references in the ABL?

FACT(s) (Environment):

OpenEdge 10.x
All Supported Operating Systems

FIX:

As of this writing, it is not possible to define an array (EXTENT) of object references in the ABL.
As a workaround the following designs are possible:
1) use a temp-table OUTPUT parameter.
In this model, the scenario is as follows:
1a. the caller provides a temp-table handle as an OUTPUT parameter to the method.
1b. The method then populates this temp-table with the list of handles.
1c. The caller can then use the contents of the temp-table.
2) return a handle to a dynamically-allocated temp-table.
In this model, the scenario is as follows:
2a. The method dynamically allocates a temp-table (CREATE), then creates a single column of the appropriate object type
2b. The method populates the dynamic temp-table with the list of handles to be returned
2c. The method returns the handle to the temp-table
2d. the caller uses the data in the dynamic temp-table, then deletes the temp-table. (DELETE)
3) create a custom "collection" class.
In this model a new class in would be created in the application, which purpose would be to simply store a list of handles. This class could have the following interface:
Add(INPUT ref AS Progress.Lang.Object)
NumEntries() AS INTEGER
Get(INPUT index AS INTEGER) AS Progress.Lang.Object
and then the scenario would be as follows:
3a. The method dynamically creates a "collection" object
3b. The method populates the collection object
3c. The method returns the collection object (as 1 reference)
3d. The caller uses the collection then DELETEs it.
4) return a string (CHAR or LONGCHAR) containing comma-separated decimal representation of handles.
In this scenario the result type is CHAR/LONGCHAR and the scenario is as follows:
4a. The method creates a string with all the handles separated by commas
4b. The caller receives the string then splits the string with the NUM-ENTRIES and ENTRY functions.