Previous Topic: Passing Data to a SubprogramNext Topic: Requirements for Subprograms


Executing a Subprogram Asynchronously

In the previous example, the user was notified to press PF5 for a report. Producing reports can be a time-consuming task, and you might want to run the report program asynchronously. This way, the user can proceed to other tasks online while the report is produced. To execute a subprogram asynchronously, use the INITIATE statement instead of the CALL statement.

In the next example, the PF5 key prints the report of outstanding orders for a back-ordered product.

<<PROCESS-INCOMNG>> PROCEDURE
  TRANSMIT INCOMING
  SELECT FIRST ACTION
    WHEN $PF3
      QUIT PROCEDURE
    WHEN $PF5
      INITIATE PRNT-ORD USING INPUT INCOMING.ITEM-ID
    WHEN $ENTER-KEY
      DO UPDATE-ITEM
    WHEN NONE
      DO BAD-KEY
  ENDSEL
ENDPROC

The PRNT-ORD program uses the ITEM-ID entered on the panel INCOMING to find the orders that could not be filled because they included that item. Meanwhile, the user can continue with the next incoming item.