Make your own free website on Tripod.com
Hints

Back Issue

Generating JCL with the Assembler

The assembler macro language can be used to generate JCL. This example produces DFDSS JCL and control statements. The sample that follows should be adapted to satisfy local requirements. For a related technique, see Generating REXX using the Assembler.

Here is the JCL used to run the assembler. It specifies output to SYSPUNCH and that no object file will be created. SYSPUNCH points to sysout in the JCL, but it could also be assigned to a dataset:

//S1 EXEC ASMC,PARM='DECK,NOOBJECT' //ASM.SYSPUNCH DD SYSOUT=* //ASM.SYSIN DD * The macros used in this example follow. They use the Assembler's PUNCH instruction to put out the generated JCL: PRINT OFF .* THESE MACROS GENERATE CONTROL STATEMENTS MACRO PREFIX &PFX .* ASSIGN A VALUE TO THE PREFIX VARIABLE GBLC &DSNPRF &DSNPRF SETC '&PFX' GBLB &PSET AIF (&PSET).NOJCL .* GENERATE THE JCL AT THE START (ONLY ONCE) PUNCH '//RESTORE EXEC PGM=ADRDSSU,PARM=''TYPRUN=NORUN''' PUNCH '//SYSPRINT DD SYSOUT=*' PUNCH '//TAPE DD DISP=SHR,DSN=INPUT.DSN' PUNCH '//DISK DD .....' PUNCH '//SYSIN DD *' .* END OF JCL AT THE START .NOJCL ANOP .* MESSAGE MNOTE *,'PREFIX SET TO &DSNPRF' &PSET SETB 1 MEXIT MEND MACRO .* ASSIGN VALUES IN THE DSN ARRAYS .* ODSN IS PREFIXED WITH PREFIX VALUE SDSN &DSN GBLC &IDSN(10),&ODSN(10) GBLA &NDSN GBLC &DSNPRF &NDSN SETA &NDSN+1 &IDSN(&NDSN) SETC '&DSN' &ODSN(&NDSN) SETC '&DSNPRF..&DSN' .* MESSAGE MNOTE *,'SOURCE DSN &NDSN IS &DSN' MNOTE *,' RENAMED TO &DSNPRF..&DSN' MEXIT MEND MACRO .* GENERATE THE CONTROL STATEMENTS .* FROM THE STORED DSN ARRAYS DONE LCLA &LOOP GBLA &NDSN GBLC &IDSN(10),&ODSN(10) .* MESSAGES MNOTE *,'GENERATING CONTROL STATEMENTS' MNOTE *,'&NDSN DSNS PROVIDED' .* GENERATE CONTROL CARD HEADERS PUNCH ' RESTORE DATASET(INCLUDE( -' .* PASS 1 .D1 ANOP &LOOP SETA &LOOP+1 AIF (&LOOP GT &NDSN).D2 .* GENERATE CONTROL CARD TYPE 1 &WORK SETC ' &IDSN(&LOOP) -' PUNCH '&WORK' AGO .D1 .* PASS 2 .D2 ANOP PUNCH ' ) ) -' PUNCH ' RENUNC(' &LOOP SETA 1 .R1 ANOP &LOOP SETA &LOOP+1 AIF (&LOOP GT &NDSN).R2 &INDSN SETC '&IDSN(&LOOP)' &OUTDSN SETC '&ODSN(&LOOP)' .* GENERATE CONTROL CARD TYPE 2 &WORK SETC ' ( &INDSN , &OUTDSN ), -' PUNCH '&WORK' AGO .R1 .R2 ANOP .* GENERATE THE FINAL CONTROL STATEMENTS AND JCL PUNCH ' ) - ' PUNCH ' INDD(TAPE) OUTDD(DISK) CANCELERROR -' PUNCH ' TOL(ENQFAILURE) CATALOG ' PUNCH '/*' PUNCH '//' .* MESSAGE MNOTE *,'JCL GENERATION IS COMPLETE' .* END OF FINAL STUFF MEXIT MEND .* END OF MACROS There are three macros defined: The sample macros provided do not validate their input; depending on your environment and who might use such a tool, it may be necessary to add additional logic to the macros. That, however, is beyond the scope of this document. Now, here is an example of the use of these macros: PRINT ON .* INVOKE THE MACROS TO GENERATE THE JCL PREFIX HLQ1.TEMP ** ASSIGN PREFIX * INPUT THE DATASET NAMES SDSN SOME.DSN1 SDSN SOME.DSN2 SDSN SOME.DSN3 SDSN SOME.DSN4 SDSN MORE.DSN5 SDSN MORE.DSN6 PREFIX HLQ2.TEMP ** CHANGE PREFIX SDSN SOME.DSN7 SDSN SOME.DSN8 SDSN MORE.DSN9 SDSN MORE.DSN10 SDSN SOME.DSN11 * GENERATE THE JCL DONE END So, if you concatenate the JCL, the macros and the example and add a final //, you should be able to produce the JCL output directed to SYSPUNCH.

This article was inspired by an inquiry on the IBM-Main newsgroup. As has been noted there, SYSPUNCH can also be directed to a temporary dataset and then submitted by copying it to an INTRDR output. That would require the addition of a JOB JCL card at many installations.

Feedback

Comments or suggestions can be sent to the author.

Last Month's Issue

Big Iron