#BEGINBUCKET DSNALLOCML
#/   {LANG}  lower case 2 byte language code from artifact instance XML.
#/   {LANG2BCODE}  upper case 2 byte language code from artifact instance XML.
#/   [MVS2BDSCODE] upper case 2 byte language code, key entry for dataset attributes in MVSDSDataTable.xml
#/   [DSLANGCODE]  upper case 2 byte language code variable which must be set within instance code to resolve
#/ This template is used in conjunction with the ActionBCModuleCheck.txt.  We need to allocate
#/ associated library datasets that are in the payload to determine whether any hotfixes
#/ were applied.  It will only allocate the definitions in MVSDSDataTable.xml if RECFM=U and
#/ in the payload.
#/
#/ ------------------------------------------------------------------
#BEGINDEFS
#/ ------------------------------------------------------------------
#/EXCEPTIONFORMISSINGSYMBOL
#SYMBOLCALLS ENTRY;SYSOUT;CUSTPRODQUAL;TMPUNI;WORKSPC
#/ ------------------------------------------------------------------
#BEGINSTATICINSTANCES
#/ ------------------------------------------------------------------
#/ These are required because they are populated with content from the
#/ CNTL data set produced by running SASEDTX and JavaEditX against the
#/ PREEDIT data sets. All other data sets are allocated only if there is
#/ product content being installed that requires them.
#/ ------------------------------------------------------------------
#IF [INSTALL-NEW] #THEN DOESNOTQUALIFY       #/If an action A DO NOT allocate the .ML dataset
#/ -------------------------------------------------
#BEGININSTANCEQUALIFIERS
#/ -------------------------------------------------
#/  Allocated data sets may be referenced *EITHER* as the target of a primary unload, *OR* as the target of
#/  secondary processing following the primary unload. The former is found once in <ENTRY><MVS2BDSCODE>,
#/  the latter none to many times within <ENTRY><MEMBER><COPY2BDSCODE>
#/  Allocate the ML.LIBRARY data set to determine whether new modules
#/  are newer than the already installed ones.  This is done by the
#/  the LLLDCK program module when doing actions b/c.
#TABLEFIX {MVS2BDSCODE}
#IFEQ [RECFM] U #THEN QUALIFIES
#IF [INSTALL-TO-STAGE] #THEN DOESNOTQUALIFY  #/ no need for the copy for staged install
#/ S1354598: This is here to create a backup copy of the SASHELP data set only when
#/ installing maintenance that includes base registry content. This is because we must
#/ remove the registry from the production SASHELP data set so that only the latest
#/ registry is imported.
#IFNOTEQ [UPDATEMODE] TRUE #THEN DOESNOTQUALIFY
#IFNOTEQ {PRODUCT} base #THEN DOESNOTQUALIFY
#IFEQ {MVS2BDSCODE} SH #THEN QUALIFIES   #/ need a copy of SASHELP to allow deletion of registry
#THEN DOESNOTQUALIFY
#QUALIFIES
#SET [MVS2BDSCODE] {MVS2BDSCODE}
#INSTANCEUNIQUEKEY [[MVS2BDSCODE]:LOQUAL] #NOTUNIQUE NEXT
#CREATEINSTANCEFROMENTRY
#DOESNOTQUALIFY
#ENDINSTANCEQUALIFIERS
#/ -------------------------------------------------------------------
#BEGINPREFIX
#/ -------------------------------------------------------------------
//MLALLOC EXEC PGM=[ENTRY],
//  PARM=('SETINIT MSGCASE CAPSOUT ERRORABEND NOWORKTERM',
//        'MACRO ERRORCHECK=STRICT SASUSER=WORK')
#IFEQ [HOST] z64 #THEN USEZE
#TABLEFIX LD  #/ Load Library
#THEN STEPLIB
#USEZE
#TABLEFIX ZE  #/ 64-bit load library
#STEPLIB
//STEPLIB  DD DISP=SHR,
//  DSN=[CUSTPRODQUAL].[LOQUAL]
#TABLEFIX SH  #/ Sashelp
//[DFLTDDN]  DD DISP=SHR,
//  DSN=[CUSTPRODQUAL].[LOQUAL]
#TABLEFIX AU  #/ Autocalls
//[DFLTDDN] DD DISP=SHR,
//  DSN=[CUSTPRODQUAL].[LOQUAL]
#IFEQ [HOST] z64 #THEN SKIPSM
#TABLEFIX SM  #/ SAS messages
//[DFLTDDN] DD DISP=SHR,
//  DSN=[CUSTPRODQUAL].[LOQUAL]
#SKIPSM
//TKMVSENV DD DATA,DLM='!1'
#SNIPPETINSERT SASDefaultTkmvsenv.txt
!1
//WORK     DD UNIT=[TMPUNI],SPACE=(6144,([WORKSPC])),
//         DCB=(RECFM=FS,LRECL=6144,BLKSIZE=6144)
//SASLOG   DD SYSOUT=[SYSOUT]
//SASCLOG  DD SYSOUT=[SYSOUT]
//CONFIG   DD DATA,DLM='!1'
#SNIPPETINSERT SASDefaultConfig.txt
!1
//SASLIST  DD SYSOUT=[SYSOUT]
//SASPARM  DD UNIT=[TMPUNI],SPACE=(400,(100,300)),
//         DCB=(RECFM=FB,LRECL=80,BLKSIZE=400,BUFNO=1)
//SYSIN  DD DATA,DLM='!1'  #/ Begin source code stream for SAS session. Delimiter is !^ in column 1 of line
options filestat symbolgen mprint mlogic;
%macro dsnq;               #/ Invoke SAS macro compiler.
#/ --------------------------------------------------------------------
#BEGININSTANCE               #/ All instance code must resolve to valid SAS source code.
#/ -------------------------------------------------------------------
#IFEQ [UPDATEMODE] TRUE #THEN SKIPDSLANG   #/ dslangcode set in updatemode section
#SET [DSLANGCODE] EN         #/ Set language symbol to EN for empty/blank language argument.
#SKIPDSLANG
#IFNOT {LANG2BCODE} #THEN NEXT     #/ Is language symbol non-blank?
#SET [DSLANGCODE] {LANG2BCODE}     #/ If so set general use language symbol to instance argument value.
#NEXT
#SET [MVSDSCODE] {MVS2BDSCODE}
#TABLEFIX [MVSDSCODE] #/ Fix ds table row to OTP2 from the instance.
#IFNOT [ALIASTO] #THEN NOALIAS #/ See if it's marked alias in ds table, if not then skip
#SET [MVSDSCODE] [ALIASTO]     #/ Hold the aliased ds from the table row
#TABLEFIX [MVSDSCODE]  #/ Reset the table row to the aliased OTP2.
#NOALIAS
#SET [USEML] TRUE
#SNIPPETINSERT AllocateDataset.txt
#/ ---------------------------------------------------------------------------------------------------
#/ This is a 'hack' if toolkit is part of an addon scenario, the production data sets need to be
#/ allocated in order for the llldck process to work.  This is only for an action c setup
#/ since an action B setup will automatically allocate the production data set.  Normally,
#/ the production data set would be allocated in the PROMOTE job for an action C.
#/ ---------------------------------------------------------------------------------------------------
#IFNOTEQ [RECFM] U  #THEN SKIPTKT
#IFEQ [HOTFIX] TRUE #THEN SKIPTKT            #/ if it is a hotfix there should already be production datasets allocated
#IFNOTEQ {PRODUCT} toolkit #THEN SKIPTKT
#IFNOT [INSTALL-TO-STAGE] #THEN SKIPTKT      #/only action c need production allocation for llldck process
 dsnexst '[CUSTPRODQUAL].[LOQUAL]';   #/query whether dataset already exists
 filename [OUTPDDNAME] '[CUSTPRODQUAL].[LOQUAL]' #/ Allocate filename
