Tuesday, January 13, 2009

Error and Condition Trapping (Call ON versus Signal ON)

Call ON and OFF is used to handle condition trap by procedure name.
SynTax:
call ON conditionName [ NAME trapLabel ] 
call OFF condition-Name

signal ON conditionName [ NAME trapLabel ] 
signal OFF condition-Name

Overview when Exception occurs Control is transferred to routine to address the errors. After the error routine handles the condition, execution of primary script can resume.

The difference between call and signal:
1. signal applies to all seven error conditions. call didn't apply to SYNTAX,NOVALUE,and LOSTDIGITS errors.
    note: other error conditions: HALT,ERROR,FAILURE,NOTREADY
2. signal forces abnormal changes in the flow of control, and unconditionally transfer the control to the trapLabel, after processed, [and then transferred the control to a specified Label manually].
   call provides a "normal" way to trap routines, control is automatically transferred from the error routine back to main program, and the result special variable is not setting when returned from a condition trap, any value coded on the return will be ignored.



Wednesday, January 7, 2009

UTIL DSNUTILB

DSNUTILB specifies a utility control program, it can be used for checks, reorg, image copys, load and so on.

Project CASE:
Scenario:
For there are several testing environment needed for several level testing, like UT, FT, ST, UAT..., so data preparation is usually a wasting-time task after environment setup.
Request:
Loading and initializing a new environment by copying an existing environment rather than creating an environment by migration and conversion is required.

1. unload the files from tables in the old env.
2. transfer the files to the new env. (change the name according to the new env.)
3. Load the received files into the tables in new env.

