/* h-CustSample.p — shows a few things about ABL */
DEFINE VARIABLE cMonthList AS CHARACTER NO-UNDO INITIAL "JAN,FEB,MAR,APR,MAY,JUN,JUL,AUG,SEP,OCT,NOV,DEC". DEFINE VARIABLE iDays AS INTEGER NO-UNDO. /* First display each Customer from New Hampshire: */ FOR EACH Customer NO-LOCK WHERE Customer.State = "NH" BY Customer.City: DISPLAY Customer.CustNum Customer.Name Customer.City. /* Show the Orders unless CreditLimit is less than twice the balance. */ IF Customer.CreditLimit < (2 * Customer.Balance) THEN DISPLAY "Credit Ratio:" Customer.CreditLimit / Customer.Balance. ELSE FOR EACH Order OF Customer NO-LOCK: DISPLAY Order.OrderNum LABEL "Order" Order.OrderDate Order.ShipDate FORMAT "99/99/99" WITH CENTERED. /* Show the month as a three-letter abbreviation, along with the number of days since the order was shipped. */ IF Order.ShipDate NE ? THEN DISPLAY ENTRY(MONTH(Order.ShipDate), cMonthList) LABEL "Month". RUN calcDays (INPUT Order.ShipDate, OUTPUT iDays). DISPLAY iDays LABEL "Days" FORMAT "ZZZ9". END. END. PROCEDURE calcDays: /* This calculates the number of days since the Order was shipped. */ DEFINE INPUT PARAMETER pdaShip AS DATE NO-UNDO. DEFINE OUTPUT PARAMETER piDays AS INTEGER NO-UNDO. piDays = IF pdaShip = ? THEN 0 ELSE TODAY - pdaShip. END PROCEDURE. |