ROUTINE-LEVEL ON ERROR UNDO, THROW.
USING acme.myObjs.Common.*. CLASS acme.myObjs.CreditObj: ... METHOD PUBLIC VOID SetCurrentCustomer (INPUT piCustNum AS INTEGER): /* Verify that this object has the current */ /* Customer before the property is referenced */ FIND FIRST Customer WHERE Customer.CustNum = piCustNum NO-ERROR. END METHOD. METHOD PUBLIC VOID CheckCustCredit ( ): /* invokes the CustCreditLimit property SET accessor */ IF AVAILABLE (Customer) THEN CustCreditLimit = Customer.Creditlimit. ELSE UNDO, THROW NEW Progress.Lang.AppError("No Customer"). END METHOD. END CLASS. |
USING acme.myObjs.*.
USING acme.myObjs.Common.*. USING acme.myObjs.Interfaces.*. CLASS acme.myObjs.CustObj INHERITS CommonObj IMPLEMENTS IBusObj: DEFINE PUBLIC VARIABLE iNumCusts AS INTEGER NO-UNDO. DEFINE PROTECTED TEMP-TABLE ttCustomer NO-UNDO FIELD RecNum AS INTEGER FIELD CustNum LIKE Customer.CustNum FIELD Name LIKE Customer.Name FIELD State AS CHARACTER. DEFINE PRIVATE VARIABLE rCreditObj AS CLASS CreditObj NO-UNDO. DEFINE PRIVATE VARIABLE rMsg AS CLASS MsgObj NO-UNDO. ... METHOD PUBLIC VOID CheckCredit ( ): IF VALID-OBJECT (rCreditObj) THEN DO: FOR EACH ttCustomer: rCreditObj:SetCurrentCustomer (ttCustomer.CustNum). rCreditObj:CheckCustCredit ( ). /* invokes the CustCreditLimit property GET accessor */ rMsg:InfoMsg(ttCustomer.Name + " is in good standing." + " Credit Limit has been increased to " + STRING(rCreditObj:CustCreditLimit)). CATCH e AS Progress.Lang.AppError: IF e:ReturnValue = "Over Limit" THEN DO: /* invokes the CustCreditLimit property GET accessor */ rMsg:Alert(ttCustomer.Name + " is on Credit Hold." + " Balance exceeds Credit Limit of " + STRING (rCreditObj:CustCreditLimit)). END. ELSE rMsg:Alert ("Customer not found"). END CATCH. END. /* FOR EACH */ END. ELSE rMsg:Alert ("Unable to check credit"). END METHOD. ... END CLASS. |