Error 91 has been driving me ccraazzzyy all afternoon.... **No srnames record is available. (91)
can you spot my error???
/*------------------------------------------------------------------------------
Purpose: Checks the values of tt-lognumber, sets cErrorMsg if there's a problem
and returns true if OK, and false if errors found
Parameters: IN-OUT table tt-lognumber
OUT pl-OK
------------------------------------------------------------------------------*/
DEFINE INPUT-OUTPUT PARAMETER TABLE FOR tt-lognumber.
DEFINE OUTPUT PARAMETER pl-ok AS LOGICAL NO-UNDO.
FOR EACH tt-lognumber NO-LOCK:
DISPLAY tt-lognumber.kaccount tt-lognumber.knote.
END.
/* find db records to check everything exists */
FOR EACH tt-lognumber NO-LOCK:
/* opworder */
FIND opworder WHERE opworder.kco = 1
AND opworder.kdoctype = "w"
AND opworder.knote = tt-lognumber.knote
NO-LOCK NO-ERROR.
IF AVAIL opworder THEN
pl-ok = YES.
ELSE tt-lognumber.cErrorMsg = "Order Not Found".
/* SrName */
FIND SrName WHERE srName.kdaccount = tt-lognumber.kAccount
NO-LOCK NO-ERROR.
IF AVAIL SrName THEN
pl-ok = YES.
ELSE tt-lognumber.cErrorMsg = "Account Not Found".
/*opgohead */
FIND opgohead WHERE opgohead.kco = opworder.kco
AND opgohead.kdoctype = opworder.kdoctype
AND opgohead.knote = opworder.knote
NO-LOCK NO-ERROR.
IF AVAIL opgohead THEN
pl-ok = YES.
ELSE tt-lognumber.cErrorMsg = "opgohead Not Found"
END.
END PROCEDURE.