Kbase P17268: How to check if all fields in a record have been entered ?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  3/10/2003 |
|
Status: Unverified
GOAL:
How to check if all fields in a record have been entered ?
GOAL:
How to check if all the fields in a record have a value, regardless of record layout, for validation purposes ?
FACT(s) (Environment):
Progress 9.x
FIX:
In Progress version 9, the buffer object and buffer-field object were introduced.
Using these objects, it is possible to access each field of any record separately. The value of this field can then be checked, and action can be taken if the field is empty.
The following example code demonstrates this:
Assumed:
- There is a connection to a Sports database.
- A field is empty when it's value is UNKNOWN ("?").
/* CheckRecord function */
FUNCTION CheckRecord RETURNS LOGICAL
(INPUT hBuffer AS HANDLE):
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.
DEFINE VARIABLE lIncomplete AS LOGICAL NO-UNDO.
IF NOT hBuffer:AVAILABLE THEN RETURN ERROR. /* no record in buffer = error */
DO iCounter = 1 TO hBuffer:NUM-FIELDS:
IF hBuffer:BUFFER-FIELD(iCounter):BUFFER-VALUE = ? THEN
lIncomplete = YES. /* any unknown value means record is incomplete */
END.
RETURN lIncomplete.
END FUNCTION.
/* --- main block --- */
DEFINE VARIABLE hTest AS HANDLE NO-UNDO.
hTest = BUFFER customer:HANDLE.
/* no record */
MESSAGE checkrecord(hTest) VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* complete record */
FIND FIRST customer.
MESSAGE checkrecord(hTest) VIEW-AS ALERT-BOX INFO BUTTONS OK.
/* incomplete record */
customer.comments = ?.
MESSAGE checkrecord(hTest) VIEW-AS ALERT-BOX INFO BUTTONS OK.
customer.comments = "This customer is on credit hold.".
/* other table works too */
hTest = BUFFER order:HANDLE.
FIND FIRST order.
MESSAGE checkrecord(hTest) VIEW-AS ALERT-BOX INFO BUTTONS OK.