/* VMFTBLFX (SAMP)EXEC */ /*===========================================================================*/ /* Copyright - */ /* */ /* THIS MODULE IS "RESTRICTED MATERIALS OF IBM" */ /* 5741-A07 (C) COPYRIGHT IBM CORP. - 2015 */ /* LICENSED MATERIALS - PROPERTY OF IBM */ /* ALL RIGHTS RESERVED. */ /* */ /* Status - z/VM Version 6 Release 3.0 */ /*===========================================================================*/ /*!--------------------------------------------------------------------------*/ /*! >>> N O T I C E <<< */ /*!--------------------------------------------------------------------------*/ /*! */ /*! This SAMPLE program is provided for use and reference as only a */ /*! programming example. Although this program may have been reviewed */ /*! by IBM for accuracy in a specific environment, there is no */ /*! guarantee that the same or similar results will be obtained */ /*! elsewhere. This code is provided on an 'as is' basis, without any */ /*! warranty expressed or implied. */ /*! */ /*!==========================================================================*/ /*! File Name: VMFTBLFX (SAMP)EXEC */ /*! */ /*! Description: */ /*! Reads an existing VMSES/E software inventory file and removes old-level */ /*! information. This is exec is intended for use against select files, */ /*! after having used the VMSES/E MIGRATE command to perform a system */ /*! migration. */ /*! */ /*!--------------------------------------------------------------------------*/ /*! Syntax: */ /*! */ /*! >>--VMFTBLFX--fname--ftype--fmode--(--options------------------------>< */ /*! */ /*! Supported file types: SYSSUF SYSDESCT */ /*! */ /*! Options: */ /*! KEEPZVM - Causes ZVM PPF file entries in a modified SYSDESCT file to */ /*! be maintained (applies to SYSDESCT file type only) */ /*! */ /*!--------------------------------------------------------------------------*/ /*! Files Used/Created: */ /*! */ /*! Input: */ /*! fname ftype fmode */ /*! - File ID of the VMSES/E inventory file that is to be modified. */ /*! */ /*! Output: */ /*! fname-M ftype A */ /*! - Modified, resultant file, based on the given input file. */ /*! */ /*!--------------------------------------------------------------------------*/ /*! Return Codes: */ /*! */ /*! 0 No errors */ /*! 1 Internal Error */ /*! 2 Operand / Parameter Input error */ /*! 4 Warning(s) issued */ /*! 8 Error(s) encountered */ /*! */ /*!--------------------------------------------------------------------------*/ /*! Notes: */ /*! Error checking/handling is minimalistic. */ /*!--------------------------------------------------------------------------*/ Main: Address 'COMMAND' rc = 0 Call Initialize /*!--------------------------------------------------------------------------*/ /*! Acquire input values. */ /*!--------------------------------------------------------------------------*/ /*! Set up corresponding output file based on given input file name. */ /*! Set 'Clear ZVM' flag based on whether 'KEEPZVM' was/was not specified. */ /*!--------------------------------------------------------------------------*/ Arg qry_file '(' opt_keepZVM . If (qry_file = "") | (qry_file = "?") | (Words(qry_file) \= 3) Then Do Call Provide_Help Call ExitR !rc.op_error End Parse Var qry_file fn_qry ft_qry . !g.file_out = Space(Left(fn_qry, 6) "-M", 0) ft_qry !g.fm_wrk !ctl.clear_ppfZVM? = (opt_keepZVM \= 'KEEPZVM') /*!--------------------------------------------------------------------------*/ /*! Setup interim debugging stages and file IDs, if debug is active. */ /*!--------------------------------------------------------------------------*/ If (!ctl.debug?) Then Do !DbgStage.tmp_ID = '| >' !g.thisexec 'INITDATA' !g.fm_wrk !DbgStage.tmp_DS = '| >' !g.thisexec 'DATASORT' !g.fm_wrk !DbgStage.tmp_UL = '| >' !g.thisexec 'UNIQLAST' !g.fm_wrk !DbgStage.tmp_UO = '| >' !g.thisexec 'UNIQOTHR' !g.fm_wrk !DbgStage.tmp_MD = '| >' !g.thisexec 'COLLMTCH' !g.fm_wrk !DbgStage.tmp_UM = '| >' !g.thisexec 'UNMAMSTR' !g.fm_wrk !DbgStage.tmp_UD = '| >' !g.thisexec 'UNMADTLS' !g.fm_wrk End /*!--------------------------------------------------------------------------*/ /*! Setup operational values based on the type of file that is to be */ /*! corrected (cleaned up). */ /*!--------------------------------------------------------------------------*/ Select When (ft_qry = 'SYSSUF') Then Do tdata_str = ':PRODID' split_str = ' :' word_pct = 'W1' word_unq = 'W2' words_srt = word_unq word_pct stage_ReBld = '| Spec / ' || tdata_str'/ 1 W1 Nw /%/ N W2-* N' End When (ft_qry = 'SYSDESCT') Then Do tdata_str = ':PPF' split_str = ' :' word_pct = 'W4' /* W4 - Initially: 'prodid%compname' */ word_unq = 'W5' /* W5 - 'compname' (only) string */ words_srt = word_unq word_pct stage_ReBld = '| Spec / ' || tdata_str || '/ 1 W1-'|| , Right(word_pct,1) 'Nw /%/ N' word_unq'-* N' End Otherwise Say "File type" ft_qry "is not supported by this exec" Call ExitR !rc.error End /* Select */ /*!--------------------------------------------------------------------------*/ /*! Setup and run VMFSIM command to acquire data from given input file. */ /*!--------------------------------------------------------------------------*/ cmd = 'VMFSIM QUERY' cmdargs = qry_file 'TDATA' tdata_str '(STEM G.SIMQRYDATA.' Say !g.hdr "Processing file:" qry_file Say !g.hdr "Command .......:" cmd cmdargs 'EXEC' cmd cmdargs If (rc \= 0) Then Do Say !g.hdr "Command" cmd "failed; RC:" rc Call ExitR !rc.error End /*!--------------------------------------------------------------------------*/ /*! Establish values for processing VMFSIM QUERY results. */ /*!--------------------------------------------------------------------------*/ key_prime = tdata_str split_pos = 'AT' stage_clearzvm = "" If (!ctl.clear_ppfZVM?) Then stage_clearzvm = '| StrNFind /ZVM_/' /*!--------------------------------------------------------------------------*/ /*! Process VMFSIM QUERY results, to remove old-level entries. */ /*!--------------------------------------------------------------------------*/ cmd = 'PIPE (Name Proc_Simdata)' 'PIPE (Name Proc_Simdata EndChar ?)' , 'Stem g.SimQryData.' , '| StrNfind /TDATA/' , '| Join * / /' , '| Split' split_pos 'String /'key_prime || ' /' , '| Change' word_pct '/%/ /' , !DbgStage.tmp_ID , /* Initially modified data */ stage_clearzvm , /* Remove ZVM PPF-related records */ '| Sort' words_srt 'Ascending', !DbgStage.tmp_DS , /* Data Sorted - Ascending order */ '| U: Unique' word_unq 'Last' , !DbgStage.tmp_UL , /* Data Sorted - Unique, Last Items */ '| Stem RecsCrrnt.' , '?' , 'U:' , '| Stem UniqOther.' , !DbgStage.tmp_UO , /* Unique Secondary Data */ '| Hole' If (rc \= 0) Then Do Say !g.hdr "Command" cmd "failed; RC:" rc Call ExitR !rc.error End /*!--------------------------------------------------------------------------*/ /*! Reform current-level data for use as input for a VMFSIM MODIFY command. */ /*!--------------------------------------------------------------------------*/ Select When (ft_qry = 'SYSSUF') Then Do cmd = 'PIPE (Name Proc_SUFModRecs)' 'PIPE (Name Proc_SUFModRecs)' , 'Stem RecsCrrnt.' , stage_ReBld , /* Record restoration processing */ '| Change / ' || tdata_str'/TDATA ' || tdata_str'/' , '| Stem vmftdmods.' If (rc \= 0) Then Do Say !g.hdr "Command" cmd "failed; RC:" rc Call ExitR !rc.error End End When (ft_qry = 'SYSDESCT') Then Do coll_range = 'W4' /* W4 - Here, is 'prodid' (only) string */ /*!--------------------------------------------------------------------------*/ /*! Recover only 'current' prodid/compname records that might have been */ /*! eliminated by 'Unique/Last' stage of preceding pipe, then combine all */ /*! 'current level' records to create VMFSIM MODIFY input stem data. */ /*!--------------------------------------------------------------------------*/ Call CollateData 'RecsCrrnt.' , 'UniqOther.' , 'RecoverCrrnt.' cmd = 'PIPE (Name Proc_SYSDModRecs)' 'PIPE (Name Proc_SYSDModRecs)' , 'Stem RecsCrrnt.' , '| Append Stem RecoverCrrnt.' , '| Sort Unique' , /* Eliminate duplicate, identical recs */ '| Sort' words_srt 'Descending', stage_ReBld , /* Record restoration processing */ '| Change / ' || tdata_str'/TDATA ' || tdata_str'/' , '| Stem vmftdmods.' If (rc \= 0) Then Do Say !g.hdr "Command" cmd "failed; RC:" rc Call ExitR !rc.error End End Otherwise Nop End /* Select */ /*!--------------------------------------------------------------------------*/ /*! Invoke VMFSIM MODIFY to create a new table with the modified content. */ /*!--------------------------------------------------------------------------*/ cmd = 'VMFSIM MODIFY' cmdargs = !g.file_out 'STEM VMFTDMODS. (ADD' 'EXEC' cmd cmdargs If (rc \= 0) Then Do Say !g.hdr "Command" cmd "failed; RC:" rc Call ExitR !rc.error End /*!--------------------------------------------------------------------------*/ /*! Program processing is complete; Call Exit routine. */ /*!--------------------------------------------------------------------------*/ Call ExitR rc ExitR: /*!==========================================================================*/ /*! Routine: ExitR */ /*! Common Exit-point Routine. */ /*!==========================================================================*/ Arg rc_er . Exit rc_er CollateData: /*!==========================================================================*/ /*! Routine: CollateData */ /*! Collate data contained in a given pair of stem variables, with matched */ /*! records saved (as prescribed) in a third stem variable. */ /*!==========================================================================*/ in_stem1 = Arg(1) in_stem2 = Arg(2) out_stem = Arg(3) 'PIPE (Name CollateData Endchar ? )' , 'Stem' in_stem1 , '| Sort' coll_range 'Ascending' , '| c: Collate' coll_range 'Details Master' , !DbgStage.tmp_MD , /* Matched Data Records */ '| Stem' out_stem , '?', 'Stem' in_stem2 , '| Sort' coll_range 'Ascending' , '| c:' , '| Stem !leftover1.' , !DbgStage.tmp_UM , /* Unmatched Master Records */ '?', ' c:' , !DbgStage.tmp_UD , /* Unmatched Detail Records */ '| Stem !leftover2.' Return "" Provide_Help: /*!==========================================================================*/ /*! Routine: Provide_Help */ /*!--------------------------------------------------------------------------*/ /*! Provides help information for this program. "Basic" command */ /*! syntax information is displayed at the console. */ /*!--------------------------------------------------------------------------*/ /*! Input: None. */ /*!==========================================================================*/ Say !g.hdr "Syntax:" Say !g.hdrspc "" parm_str = "--fname--ftype--fmode--(--options" Say Left(">>--" || !g.thisexec || parm_str, 77, "-") || "><" Say "" Say !g.hdr "Supported file types:" !g.ft_lst Say !g.hdr "Options:" Say !g.hdr "KEEPZVM (applies to SYSDESCT file type only)" /* Call CommonExit !rc.ok */ Return Initialize: /*!==========================================================================*/ /*! Routine: Initialize */ /*! Initialize variables and program defaults. */ /*!--------------------------------------------------------------------------*/ /*! Setup variables essential for running this program. */ /*!==========================================================================*/ Parse Value ("") With , !g. , 1 !dflt. , 1 !DbgStage. Parse Upper Source . . !g.thisexec . !g.hdr = !g.thisexec || ':' !g.hdrspc = Copies(" ", Length(!g.hdr)) !ctl. = '0' !rc. = 1 !dflt.fm_wrk = 'A' /* Default work file mode */ !g.fm_wrk = !dflt.fm_wrk !g.ft_lst = 'SYSSUF SYSDESCT' /*!--------------------------------------------------------------------------*/ /*! Initialize return code values. */ /*!--------------------------------------------------------------------------*/ !rc.global = 0 !rc.ok = 0 !rc.itlerr = 1 !rc.op_err = 2 !rc.warn = 4 !rc.error = 8 /*!--------------------------------------------------------------------------*/ /*! Set debug flag, as needed. */ /*!--------------------------------------------------------------------------*/ !ctl.debug? = 0 /* !ctl.debug? = '1' */ Return ""