View previous topic :: View next topic
|
Author |
Message |
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
I wrote the below clist to run a program under DSN. The advantage of this is that the program and plan name appear in the JCL instead of being buried in a pds member. This is handy for JCL proc since a symbolic can be used.
Code: |
/* Execute db2 program in batch using DSN RUN command */
/* Parms: */
/* - db2 subsystem */
/* - program name */
/* - plan name */
/* - (optional) PARMS(program parameters) */
/* Example: */
/* //DSNRUN EXEC PGM=IKJEFT01, */
/* // PARM=('%DSNRUN DSN1 MYPGM MYPLAN', */
/* // 'PARMS(''MY PROGRAM PARMS'')') */
/* */
PROC 3 DB2SYS PGM PLAN PARMS()
CONTROL LIST END(ENDC)
/* Check for optional parms */
IF &PARMS = &Z THEN +
SET RUNPARMS = &Z
ELSE +
SET RUNPARMS = &STR(PARMS('&PARMS'))
/* Invoke db2 subsytem. DB2 will produce error message if it fails */
DSN SYSTEM(&DB2SYS)
SET DSNRC = &LASTCC
IF &DSNRC = 0 THEN +
DO
/* Run program */
RUN PROGRAM(&PGM) PLAN(&PLAN) &RUNPARMS
SET DSNRC = &LASTCC
/* End db2 */
END
ENDC /* of IF statement */
EXIT CODE(&DSNRC)
|
This is one example where a clist works better then a Rexx. This is because the "RUN" and the "END" commands are run under the DSN environment and not TSO. The clist also enforces the parms nicely.
I was unsure about the order of the parms. I chose it to match what would normally appear in a DSN RUN . Comments and critisims are welcome. |
|
Back to top |
|
|
Peter Nancollis
New User
Joined: 15 Mar 2011 Posts: 47 Location: UK
|
|
|
|
Good solution but cant the same be achieved with Rexx using QUEUE |
|
Back to top |
|
|
jerryte
Active User
Joined: 29 Oct 2010 Posts: 202 Location: Toronto, ON, Canada
|
|
|
|
By using a Clist I can check the return code of the DSN command before issuing the RUN command. I can also trap the return code from the RUN command. Also given that this is a small script a Clist works in this case. |
|
Back to top |
|
|
parsesource
New User
Joined: 06 Feb 2006 Posts: 97
|
|
Back to top |
|
|
|