There are those occasions when control cards need to be rendered dynamically before subsequent processing via clist or rexx exec. The balance of this article delves into idiosyncrasies of dynamically generating control card within clist (or rexx).
PROC 0 RPDS(AB.AB0069.CNTL) CMEM(XXZZ) ABMEM(AB15032) DELALL(N) + VIEW(Y) FREE FI(CTLCD) ALLOC FI(CTLCD) DA('&RPDS.(&CMEM.)') SHR OPENFILE CTLCD OUTPUT SET &CTLCD = &STR(-SEL )&ABMEM. PUTFILE CTLCD IF &DELALL = N THEN GOTO E00 SET &CTLCD = &STR(-DEL ALL) PUTFILE CTLCD E00: CLOSFILE CTLCD IF &VIEW = N THEN GOTO E01 ISPEXEC BROWSE DATASET('&RPDS.(&CMEM.)') E01: EXIT
In our example we are generating control cards to be used as input to CA Librarian. The general format of those control cards begins with a minus sign followed by a subcommand such as SEL followed by a space and possible some parameters.
This presents our first hurdle to successfully negotiate. In a clist all variables are scanned and any math (‘-‘) operation is resolved and the processing continues.
Since we do not desire evaluation of the minus sign in this case we would use the &str variables which turns off evaluation of the string contained within the &str variable.
Now that we have successfully relaxed the math evaluation of the control card we can continue to complete the balance of the control card.
Now let’s examine the clist further. Notice there are positional parameters in this example that establishes default values.
rpds – output partitioned data set
cmem – output member name
abmem – librarian member to act upon
delall – specifies inclusion of the delete all line control card
view – specifies browse options of generated output control cards
In a typical production environment the values for the variables would be supplied from the variable pools populated by a previously executed dialog management facility.
The ctlcd file allocation specification is used as the file to act upon.
The openfile command opens file ctlcd for output.
The set &ctlcd statement populates the output buffer with the desired content to be added to the file.
The putfile statement write the contents to the file.
The closefile command closes the output file.
The delall variable indicates whether or not to generate the delete all lines control card. If the delete all lines card is to be generated the output buffer is populated and the content is added to the file by issuing a subsequent putfile command.
The final function of the clist is to display the generated output in the ISPF browser faciliy. This is just a nicety for the developer which allows inspection of the generated control cards.
As previously stated in a production environment this clist would be modified to facilitate seamless generation of control cards and in most cases the browse feature would remain relaxed after inital design and debugging.
Mr. Arch Brooks, Software Engineer, Brooks Computing Systems authored this article.