Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

FetchDataByKeyTable

The method FetchDataByKeyTable is implemented as an Invokable Method and requires the two usual parameters Dataset Handle and a  parameter object that implements the IFetchDataByKeyTableParameter interface.

The IFetchDataByKeyTableParameter Object

 The IFetchDataByKeyTableParameter parameter object contains two properties allowing PUBLIC GET access.

Property Name
Description
TablesThis property is used to return a comma delimited list of Tables
KeyValueTableHandleThis property is used to return the handle of the temp-table containing the key values


The

Dataset Handle

The Dataset Handle should be a reference to the Dataset that you wish to query against.

The FetchDataByKeyTable Method expects an object that exposes a temp-table containing a single record per key-value combination. Internally, the Default Query for your Business Entity subsequently performs a Join using the ‘Object’ to return only the records matching those specified within the temp-table.

The Dataset Handle

The Dataset Handle should be a reference to the Dataset that you wish to query against.


Example Usage

Outlined below is an example on how to implement the FetchDataByKeyTable Method. The example shall be based on a OrderLine Business Entity.

First, we shall need to create an appropriate Parameter Object Class relevant to the Business Entity in hand.

 

Code Block

Implementation of an FetchOrderLineParameter class:

Code Block
titleSample FetchOrderLineparameter Implementation
CLASS /classpath/.FetchOrderLineParameter
      IMPLEMENTS IFetchDataByKeyTableParameter:

      DEFINE TEMP-TABLE ttOrderLineFilter NO-UNDO
          FIELD OrderNum AS INTEGER
          FIELD LineNum AS INTEGER .
      /*------------------------------------------------------------------------------
           Purpose:
           Notes:
      ------------------------------------------------------------------------------*/
      DEFINE PUBLIC PROPERTY KeyValueTableHandle AS HANDLE NO-UNDO
      GET:
            RETURN TEMP-TABLE ttOrderLineFilter:HANDLE .
      END GET.
      /*------------------------------------------------------------------------------
           Purpose:
           Notes:
      ------------------------------------------------------------------------------*/
      DEFINE PUBLIC PROPERTY Tables AS CHARACTER NO-UNDO
      GET.
      SET.
     /*------------------------------------------------------------------------------
          Purpose: Clears the filter values
          Notes:
     ------------------------------------------------------------------------------*/
    METHOD PUBLIC VOID ClearEntries ():
          EMPTY TEMP-TABLE ttOrderLineFilter .
    END METHOD.
    /*------------------------------------------------------------------------------
          Purpose: Creates a record in the filter values temp-table
          Notes:
     ------------------------------------------------------------------------------*/
    METHOD PUBLIC VOID CreateOrderLineEntry (piOrderNum AS INTEGER,
                                             piLineNum AS INTEGER):
         CREATE ttOrderLineFilter .
         ASSIGN ttOrderLineFilter.OrderNum = piOrderNum
                       ttOrderLineFilter.LineNum = piLineNum .
    END METHOD.
END CLASS.

 

How to Invoke the FetchDataByTableKey method:

Code Blockcode
titleSample Invoke of the method FetchDataByTableKey
DEFINE VARIABLE oParameter AS FetchOrderLineParameter NO-UNDO .

oParameter = NEW FetchOrderLineParameter () .
oParameter:Tables = "eOrderLine,eItem" .
oParameter:CreateOrderLineEntry (1, 1) .
oParameter:CreateOrderLineEntry (1, 2) .
oParameter:CreateOrderLineEntry (1, 3) .
oParameter:CreateOrderLineEntry (2, 1) .
oParameter:CreateOrderLineEntry (2, 2) .
ServiceInterface:InvokeMethod (GET-CLASS (OrderLineBusinessEntity):TypeName,
 							   "FetchDataByKeyTable",
							   INPUT-OUTPUT DATASET dsOrderLine,
							   oParameter) .