I'm using the if Q[database=...] notation in my scripts to distinguish between different SAP systems. We have now installed a new SAP release, and temporarily we have 2 systems with the same SAP name, e.g. D01. How can I distinguish these systems in my script?

If you know the application server names for these systems, e.g. P00128 for one of the systems, you can use

if  V[_ashost=P00128]