Consultor Eletrônico



Kbase P146638: 4GL/ABL: What are the unknown values returned by the ACCUM function?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   20/05/2009
Status: Unverified

GOAL:

4GL/ABL: What are the unknown values returned by the ACCUM function?

GOAL:

When does the ACCUM function return unknown values?

GOAL:

How to use the ACCUM function to generate the absolute MINIMUM value or the absolute MAXIMUM value for a 4GL data type?

FACT(s) (Environment):

All Supported Operating Systems
Progress 6.x
Progress 7.x
Progress 8.x
Progress 9.x
OpenEdge 10.x

FIX:

The unknown values are returned by the ACCUM function when an ACCUMULATE is done on an empty loop. These unknown values are not your standard 4GL/ABL unknown values. Consequently, they do not compare EQUAL to the familiar 4GL/ABL unknown value.
Although these values display as a "?", they are the absolute MINIMUM value and / or the absolute MAXIMUM value for the data type of the field or expression of the ACCUMULATE statement.
To generate the absolute MAXIMUM value for a 4GL/ABL data type, do an ACCUMULATE (MINIMUM) on an empty loop using a field or an expression of that data type. For example, the following code generates the absolute MAXIMUM 4GL/ABL DATE value possible. Note that although the value is unknown and is not equal to the 4GL/ABL standard ? unknown value, it compares GREATER than any 4GL/ABL DATE value possible:
DEFINE VARIABLE dAbsoluteMaximumDateValue AS DATE NO-UNDO.
DEFINE TEMP-TABLE ttOrder NO-UNDO
FIELD ShipDate AS DATE.
FOR EACH ttOrder NO-LOCK:
ACCUMULATE ttOrder.ShipDate (MINIMUM).
END.
ASSIGN
dAbsoluteMaximumDateValue = ACCUM MINIMUM (ttOrder.ShipDate ).
/* The resulting value is greater than any possible 4GL DATE value. For example: 12/31/9999 */
MESSAGE
dAbsoluteMaximumDateValue "~n"
dAbsoluteMaximumDateValue = ? "~n"
dAbsoluteMaximumDateValue GT 12/31/9999
VIEW-AS ALERT-BOX INFO BUTTONS OK.
Conversely, doing an ACCUMULATE (MAXIMUM) on an empty loop causes the ACCUM MAXIMUM function to return the absolute MINIMUM value for the data type of the field or expression listed in the listed in the ACCUMULATE statement. For example, the following code defines the absolute MINIMUM 4GL/ABL INTEGER value possible which compares LESS than the smallest valid 4GL/ABL INTEGER value of -2147483648:
DEFINE VARIABLE dAbsoluteMinimumIntegerValue AS INTEGER NO-UNDO.
DEFINE TEMP-TABLE ttOrder NO-UNDO
FIELD iField AS INTEGER.
FOR EACH ttOrder NO-LOCK:
ACCUMULATE ttOrder.iField (MAXIMUM).
END.
ASSIGN
dAbsoluteMinimumIntegerValue = ACCUM MAXIMUM (ttOrder.iField ).
/* The resulting value is less than the least valid 4GL INTEGER value: -2147483648 */
MESSAGE
dAbsoluteMinimumIntegerValue "~n"
dAbsoluteMinimumIntegerValue = ? "~n"
dAbsoluteMinimumIntegerValue LT -2147483648
VIEW-AS ALERT-BOX INFO BUTTONS OK.