Consultor Eletrônico



Kbase P147505: LAST-OF function returns unexpected value
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   04/06/2009
Status: Unverified

SYMPTOM(s):

LAST-OF function returns unexpected value

LAST-OF returns TRUE for a field whose value has not changed

FACT(s) (Environment):

Multiple fields in BREAK BY list.
All Supported Operating Systems
Progress/OpenEdge Product Family
OpenEdge Category: Language (4GL/ABL)

CAUSE:

This is expected behavior. When there is more than one field in the BREAK BY phrase in a query, the LAST-OF function returns true not only for the field whose value changes but also for all fields listed to the right of that field in the BREAK BY phrase. Many people think that the LAST-OF function should only return true for each field in the BREAK BY phrase when the value for that field changes (without regards to any of the other fields listed in the BREAK BY phrase). This belief is incorrect.
For example, consider the following data and query:
Cust-Name Sales-Rep
========= =========
ABC Co. GRF
ABC Co. SLS
NOP Co. SLS
FOR EACH CustInfo BREAK BY Cust-Name BY Sales-Rep:
DISPLAY Cust-Name LAST-OF(Cust-Name) Sales-Rep LAST-OF(Sales-Rep).
END.
The results of the query are:
Cust-Name LAST-OF(Cust-Name) Sales-Rep LAST-OF(Sales-Rep)
========= ================== ========= ==================
ABC Co. No GRF Yes
ABC Co. Yes SLS Yes
NOP Co. Yes SLS Yes


FIX:

Consider all fields in the BREAK-BY phrase when using the LAST-OF function. The results of LAST-OF with multiple BREAK-BY fields are only meaningful if the field values are considered as groups, nested by field as the fields are listed left-to-right.