Topic
  • 2 replies
  • Latest Post - ‏2017-09-27T19:49:09Z by pjackson
pjackson
pjackson
7 Posts

Pinned topic How to handle sys req 2 (endrqs) in CL pgm

‏2017-09-26T23:39:28Z |

I have a situation where I have a CL program that needs to switch to a higher authority profile using the QsySetToProfileHandle API to handle some work before switching back to the standard user and displaying results.

 

What would be the best way to handle the situation of the program being cancelled with the system request menu option 2 so that I can make sure that the current authority is switched back before ending the program?

 

I have been looking at the CEERTX (Register Call Stack Entry Termination User Exit Procedure) API, but it seems geared towards usage within RPG code..  Is there some other mechanism that would be best to detect abnormal termination from within the CL so I can perform cleanup?

 

Thanks in advance,

Paul 

  • cmasse
    cmasse
    8 Posts
    ACCEPTED ANSWER

    Re: How to handle sys req 2 (endrqs) in CL pgm

    ‏2017-09-27T04:52:44Z  

    Hi Paul.

     

    you must initiate a dialogue with the external (pgmq *EXT) and you will be a "request processor" then you will receive CPF1907 in case of cancel request

     

    
    MONMSG CPF1907 EXEC(GOTO ENDEXEC)
     
     
             SNDPGMMSG  MSG('/* any message */') TOPGMQ(*EXT) MSGTYPE(*RQS)
     
             RCVMSG     PGMQ(*EXT) MSGTYPE(*RQS) RMV(*NO)
     
              ...
     
              ...
     
              ...
     
    ENDEXEC: RCLRSC
     
              ...
    

     

    Christian

  • cmasse
    cmasse
    8 Posts

    Re: How to handle sys req 2 (endrqs) in CL pgm

    ‏2017-09-27T04:52:44Z  

    Hi Paul.

     

    you must initiate a dialogue with the external (pgmq *EXT) and you will be a "request processor" then you will receive CPF1907 in case of cancel request

     

    
    MONMSG CPF1907 EXEC(GOTO ENDEXEC)
     
     
             SNDPGMMSG  MSG('/* any message */') TOPGMQ(*EXT) MSGTYPE(*RQS)
     
             RCVMSG     PGMQ(*EXT) MSGTYPE(*RQS) RMV(*NO)
     
              ...
     
              ...
     
              ...
     
    ENDEXEC: RCLRSC
     
              ...
    

     

    Christian

  • pjackson
    pjackson
    7 Posts

    Re: How to handle sys req 2 (endrqs) in CL pgm

    ‏2017-09-27T19:49:09Z  
    • cmasse
    • ‏2017-09-27T04:52:44Z

    Hi Paul.

     

    you must initiate a dialogue with the external (pgmq *EXT) and you will be a "request processor" then you will receive CPF1907 in case of cancel request

     

    <pre class="vert" dir="ltr" style="box-sizing: border-box; font-family: "Lucida Console", Monaco, monospace; font-size: large; width: 785.265625px; padding: 20px; margin: 20px 16.359375px; overflow: auto; line-height: 15.300000190734863px; border: 1px solid rgb(100, 225, 203); color: rgb(0, 0, 0);"> MONMSG CPF1907 EXEC(GOTO ENDEXEC) SNDPGMMSG MSG('/* any message */') TOPGMQ(*EXT) MSGTYPE(*RQS) RCVMSG PGMQ(*EXT) MSGTYPE(*RQS) RMV(*NO) ... ... ... ENDEXEC: RCLRSC ... </pre>

     

    Christian

    Thanks you Christian!  that'll work.

     

    I had also been looking at scope messages, but this seems a lot more straightforward.

     

    Paul