使用JCL在DSN中从上个月的日期开始计算年份 [英] Incude the year from last month's date in the DSN using JCL

查看:285
本文介绍了使用JCL在DSN中从上个月的日期开始计算年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似于数据集名称中前一个月年份的JCL"问题的请求.该问题的答案使用了ALTER语句,该语句假定知道日期.我有JCL将年份附加到DSN,但是在1月,我需要上一年.我认为借助SYNCSORT或DFSORT可以做到这一点,但我对这两种方法都没有经验.感谢您的协助.

I have a request similar to the "JCL for previous month-year in dataset name" question. The answer to that question used an ALTER statement, which assumes knowledge of the date. I have JCL to append the year to the DSN, however in January, I need the previous year. I think this is possible with the help of SYNCSORT or DFSORT, but am not experienced with either of these. Any assistance is appreciated.

这是当前的JCL:

//B999999X JOB (80594,XXX),'MAKE DATE',                      
//         CLASS=C,MSGCLASS=C,NOTIFY=&SYSUID                 
//STEP0100 EXEC PGM=EZACFSM1                                 
//SYSOUT   DD SYSOUT=(*,INTRDR)                              
//SYSIN    DD DATA,DLM=@@                                    
//B8025501 JOB (,9999),'TESTING',                            
//         CLASS=A,MSGCLASS=C,MSGLEVEL=(1,1),NOTIFY=&SYSUID  
//STEP01   EXEC PGM=IEFBR14                                  
//FILE01   DD DSN=B999999.TEST.MYFILE.FUEL&YR2,              
//            DISP=(NEW,CATLG,DELETE),                       
//            UNIT=SYSDA,                                    
//            SPACE=(CYL,(10,10),RLSE),                      
//            DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)              
/*                                                           
@@          

推荐答案

实际上,答案是您所引用的问题首先指出最好的解决方案是使用作业计划程序的功能." 这仍然是最好的答案.我展示了如何完成 并不是要暗示我认为这是最好或最可维护的方法.

Actually, the answer to the question you reference first states "The best solution for this is to use the features of your job scheduler." That remains the best answer. That I showed how something could be done was not intended to imply I thought it was the best or most maintainable method.

您可以使用

You could do this with Rexx, or a Unix System Services shell script, or an awk script, or Perl, again constructing an ALTER statement to be used in a subsequent step to rename a statically-named dataset to one containing the date qualifier you desire.

还有其他一些技术但是,如果您有一个工作计划程序包,那么您确实应该使用它的功能.

But, if you have a job scheduler package available, you really should be using its capabilities.

以下提出的解决方案的示例.

Examples of the above proposed solutions follow.

Rexx程序MKALTR

Rexx program MKALTR

dsn = Arg(1)                                                  
Parse Value Date('O') With yy '/' mm '/' dd                   
If mm = 1 Then                                                 
  If yy > 0 Then                                              
    yy = yy - 1                                               
  Else                                                        
    yy = 99                                                    
outLine.1 = ' ALTER ' || dsn || ' - '                         
outLine.2 = ' NEWNAME(' || dsn || yy || ')'                   
outLine.0 = 2                                                 
Address TSO 'EXECIO * DISKW OUTPUT01 ( STEM' outLine. 'FINIS )'
Exit 

JCL运行Rexx程序MKALTR

JCL to run Rexx program MKALTR

//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG    EXEC PGM=IEFBR14                                     
//STDOUT   DD  DISP=(,CATLG),                                   
//             DSN=&DS,                       
//             AVGREC=U,                                        
//             LRECL=80,                                        
//             RECFM=FB,                                        
//             SPACE=(80,(1,1))                                 
//*                                                             
//MKALTER  EXEC PGM=IKJEFT1B,PARM='MKALTR &DS'
//SYSEXEC  DD  DISP=SHR,DSN=dataset.where.rexx.code.resides                  
//SYSTSPRT DD  SYSOUT=*                                         
//SYSPRINT DD  SYSOUT=*                                         
//SYSTSIN  DD  DUMMY                                            
//OUTPUT01 DD  DISP=(,PASS),                                     
//             AVGREC=K,                                        
//             LRECL=80,                                        
//             RECFM=FB,                                        
//             SPACE=(80,(2,1))                                  
//*                                                             
//DOALTER  EXEC PGM=IDCAMS                                      
//SYSIN    DD  DISP=(OLD,DELETE),DSN=*.MKALTER.OUTPUT01         
//SYSPRINT DD  SYSOUT=*                                          
//* 

Shell脚本mkaltr

Shell script mkaltr

let "mon=`date +'%m'`"     
let "yr=`date +'%y'`"      
if [ $mon -eq 01 ]         
then                       
  let "outyr=$yr-1"        
fi                         
echo \ ALTER $1 -          
echo \ \ NEWNAME\($1$outyr\)

JCL运行shell脚本mkaltr

JCL to run shell script mkaltr

//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG    EXEC PGM=IEFBR14                         
//STDOUT   DD  DISP=(,CATLG),                       
//             DSN=&DS,          
//             AVGREC=U,                            
//             LRECL=80,                             
//             RECFM=FB,                            
//             SPACE=(80,(1,1))                     
//*                                                 
//MKALTER  EXEC PGM=BPXBATCH,                       
// PARM='SH /path/to/script/mkaltr &DS'    
//STDOUT   DD  DISP=(,PASS),                        
//             AVGREC=U,                            
//             LRECL=80,                            
//             RECFM=FB,                            
//             SPACE=(80,(2,1))                     
//STDERR   DD  SYSOUT=*                             
//*                                                 
//DOALTER  EXEC PGM=IDCAMS                          
//SYSIN    DD  DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT
//SYSPRINT DD  SYSOUT=*                             
//*     

使用awk的Shell脚本mkaltr

Shell script mkaltr using awk

date +"$1 %m %y" | awk '                             
{                                                    
yr = $3                                              
if ( $2 = 1 ) yr -= 1                                
if ( yr > 100 ) yr -= 100                             
printf( " ALTER %s -\n NEWNAME(%s%2d)\n", $1, $1, yr )
}'

JCL运行shell脚本mkaltr

JCL to run shell script mkaltr

//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG    EXEC PGM=IEFBR14                         
//STDOUT   DD  DISP=(,CATLG),                       
//             DSN=&DS,          
//             AVGREC=U,                            
//             LRECL=80,                            
//             RECFM=FB,                            
//             SPACE=(80,(1,1))                     
//*                                                  
//MKALTER  EXEC PGM=BPXBATCH,                       
// PARM='SH /path/to/script/mkaltr &DS'   
//STDOUT   DD  DISP=(,PASS),                        
//             AVGREC=U,                             
//             LRECL=80,                            
//             RECFM=FB,                            
//             SPACE=(80,(2,1))                     
//STDERR   DD  SYSOUT=*                             
//*                                                  
//DOALTER  EXEC PGM=IDCAMS                          
//SYSIN    DD  DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT
//SYSPRINT DD  SYSOUT=*                             
//*

Perl程序mkaltr

Perl program mkaltr

if ( @ARGV ) {                                                         
  $dsn = shift( @ARGV );                                                
} else {                                                               
  die "dataset name required";                                         
}                                                                      

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
if ($mon == 0) {                                                       
  $year -= 1                                                           
}                                                                      
if ($year >= 100) {                                                    
  $year -= 100;                                                         
}                                                                      
printf (" ALTER %s -\n NEWNAME(%s%2d)\n", $dsn, $dsn, $year); 

JCL运行Perl程序mkaltr

JCL to run Perl program mkaltr

//*
// SET &DS=MY.DATASET.NAME
//*
//CATLG    EXEC PGM=IEFBR14                              
//STDOUT   DD  DISP=(,CATLG),                            
//             DSN=&DS,               
//             AVGREC=U,                                 
//             LRECL=80,                                 
//             RECFM=FB,                                  
//             SPACE=(80,(1,1))                          
//*                                                      
//MKALTER  EXEC PGM=BPXBATCH,                            
// PARM='SH perl /path/to/perl/program/mkaltr &DS'
//STDOUT   DD  DISP=(,PASS),                             
//             AVGREC=U,                                 
//             LRECL=80,                                 
//             RECFM=FB,                                 
//             SPACE=(80,(2,1))                          
//STDERR   DD  SYSOUT=*                                  
//*                                                      
//DOALTER  EXEC PGM=IDCAMS                               
//SYSIN    DD  DISP=(OLD,DELETE),DSN=*.MKALTER.STDOUT    
//SYSPRINT DD  SYSOUT=*                                  
//* 

这篇关于使用JCL在DSN中从上个月的日期开始计算年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