Rexx to the Rescue!
Total Page:16
File Type:pdf, Size:1020Kb
Session: G9 Rexx to the Rescue! Damon Anderson Anixter May 21, 2008 • 9:45 a.m. – 10:45 a.m. Platform: DB2 for z/OS Rexx is a powerful tool that can be used in your daily life as an z/OS DB2 Professional. This presentation will cover setup and execution for the novice. It will include Edit macro coding examples used by DBA staff to solve everyday tasks. DB2 data access techniques will be covered as will an example of calling a stored procedure. Examples of several homemade DBA tools built with Rexx will be provided. Damon Anderson is a Senior Technical DBA and Technical Architect at Anixter Inc. He has extensive experience in DB2 and IMS, data replication, ebusiness, Disaster Recovery, REXX, ISPF Dialog Manager, and related third-party tools and technologies. He is a certified DB2 Database Administrator. He has written articles for the IDUG Solutions Journal and presented at IDUG and regional user groups. Damon can be reached at [email protected] 1 Rexx to the Rescue! 5 Key Bullet Points: • Setting up and executing your first Rexx exec • Rexx execs versus edit macros • Edit macro capabilities and examples • Using Rexx with DB2 data • Examples to clone data, compare databases, generate utilities and more. 2 Agenda: • Overview of Anixter’s business, systems environment • The Rexx “Setup Problem” Knowing about Rexx but not knowing how to start using it. • Rexx execs versus Edit macros, including coding your first “script” macro. • The setup and syntax for accessing DB2 • Discuss examples for the purpose of providing tips for your Rexx execs • A few random tips along the way. 2 Overview of Anixter’s Business • Anixter Inc. is a Global Distributor ($4.9 Billion) • Wire, Cable, Sound & Security, Networking, Fasteners • Corporate Snapshot: • Year Founded: 1957 • Number of employees: 7500 • 2007 Revenues: $5.8 billion • Products: 400,000 • Inventory: $1 billion • Customers: 95,000 • Stock Symbol: AXE • Countries: 49 3 About Anixter Anixter Inc. is the world’s leading supplier of Supply Chain Services and products used to connect voice, video, data and security systems. Anixter is also the leading provider of specialty electrical and electronic wire and cable for building construction, industrial maintenance and repair, and original equipment manufacturing as well as the leader in providing fasteners and “C” Class components to OEMs and production lines. Anixter adds value to the distribution process by providing its customers access to the following: 1) Innovative inventory management programs. 2) More than 400,000 products and over $1 billion in inventory. 3) 226 warehouses with more than 5.5 million square feet of space. 4) locations in 251 cities in 49 countries. Founded in 1957 and headquartered near Chicago, Anixter trades on The New York Stock Exchange under the symbol AXE. 3 Overview of Anixter’s Systems Mainframe Mainframe Hardware: Software: 2 Mainframes • Z/8 • z/OS 1.7 • Z/9 - Moving to z/OS 1.9 • Soon: • DB2 8.1 • Replace Z/8 with Z/9 4 Anixter currently has 2 mainframes. We have 2-way Data Sharing for DB2 and IMS. CICS and WebSphere are the main OLTP (Online Transaction Processing) environments. At last count: 12 DB2 Subsystems 11 IMS Subsystems 4 Rexx – The Setup Problem Symptoms of the “Rexx Setup Problem” • I went to a REXX Class but still don’t use it. • I downloaded a REXX Exec of the Internet but I don’t know how to make it work. • I saw Kyle using an Edit Macro, but it doesn’t work for me. Solutions to the “Rexx Setup Problem” • Talk to the Systems Programmer(s) responsible for ISPF. • Talk to someone who it works for. • Investigate your environment. 5 REXX = Restructured Extended Executor A general-purpose, procedural language for end-user personal programming, designed for ease by both casual general users and computer professionals. It is also useful for application macros. REXX includes the capability of issuing commands to the underlying operating system from these macros and procedures. Features include powerful character-string manipulation, automatic data typing, manipulation of objects familiar to people, such as words, numbers, and names, and built-in interactive debugging. One of the main problems with Rexx tends to be what I call the “Setup” problem. Some people are familiar with the capabilities of Rexx, but cannot utilize it because they cannot established an environment where they can code and test their Rexx programs. The first quarter of this presentation is targeting those individuals. Walking them through the setup of a Rexx PDS and the various allocation options available. Additional steps are included for running Rexx execs in batch, interactively and running edit macros. 5 Setup – Step 1, Allocate a PDS. • Allocate a PDS or PDSE to hold your Rexx Execs. • Add the member REXXSYNT below to your Rexx PDS. Save the member. The comment on the first line is required to identify this as a REXX exec. Depending on where the exec resides, you may be able to remove it… my suggestion: just leave it. 6 Once you are ready to start coding Rexx exec and/or edit macros, you will need a library to store them in. The naming convention for this library should adhere to the naming conventions of your company. Sometimes, properly naming your Rexx PDS is all that will be required to get it properly allocated…. potentially simplifying upcoming step 4. Go to ISPF 3.2 and allocate a PDS. It can be Fixed Block, LRECL=80 or Variable Block, LRECL=255. Once allocated, proceed to create a member in the PDS called REXXSYNT. Add the three lines from the screenshot into the member and save it. The comment on the first line is required to identify this as a REXX exec. Depending on where the exec resides, you may be able to remove it… my suggestion: just leave it. 6 Setup – Step 2, Run a sample. • Execute your first REXX • On the command line, type TSO EXEC followed by the quoted fully qualified Rexx member… • TSO EXEC “E200301.PDS.REXX(REXXSYNT)” This was nice, but there has to be an easier way. 7 At this point, you have your Rexx PDS allocated and you have saved your first Rexx Exec into the PDS. We will now attempt to run the Exec. On the command line, type TSO EXEC followed by the quoted fully qualified Rexx PDS member, for example: TSO EXEC “E200301.PDS.REXX(REXXSYNT)” If all goes well, you should be greeted by the SAY statement of your first Rexx exec. I am notoriously lazy when it comes to typing. I really do not want to type a fully qualified PDS name and member every time I want to invoke a Rexx. Let’s investigate what can be done to simplify this. 7 Setup – Step 3, Run it in Batch. • Execute your first REXX in Batch mode. • Create a job similar to the following… Your Jobcard Your Rexx PDS 8 We will now attempt to run your first Rexx exec in a Batch job. The JCL is extremely simple. The parm to the Terminal Monitor Program is the member name of Rexx exec to be executed. The TMP may be one of the following: IKJEFT01, IKJEFT1A, or IKJEFT1B. Please refer to the TSO/E User’s Guide ( SA22-7794-03 ) for information on the differences between these programs. Just an opinion, but you will likely want to use IKJEFT1B. The PDS containing the Rexx exec is allocated to the SYSEXEC DD statement. It can also be a SYSPROC DD statement. 8 Setup – Step 3, Run it in Batch. • That’s worse… why did I just do that? 2 Reasons: 1. We learned that Rexx Execs can be easily executed in a batch job. 2. We learned that Rexx Execs can be loaded from the SYSEXEC DD. ( or the SYSPROC DD ) 9 It seemed to add no value to this Exec, but what about the Exec that processes for 10 minutes. The main takeaway is that Rexx Execs can easily be ran in a batch job. We also learned which DD statement Rexx Execs can be loaded from. We will use that information when we move on to allocating our Rexx PDS to our ISPF session. 9 Setup - Step 4, get allocated. • The goal is is to get your Rexx PDS in either your SYSPROC or SYSEXEC DD allocations for you ISPF Session. • Talk to the Systems Programmer(s) responsible for ISPF. • Find out if your site has a “Realloc” or “Setup” Exec or Clist to allocate your libraries. • Talk to someone that you know uses Rexx at your company. • Ask them for help… how do they get their Rexx PDS allocated to their ISPF Session? 10 For ease of use, it is best to get you Rexx PDS allocated to your TSO/ISPF session. There are several methods of accomplishing this: ALTLIB ACTIVATE can be used to dynamically add a Rexx Exec library to the search path. This method is not “global” in that it must be done for each new split screen. This isn’t a great option. The best method from the perspective of the person wanting to execute the Rexx program is to have your Rexx PDS in the concatenation of either your SYSPROC or SYSEXEC DD. Many sites utilize a “REALLOC” or “SETUP” Rexx Exec or clist to perform this concatenation every time you logon. It finds the names of PDS’s currently allocated to the DDNAME SYSEXEC or SYSPROC and then adds your Rexx PDS to the list. Ask around as you don’t want to utilize a lesser solution when a better one may exist.