IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Clist to run sql program in DSN


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Thu Mar 17, 2011 8:22 pm
Reply with quote

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
View user's profile Send private message
Peter Nancollis

New User


Joined: 15 Mar 2011
Posts: 47
Location: UK

PostPosted: Sat Mar 19, 2011 6:43 am
Reply with quote

Good solution but cant the same be achieved with Rexx using QUEUE
Back to top
View user's profile Send private message
jerryte

Active User


Joined: 29 Oct 2010
Posts: 202
Location: Toronto, ON, Canada

PostPosted: Sun Mar 20, 2011 1:03 am
Reply with quote

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
View user's profile Send private message
parsesource

New User


Joined: 06 Feb 2006
Posts: 97

PostPosted: Sun Mar 20, 2011 1:39 am
Reply with quote

we use this fancy tool
gsf-soft.com/Products/CCSS.shtml

to use system symbols in instream-data. no need for rexx&clist apps
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top