MQSCX feature – String Replace

MQSCX String ReplaceWhen building a report, or outputting information to the screen about your IBM MQ Queue Manager, you may wish to manipulate strings, as is shown in a new example script, mqauthlist.mqsx, available in our Example Scripts bundle. This script builds an array of temporary dynamic queues to exclude from the report later. Some string manipulation is done on the names to make the search easier using the strreplace() function of MQSCX to replace underscores with dots. Here’s how:-

** Query the queue manager for the current temporary dynamic queues
@x = 0

   if( !_cmdok )
      print "Error querying TempDyn queues for queue manager", _qmgr

   @x = @x + 1
   ** In order for the search to work properly,
   ** we need to uppercase the queue names
   ** and substitute underscores with periods.
   @tempqlist[@x] = strreplace(upper(QUEUE), "_", ".")

Of course there are many uses you might find for using the strreplace() function, especially if you want to work with MQ object names that follow a Naming Convention, then you might find yourself wanting to replace the characters TEST with the characters PROD when working with different environments for Test and Production.

The best way to understand scripts is of course to have a go with them yourself. There are various examples in the download, so why not try them out yourself. If you are not currently an MQSCX licence holder, you may email to request a trial licence.


The team at MQGem would love to hear what you think. Leave your comments here.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.