Please DO Twitter In My Sessions

(Originally posted 2009-04-09.)

It’s approaching conference season again – at least the UKCMG / European System z Conference portion of it.

Bearing that in mind I want to share this article with you: “Professor Encourages Students to Pass Notes During Class — via Twitter”. It’s well worth reading the comments that follow the article. They’re rather more enlightening and illustrative than the (short) article itself.

I’ve been in the habit for two years now of Tweeting in sessions where I’ve been in the audience. Yes, some of it has been irrelevant to the topic but much of it has been relaying items of importance from the session itself. I hope it hasn’t been too distracting, and certainly I’ve used “low key” technologies to do it. (Of course before that I’d blog about sessions.)

Now that Twitter has become mainstream (evidenced by me no longer asking “are you on Twitter?” but rather “what’s your Twitter ID?” and the HUGE onrush of people (including mainframe folks) onto Twitter in the past year) I’d expect a fair proportion of people in my audiences to be on Twitter. And so we can begin to do what the article suggests: Encourage participation via Twitter.

So, in MY sessions please feel free to use Twitter. If you want to turn it into a “back channel” that’s fine. In fact, as the article says and the comments amplify, that’s a very valuable thing to do.

If you happen not to be in the room but some friend of yours is feel free to tweet at them to get them to ask questions. Or whatever.

I guess, as a presenter, the thing you fear most is “loss of control”. Personally that’s a very minor fear for me. I’m much more interested in making the time we have together, thinking about the topic and hopefully discussing it, as valuable as possible.

A while ago I adopted the practice of leaving my favourite Twitter client – Twhirl – on. It was a fun stunt to pull – as tweets flew across my beloved presentation foils live on screen. 🙂 I mightn’t do that anymore, though some of the tweets undoubtedly were FAR more interesting than the slides. 🙂 And, though I’d like to be able to, I don’t think I can tweet and speak at the same time. 😦 So don’t expect me to participate until after the session.

One other thing: I realise that not having access to Twitter during a session is disenfranchising. And it’s been annoying when I’ve been in the back of someone else’s session when NONE of my Twitter clients – whether on phones or laptops – have been functional.

But, in general, feel free to use Twitter whenever I’m presenting. And hopefully I won’t give you much occasion to tweet about my dress sense. 🙂

Workload Manager Policy in XML Format – Part III

(Originally posted 2009-04-08.)

Here’s another way to process a WLM Service Definition – once you’ve got it into XML format.

XSLT (XML Stylesheet Transformations if you prefer) is another technology that’s been around for a while.

In simple terms you write another piece of XML (the stylesheet) that describes how to transform your original XML into something else. There’s a lot of flexibility in this but the example in this post is plain old HTML as a target.

There are lots of tools to take the XSLT file and use it to transform the original XML. In my case I’m using a java-based free engine(Saxon)but you could, for example, do it from javascript. Saxon’s command-line based and works fast and well – for my purposes.

So here’s a sample XSLT file:

<?xml version="1.0"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  xmlns:wlm="http://www.ibm.com/WLM/ServiceDefinition/Level008">

<xsl:output method="xhtml" /> <xsl:template match="/"> <xhtml> <body> <h1><xsl:value-of select="wlm:ServiceDefinition/wlm:Name"/> - <xsl:value-of select="wlm:ServiceDefinition/wlm:Description"/></h1> <table border="1"> <tr> <th>Name</th> <th>Description</th> <th>Subsystem Type</th> <th>Limit</th> <th>Procedure Name</th> <th>Start Parameters</th> </tr> <xsl:apply-templates select="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment"/> </table> </body> </xhtml> </xsl:template>

<xsl:template match="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment"> <tr> <td><xsl:value-of select="wlm:Name"/></td> <td><xsl:value-of select="wlm:Description"/></td> <td><xsl:value-of select="wlm:SubsystemType"/></td> <td><xsl:value-of select="wlm:Limit"/></td> <td><xsl:value-of select="wlm:ProcedureName"/></td> <td><xsl:value-of select="wlm:StartParameter"/></td> </tr> </xsl:template>

