4 Replies Latest reply on Sep 18, 2017 6:30 PM by Paul Robins

    Passing KSL return code up to the JCL?

    Dwayne Hendrickson
      Share This:

      Running IOA 8 on z/OS 2.02 MVS mainframe. I am using RETURN 99 to indicate I have a problem within my KSL but I have not been able to pass that back up to the JCL so that the batch job will fail. I have tried using the SETOLOC with no success.

       

      This code currently works

       

      //DAKSLOUT  DD SYSOUT=*                                  

      //DAKSLPRM  DD *                                         

      *--------------------------------------------------------

        MAXCOMMAND 999999                                      

        TRACE ON                                               

        CALLMEM RET99                                          

        SHOUT TO OPER TEXT 1ST %CALLRC TESTING FOR DAH         

        END                                                    

      /*                                                      

       

      Member RET99 consists of

      RETURN 99

      The SHOUT TO OPER works and replaces %CALLRC with 99. How can I get that value up into the JCL so I can utilize it as an Autoedit variable?

        • 1. Re: Passing KSL return code up to the JCL?
          Paul Robins

          Hi Dwayne,

          Try:

          SETVAR %RC DATA '99'    

          END

           

          As per the KeyStroke Language User Guide:

          %RC Supplies the return code of the script. The value at successful script termination is the condition code of the step. Valid values are: 0 through 4095.
          %MSG Specifies text assigned at script termination, which appears as a message in the job’s SYSLOG and the script execution listing. Only the value of variable %MSG at the script member issuing command END is displayed.

          • 2. Re: Passing KSL return code up to the JCL?
            Dwayne Hendrickson

            Hi Paul,

             

            Are you suggesting replacing the

            RETURN 99

            with

            SETVAR %RC DATA '99'   

             

            I currently have no problem with the KSL ending with a return code of 99, the RETURN works fine for that. My problem is that batch job JCL does not fail. It ends with C0000. I am trying to get the return code 99 from the KSL as a usable variable in the JCL, probably as an Autoedit variable, so that I can have the JCL get a non zero Condition Code and fail..

            • 3. Re: Passing KSL return code up to the JCL?
              Paul Robins

              Yes, as per the User Guide extract that I pasted, %RC provides the return code of the script.

              I believe RETURN is for returning a value from a nested KSL back to the calling KSL, not for terminating the script.

              • 4. Re: Passing KSL return code up to the JCL?
                Paul Robins

                Description of RETURN from the manual:

                Returns to the calling script. return-code must be a number from 0 through 4095. When command RETURN is activated, control is passed to the command after the CALLMEM command in the calling member. The variable %CALLRC in the calling member is set to the value of the return code. Default: 0.

                 

                So RETURN only works to return the RC to a calling KSL.