MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

code for JCL and PROC needed

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Tue Nov 14, 2006 11:24 am    Post subject: code for JCL and PROC needed Reply with quote

Members,

I want to create a JCL which will execute a PROC but in the proc we are unloading data from a DB2 table and the queries for unload are different for each day based on day name of the week.If it is run on Monday it should take EMPDAY = '1' and so on but i want the PROC to be one only.Plese let me know the code for JCL and PROC.

The sample queries are:
Code:

SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '1';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '2';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '3';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '4';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '5';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '6';
SELECT EMPLNO,EMPNAME,EMPDAY FROM EMPTABLE WHERE EMPDAY = '7';
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Nov 14, 2006 11:39 am    Post subject: Reply with quote

mfuser,

You don't need multiple sql statements. Use DAYOFWEEK function to get the current day no. The DAYOFWEEK function returns an integer in the range of 1 to 7 that represents the day of the week where 1 is Sunday and 7 is Saturday.

Check this sql

Code:

SELECT EMPLNO
      ,EMPNAME
      ,EMPDAY
 FROM EMPTABLE WHERE EMPDAY = DAYOFWEEK(CURRENT DATE)
;



Check this link for explanation of DAYOFWEEK

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/DSNSQH11/3.2.20?SHELF=&DT=20010718164132&CASE=

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mfuser
Banned


Joined: 01 Mar 2005
Posts: 105
Topics: 58

PostPosted: Tue Nov 14, 2006 12:39 pm    Post subject: Reply with quote

Kolusu,

Many thanks to your answer and it is working fine.But if i want to code JCL and PROC instead of using the DB2 Builtin function how would the code be , i want to know how can we make use of JCL and PROC and pass the value day of the week ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Nov 14, 2006 1:34 pm    Post subject: Reply with quote

Quote:

i want to know how can we make use of JCL and PROC and pass the value day of the week ?



mfuser,

*sigh* JCL is just a job control language . It CanNOT do anything on it own. It is just a control language used to identify a job to an operating system and to describe the job's requirement. It is your utilities and pgms that does the data manipulation.

There are no built-in functions in JCL that will give you the day of the week. I guess you like the long route. Here is an example. This uses 1 proc and seven JCL's to run to different days.

Code:

//UNLDPROC PROC
//*                                                           
//************************************************************
//* THIS PROCEDURE IS UNLOADING A DB2 TABLE USING DSNTIAUL.  *   
//************************************************************
//STEP0100 EXEC PGM=IKJEFT01,DYNAMNBR=20                     
//*                                                           
//SYSTSPRT DD  SYSOUT=*,DCB=BLKSIZE=121                       
//SYSUDUMP DD  SYSOUT=*                                       
//SYSOUT   DD  SYSOUT=*                                       
//SYSPRINT DD  SYSOUT=*                                       
//SYSTSOUT DD  SYSOUT=*                                       
//SYSTSIN  DD  DSN=YOUR PARMLIB(PLAN PARM),               
//             DISP=SHR                                       
//SYSREC00 DD  DSN=YOUR.OUTPUT.UNLOAD.EMP.TABLE,           
//             DISP=(NEW,CATLG,DELETE),                       
//             UNIT=SYSDA,                                   
//             SPACE=(CYL,(X,Y),RLSE)
//SYSPUNCH DD  SYSOUT=*
//SYSIN    DD  DSN=YOUR PARM.PARMLIB(UNLOAD PARM1),               
//             DISP=SHR                                       
//         DD  DSN=YOUR PARM.PARMLIB(UNLOAD PARM2),               
//             DISP=SHR                                       
/*



Plan parm will have

Code:

 DSN SYSTEM(xxxx)             
 RUN  PROGRAM(DSNTIAUL) -     
      PLAN(DSNTIAUL)    -     
      PARMS('SQL')      -     
      LIB('DB2P.RUNLIB.LOAD') 


unload parm1 will have
Code:

SELECT EMPLNO
      ,EMPNAME
      ,EMPDAY
  FROM EMPTABLE


unload parm2 will just have a blank lin
Code:

   


You will override the unload parm2 depending on the day like shown below.

ex : for monday

Code:

//MonJCL   EXEC UNLDPROC                       
//STEP0100.SYSIN DD                           
//               DD *                         
  WHERE EMPDAY = 1;


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Wed Nov 15, 2006 1:21 pm    Post subject: Reply with quote

I salute your patience, Kolusu
________
Sienna
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group