You can use the RELEASE and ASSIGN statements in the program code to split the customer report into different files for each state. The following code segment releases the current report, CUSTRPT, and assigns the output to another file and output destination before obtaining the next set of customers.
The sub procedure GETSTATE uses a table to set the variable STNAME to the name of the state and DDNAME to the name of an output file. The value of STNAME is the base (for example, IDLRTX is generated for Texas). DDNAME corresponds to an output file named in the z/OS JCL or as a VSE DLBL, depending on the operating system.
In this example, the value of STNAME is used in the WHERE criteria on the FOR construct. A flag, NOMORE, is set to true in the subprocedure GETSTATE when the table is exhausted. This terminates the LOOP processing.
<<CUST‑RPT>> PROCEDURE
SET NOMORE = FALSE
LOOP
DO GETSTATE
UNTIL NOMORE
ASSIGN REPORT CUSTRPT TO DDNAME
FOR EACH CUSTOMER
WHERE CUSTOMER.STATE EQ STNAME
MOVE CUSTOMER TO CUST‑INQ BY NAME
PRODUCE CUSTRPT
WHEN NONE
LIST $STRING('NO CUSTOMERS IN ',STNAME,'ON FILE')
ENDFOR
RELEASE REPORT CUSTRPT
ENDLOOP
ENDPROC
The report is assigned before executing the PRODUCE statement. The report is released when there is no more data for the current report. The next execution of the PRODUCE statement sends the output to the next assigned output file.
|
Copyright © 2015 CA Technologies.
All rights reserved.
|
|