</xsl:stylesheet>

Again, I’m showing you a sample that handles a different fragment of the Service Definition.

In this case it’s the Application Environment definitions (most notably for use with DB2 Stored Procedures). The stylesheet does two things.

  • Shows the Service Definition name and associated description.
  • Lists in a table information about each Application Environment. (For me the most interesting thing here is the NUMTCB value.)

The “wlm:” throughout is required because the XML file has a namespace associated with it. So all the searches have to respect that. An example of such a search is

match="wlm:ServiceDefinition/wlm:ApplicationEnvironments/wlm:ApplicationEnvironment">

Searches in XSLT are in XPath format. Basically this one says “match on ApplicationEnvironment elements within ApplicationEnvironments elements within the ServiceDefinition element, respecting the use of the namespace “wlm” which is really “http://www.ibm.com/WLM/ServiceDefinition/Level008&#8221;.

As both XPath and XSLT are widely documented on the web (and because this is a technology I’m still almost at the bottom of the learning curve for) I won’t describe the code any further. Again I’d suggest you try it, having taken a text editor to your XML-format Service Definition, and then play with it some.

(Annoyingly there’s an emoticon that appeared in the code instead of “xmlns : xsl” and you’ll need to take the spaces out of this to make it work.)

This is and XSLT file I wrote myself. It was a little fiddly at first but now I think it’s quite easy to understand and modify. But I know I’ve missed many tricks, XSLT and XPath being incredibly powerful.

Have fun playing!

Workload Manager Policy in XML Format – Part II

(Originally posted 2009-04-07.)

In Workload Manager Policy in XML Format – Part I I showed you how you can use PHP to extract Classification Rules information from the WLM Service Definition (once converted to XML format).

This post gives an example of extracting a different set of information from the XML Service Definition, using javascript and, in particular, XMLHttpRequest (sometimes known as XHR).

There is a slightly ulterior motive here: Acquainting mainframe people with some of the more modern web techniques. (I’m hoping you’ll explore some of them for yourselves.)

Here’s some sample code:

