/* REXX SCRAMX Create FTP package for pulling an entire PDS to the PC. |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| | | | WARNING: EMBEDDED COMPONENTS. | | See text following TOOLKIT_INIT | | | |**-***-***-***-***-***-***-***-***-***-***-***-***-***-***-***-**| Written by Frank Clarke 20090205 Impact Analysis . SYSEXEC TRAPOUT Modification History ccyymmdd xxx ..... .... */ arg argline address TSO /* REXXSKEL ver.20040227 */ arg parms "((" opts signal on syntax signal on novalue call TOOLKIT_INIT /* conventional start-up -*/ rc = Trace("O"); rc = Trace(tv) info = parms /* to enable parsing */ call A_INIT /* -*/ call B_ACQUIRE_PARMS /* -*/ if \sw.0error_found then, call C_GENERATE_BAT /* -*/ call Z_EPILOGUE /* -*/ if \sw.nested then call DUMP_QUEUE /* -*/ exit /*@ SCRAMX */ /* Initialization . ----------------------------------------------------------------- */ A_INIT: /*@ */ if branch then call BRANCH address TSO return /*@ A_INIT */ /* Pop a panel to discover the PDS name and the destination on the PC. . ----------------------------------------------------------------- */ B_ACQUIRE_PARMS: /*@ */ if branch then call BRANCH address TSO call BA_PROLOG /* extract ISPF assets -*/ call BD_GET_PARMS /* get SCRDSN and PCDIR -*/ call BZ_EPILOG /* release ISPF assets -*/ return /*@ B_ACQUIRE_PARMS */ /* . ----------------------------------------------------------------- */ BA_PROLOG: /*@ */ if branch then call BRANCH address ISPEXEC call DEIMBED /* -*/ dd = "" do Words(ddnlist) /* each LIBDEF DD */ parse value ddnlist dd with dd ddnlist $ddn = $ddn.dd /* PLIB322 <- PLIB */ "LIBDEF ISP"dd "LIBRARY ID("$ddn") STACK" end ddnlist = ddnlist dd return /*@ BA_PROLOG */ /* . ----------------------------------------------------------------- */ BD_GET_PARMS: /*@ */ if branch then call BRANCH address ISPEXEC do forever "DISPLAY PANEL(SCRAM00)" /* */ if rc > 0 then do /* PF3 ? */ sw.0error_found = 1 return end if Sysdsn( scrdsn ) = "OK" then leave else do zerrsm = Sysdsn( scrdsn ) zerrlm = "Something isn't quite right with that DSName. ", "Is it in TSO-form (quoted if fully-qualified)?" "SETMSG MSG(ISRZ002)" end end /* forever */ if Left( scrdsn,1 ) = "'" then, scrdsn = Strip( scrdsn,,"'" ) /* unquoted */ else, scrdsn = Userid()"."scrdsn /* fully-qualified */ scrlen = Length( scrdsn ) + 15 if Pos( "\",pcdir ) > 0 then, if Right( pcdir,1 ) <> "\" then, pcdir = pcdir"\" /* add trailing slash */ return /*@ BD_GET_PARMS */ /* . ----------------------------------------------------------------- */ BZ_EPILOG: /*@ */ if branch then call BRANCH address ISPEXEC dd = "" do Words(ddnlist) /* each LIBDEF DD */ parse value ddnlist dd with dd ddnlist $ddn = $ddn.dd /* PLIB322 <- PLIB */ "LIBDEF ISP"dd address TSO "FREE FI("$ddn")" end ddnlist = ddnlist dd return /*@ BZ_EPILOG */ /* SCRDSN and PCDIR are populated. . ----------------------------------------------------------------- */ C_GENERATE_BAT: /*@ */ if branch then call BRANCH address TSO call CA_GET_MEMBERS /* -*/ call CB_WRITE_GETS /* -*/ if sw.batch = 0 then, call CV_VIEW_OUTPUT /* -*/ return /*@ C_GENERATE_BAT */ /* . ----------------------------------------------------------------- */ CA_GET_MEMBERS: /*@ */ if branch then call BRANCH address TSO "MEMBERS '"scrdsn"' (( STACK LINE" pull mbrlist return /*@ CA_GET_MEMBERS */ /* . ----------------------------------------------------------------- */ CB_WRITE_GETS: /*@ */ if branch then call BRANCH address TSO "NEWSTACK" do Words( mbrlist ) /* each member */ parse var mbrlist mbr mbrlist /* isolate */ source = "'"scrdsn"("mbr")'" queue "GET" Left( source,scrlen ) pcdir""mbr".txt" end /* mbrlist */ queue "quit" outdsn = "INSTR.TXT" ldrc = LISTDSI(outdsn "NORECALL") if sysreason = 9 then /* migrated */ "HDELETE" outdsn alloc.0 = "NEW CATALOG UNIT(SYSDA) SPACE(5 5) TRACKS", "RECFM(V B) LRECL(121) BLKSIZE(0)" alloc.1 = "SHR" /* if it already exists... */ tempstat = Sysdsn(outdsn) = "OK" /* 1=exists, 0=missing */ "ALLOC FI($TMP) DA("outdsn") REU" alloc.tempstat "EXECIO" queued() "DISKW $TMP (FINIS" "DELSTACK" "FREE FI($TMP)" return /*@ CB_WRITE_GETS */ /* . ----------------------------------------------------------------- */ CV_VIEW_OUTPUT: /*@ */ if branch then call BRANCH address ISPEXEC "VIEW DATASET(INSTR.TXT)" return /*@ CV_VIEW_OUTPUT */ /* . ----------------------------------------------------------------- */ Z_EPILOGUE: /*@ */ if branch then call BRANCH address TSO return /*@ Z_EPILOGUE */ /* . ----------------------------------------------------------------- */ LOCAL_PREINIT: /*@ customize opts */ address TSO return /*@ LOCAL_PREINIT */ /* subroutines below LOCAL_PREINIT are not selected by SHOWFLOW */ /* Parse out the embedded components at the back of the source code. . ----------------------------------------------------------------- */ DEIMBED: Procedure expose, /*@ */ (tk_globalvars) ddnlist $ddn. daid. address TSO address ISPEXEC "VGET ZSCREENW" fb80po.0 = "NEW UNIT(VIO) SPACE(5 5) TRACKS DIR(40)", "RECFM(F B) LRECL("zscreenw") BLKSIZE(0)" parse value "" with ddnlist $ddn. daid. lastln = sourceline() currln = lastln /* */ if Left(sourceline(currln),2) <> "*/" then return currln = currln - 1 /* previous line */ "NEWSTACK" address ISPEXEC do while Left( sourceline(currln),2 ) <> "/*" text = sourceline(currln) /* save with a short name ! */ if Left(text,3) = ")))" then do /* package the queue */ parse var text ")))" ddn mbr . /* PLIB PANL001 maybe */ if Pos(ddn,ddnlist) = 0 then do /* doesn't exist */ ddnlist = ddnlist ddn /* keep track */ $ddn = ddn || Random(999) $ddn.ddn = $ddn address TSO "ALLOC FI("$ddn")" fb80po.0 "LMINIT DATAID(DAID) DDNAME("$ddn")" daid.ddn = daid end daid = daid.ddn "LMOPEN DATAID("daid") OPTION(OUTPUT)" do queued() parse pull line "LMPUT DATAID("daid") MODE(INVAR) DATALOC(LINE)" , "DATALEN("zscreenw")" end "LMMADD DATAID("daid") MEMBER("mbr")" "LMCLOSE DATAID("daid")" end /* package the queue */ else push text /* onto the top of the stack */ currln = currln - 1 /* previous line */ end /* while */ address TSO "DELSTACK" return /*@ DEIMBED */ /* . ----------------------------------------------------------------- */ HELP: /*@ */ address TSO;"CLEAR" ; say "" if helpmsg <> "" then do ; say helpmsg; say ""; end ex_nam = Left(exec_name,8) /* predictable size */ say " "ex_nam" is entirely panel-driven. When called, it prompts for its" say " required information, then prepares FTP 'GET' commands to" say " FTP each member of a PDS from the Host system to single " say " '.txt' files on the PC. " say "" say " It produces a file, INSTR.TXT, that must be pulled down to" say " the PC and adjusted with the userid and password needed " say " for the FTP. If running in foreground, INSTR.TXT will be" say " presented in VIEW." say " " say " If the entire PDS is not to be pulled, but merely selected" say " members, INSTR.TXT should be trimmed before sending to the" say " PC." say " Syntax: "ex_nam" < no parms > " say " " "NEWSTACK"; pull ; "CLEAR" ; "DELSTACK" say " Debugging tools provided include: " say " " say " MONITOR: displays key information throughout processing. " say " " say " NOUPDT: by-pass all update logic. " say " " say " BRANCH: show all paragraph entries. " say " " say " TRACE tv: will use value following TRACE to place the " say " execution in REXX TRACE Mode. " say " " say " " say " Debugging tools can be accessed in the following manner: " say " " say " TSO "ex_nam" parameters (( debug-options " say " " say " For example: " say " " say " TSO "ex_nam" (( MONITOR TRACE ?R " if sw.inispf then, address ISPEXEC "CONTROL DISPLAY REFRESH" exit /*@ HELP */ /* . ----------------------------------------------------------------- */ BRANCH: Procedure expose, /*@ */ sigl exec_name rc = trace("O") /* we do not want to see this */ arg brparm . origin = sigl /* where was I called from ? */ do currln = origin to 1 by -1 /* inch backward to label */ if Right(Word(Sourceline(currln),1),1) = ":" then do parse value sourceline(currln) with pgfname ":" . /* Label */ leave ; end /* name */ end /* currln */ select when brparm = "NAME" then return(pgfname) /* Return full name */ when brparm = "ID" then do /* wants the prefix */ parse var pgfname pgfpref "_" . /* get the prefix */ return(pgfpref) end /* brparm = "ID" */ otherwise say left(sigl,6) left(pgfname,40) exec_name "Time:" time("L") end /* select */ return /*@ BRANCH */ /* . ----------------------------------------------------------------- */ DUMP_QUEUE: /*@ Take whatever is in stack */ rc = trace("O") /* and write to the screen */ address TSO arg mode . "QSTACK" /* how many stacks? */ stk2dump = rc - tk_init_stacks /* remaining stacks */ if stk2dump = 0 & queued() = 0 then return if mode <> "QUIET" then, say "Total Stacks" rc , /* rc = #of stacks */ " Begin Stacks" tk_init_stacks , /* Stacks present at start */ " Excess Stacks to dump" stk2dump do dd = rc to tk_init_stacks by -1 /* empty each one. */ if mode <> "QUIET" then, say "Processing Stack #" dd " Total Lines:" queued() do queued();parse pull line;say line;end /* pump to the screen */ "DELSTACK" /* remove stack */ end /* dd = 1 to rc */ return /*@ DUMP_QUEUE */ /* Handle CLIST-form keywords added 20020513 . ----------------------------------------------------------------- */ CLKWD: Procedure expose info /*@ hide all except info */ arg kw kw = kw"(" /* form is 'KEY(DATA)' */ kw_pos = Pos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ rtpt = Pos(") ",info" ",kw_pos) /* locate end-paren */ slug = Substr(info,kw_pos,rtpt-kw_pos+1) /* isolate */ info = Delstr(info,kw_pos,rtpt-kw_pos+1) /* excise */ parse var slug (kw) slug /* drop kw */ slug = Reverse(Substr(Reverse(Strip(slug)),2)) return slug /*@CLKWD */ /* Handle multi-word keys 20020513 . ----------------------------------------------------------------- */ KEYWD: Procedure expose info /*@ hide all vars, except info*/ arg kw /* form is 'KEY DATA' */ kw_pos = wordpos(kw,info) /* find where it is, maybe */ if kw_pos = 0 then return "" /* send back a null, not found*/ kw_val = word(info,kw_pos+Words(kw))/* get the next word */ info = Delword(info,kw_pos,2) /* remove both */ return kw_val /*@ KEYWD */ /* . ----------------------------------------------------------------- */ KEYPHRS: Procedure expose, /*@ */ info helpmsg exec_name /* except these three */ arg kp /* form is 'KEY ;: DATA ;:' */ wp = wordpos(kp,info) /* where is it? */ if wp = 0 then return "" /* not found */ front = subword(info,1,wp-1) /* everything before kp */ back = subword(info,wp+1) /* everything after kp */ parse var back dlm back /* 1st token must be 2 bytes */ if length(dlm) <> 2 then /* Must be two bytes */ helpmsg = helpmsg "Invalid length for delimiter("dlm") with KEYPHRS("kp")" if wordpos(dlm,back) = 0 then /* search for ending delimiter*/ helpmsg = helpmsg "No matching second delimiter("dlm") with KEYPHRS("kp")" if helpmsg <> "" then call HELP /* Something is wrong */ parse var back kpval (dlm) back /* get everything b/w delim */ info = front back /* restore remainder */ return Strip(kpval) /*@ KEYPHRS */ /* . ----------------------------------------------------------------- */ NOVALUE: /*@ */ say exec_name "raised NOVALUE at line" sigl say " " say "The referenced variable is" condition("D") say " " zsigl = sigl signal SHOW_SOURCE /*@ NOVALUE */ /* . ----------------------------------------------------------------- */ SHOW_SOURCE: /*@ */ call DUMP_QUEUE /* Spill contents of stacks -*/ if sourceline() <> "0" then /* to screen */ say sourceline(zsigl) rc = trace("?R") nop exit /*@ SHOW_SOURCE */ /* . ----------------------------------------------------------------- */ SS: Procedure /*@ Show Source */ arg ssbeg ssct . /* 'call ss 122 6' maybe */ if ssct = "" then ssct = 10 if \datatype(ssbeg,"W") | \datatype(ssct,"W") then return ssend = ssbeg + ssct do ssii = ssbeg to ssend ; say Strip(sourceline(ssii),'T') ; end return /*@ SS */ /* . ----------------------------------------------------------------- */ SWITCH: Procedure expose info /*@ */ arg kw /* form is 'KEY' */ sw_val = Wordpos(kw,info) > 0 /* exists = 1; not found = 0 */ if sw_val then /* exists */ info = Delword(info,Wordpos(kw,info),1) /* remove it */ return sw_val /*@ SWITCH */ /* . ----------------------------------------------------------------- */ SYNTAX: /*@ */ errormsg = exec_name "encountered REXX error" rc "in line" sigl":", errortext(rc) say errormsg zsigl = sigl signal SHOW_SOURCE /*@ SYNTAX */ /* Can call TRAPOUT. . ----------------------------------------------------------------- */ TOOLKIT_INIT: /*@ */ address TSO info = Strip(opts,"T",")") /* clip trailing paren */ parse source sys_id how_invokt exec_name DD_nm DS_nm, as_invokt cmd_env addr_spc usr_tokn parse value "" with tv helpmsg . parse value 0 "ISR00000 YES" "Error-Press PF1" with, sw. zerrhm zerralrm zerrsm if SWITCH("TRAPOUT") then do "TRAPOUT" exec_name parms "(( TRACE R" info exit end /* trapout */ sw.nested = sysvar("SYSNEST") = "YES" sw.batch = sysvar("SYSENV") = "BACK" sw.inispf = sysvar("SYSISPF") = "ACTIVE" if Word(parms,1) = "?" then call HELP /* I won't be back */ "QSTACK" ; tk_init_stacks = rc /* How many stacks? */ parse value SWITCH("BRANCH") SWITCH("MONITOR") SWITCH("NOUPDT") with, branch monitor noupdt . parse value mvsvar("SYSNAME") sysvar("SYSNODE") with, #tk_cpu node . parse value KEYWD("TRACE") "O" with tv . tk_globalvars = "exec_name tv helpmsg sw. zerrhm zerralrm ", "zerrsm zerrlm tk_init_stacks branch monitor ", "noupdt" call LOCAL_PREINIT /* for more opts -*/ return /*@ TOOLKIT_INIT */ /* ISPF assets follow immediately )))PLIB SCRAM00 )ATTR % TYPE(TEXT) INTENS(HIGH) SKIP(ON) + TYPE(TEXT) INTENS(LOW) SKIP(ON) _ TYPE(INPUT) INTENS(LOW) CAPS(ON) { TYPE(INPUT) INTENS(LOW) CAPS(OFF) @ TYPE(TEXT) INTENS(HIGH) COLOR(YELLOW) ! TYPE(INPUT) INTENS(NON) )BODY EXPAND(||) WIDTH(&ZSCREENW) @|-|% FTP Transfer Parameters @|-| %COMMAND ===>_ZCMD %SCROLL ===>_ZAMT+ + + PDS to be transferred ===>_scrdsn + + + PC drive/directory ===>{pcdir + )INIT .HELP=SCRAMH0 )PROC VER( &SCRDSN,NB,DSNAME ) VER( &PCDIR ,NB ) )END )))PLIB SCRAMH0 )ATTR % TYPE(TEXT) INTENS(HIGH) SKIP(ON) + TYPE(TEXT) INTENS(LOW) SKIP(ON) _ TYPE(INPUT) INTENS(HIGH) ! TYPE(OUTPUT) INTENS(HIGH) SKIP(ON) @ TYPE(OUTPUT) INTENS(LOW) SKIP(ON) )BODY EXPAND(||) WIDTH(&ZSCREENW) %TUTORIAL |-| FTP Transfer Parameters |-| TUTORIAL %Next Selection ===>_ZCMD + Enter the name of the PDS to be transferred to the PC in TSO-format: quoted if fully-qualified. Enter the full drive+directory on the PC where the transferred .TXT files will be stored. )PROC )END */