Writing a script to make changes to an MQ Namelist is actually very difficult to do. You have to display the contents of the list of names, and then build an ALTER NAMELIST command passing in the original list along with your changes to that list. What a palaver.
MQSCX makes that operation marvelously simple. Adding, or removing names from the list in a namelist is very simple. Here’s an example to show you just how simple it is.
ALTER NAMELIST(OVERLAPPING.CLUSTER) =add(SALES)
Before the command was issued the OVERLAPPING.CLUSTER had, let’s say, three names in the list:-
AMQ8550: Display namelist details. NAMELIST(OVERLAPPING.CLUSTER) NAMCOUNT(3) NAMES(NEWS ,INVENTORY ,PAYMENT) DESCR(Cluster Repos NL) ALTDATE(2016-02-11) ALTTIME(21.03.44)
After the command was issued it now looks like:-
AMQ8550: Display namelist details. NAMELIST(OVERLAPPING.CLUSTER) NAMCOUNT(4) NAMES(NEWS ,INVENTORY ,PAYMENT ,SALES) DESCR(Cluster Repos NL) ALTDATE(2016-02-11) ALTTIME(21.04.50)
The beauty of this command is that, you didn’t need to know what the names in the namelist were in order to add a new name to the list.
If the list already had the name you tried to add in the list, then the command won’t add it in a second time.
There is also the capability to remove names from the list – also with a very simple command.
ALTER NAMELIST(OVERLAPPING.CLUSTER) =rmv(NEWS)
Not only can you remove a single name, you can also use wildcards in the =rmv field to match against multiple names in the list and remove them all.
Of course, the best way to understand scripts is of course to have a go with them yourself. If this looks like something you’d like to try, and you are not currently an MQSCX licence holder, you may email email@example.com to request a trial licence and have a go with it yourself.