Accessing Database Records

  1. Set the D@ key fields as you would for any database inquiry routine.
  2. Express the ending value for the range key:

    EVAL D#END#<FieldName> = <identifier>

  3. Identify the range key by setting E@DBSUBRNG to a number that represents the position of the key field in the index.

    EVAL E@DBSUBRNG = <IndexPosition>

  4. Initialize the aggregation request.

    CALLP U@DB@AGINIT(D<Prefix>@@HANDLE: %ADDR(DA@<Logical>))

  5. Set the fields to aggregate and what function to apply.

    CALLP U@DB@AGSET(DGAM@@HANDLE: DA@DBGLGAM2:

    'SUM': 'CR-AMOUNT ': I2:

    %ADDR(DGAM#AG#CRAMNT(I2)):

    %ADDR(DGAM#SU#CRAMNT(I2)))

  6. Submit the request:

    CALLP DS@DB<Logical>(E@DBAGGREGATE)

  7. Test for function validity by checking the D<Prefix>@NOTFOUND variable.

    IF D<Prefix>@NOTFOUND = FALSE

  8. Un-reference the return values in the fields named D<Prefix>#AG#<FieldName>:

    Z-ADD D<Prefix>#AG#<FieldName> = <StorageField>