Defining additional input/output streams
- Last Updated: October 18, 2024
- 4 minute read
- OpenEdge
- Version 12.2
- Documentation
When you start a procedure, the AVM automatically provides
that procedure with input and output streams. As described in the previous
sections, the default source for the input stream is the terminal
and the default destination for the output stream is also the terminal.
You saw how to use the INPUT FROM and OUTPUT TO statements
to redirect these input and output streams.
You might find that having just one input stream and one output stream is not enough for particular procedures. That is, you might want to get input from more than one source at the same time or send output to more than one destination at the same time.
Suppose you want to
produce a report of the items you have in inventory and you want
to send the report to a file. You already know how to use the OUTPUT TO statement
to redirect the output stream to a file. Suppose that you also want
to produce an "exceptions" report at the same time. Any item where
the allocated amount is greater than the on-hand amount is an exception.
The following figure illustrates this scenario.

For items that are exceptions, the procedure needs to send output to a second location. That means you need two different output streams.
You
use the DEFINE STREAM statement
to define additional streams for a procedure to get input from more than
one source simultaneously and send output to more than one destination simultaneously.
Streams you name can be operating system files, printers, the terminal,
or other non-terminal devices.
For information regarding the maximum number of streams allowed in OpenEdge applications, see the Input/Output Limits table in Manage ABL Applications.
For information about the size limit of operating system files, see the input/output limits section of Manage ABL Applications.
The procedure i-dfstr.p uses the two report scenarios shown in the above figure.
i-dfstr.p
|
The numbers on the left of the procedure correspond to the following step-by-step descriptions:
- The
SETstatement prompts you for the filenames you want to use for the Item Inventory Report and for the Item Exception Report. It stores your answers in thefnrandfnevariables, respectively. - The
OUTPUT STREAMstatements open two output streams, namedrptand exceptions. These streams were defined at the start of the procedure with theDEFINE STREAMstatement.The
rptand exceptions streams are directed to the files whose names you supplied:VALUE(fnr)andVALUE(fne). This means that output can now be sent to either or both of those files. - The
DISPLAYstatement displays the text Item Inventory Report. But instead of displaying that text on the terminal, it displays it to therptstream. The file you named for the Item Inventory Report contains the text Item Inventory Report. - This
DISPLAYstatement also displays text but it uses the exceptions stream. The file you named for the Item Exception Report contains the text Item Exception Report. - The
FOR EACHblock reads a single item record on each iteration of the block. - If the allocated amount of an item is larger than the on-hand
amount of that item then:
- The
DISPLAYstatement displays item data to the exceptions stream. After thisDISPLAYstatement finishes, the file you named for the Item Exception Report contains item data for a single item. - The excount counter variable, defined at the start of the procedure, is incremented by 1. The value of this variable is displayed at the end of the procedure so that you know the total number of exception items in inventory.
- The exception logical variable, defined at the start of the
procedure, is set to
TRUE.
- The
- The
DISPLAYstatement displays some item data to therptstream. After this statement finishes, the file you named for the Item Inventory Report contains item data for a single item. - If the item is an exception, determined by the value in the
exception logical variable, the
DISPLAYstatement displays the string "See Exception Report" to therptstream. That way you know, when looking at the Item Inventory Report, which items are exceptions. - The
DISPLAYstatement displays the value of the excount variable to the exceptions stream. The value of this variable is the total number of exception items. - This
DISPLAYstatement displays the value of the excount variable to therptstream. Although theDISPLAYstatement does not explicitly say what is being displayed, it does name the same frame,exc, as is used to display excount in the previousDISPLAYstatement. That means that theexcframe already contains the excount value. Thus, all this secondDISPLAYstatement has to do is name the same frame. - The
OUTPUT STREAM CLOSEstatements close therptand exception streams, redirecting all further output to the default output destination.