The ASSIGN statement is executes in the program to change the output destination based on runtime conditions.
For example, assume that an application was created that writes a report CUSTRPT. This application is available to several users at different locations. To ensure that each user's request for the report prints at a location available to the user, the ASSIGN statement is used.
For this example, assume that a table named USERS is defined to contain the user identification number and the identification number of the local printer available to that user. The following is a sample of the data in the table:
|
USERID |
PRINTED |
|---|---|
|
BROWN |
PNP1 |
|
JONES |
PDL2 |
|
SMITH |
PRS8 |
When the user requests the report, the program retrieves the printer identification number based on the value of $USER‑ID (a function that returns the current user identification number) and sets a working data variable, PRINTID. The program code contains the following:
FOR FIRST USERS
WHERE USERS.USERID EQ $USER‑ID
SET PRINTID = USERS.PRINTID
ENDFOR
ASSIGN REPORT CUSTRPT DESTINATION NETWORK PRINTID
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|