Try OpenEdge Now
skip to main content
Programming Interfaces
Input/Output Processes : Creating Reports : Redirecting output : Directing output to multiple destinations
 
Directing output to multiple destinations
ABL lets you specify multiple output destinations in a single procedure. You can use OUTPUT TO several times in a single procedure to direct the output to different destinations. You can also define named streams so you can output to several destinations.
First, you use the DEFINE STREAM statement to create the streams you need. This is a partial syntax for DEFINE STREAM:

Syntax

DEFINE STREAM stream-name
To output to the stream, you reference it in your output statement with the keyword STREAM, as shown in the following example:
/*1*/ DEFINE STREAM sToFile.

/*2*/ OUTPUT TO PRINTER.
/*3*/ OUTPUT STREAM sToFile TO "tut-temp.txt".

FOR EACH Customer NO-LOCK:
/*4*/   DISPLAY Customer.Name Customer.Balance WITH STREAM-IO.
/*5*/   DISPLAY STREAM sToFile Customer.Name Customer.Balance WITH STREAM-IO.
      END.

/*6*/ OUTPUT CLOSE.
/*7*/ OUTPUT STREAM sToFile CLOSE.
The notes below describe how the code works:
*When the procedure starts, it has a default unnamed stream that outputs to the screen by default. This statement establishes a second stream that also outputs to the screen by default. Both streams are now available for the life of the procedure.
*This OUTPUT TO statement redirects the unnamed stream to the default printer.
*This OUTPUT TO statement redirects the named stream to output to a file.
*The first DISPLAY statement outputs to the unnamed stream only.
*The second DISPLAY statement outputs to the named stream only.
*This OUTPUT CLOSE statement redirects the default stream back to the screen.
*This OUTPUT CLOSE statement redirects the named stream back to the screen.