%if &sysdexst %then %do;  #/ does this dataset already exist?
     disp=old;            #/ if so then allocate disposition=old
%end;
%else %do;   #/ otherwise do rest of this to create new dataset
disp=(new,catlg,delete) blksize=[BLKSIZE]
space=[SPACEPARMS]
#IFNOTEQ [DATASETTYPE] PDS #THEN NEXT
dsntype=PDS            #/ Specify dataset is a PDS
#NEXT
#IFNOTEQ [DATASETTYPE] PDSE #THEN NEXT
dsntype=LIBRARY        #/ Specify dataset is a PDSE
#IFEQ [SMS-ALLOC-PDSE] false #THEN NOTSMSPDSE #/ no PDSE-specific SMS
#IFNOT [SMS-PDSE-STORCLAS] #THEN NOSC
storclas=[SMS-PDSE-STORCLAS]         #/ STORCLAS keyword, if used
#NOSC
#IFNOT [SMS-PDSE-MGMTCLAS] #THEN NOMC
mgmtclas=[SMS-PDSE-MGMTCLAS]         #/ MGMTCLAS keyword, if used
#NOMC
#IFNOT [SMS-PDSE-DATACLAS] #THEN NODC
dataclas=[SMS-PDSE-DATACLAS]         #/ DATACLAS keyword, if used
#NODC
#THEN NOVOLSER
#NOTSMSPDSE
#NEXT
#IFEQ [SMS-ALLOC] true #THEN SMSALLOC   #/ branch to section if customer using IBM SMS to manage storage
#IFNOT [VOLSER] #THEN NOVOLSER  #/ if volser has resolved to null, then branch.
#IF [TMPDS] #THEN TMPU #/ if this is a pre-allocated dataset deleted after the install then branch
unit=[DISKUNIT] volser='[BYDSVOLSER]';   #/ having volser by dataset allows splitting installation storage
#THEN NEND
#NOVOLSER
#IF [TMPDS] #THEN TMPU
UNIT=[DISKUNIT];     #/ set unit to permanent diskunit
#THEN NEND
#TMPU
UNIT=[TMPUNI];       #/ set unit to temporary diskunit
#THEN NEND
#SMSALLOC            #/ SMS parameter settings
#IFNOT [SMS-STORCLAS] #THEN NOSC
storclas=[SMS-STORCLAS]              #/ STORCLAS keyword, if used
#NOSC
#IFNOT [SMS-MGMTCLAS] #THEN NOMC
mgmtclas=[SMS-MGMTCLAS]              #/ MGMTCLAS keyword, if used
#NOMC
#IFNOT [SMS-DATACLAS] #THEN NODC
dataclas=[SMS-DATACLAS]              #/ DATACLAS keyword, if used
#NODC
unit=[DISKUNIT];              #/ hard set to permanent diskunit, SMS not used for temps
#NEND
%end;
#SKIPTKT
#/ ----------------------------------------------------------------------
#BEGINSUFFIX
#/ -------------------------------------------------------------------
%mend dsnq; %dsnq             #/ close SAS macro, invoke SAS macro once.
!1                           #/ Delimiter for SAS session SYSIN definition.
#/ ----------------------------------------------------------------------
#ENDBUCKET DSNALLOCML
