Creating "site"-independent code

This forum provides the support of Dezhi Mainframe systems. Please post your questions about logon, usage of our mainframe environment.

Moderators: sysprog, prino, sfan, steve-myers, Tim001

Creating "site"-independent code

Postby prino » Sun 16 Aug 2009, 09:23

So you've discovered the FanDezHi system and you want to copy your code to it...

Ouch, all those nice REXX exec's you've created suddenly stop running (unless you decided to ask for a userid that is the same as the one you use for your everyday job, something I'd advise against), so what do you do?

One obvious way to reduce site-dependency is to use the 'userid()' builtin function, or the 'ZPREFIX' variable, but there are things that you cannot catch this way, like the names of system datasets like the ones hanging off the DDNAMEs in your logon procedure, e.g. SYSFAN.REXX or the fact that JOBNAMEs and/or the (MSG)CLASSes are different.

To catch such issues, you can create an exec that takes a parameter, and returns the correct value for system dependent variables. Very basic, it might look like this:

Code: Select all
/* REXX exec to return common values to calling execs                 */
/*** trace ?r ***************************************************** \| *
* GETVAR is a REXX exec to return a number of commonly used values to  *
* the calling exec.                                                    *
*                                                                      *
* The objective of this exec is to make it possible to change the      *
* commonly used values at one single location, instead of having to    *
* change the values in every exec that uses them.                      *
***********************************************************************/
parse source source
parse value source with . . moi .

/***********************************************************************
* Check if ISPF is active                                              *
***********************************************************************/
"ispqry"
!ispf = (rc = 0)

if rc = 0 then
  do
    "ispexec control errors return"
    "ispexec vget (zenvir)"
  end
else
  zenvir = ''

env = strip(substr(zenvir, 17, 8))

parse arg !what

signal fandezhi                                                 /*  5 */
signal xxxx                                                     /*  3 */

/***********************************************************************
* FANDEZHI:                                                            *
*                                                                      *
* This procedure contains all site-specific data for FanDeZhi          *
***********************************************************************/
fandezhi:
  if !ispf then
    !here = 'FanDeZhi'
  else
    !here = 5

  !qual = 'prino.'
  !live = 'rahp.'
  !rahp = 'prino'

  select
    when !what = 'EXEC'     then return !rahp'.rahp.exec'
    when !what = 'LOAD'     then return !qual || !live || 'load'
    when !what = 'HERE'     then return !here
    when !what = 'JCM'      then return '//PRINOJOB JOB (PRINO),|M|X|'

    otherwise                    return '?'
  end
exit

/***********************************************************************
* XXXX:                                                                *
*                                                                      *
* This procedure contains all site-specific data for XXXX              *
***********************************************************************/
xxxx:
  if !ispf then
    !here = 'XXXX'
  else
    !here = 4

  !qual = 'xxxxxx.'
  !live = 'rahp.'
  !rahp = 'xxxxxx'

  select
    when !what = 'EXEC' then return !rahp'.rahp.exec'
    when !what = 'LOAD' then return !qual || !live || 'load'
    when !what = 'HERE' then return !here
    when !what = 'JCM'  then return '//xxxxxxCL JOB (xxxxxx),|T|X|'

    otherwise                return '?'
  end
exit


Using this, you can e.g. call your execs by using "exec '"getvar('EXEC')"(whatever)'", and when moving to a new site, the only exec you have to change is "getvar" (or whatever you decide to call it) by adding a new section and an extra "signal" statement. I've been doing this for years and it makes life a lot easier.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
Some programming here :mrgreen:
prino
 
Posts: 479
Joined: Sat 06 Jun 2009, 21:41
Location: Vilnius, Lithuania

Re: Creating "site"-independent code

Postby gnanas » Sun 16 Aug 2009, 13:33

Thanks a lot for sharing the code, Prino. It is really helpful.

We'd be grateful to you if you share the points like this. Appreciating your efforts.

Have a good day!
Cheers,
Gnanas N.
gnanas
 
Posts: 25
Joined: Sat 13 Jun 2009, 04:57

Re: Creating "site"-independent code

Postby prino » Sun 16 Aug 2009, 13:59

For those interested in more REXX, feel free to browse my exec library on the system, PRINO.RAHP.EXEC, which might contain more useful code, including a full-blown version of GETVAR.

Please be aware that most code in it is (C) Copyright Robert AH Prins, but that I'm in the process of releasing everything that I have written myself under the provisions of the Gnu Public License V3.0 and obviously those members that already contain a
Code: Select all
/***********************************************************************
* This program is free software: you can redistribute it and/or        *
* modify it under the terms of the GNU General Public License as       *
* published by the Free Software Foundation, either version 3 of       *
* the License, or (at your option) any later version.                  *
*                                                                      *
* This program is distributed in the hope that it will be useful,      *
* but WITHOUT ANY WARRANTY; without even the implied warranty of       *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
* GNU General Public License for more details.                         *
*                                                                      *
* You should have received a copy of the GNU General Public License    *
* along with this program. If not, see <http://www.gnu.org/licenses/>  *
***********************************************************************/

comment can be copied freely. If you want to copy anything else, please have the courtesy to ask if you can do so and I'll probably will give you permission.
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
Some programming here :mrgreen:
prino
 
Posts: 479
Joined: Sat 06 Jun 2009, 21:41
Location: Vilnius, Lithuania


Return to Dezhi systems: Mainframe

Who is online

Users browsing this forum: No registered users and 0 guests