My brain hurts, I'd have to see this.
RTVCURDIR RTNDIR(&CD) DIRNAMLEN(&CDL)so that we can return to whatever the current directory was before we started looking for JVMs.
CHGVAR VAR(&VER) VALUE('XYY') CD DIR('/qopensys/QIBM/ProdData/JavaVM/jdkXX/YYbit') MONMSG MSGID(CPFA0A9) EXEC(DO)where X and XX are the Java version, and YY is 32 or 64. &VER keeps track of the last version tried. If the CD fails (indicating that the JVM directory doesn't exist), then the DO group tries another block of the same pattern. If the last one we try fails, we RETURN with a message, "Unable to find a compatible JVM."
RTVCURDIR RTNDIR(&JD) DIRNAMLEN(&JDL) ADDENVVAR ENVVAR(JAVA_HOME) VALUE(&JD) REPLACE(*YES)