home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / viscobv7.zip / vac22os2 / ibmcobol / macros / iwzmesb.lx < prev    next >
Text File  |  1998-01-08  |  11KB  |  385 lines

  1. /* Reinvoking as "REXX %0 %1 %2 %3 %4 %5 %6 %7 %8 %9"  2>nul
  2. @goto runit */
  3. /*********************************************************************/
  4. /* Licensed Material - Property of IBM                               */
  5. /* 5639-B92 , 5639-D65 (C) Copyright IBM Corp., 1997, 1998           */
  6. /* All rights reserved.                                              */
  7. /* US Government Users Restricted Rights - Use, duplication or       */
  8. /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */
  9. /*********************************************************************/
  10. trace off;
  11. signal on novalue;
  12. parse source opsys . whoami rest;
  13. /* cobolroot is now set by iwzmIR.CMD */
  14. if opsys = 'OS/2' then
  15.   do;
  16.   env = 'OS2ENVIRONMENT';
  17.   callit = '@Call';
  18.   call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs';
  19.   call SysLoadFuncs;
  20.   end;
  21. else
  22.   do;
  23.   env = 'ENVIRONMENT';
  24.   callit = '@Rexx';
  25.   end;
  26. tempdir = value('TMP',,env);
  27. tempout = SysTempFileName(tempdir'\TM?????.OUT');
  28. tempout2 = SysTempFileName(tempdir'\T2?????.OUT');
  29. xx = Get_MVSINFO();
  30. if xx <> 0 then
  31.   exit 16;
  32. call Set_MVSINFO_Vars;
  33. if tracemod = '*' |,
  34.   wordpos(translate(substr(whoami,lastpos('\',whoami)+1)),tracemod) > 0 then
  35.   do;
  36.   if trace > 3 then trace results;
  37.   if trace > 4 then trace ?;
  38.   end;
  39. parse arg the_input_args;
  40. call traceit 1 'Entry' '!'the_input_args'!';
  41. 'set messages on';
  42. 'extract doctype into doctype';
  43. if translate(doctype) <> 'JCL' then
  44.   call message 01;
  45. usedrive = '';
  46. if tempdata <> '' then
  47.   do;
  48.   if numdrive > 0 then
  49.     do;
  50.     do ii = 1 to numdrive;
  51.       if tempdata = drive.ii & trans.ii = 'text,crlf' then
  52.         do;
  53.         usedrive = drive.ii;
  54.         temphqual = highqual.ii;
  55.         leave;
  56.         end;
  57.       end;
  58.     end;
  59.   if usedrive = '' then
  60.     call message 02;
  61.   if pos('.',temphqual) > 0 then
  62.     do;
  63.     dsname = "'"temphqual".@@TMPE@@.CNTL'";
  64.     dsnamew = usedrive"\@@TMPE@@.CNTL";
  65.     end;
  66.   else
  67.     do;
  68.     dsname = "'"temphqual".IWZ.@@TMPE@@.CNTL'";
  69.     dsnamew = usedrive"\IWZ.@@TMPE@@.CNTL";
  70.     end;
  71.   end;
  72. else
  73.   do;
  74.   if numdrive > 0 then
  75.     do;
  76.     do ii = 1 to numdrive;
  77.       if highqual.ii = userid & trans.ii = 'text,crlf' then
  78.         do;
  79.         usedrive = drive.ii;
  80.         leave;
  81.         end;
  82.       end;
  83.     end;
  84.   if usedrive = '' then
  85.     call message 03;
  86.   dsname = "'"userid".IWZ.@@TMPE@@.CNTL'";
  87.   dsnamew = usedrive"\IWZ.@@TMPE@@.CNTL";
  88.   end;
  89. /* 'extract name into name'; */
  90. 'check';
  91. 'extract changes into changes';
  92. 'lxn save' dsnamew;
  93. save_rc = rc;
  94. /* 'set name' name; */
  95. 'check';
  96. 'set changes' changes;
  97. if save_rc <> 0 then
  98.   call message 04 dsname;
  99. if filesys <> 'SDU' then
  100.   do;
  101.   if closefile = 'YES' then
  102.     do;
  103.     address cmd '@iwzmnfc.exe' dsnamew;
  104.     fclose_rc = rc;
  105.     end;
  106.   else
  107.     fclose_rc = 4;
  108.   if fclose_rc = 0 then
  109.     xx = SysSleep(1);
  110.   else
  111.     do;
  112.     timeout = writetimeout + 1;
  113.     xx = SysSleep(timeout);
  114.     end;
  115.   end;
  116. subcmd = 'IGYFSUB' dsname;
  117. if mvscomm = 'YES' then
  118.   address cmd callit 'iwzmvws.cmd' subcmd '}'tempout
  119. else
  120.   address cmd callit 'iwzmscm.cmd' callit 'iwzmtso.cmd !!??'tempout'??+'subcmd;
  121. read_stem.0 = 0;
  122. xx = linein(tempout,1,0);
  123. do forever;
  124.   if lines(tempout) = 0 then
  125.     leave;
  126.   read_stem.0 = read_stem.0 + 1;
  127.   nn = read_stem.0;
  128.   read_stem.nn = linein(tempout);
  129.   if substr(read_stem.nn,1,2) = '??' then
  130.     read_stem.nn = substr(read_stem.nn,3);
  131.   end;
  132. xx = stream(tempout,'C','CLOSE');
  133. address cmd '@erase' tempout;
  134. if read_stem.0 = 0 then
  135.   call message 05;
  136. output = strip(read_stem.1,'T');
  137. if pos('SUBMITTED',output) = 0 then
  138.   call errmsg output;
  139. parse var output dummy 'JOB ' jobname rest;
  140. if pos('(',jobname) = 0 | pos(')',jobname) = 0 then
  141.   call message 06 output;
  142. call traceit 3 '--->' output;
  143. 'msg' output;
  144. call traceit 1 'Normal exit';
  145. exit 0;
  146. /* */
  147. errmsg:
  148. parse arg the_msg;
  149. call traceit 3 '--->' the_msg;
  150. 'msg' the_msg;
  151. 'alarm';
  152. call traceit 1 'Error exit';
  153. exit 16;
  154. /* */
  155. message:
  156. parse arg iwz_message_num,
  157.           iwz_message_arg1 '\\',
  158.           iwz_message_arg2 '\\',
  159.           iwz_message_arg3 '\\',
  160.           iwz_message_arg4 '\\',
  161.           iwz_message_arg5 '\\',
  162.           iwz_message_arg6 '\\',
  163.           iwz_message_arg7 '\\',
  164.           iwz_message_arg8;
  165. select;
  166.   when language = 'ENG' then
  167.     call message_eng;
  168.   when language = 'JPN' then
  169.     call message_jpn;
  170.   otherwise
  171.     call message_eng;
  172.   end;
  173. return;
  174. /* */
  175. message_eng:
  176. select;
  177.  
  178. when iwz_message_num = 1 then do;
  179. call errmsg 'File is not of type JCL';
  180. end;
  181.  
  182. when iwz_message_num = 2 then do;
  183. call errmsg 'Cannot find drive for temporary data sets';
  184. end;
  185.  
  186. when iwz_message_num = 3 then do;
  187. call errmsg 'Cannot find drive with userid as high level qualifier';
  188. end;
  189.  
  190. when iwz_message_num = 4 then do;
  191. call errmsg 'Cannot save to temporary file' iwz_message_arg1;
  192. end;
  193.  
  194. when iwz_message_num = 5 then do;
  195. call errmsg 'Unknown error submitting job';
  196. end;
  197.  
  198. when iwz_message_num = 6 then do;
  199. call errmsg 'Unknown output' iwz_message_arg1;
  200. end;
  201.  
  202. otherwise
  203. call sayit 'Invalid message number' iwz_message_num;
  204. end;
  205. return;
  206. /* */
  207. message_jpn:
  208. 'msg Japanese message';
  209. select;
  210.  
  211. when iwz_message_num = 1 then do;
  212. call errmsg 'File is not of type JCL';
  213. end;
  214.  
  215. when iwz_message_num = 2 then do;
  216. call errmsg 'Cannot find drive for temporary data sets';
  217. end;
  218.  
  219. when iwz_message_num = 3 then do;
  220. call errmsg 'Cannot find drive with userid as high level qualifier';
  221. end;
  222.  
  223. when iwz_message_num = 4 then do;
  224. call errmsg 'Cannot save to temporary file' iwz_message_arg1;
  225. end;
  226.  
  227. when iwz_message_num = 5 then do;
  228. call errmsg 'Unknown error submitting job';
  229. end;
  230.  
  231. when iwz_message_num = 6 then do;
  232. call errmsg 'Unknown output' iwz_message_arg1;
  233. end;
  234.  
  235. otherwise
  236. call sayit 'Invalid message number' iwz_message_num;
  237. end;
  238. return;
  239. Get_MVSINFO:
  240. Procedure expose env cobolroot mvsinfo. whoami tempdir trace
  241.  
  242. rtn = 0
  243. null = '0000'x
  244. crlf = '0D0A'x
  245. mvsinfo. = ''
  246. mvsinfoQ = translate('iwzm_MVSINFO.DAT_YALE');
  247.  
  248. oldq = rxqueue('Set',mvsinfoQ)   /* switch to mvsinfo queue */
  249. if queued() = 0 then do                   /* if Q is missing we'll */
  250.   qname = rxqueue('Create',mvsinfoQ)      /* create it and put a bad */
  251.   if qname = mvsinfoQ then push 'Sven'    /* timestamp on it, else */
  252.   else x=rxqueue('Delete',qname)          /* it was in use (we hope) */
  253.   end                                     /* so we'll assume we can */
  254. parse pull mvsstuff; push mvsstuff        /* get/replace Q contents */
  255. parse value mvsstuff with ts (null) . cobolroot (null) mvsstuff /* get */
  256.                                         /* timestamp and cobolroot */
  257. if ts <> 'Sven' then do;
  258.   mvsinfo = cobolroot'\MACROS\MVSINFO.DAT'
  259.   bad_mvsinfo = '    **' whoami '****'crlf'    **error*' mvsinfo,
  260.                 'is unavailable, missing or empty **'
  261.  
  262.   x=SysFileTree(mvsinfo,'ts','F')       /* get MVSINFO.DAT's timestamp */
  263.   if ts.0 <> 1 then do
  264.     say bad_mvsinfo
  265.     return 12;
  266.     end
  267.   parse var ts.1 v0 v1 v2 .
  268.   timestamp ='mvsinfo.dat.timestamp' v0 v1 v2
  269.   end;
  270. else
  271.   timestamp = 'Yale'
  272. if timestamp <> ts then do              /* timestamps match? */
  273.   pull mvsstuff                         /* no, remove bad contents */
  274.   rtn = "iwzmIR.CMD"()                /* ask for new stuff */
  275.   if rtn = 0 then do
  276.     parse pull mvsstuff; push mvsstuff    /* get/replace Q contents */
  277.                                         /* remove timestamp and     */
  278.                                         /* cobolroot                */
  279.     parse value mvsstuff with . (null) . cobolroot ( null) mvsstuff
  280.     end
  281.   end
  282. qname = rxqueue('Set',oldq)      /* restore normal queue */
  283.  
  284. do while (mvsstuff<>'') & (rtn=0)   /* mvsinfo. structure */
  285.   parse value mvsstuff with key val (null) mvsstuff
  286.   if mvsinfo.key = '' then do       /* e.g. mvsinfo.TYPE='' */
  287.     mvsinfo.KEYS = mvsinfo.KEYS key /* no substitution for KEYS */
  288.     mvsinfo.key.1 = val             /* e.g. mvsinfo.TYPE.1=val  */
  289.     mvsinfo.key = 1                 /* e.g. mvsinfo.TYPE=1      */
  290.     end
  291.   else do
  292.     x = mvsinfo.key + 1             /* e.g. mvsinfo.TYPE+1     */
  293.     mvsinfo.key.x = val             /* e.g. mvsinfo.TYPE.2=val */
  294.     mvsinfo.key = x                 /* e.g. mvsinfo.TYPE=2     */
  295.     end
  296.   end
  297.  
  298. return rtn
  299.  
  300. Set_MVSINFO_Vars:
  301.  
  302.  parse var mvsinfo.CLOSECMD.1 closecmd;
  303.  parse var mvsinfo.CLOSEFILE.1 closefile;
  304.  parse var mvsinfo.FILESYS.1 filesys accessmon testaccess;
  305.  parse var mvsinfo.FSSTARTCMD.1 fsstartcmd;
  306.  parse var mvsinfo.FSSTOPCMD.1 fsstopcmd;
  307.  parse var mvsinfo.HEADER.1 header;
  308.  parse var mvsinfo.JOBLOG.1 joblog;
  309.  parse var mvsinfo.MAXCMD.1 maxcmd;
  310.  parse var mvsinfo.LANGUAGE.1 language;
  311.  parse var mvsinfo.MOUNTCMD.1 mountcmd;
  312.  parse var mvsinfo.MVSCOMM.1 mvscomm;
  313.  parse var mvsinfo.iwzmEDT.1 iwzmedt;
  314.  parse var mvsinfo.NFS.1 nfs;
  315.  parse var mvsinfo.NULLSTDIN.1 nullstdin;
  316.  parse var mvsinfo.OUTSHOW.1 outshow;
  317.  parse var mvsinfo.PROTSAVE.1 protsave tempmult;
  318.  parse var mvsinfo.PWD.1 pwd pwdasis pwdt pwde;
  319.  parse var mvsinfo.READTIMEOUT.1 readtimeout;
  320.  parse var mvsinfo.REXECCMD.1 rexeccmd;
  321.  parse var mvsinfo.SDU.1 sdu;
  322.  parse var mvsinfo.SIGYCLST.1 sigyclst;
  323.  parse var mvsinfo.SYSPROC.1 sysproc;
  324.  parse var mvsinfo.SYSTEM.1 system;
  325.  parse var mvsinfo.TEMPDRIVE.1 tempdrive;
  326.  parse var mvsinfo.TEMPDATA.1 tempdata;
  327.  parse var mvsinfo.TESTFILE.1 testfile;
  328.  parse var mvsinfo.TRACE.1 trace tracekeep;
  329.  parse var mvsinfo.TRACECMD.1 tracecmd;
  330.  parse var mvsinfo.TRACEMOD.1 tracemod;
  331.  parse var mvsinfo.UMOUNTCMD.1 umountcmd;
  332.  parse var mvsinfo.USERID.1 userid;
  333.  parse var mvsinfo.WORKSYS.1 worksys;
  334.  parse var mvsinfo.WRITETIMEOUT.1 writetimeout;
  335.  
  336.  parse var mvsinfo.DRIVE numdrive;
  337.  if numdrive = '' then
  338.    numdrive = 0;
  339.  do ii = 1 to numdrive;
  340.    parse var mvsinfo.DRIVE.ii,
  341.              drive.ii highqual.ii trans.ii mapping.ii sidefile.ii;
  342.    end;
  343.  
  344.  parse var mvsinfo.TYPE numtype;
  345.  if numtype = '' then
  346.    numtype = 0;
  347.  do ii = 1 to numtype;
  348.    parse var mvsinfo.TYPE.ii type.ii ext.ii;
  349.    end;
  350.  
  351. return
  352.  
  353. /* */
  354. Traceit:
  355.  parse arg iwz_trc_level iwz_trc_message;
  356.  if iwz_trc_level > trace then
  357.    return;
  358.  if pwd <> '********' & pwd <> '++++++++' & pwd <> '========' then
  359.    do;
  360.    do forever;
  361.      if pos(pwd,iwz_trc_message) = 0 then
  362.        leave;
  363.      parse var iwz_trc_message iwz_trc_message1 (pwd) iwz_trc_message2;
  364.      iwz_trc_message = iwz_trc_message1||'********'||iwz_trc_message2
  365.      end;
  366.    end
  367.  iwz_trc_message = date('O') time('L') whoami':' iwz_trc_message;
  368.  xx = lineout(tempdir'\iwzmTRC.TRC',iwz_trc_message);
  369.  xx = stream(tempdir'\iwzmTRC.TRC','C','CLOSE');
  370.  if tracecmd <> '' then
  371.    interpret tracecmd;
  372. return;
  373.  
  374. /* */
  375. sayit:
  376.  parse arg iwz_sayit_arg;
  377.  if trace > 2 then
  378.    call traceit 3 '--->' iwz_sayit_arg;
  379.  say iwz_sayit_arg;
  380. return;
  381. /*
  382. :runit
  383. @rexx %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
  384. @rem */
  385.