Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Clist to run sql program in DSN

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
jerryte

Active User


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

PostPosted: Thu Mar 17, 2011 8:22 pm    Post subject: Clist to run sql program in DSN
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    Post subject:
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: 187
Location: Toronto, ON, Canada

PostPosted: Sun Mar 20, 2011 1:03 am    Post subject:
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    Post subject:
Reply with quote

we use this fancy tool
http://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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts Need help in REXX CALL program Raje1002 CLIST & REXX 5 Wed Apr 19, 2017 11:18 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us