<html><body><h2>Workloads</h2><ul id="workloads"></ul><script type="text/javascript">  var req = new XMLHttpRequest();  req.open('GET', 'wlmpolicy.xml', true)  req.onreadystatechange = function (aEvt)  {    if (req.readyState == 4)    {      if(req.status == 200)      {        DOM=req.responseXML;                // Get list of workloads        workloads=DOM.getElementsByTagName("Workload")                // Add a list item for each workload        ul=document.getElementById("workloads")        for(w=0;w<workloads.length;w++)        {          // Get workload name          nameNode=workloads[w].getElementsByTagName("Name")[0].firstChild          workloadName=nameNode.nodeValue

// Get workload description descNode=workloads[w].getElementsByTagName("Description")[0].firstChild workloadDesc=descNode.nodeValue

// Create list item and add workload name / desc to it li=document.createElement("li") liText=document.createTextNode(workloadName+" - "+workloadDesc) li.appendChild(liText) // List item to the list ul.appendChild(li) } } } } req.send(null);</script></body></html>

Now, hopefully that wasn’t too intimidating: If you have a webserver to stick your XML on try it for yourself: The only thing you’ll need to change is the target URL in the XMLHttpRequest.

Most of the code is designed to fire – as a block – when the XML document is retrieved. It parses the returned XML, looking for “<Workload>” elements. The list of those is in array “workloads”.

For each of the workloads it looks for “<Name>” and “<Description>” elements and retrieves the text associated with them.

Finally, for each workload, a new “<li>” tag is created and populated with the workload’s name and description.

Thus the code sample prints a list of workloads and their descriptions.

There’s obviously a lot more in the WLM Service Description. I’ve shown you two techniques for parsing it. The simplest thing to do next is to convert your own WLM Service Definition to XML and browse it with a text editor. (On Windows I’m using Notepad++ but any editor will do, preferably one that syntax highlights XML).

Workload Manager Policy in XML Format – Part I

(Originally posted 2009-04-06.)

This isn't particularly new – but I'm guessing most people who work with WLM don't know about this…

For some time now you've been able to download a java application that enables you to convert your WLM Service Definition to and from XML. Perhaps more importantly, the application provides a nice way to edit the Service Definition – and that is actually its main purpose.

You can get the program from here. Unfortunately – from my perspective as someone who aspires to migrate to Linux over time – it is packaged for Windows. (I have mentioned this to Development – as it appears to be a java/Swing application and hence potentially portable.)

To retrieve the ISPF-based Service Definition, to convert it to and from XML, and to update it on z/OS a pair of batch jobs are used, submitted via FTP. If you get the setup right – and this is quite easy – the whole round-trip works well.

In any case the java application is a nice way to edit the Service Definition.

Now to the main purpose of this blog entry.

Manipulating the XML WLM Service Definition using PHP

The java application saves a copy of the XML Service Definition to your local workstation.XML is really nice as you can manipulate it in so many different ways.

Consider PHP, as an example. I may blog about this some more one day but I've installed Apache, with PHP support, on my Thinkpad. And this webserver is permanently up but only accessible via "localhost" URLs. (I've written a few scripts that automate most of the tedious parts of retrieving performance reports from the mainframe and displaying them.)

PHP is a good webserver scripting language, well suited to lots of tasks, and with an active development community. One of the things it's good at is processing XML. The following code example does some basic processing that's useful to me. You might find it useful to build on.


<?php
$dom=new DOMDocument;
$dom->load('wlmpolicy.xml');
$xpath=new DOMXPath($dom);
$xpath->registerNamespace("wlm","http://www.ibm.com/WLM/ServiceDefinition/Level008");

// List classification rules
echo "<h2>Classifications</h2>\n";
echo "<ul>\n";
$classifications=$xpath->query('/wlm:ServiceDefinition/wlm:Classifications/wlm:Classification');
foreach($classifications as $c)
{
  $subsysNode=$xpath->query("wlm:SubsystemType",$c);
  $subsys=$subsysNode->item(0)->nodeValue;
  $descNode=$xpath->query("wlm:Description",$c);
  $desc=$descNode->item(0)->nodeValue;
  echo "<li>$subsys - $desc\n";
  echo "<ul>\n";
  $crs=$xpath->query('wlm:ClassificationRule',$c);
  foreach($crs as $cr)
  {
    $qtypeNode=$xpath->query("wlm:QualifierType",$cr);
    $qtype=$qtypeNode->item(0)->nodeValue;
    $qvalueNode=$xpath->query("wlm:QualifierValue",$cr);
    $qvalue=$qvalueNode->item(0)->nodeValue;
    $sclassNode=$xpath->query("wlm:ServiceClassName",$cr);
    $sclass=$sclassNode->item(0)->nodeValue;
    $rclassNode=$xpath->query("wlm:ReportClassName",$cr);
    $rclass=$rclassNode->item(0)->nodeValue;
    echo "<li>$qtype - $qvalue ($sclass / $rclass)\n";
  }
  echo "</ul></li>\n";
}
echo "</ul>\n";?>

In XML terms the root node is <ServiceDefinition>. You can get to the classification rules with an XPath of

"/wlm:ServiceDefinition/wlm:Classifications/wlm:Classification"

The "wlm" in the above XPath expression refers to the need to register a namespace. The line

$xpath->registerNamespace("wlm","http://www.ibm.com/WLM/ServiceDefinition/Level008");

does that. Using this XPath expression yields a list of <Classification> nodes, which the code stores in the PHP variable $classifications. The rest of the code loops through the list, pumping out list items. Each list item in this sample describes the classification rule and (in brackets) the Service Class and Report Class the rule's firing leads to.

This is all simple PHP. I chose this small part of the WLM Service Definition to format as it's an example of something that's not in RMF's Type 72 record. When I look at how customers have set up WLM I really think I need to know how the classification rules were coded.

I'm hoping this code fragment will get you thinking about the value of having the WLM Service Definition in XML form. (By the way the XML form is saved on z/OS as part of the conversion and download process – and the conversion code is very visible if you nose around a bit.)

I've written "Part I" in the title of this blog post because I think I'm going to play with some more XML-related technologies – just to show the flexibility of the approach.

My HackDay 6 Project – Mashing Up RMF

(Originally posted 2008-11-03.)

Another 6 months on and another HackDay…

Hackday6 was on 24 October – and being distracted by little things such as GSE Conference and an important customer situation I haven’t blogged about it yet. So, a little late, here goes…

Many of you will know that RMF has a WebPortal for monitoring performance and capacity usage. And you’ll know that the z10 processor’s HMC is web-based (though I don’t think z10 was the first System z processor to have one). Let’s park the HMC thing for a moment…

Before I go any further I should acknowledge my team mate in this: Stepane Rodet from the Boeblingen Lab (where, most relevantly to me, RMF, WLM and Capacity Provisioning Manager come from). He did a lot of the programming work and put together the foils we’re waving around (the latter, thankfully, using OpenOffice).

Here’s the idea…

Any web interface, just about, can be “mashed up”, hacked about or (as I prefer to call it) defaced. So we thought we’d demonstrate this using RMF. Choosing RMF was not exactly gratuitous – just to get “z” in the hack. 🙂 The point is we think that the RMF WebPortal has information in it that would be good to mash up. We don’t really know how people would choose to mash up the data but we think there’s a lot of potential there. Such vague notions are what get me into trouble. 🙂

So, we devised a shopping list of web technologies to use against this web data source, including

  • GreaseMonkey (a most excellent scripter for Firefox).
  • PHP (which would run in a web server that acted as a front end).
  • cURL (a command line HTTP client).
  • Adobe AIR (which uses HTML and javascript to build desktop applications).
  • Java applets.

In the end we concentrated on a very small number of these and went against a small number of RMF-served web pages.

And our hacks were rather modest – just showing we could extract names and numbers (of LPARs) and do some arithmetic and redisplay with them (building a simple table with scaled bars in it).

We had a lot of fun doing it and, though the hack was rather small, we count it a success because…

  • We demonstrated RMF WebPortal could be mashed up.
  • We learnt some lessons on behalf of Development… such as the need to be able to navigate direct to pages that are in frames and the need for “id” attributes on some of the key HTML tags.

So, as I mentioned before, Stephane has written some foils (and I’ve contributed a little to them) that he is taking to RMF and WLM development groups – to get their interest. (Stephane works on Capacity Provisioning Manager and is in the same group as WLM and RMF.)

There are no promises here but we’ve started the conversation with RMF about how to make its information more consumable by web clients. (You have to be careful in this because there’s no guarantee of “HTML stability” as, in principle, RMF could change the HTML with a single PTF – to meet some other need.) And, no, I don’t think HTML hacking is the best way to do this… I’d like to see some robust web services (probably JSON or maybe XML).

Now, why the HMC?

Because I think that this is equally mashable and combining its data with RMF might be an interesting thing to do. But we didn’t get there this time. We wanted to actually get something working… to demonstrate the possibilities.

Maybe next time…

Unless you (dear customer) have something in the z/OS space that’s relatively small you’d like us to try and do (or mock up or experiment with). Ideas?

Oh, and by the way, maybe Twitter is a good place to bounce around ideas like that. Lots of mainframers and DB2 folks are there now. DB2 is doing especially well with household names right now. You can fine Stephane as “rodet” and me as “martinpacker” on Twitter.

System z Expo, Las Vegas, 13-17 October

(Originally posted 2008-09-25.)

With a couple of working days to go before the deadline I’ve completed my two presentations for Expo.

As usual I’ve added some new stuff, based on new technologies and some situations I’ve encountered. And rather than throwing older stuff out I’ve moved most of it to backup foils. While I’m prepared to present the backup material I don’t expect to have time to in the sessions. But at least you’ll have the material. And at other times, in other places, I can present the material.

As my presentations are of the “evolutionary” variety I suspect if you saw me present twice in a year you’d barely feel they’d changed at all. Hopefully most people see them but once a year and get value out of what has changed.

So, here are the two sessions I’m giving:

  • Much Ado About CPU – Now with z10 Too

    Depending on your perspective the most notable new stuff is

      Structure-Level Coupling Facility CPU
    • More focused zIIP and zAAP stuff
    • Blocked Workloads
    • z10 Hiperdispatch
  • Memory Matters in 2009

    For some reason the organisers of the US conference think I should be ultra forward looking and name the presentation after the coming year. In Europe we seem to be more relaxed about this and the same presentation would be “in 2008”. To be honest I don’t know which I called it for GSE Conference (which is at the end of October).

    Again, depending on your perspective the most notable new stuff is

    • More on paging subsystem design and dump space
    • System z10 1MB pages
    • z/OS Release 10 64-Bit Common

It’s going to be interesting to catch up with some of the other presenters and to see what they think is interesting to talk about. And to see some friendly customers I haven’t seen for a year.

I’ll also be updating you via Twitter: Remember my id is MartinPacker so feel free to follow me and to interact with me on Twitter. I’m going to be using the hashtag #zOSExpo2008 and would encourage other twitterers at the conference to do the same. Using a hashtag to mark tweets has worked well at other conferences. I expect, for instance, to flag what session I’m in. So you might want to ensure questions you’re interested in get asked. Of course, I’d have to find the question interesting and not to have asked too manyquestions already. 🙂 You know how difficult that’ll be. 🙂

I think you can tell I’m looking forward to this conference (don’t I always?) even if the flights are bit of a bore and so’s the jetlag. I have been to Las Vegas three times before and have the Saturday after the conference free. I think I might hire a car and get out of town and take my camera with me. Anyone else attending who has the same idea?

And if you were wondering about going I can tell you the agenda looks easily good enough to make it a great use of time. Join me in Las Vegas!

How Many Browsers Do You Have On Your Machine?

(Originally posted 2008-09-20.)

Well, how many do you have?

I’ll admit to 4 on my Windows XP Laptop (and 2 versions of 1 on my ASUS EEE PC, running Linux)…

I firmly believe in having an “emergency browser”. At 0ne time that would have been Internet Explorer – for two reasons:

  • To recover a broken browser. As I mainly use Firefox Nightly builds I sometimes get cases where I need a fresh install of a prior nightly to get me out of trouble. (Nightlies are the bleeding edge in Firefox terms, nice but sometimes too bleeding edge.)
  • To access pages that Firefox has a problem with.

Nowadays, however, there are almost no web pages I can’t read with Firefox. So it doesn’t have to be Internet Explorer anymore.

In fact IBM really doesn’t care what browser I use – so long as I don’t want support. 🙂 (I haven’t wanted support for probably 20 years.) 🙂 Certainly, to be serious, there is strong endorsement by all and sundry for Firefox, even though it isn’t in any formal sense the mandated browser.

So what do I have now?

  • Firefox 3 Nightlies (as I said before) as my main browser. And I occasionally get involved in design or bug spotting discussions.
  • Internet Explorer 6 – seldom used.
  • Safari as my real “emergency browser” at the latest released level. Webkit goes on apace and so I might take a more bleeding edge stance soon.
  • Google Chrome – just out of curiosity.

One thing to note now is that there is a great race going on between the various browsers for speed, especially (this year) in their javascript execution engines.

And the significance of the “javascript wars” is that, through means like Adobe AIR and toolkits such as dojo, the web experience (and perhaps more general application experience) is become increasingly dependent on javascript. And heavy execution at that.

So the browser war may have become dull (or maybe not) but it’s fascinating to see the javascript front open up.

But, finally, in case anyone thinks I’m about to shift browser I’m not expecting to replace Firefox as my main browser anytime soon. I really don’t think Google Chrome is a Firefox killer (or an anything else killer, either).

Happy browsing folks and remember you should have more than one browser – not counting the (perhaps ignored) one that came with your operating system.

Minor Good News On Coupling Facility Performance Reporting

(Originally posted 2008-09-19.)

In recent releases RMF have put the machine serial number into both SMF Type 74 Subtype 4 (Coupling Facility Activity) and SMF Type 70 Subtype 1 (CPU Activity). Actually we get two fields in each case: Plant Number and Sequence Number, which you can put together as eg “51-12345”.

Soon we’ll get another piece of the jigsaw: Partition Number in 74-4.

This is a small change but a nice useful one…

It finally enables you to correlate the CPU Activity Report view of a Coupling Facility LPAR and the Coupling Facility Activity Report view. I have seen several customer cases where this has been impossible from SMF alone, even from counting engines in both records.

I intend to say a little more about it in my “Much Ado About CPU – Now with z10 Too” presentation at Expo in October. In fact I’d better get writing the new foils… given that I think it needs restructuring to compress much of the “everybody knows this already” material. (I expect to put quite a bit about z10 in, as well as some more stuff about Coupling Facility CPU such as the Structure-Level CPU field R744SETM.)

System z10 CPU Instrumentation

(Originally posted 2008-09-18.)

Since I got back off vacation in L’Hérault in late August I’ve been working on adding z10 support to our CPU analysis code. It’s quite a substantial set of changes – and I don’t think I’m finished yet. But I’d like to share with you what I’ve learned so far.

But first let’s briefly review what’s changed with z10. (This is a very brief review and not a tutorial on the subjects mentioned.)

  • z10 introduces a bunch of changes in the area of how upgrades – whether temporary or permanent and whether wanted or forced by circumstances – work. So we now have the notion of Permanent and Temporary capacity models (and indeed capacity values).
  • HiperDispatch is a very significant set of changes in the way PR/SM and the z/OS Dispatcher work – especially since they work together.

I’ve had data from one customer who is using Hiperdispatch for real. But already I’m seeing “behaviours”.

I would assume, by the way, that MXG already has support for the new fields and has adjusted any calculations that needed adjusting. While I follow MXG-L Listserver I don’t take more than a passing interest in MXG itself. And, also by the way, I’m talking exclusively about Type 70 Subtype 1 in this post.

Capacity Models

We now have four different models in Type 70:

  • SMF70MDL – the original model. (Prior to z990 software model (this one) was equal to the hardware model)
  • SMF70HWM – hardware model (introduced with z990 because of the book structure)
  • SMF70MPC – permanent capacity model (new with z10)
  • SMF70MTC – temporary capacity model (new with z10)

There are also three capacity ratings:

  • SMF70MCR – corresponding to SMF70MDL
  • SMF70MPR – corresponding to SMF70MPR
  • SMF70MTR – corresponding to SMF70MTR

These are all interesting in an environment where your machine configuration changes – whether through “On-Off Capacity On Demand”, “Capacity Backup”, “Capacity For Planned Events” or whatever. You can now do your usual performance and capacity work even when the configuration changes.

At this point I’m just listing the numbers in my reporting. I suspect I’ll do more when I get performance data from customers who actually do e.g. time-of-the-month upgrades/downgrades (and I know one or two who already do).

Hiperdispatch

When looking at Hiperdispatch you have to understand there are two major parts to it:

  • Dispatcher Affinity (DA) – from z/OS
  • Vertical CPU Management (VCM) – from PR/SM

Internally I still sometimes hear it using the terms DA and VCM. The point is it’s got two parts to it. So there is information in sections of the record related to z/OS and other information in sections related to PR/SM. You have to put the two together.

And here’s the most important bit…

You need to collect Type 70s from ALL z/OS images of any significance on the machine to get the full picture.

A good example of this is understanding how many logical engines are really in play when some of them are parked (in most LPARs).

z/OS – Related Information

SMF70HHF has flags for whether Hiperdispatch is supported or is active. These are, fairly obviously, for the reporting z/OS image.

SMF70PPT is the amount of time this engine was “parked” in the interval. (That is when work is deliberately not dispatched to it.) These are some or all of the “Low Polarization” engines. More on that a little later. But parked engines are important because the new calculation for CPU Busy counts parked engines as not part of the z/OS image’s capacity.

PR/SM – Related Information

SMF70POW is used to calculate the Polarization Weight for a logical engine. Logical engines are classified as High, Medium or Low. An LPAR’s weights are spread across its logical engines to ensure the High engines each have a weight corresponding to one physical engine. Each Low engine has a zero weight. Any weight left over from assigning the High weights is assigned to either 1 or 2 Medium engines. (1 if the remainder is more than half an engine, 2 if the remainder would have been less than half an engine.)

You can observe this Polarization Weight distribution using SMF70POW…

The highest value of SMF70POW for an LPAR is a High logical engine, that is 1 whole physical engine. Any values of SMF70POW smaller than that but greater than zero are for Medium logical engines. I’ve seen cases of both 1 Medium and of 2 Mediums for different LPARs on the same machine.

Bringing It All Together

So, to understand Hiperdispatch you need both LPAR and z/OS image information.

Actually, since IRD was introduced, you’ve had to marry up both perspectives. Because Online Time (in the case of Logical CP Management) became a part of the calculation. And now Parked Time is.

(After a number of years of owning our CPU Analysis code I’ve recast it – for Hiperdispatch – in a way that makes it much easier to morph our CPU calculations in case anything else happens. I’m not foretelling anything – just knowing that CPU Utilisation is one of those things whose definition will never settle for long.) 🙂

Replace String A With String B But Not If It’s Part Of String A1

(Originally posted 2008-07-31.)

As I mentioned in this blog post DFSORT just shipped a new FINDREP function to do “find and replace”.

I mentioned an example of where I might use it to replace SMFIDs in SMF records. That example generally works well.

But suppose (say, for SMF 42-6 Data Set Performance records) I want to replace “SYS1” with “MVSA” but don’t want to replace “SYS1.” with “MVSA.”.

There’s something useful about FINDREP that saves the day: Only the first match is used. So consider the following FINDREP example:

  OPTION COPY                                                
  INREC FINDREP=(INOUT=(C'SYS1.',C'SYS1.',C'SYS1',C'MVSA'))
  

With this code any data set references of the form “SYS1.” are transformed to themselves – and the cursor moves past them – whereas any other “SYS1” reference is transformed to “MVSA”.

It makes sense to put the most restrictive find string first. Otherwise the following wouldn’t work…

   OPTION COPY                                              
   INREC FINDREP=(INOUT=(C'SYS1.MODIFYME',C'MVSA.MODIFYME',
     C'SYS1.',C'SYS1.',
     C'SYS1',C'MVSA'))

which will change “SYS1.MODIFYME” into “MVSA.MODIFYME” but no other “SYS1.” string (unless it starts with “SYS1.MODIFYME”).

Of course, given you can use FINDREP as part of IFTHEN there’s a lot more you can do with it. But for now I just wanted to point out the “first hit wins” characteristic that can be useful.