unload PROC:
000001 //TBLUNLD PROC TBSP=,SIZE=0M
000002 //*
000003 //*********************************************************************
000004 //* STEP DELETE: DELETE OLD DATASETS
000005 //*********************************************************************
000006 //STEP010 EXEC PGM=IEFBR14,COND=(4,LT)
000007 //SYSREC DD DSN=OLD.UNLOAD.FILE,
000008 // UNIT=SYSDA,DISP=(MOD,DELETE,DELETE),SPACE=(TRK,1)
000009 //*********************************************************************
000010 //* STEP UNLOAD: UNLOAD TABLES
000011 //*********************************************************************
000012 //UNLOAD EXEC PGM=DSNUTILB,REGION=&SIZE,COND=(4,LT),
000013 // PARM='&DB2SYS,&ENVID.&TBSP,&UTPROC'
000014 //STEPLIB DD DSN=&DB2LOAD,DISP=SHR
000015 //SYSPRINT DD SYSOUT=&OUTP
000016 //UTPRINT DD SYSOUT=&OUTP
000017 //SYSUDUMP DD SYSOUT=&OUTD
000018 //SYSPUNCH DD DSN=Unload.card.lib(LOD&TBSP.),
000019 // DISP=SHR
000020 //SYSREC DD DSN=Unload.file,
000021 // DISP=(,CATLG,DELETE),
000022 // DCB=(BLKSIZE=8192),
000023 // SPACE=(CYL,(50,500),RLSE),
000024 // UNIT=(3390,6)
000025 //SYSIN DD DSN=unload.card,DISP=(OLD,DELETE)
Unload card layout:
000001 UNLOAD TABLESPACE &DB..&TBSP FROM TABLE
000002 &OWNER..&TBNAME
000003 HEADER NONE
Unload job layout:
000001 //DMRUDAC1 JOB (ACCT#,ACCT-INFO),'PROGRAMMER',
000002 //  MSGCLASS=X,TIME=1440,REGION=0M
000003 // JCLLIB ORDER=(Lib01)
000004 //*
000005 //FMSSYM INCLUDE MEMBER=emv#SYM
000006 //*
000007 // SET ENVID=&LVL2
000008 //*********************************************************************
000009 //* THIS JOB SHOULD ONLY BE RUN : *
000010 //* ============================= *
000011 //* - IN THE SOURCE(OLD) ENVIRONMENT *
000012 //* *
000013 //*********************************************************************
000014 //* I UNLOAD FMS ACHIEVEMENT TABLES, JOBS FMSUD### CAN RUN *
000015 //* SIMULTANEOUSLY *
000016 //*********************************************************************
000017 //* RERUN : YES *
000018 //* STEP RESTART : FROM THE FAILED STEP *
000019 //*********************************************************************
000020 //*
000021 //*********************************************************************
000022 //* CHANGE HISTORY *
000023 //*-------------------------------------------------------------------*
000024 //* DATE   | REQ#   |BY  | STEP  | DDNAME |COMMENTS *
000025 //*--------|--------|----|-------|--------|---------------------------*
000026 //*        |        |    |       |        |- INITIAL VERSION *
000027 //*********************************************************************
000028 //*
000029 //*--------------------------------------------------------------------
000030 //* UNLOAD ACH-1
000031 //FMSBFE EXEC FMSUNLD,DB=DB01,TBSP=SPACE1,TBN='TABLE_01'
Load PROC
000001 //DB2LOAD JOB (ACCT#,ACCT-INFO),'PRG-NM',
000002 // MSGCLASS=X,NOTIFY=USERID,USER=USERID,
000003 // TIME=1440,REGION=0M
000004 //* LOAD TABLE 
000005 //*--------------------------------------------------------------------*
000006 //* **************************************************** *
000007 //* * CHANGE THE DB2 UTIL NAME BELOW * *
000008 //* **************************************************** *
000009 //* 
000010 //DSNUPROC PROC LIB=’DSN.SSPGM’,SYSTEM=DSN,UID=’’,UTPROC=’’
000011 //DSNUPROC EXEC PGM=DSNUTILB,REGION=0M,
000012 // PARM=(&SYSTEM,&UID,&UTPROC)
000013 //STEPLIB DD DSN=&LIB,DISP=SHR
000014 //SYSPRINT DD SYSOUT=*
000015 //UTPRINT DD SYSOUT=*
000016 //SYSUDUMP DD SYSOUT=*
000017 //SYSERR DD DSN=&&SYSERR,DISP=(MOD,DELETE),
000018 // SPACE=(CYL,(100,100),RLSE),UNIT=(3390,1)
000019 //SYSMAP DD DSN=&&SYSMAP,DISP=(MOD,DELETE),
000020 // SPACE=(CYL,(100,100),,,ROUND),UNIT=(3390,1)
000021 //SYSDISC DD DUMMY
000022 //SYSUT1 DD DSN=&&SYSUT1,UNIT=(3390,24),
000023 // DISP=(MOD,PASS),
000024 // SPACE=(CYL,(200,200),,,ROUND)
000025 //SORTOUT DD DSN=&&SORTOUT,UNIT=(3390,24),
000026 // DISP=(MOD,PASS),
000027 // SPACE=(CYL,(200,200),,,ROUND)
000028 //* **************************************************** *
000029 //* * THE SYSREC IS THE UNLD DATASET * *
000030 //* * THE SYSIN IS THE CNTL DATASET *
000031 //* * (CAN BE GENERATED WHILE UNLOAD) *
000032 //* **************************************************** *
000033 //SYSREC DD DUMMY,DISP=SHR
000034 //SYSIN DD DSN=DUMMY,
000035 // DISP=SHR
000036 // PEND 
000037 //* TABLE_01
000038 //STEP010 EXEC DSNUPROC
000039 //DSNUPROC.SYSREC DD DSN=unloaddsn
000040 // ,DISP=SHR
000041 //DSNUPROC.SYSIN DD DSN=loadcard_01
000042 // ,DISP=SHR
the above utility is used to load SYSREC file to table TABLE_01 with load card Loadcar_01,the following is the layout of load card for TABLE_01,pay attention to INDDN SYSREC and REPLACE ...
Load Card:
000001 LOAD DATA INDDN SYSREC LOG NO DISCARDS 1 REPLACE
000002 UNICODE CCSID(00367,01208,01200)
000003 INTO TABLE "DB2Scham1"."TABLE_01"
000004 ( 
000005 "ACCT_YR"
000006 POSITION( 00001:00004 ) CHAR (004)
000007 ,"ACCT_MTH"
000008 POSITION( 00005:00006 ) CHAR (002)
000009 ,"USERID_LOCK"
000010 POSITION( 00007:00014 ) CHAR (008)
000011 ,"LAST_UPT_CTY"
000012 POSITION( 00015:00017 ) CHAR (003)
000013 ,"LAST_UPT_ID"
000014 POSITION( 00018:00025 ) CHAR (008)
000015 ,"LAST_UPT_TIME"
000016 POSITION( 00026:00051 ) TIMESTAMP EXTERNAL
000017 
000018 ) 
000019 REPAIR OBJECT LOG NO
000020 SET TABLESPACE FMSDFP1.FMSSOYR
000021 NOCOPYPEND



Tuesday, January 6, 2009

Developing ISPF program with Rexx

The Main Process:
1.Panel definition, Message Definition and file tailoring skeletons are created  and saved in ISPF library before running the Dialog.
2.Program(after compiled) and command procedure created and stored in system program library.