Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development

> ## Testing the completed business logic procedure

> The following code sample is the complete business logic procedure:

>     PROCEDURE ShowAvailCredit:
>     /*-------------------------------------------------------------------------
>       Purpose: Retrieves the Credit Limit from the server and displays it viewer.
>     -------------------------------------------------------------------------*/
>     DEFINE VARIABLE hDataSource  AS HANDLE     NO-UNDO.
>     DEFINE VARIABLE cFieldNames  AS CHARACTER  NO-UNDO.
>     DEFINE VARIABLE cFieldHandles AS CHARACTER  NO-UNDO.
>     DEFINE VARIABLE ilookup      AS INTEGER    NO-UNDO.
>     DEFINE VARIABLE hField       AS HANDLE     NO-UNDO.
>     DEFINE VARIABLE iKeyNum      AS INTEGER    NO-UNDO.
>     DEFINE VARIABLE cKeyType     AS CHARACTER  NO-UNDO.
>     DEFINE VARIABLE dAvailCredit AS DECIMAL    NO-UNDO.
>       {get AllFieldNames   cFieldNames}.
>       {get AllFieldHandles cFieldHandles}.
>       hDataSource = DYNAMIC-FUNCTION('getDataSource':U IN TARGET-PROCEDURE).
>       hDataSource = DYNAMIC-FUNCTION('getDataSource':U IN hDataSource).
>       IF VALID-HANDLE (hDataSource) THEN
>           ASSIGN cKeyType = "CustNum"
>                  iKeyNum = INTEGER(DYNAMIC-FUNCTION
>                          ('columnStringValue':U IN hDataSource, "CustNum":U)).
>       ELSE
>           ASSIGN ilookup = LOOKUP("OrderNum", cFieldNames)
>                  hField = WIDGET-HANDLE(ENTRY(ilookup, cFieldHandles))
>                  iKeyNum = INTEGER(hField:SCREEN-VALUE)
>                  cKeyType = "OrderNum".
>       {dynlaunch.i &PLIP = 'oe/customerplip.p'
>                  &IProc = 'AvailCredit'
>                  &mode1 = INPUT   &parm1=’cKeyType’     &dataType1 = CHARACTER
>                  &mode2 = INPUT   &parm2=’iKeyNum’      &dataType2 = INTEGER
>                  &mode3 = OUTPUT  &parm3=’dAvailCredit’ &dataType3 = DECIMAL
>       }
>       {checkerr.i &display-error = YES &return-only = YES}
>       ASSIGN ilookup = LOOKUP("AvailCredit", cFieldNames)
>              hField = WIDGET-HANDLE(ENTRY(ilookup, cFieldHandles))
>              hField:SCREEN-VALUE = STRING(dAvailCredit).
>     END PROCEDURE.

> | To try out the finished application window:

> 1. Launch orderbrowsewin and select an order, as shown:

> 2. Double-click on the order to bring up orderfoldwin, as shown:

> Remember that some of the links you defined in the Container Builder set up a connection from the browse window to the maintenance window. These are the links that have `THIS-OBJECT` (the maintenance window) as the source for the link. These pass-through links allow the `Order` data to be retrieved and displayed by the `Order` viewer on Page 1, and also allow the `OrderLine` SDO on Page 2 to retrieve the `OrderNum` to use for filtering its own query.

> 3. Select Page 2. Then select the Available Credit field you created and tab out of it. The `Leave` trigger fires, which runs `showAvailCredit` in the viewer’s custom super procedure `orderlinsuper.p`. This, in turn, runs `AvailCredit` in the `customerplip.p` procedure, which returns the `Customer.CreditLimit` for display, as shown:

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095