IBM Support

QIBM_QWC_PRERESTRICT Example and Usage Notes

How To


Summary

The document provides an example that uses QIBM_QWC_PRERESTRICT and extra usage notes.

Environment

IBM grants you a nonexclusive license to compile, link, execute, display, reproduce, distribute, and prepare derivative works of this Sample Code.  The Sample Code has not been thoroughly tested under all conditions.  Therefore, IBM does not guarantee or imply its reliability, serviceability, or function. IBM provides no program services for the Sample Code.
    
All Sample Code is provided to you "AS IS" without any warranties of any kind. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGMENT ARE EXPRESSLY DISCLAIMED.  SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO THE ABOVE EXCLUSIONS MAY NOT APPLY TO YOU.  IN NO EVENT WILL IBM BE LIABLE TO ANY PARTY FOR ANY DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL DAMAGES FOR ANY USE OF THE SAMPLE CODE INCLUDING, WITHOUT LIMITATION, ANY LOST PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN IF WE ARE EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Additional Information

NOTE:
The cancel phase is only called if the check phase has already completed successfully for one of the exit programs. If your exit program returns a status flag of 0 to stop the ending to restricted state, it will not be called again.

This first program returns a 1 for the status flag to go to restricted state (GO).
PGM        PARM(&RTN &FMT &ACTION &DLY)

      DCL        VAR(&RTN)    TYPE(*CHAR) LEN(12)   /* INPUT-OUTPUT */
      DCL        VAR(&FMT) TYPE(*CHAR) LEN(8)       /* INPUT        */
      DCL        VAR(&ACTION)   TYPE(*CHAR) LEN(1)  /* INPUT        */
      DCL        VAR(&DLY)    TYPE(*INT) LEN(4)     /* INPUT        */

DMPCLPGM
IF COND(&ACTION = '1') THEN(DO)                     /* CHECK PHASE  */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'0000000C')     /* LENGTH       */
  CHGVAR VAR(%SST(&RTN 5 4)) VALUE(X'00000001')     /*   GO         */
  CHGVAR VAR(%SST(&RTN 9 4)) VALUE(X'00000000')     /* DELAY TIME   */
  SNDMSG MSG('Prerestricted state check phase GO') +
                          TOUSR(*SYSOPR)
 ENDDO

IF COND(&ACTION = '2') THEN(DO)                  /* EXECUTE PHASE   */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'00000004')  /* LENGTH          */
  SNDMSG MSG('Prerestricted state execute phase GO') +
                          TOUSR(*SYSOPR)
 ENDDO

IF COND(&ACTION = '3') THEN(DO)                  /* CANCEL PHASE  */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'00000004')  /* LENGTH        */
  SNDMSG     MSG('Prerestricted state cancel phase GO') +
                          TOUSR(*SYSOPR)
 ENDDO
DMPCLPGM
ENDPGM
The second program returns a 0 for the status flag, meaning do not go to a restricted state (NOGO).
PGM        PARM(&RTN &FMT &ACTION &DLY)

      DCL        VAR(&RTN)    TYPE(*CHAR) LEN(12)  /* INPUT-OUTPUT */
      DCL        VAR(&FMT) TYPE(*CHAR) LEN(8)      /* INPUT        */
      DCL        VAR(&ACTION)   TYPE(*CHAR) LEN(1) /* INPUT        */
      DCL        VAR(&DLY)    TYPE(*INT) LEN(4)    /* INPUT        */

DMPCLPGM
IF COND(&ACTION = '1') THEN(DO)                    /* CHECK PHASE  */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'0000000C')    /* LENGTH       */
  CHGVAR VAR(%SST(&RTN 5 4)) VALUE(X'00000000')    /* NOGO         */
  CHGVAR VAR(%SST(&RTN 9 4)) VALUE(X'00000000')    /* DELAY TIME   */
  SNDMSG MSG('Prerestricted state check phase NOGO') +
                          TOUSR(*SYSOPR)
 ENDDO

IF COND(&ACTION = '2') THEN(DO)                    /* EXECUTE PHASE */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'00000004')    /* LENGTH        */
  SNDMSG MSG('Prerestricted state execute phase NOGO') +
                          TOUSR(*SYSOPR)
 ENDDO

IF COND(&ACTION = '3') THEN(DO)                   /* CANCEL PHASE   */
  CHGVAR VAR(%SST(&RTN 1 4)) VALUE(X'00000004')   /* LENGTH         */
  SNDMSG     MSG('Prerestricted state cancel phase NOGO') +
                          TOUSR(*SYSOPR)
 ENDDO
DMPCLPGM
ENDPGM
When both programs are registered:
The first program is called to run the Check phase.
Then, the 2nd program is called to run the Check phase.
Then, the first program is called a second time to run the cancel phase (since the 2nd program returned a status flag to stop it from continuing to restricted state).
Extra Usage Notes:
If you only have an exit program registered for QIBM_QWC_PRERESTRICT and you call PWRDWNSYS only, the pre-restricted state exit program is NOT called.
If you called ENDSYS first before calling PWRDWNSYS, the pre-restricted state exit program would be called from ENDSYS, but it is not called a second time from the PWRDWNSYS.

The power-down exit point QIBM_QWC_PWRDWNSYS has two formats. Format PWRD0100 has no parameters and simply calls the user exit program.  Format PWRD0200 is similar to the QIBM_QWC_PRERESTRICT exit point having the same parameters and Action phases and it also allows you to block the PWRDWNSYS in the cases where the pre-restricted state exit is not called.

If you have exit programs for both QIBM_QWC_PRERESTRICT and QIBM_QWC_PWRDWNSYS and you call PWRDWNSYS, only the power down exit program is called (not the pre-restricted state exit program).
If you call ENDSYS first before calling PWRDWNSYS, the pre-restricted state exit program is called from ENDSYS, but once restricted state is reached, the power down exit is not called.

If you only have an exit program registered for QIBM_QWC_PWRDWNSYS and you call PWRDWNSYS, the power down exit program is called once.
If you call ENDSYS first before calling PWRDWNSYS, the power down exit is called during ENDSYS, but once restricted state is reached, the power down exit program is not called a second time.

When using formats with the Action phases:
The exit program is called a second time with an Action of '2' (execute) if all the registered exit programs returned a status of '1' during the check phase (indicating continue going to restricted state).
The exit program is called a second time with an Action of '3' (cancel) if another registered exit program returned a status of '0' during the Check phase (indicating to abort going to restricted state).

If your own program returns a status of '0' to stop the ENDSBS/ENDSBS *ALL, the program is not called a second time because we assume that since your program is preventing the system from going to restricted state, that your program is already aware that the command will not continue, and can take appropriate action.

If another exit program cancels the command after your program has already run, your program is called with the cancel action as a courtesy in case it needs to undo or clean up any action taken during the check phase.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m3p000000hB4rAAE","label":"API"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"All Versions"}]

Document Information

Modified date:
27 February 2023

UID

ibm16958454