Consultor Eletrônico



Kbase P32928: How to trap invalid date input to prevent the standard Progress invalid date message in a SDV
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   12/11/2010
Status: Verified

GOAL:

How to trap invalid date input to prevent the standard Progress invalid date message in a SDV

GOAL:

How to programmatically validate input into a DATE fill-in in a SmartDataViewer

FACT(s) (Environment):

Windows
Progress 9.x
OpenEdge 10.x

FIX:

In order to achieve you should read the value at screen level before the updateRecord is run. Therefore this has to be implemented on an override of the updateRecord on the SmartDataViewer.
This override sample has been developed on promisedate field of the order table on sports2000 database:
*------------------------------------------------------------------------------
Purpose: Super Override of updateRecord
Parameters:
Notes:
------------------------------------------------------------------------------*/

/* Code placed here will execute PRIOR to standard behavior. */

DEFINE VARIABLE cAllFieldsHandles AS CHARACTER NO-UNDO.
DEFINE VARIABLE hMyFieldHandle AS HANDLE NO-UNDO.
DEFINE VARIABLE cMyFieldName AS CHARACTER NO-UNDO.
DEFINE VARIABLE cDisplayedFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.

DEFINE VARIABLE charDate AS CHARACTER NO-UNDO.
DEFINE VARIABLE myDate AS DATE NO-UNDO.

ASSIGN
cMyFieldName = "promiseDate"
cDisplayedFields = DYNAMIC-FUNCTION('getDisplayedFields':U IN THIS-PROCEDURE)
iCounter = LOOKUP ( cMyFieldName, cDisplayedFields )
cAllFieldsHandles = DYNAMIC-FUNCTION('getFieldHandles':U IN THIS-PROCEDURE)
hMyFieldHandle = WIDGET-HANDLE(ENTRY(iCounter, cAllFieldsHandles)).

charDate = hMyFieldHandle:SCREEN-VALUE.

myDate = DATE (charDate) NO-ERROR.
/*if charDate is not a valid date format ->
ERROR-STATUS:ERROR = yes */

IF ERROR-STATUS:ERROR THEN
MESSAGE "Promise date not valid. Abort update"
VIEW-AS ALERT-BOX INFO BUTTONS OK.
ELSE RUN SUPER.