Problem solve Get help with specific problems with your technologies, process and projects.

Was the function cancelled?

This tip provides you with an easy way to see if was pressed.

Some functions allow users to press to cancel, but don't provide your job an easy way to tell if was pressed. The Display Long Text API in another tip is one example; RUNQRY RCDSLT(*YES) is another, more common one.

The sample CL code shows how to use the Retrieve Job Information (QUSRJOBI) API to check the "cancel key" status of a job after running a function such as those above. If the assigned "cancel" key was pressed, the retrieved job information will have a '1' in position 104 (or offset 103) of format JOBI0600. The documentation describes this position as "Cancel key"; position 103 (offset 102) is described as "Exit key" and would normally be associated with pressing .


 
		pgm    ( +
         &pAction       +
       )

   dcl   &pAction         *char    20


   dcl   &Action          *char    20

   dcl   &msgdta          *char    256


/* API General Variables */
   dcl   &a_len           *char      4       /* Bin Data/Entry length  */
   dcl   &a_rcv           *char   1000       /* Receiver Variable, the */
                                             /* length is variable. It */
                                             /* must be in &A_LEN.     */


   chgvar   &Action              &pAction


/* -----------------------------------------------------------------*/
/*   QUSRJOBI - Retrieve Job Information -- Test *CANCEL            */
/* -----------------------------------------------------------------*/

   chgvar     %bin( &a_len 1 4 )    307

   Qsys/call  QUSRJOBI      ( +
                              &a_rcv              +
                              &a_len              +
                              'JOBI0600'          +
                              '*'                 +
                              '                '  +
                            )

   if ( %sst( &a_rcv 104 1 ) *eq '1' )   do

      chgvar     &msgdta            ( +
                                      'Action'  *bcat +
                                      &action   *bcat +
                                      'cancelled.'    +
                                    )
      Qsys/sndpgmmsg  msgid( CPF9897 ) msgf( QSYS/QCPFMSG ) +
                   msgdta( &msgdta ) +
                   msgtype( *INFO )

      goto       Exit

   enddo


Exit:

   Qsys/rmvmsg     msgq( *PGMQ ) clear( *ALL ) rmvexcp( *NO )
   monmsg    ( cpf0000 mch0000 )


Done:

   return

   EndPgm 
This was last published in June 2001

Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close