zOs/SQL/PROFEX

$#@
$*( ---------------------------------------------------  walter 08.01.13
    profEx: wsh script zum verteilen der CA profile fuer dbx
      1. DSN.DBX.GLBCHG(#PROFILE) erstellen
             mit sql delete/insert für alle Profile
      2.  alle global changes mit creator=DBX exportieren
             nach DSN.DBX.GLBCHG(*)
      3.  jcl erstellen zum verteilen von DSN.DBX.GLBCHG(*)
             und ausfuehren der SQLs den Db2Subsystemen
  26.11.13 walter verteilung aus rz4
-------------------------------------------------------------------- $*)
$= dbSys  = DP4G
$= j7     = YPROFEX
$= outPds = DSN.DBX.GLBCHG
$= outSql = $outPds(#PROFILE)
$= cr     = DBX
$= wh     =- "creator = '"$cr"'"
$= whMo   =- "model_creator = '"$cr"'"
$= whTy   =- $wh 'and type ='
$= myRz   =- sysvar(sysnode)
if 1 then $@[
    $@expProfs
    $]
if 1 then $@[
    $@sendProfs
    $>. fEdit()
    $<=[
        RZ2 DBOF DVBP DP2G
        RZ4 DBOL                     $** |||dp4g is the source|||
        RZX DE0G DEVG DPXG DX0G
        RZY DE0G DEVG DPYG
        RZZ DE0G DEVG DPZG
        RR2 DBOF DVBP DP2G
        RQ2 DBOF DVBP DP2G
        $]
    $]

$@proc expProfs $@/expProfs/
say 'exporting CAProfiles from ' $dbSys
say '                     where' $wh
say '                     to   ' $outPds
call sqlConnect $dbSys
$;

$>$outSql
$$                            ------- export  $-[date('s') time()$]
$$                            --------------- 1 - GlobalProfile
$$                            --------------- 2 - RCMProfile
$@%[expTb - pti.PTMG5_GLOBAL_0400, $wh,       "3 - GlobalChange"$]
names = $names
$@%[expTb - pti.PTMGA_LNAME_0200, $whTy "'G'", "3 - GlobalChange/Name"$]
$@%[expTb - pti.PTMG4_RULES_0300, $wh,        "4 - CompareRule"$]
$@%[expTb - pti.PTMG9_MASK_0510 , $wh,        "5 - AutomapMask"$]
$@%[expTb - pti.PTMGA_LNAME_0200, $whTy "'M'", "5 - AutomapMask/Name"$]
$@%[expTb - pti.PTMOD_UTLSYM_0401, $whMo,     "6 - UtilityModel"$]
$$                            --------------- 7 - CopyGroup
$@%[expTb - pti.PTMGB_APTABLE_0100,$wh,       "P - AnalysisProfile"$]
$$                            --------------- U - UtilityProfile
$;
$do gx=1 to words(names) $@[
    gc = word(names, gx)
    $;
    $>$outPds($-[gc$])
    $@%[globalChangeExp - $cr, gc$]
    $]
$/expProfs/

$@proc $@/expTb/
    parse arg , tb, wh, tit
    $$- ''
    $$- '---------------' tit
    $$-  'delete from' tb 'where' wh
    $$  ;
    $;
    call sqlSel 'select * from' tb 'where' wh
    $|
    lst = ''
    cx = 0
    $@for oo $@[
        cx = cx + 1
        o1 = $.oo
        call sql4Obj o1, tb
        if wordPos(m.o1.name, lst) < 1 then
            lst = lst m.o1.name
        $]
    say right(cx, 5) 'inserts into' left(tb, 24) 'for' tit
    $=names=- lst
$/expTb/

$@proc $@/globalChangeExp/
parse arg , Cr, Nm
    say 'export globalChange' Cr'.'Nm
    call sqlQuery 7, 'select * from pti.PTMG5_GLOBAL_0400' ,
        "where node_type=2 and creator = '"cr"' and name = '"nm"'",
        , "c n ty se"
    do while sqlFetch(7,ff)
        lc = c2d(substr(m.ff.se, 1, 2))
        $$- ' GLBLNAME  'left(m.ff.n, 20) '--' date('s') time()
        $$- ' GLBLCRTR  'left(m.ff.c, 20)
        do lx=1 to lc
            sx = lx*40-37
            $$- ' 'substr(m.ff.se, sx, 4) left('', 4) $*+
                   substr(m.ff.se, sx+4, 18) ' '      $*+
                   substr(m.ff.se, sx+22, 18)
            end
   $**  say length(m.ff.se) '<' 2+lc*40
        if length(m.ff.se) < 2+lc*40 then
            call err 'bad segment too short' m.ff.c'.'m.ff.n
        if substr(m.ff.se, 3+lc*40) <> '' then
            call err 'bad segment addition infos' m.ff.c'.'m.ff.n
        end
    call sqlClose 7
$/globalChangeExp/

$@proc $@=/sendProfs/
//${j7}W JOB (CP00,KE50),'DB2 REO',
//         MSGCLASS=T,TIME=1440,
//         NOTIFY=&SYSUID,REGION=0M,SCHENV=DB2
//*MAIN CLASS=LOG
    $@for li $@/rz/
        $=rz =- word($li, 1)
        $$ //*---------------------------------------- $rz
        if $rz \= $myRz then $@=[
//${rz}SEND  EXEC PGM=IKJEFT01,DYNAMNBR=200,TIME=99,PARM=WSH
//SYSPROC    DD DISP=SHR,DSN=TSO.$myRz.P0.PROD.EXEC
//SYSPRINT   DD SYSOUT=*
//SYSUDUMP   DD SYSOUT=*
//SYSTSPRT   DD SYSOUT=*
//*UT        DD SYSOUT=*
//SYSTSIN    DD DUMMY
//WSH        DD *
  call csmCopy '$outPds', '$rz/$outPds'
        $]
        $@=[
//${rz}SUB   EXEC PGM=IEBGENER
//SYSPRINT   DD SYSOUT=*
//SYSUT2     DD SUBSYS=(CSM,'SYSTEM=$rz,SYSOUT=(A,INTRDR)')
//SYSUT1     DD *,DLM='}}'
//${j7}S JOB (CP00,KE50),'DB2 REO',
//             MSGCLASS=T,TIME=1440,
//             NOTIFY=&SYSUID,REGION=0M,SCHENV=DB2
//*MAIN CLASS=LOG
        $]
        $@do wx=2 while word($li, wx) \== '' $@=/dbSy/
        $=dbSy =- word($li, wx)
//${dbSy}SQL   EXEC PGM=IKJEFT01,DYNAMNBR=200,TIME=99
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSTERM  DD DUMMY
//SYSIN    DD DISP=SHR,DSN=$outSql
//SYSTSIN  DD *
   DSN SYSTEM($dbSy)
   RUN PROGRAM(DSNTEP2) PARMS('ALIGN(LHS)') PLAN(DSNTEP2)
        $/dbSy/
    $$ }}
    $/rz/
$/sendProfs/

$#out                                              20150317 14:01:28
$#out                                              20150223 10:01:00
$#out                                              20150106 12:26:53