How to ESCAPE RPG-program in error-case ?

asdf13
asdf13 used Ask the Experts™
on
How to ESCAPE RPG-program in error-case ?

RPG calls some API. if error happens in API-call, RPG program loops,
because of parm-length error.

How to use SDS to avoid looping (escape, without MSG, only leave RPG-pgm) ?
For example :

 I*                                                                
 I           SDS                                                  
 I                                     *PROGRAM PGNAME            
 I                                     *STATUS  PSTAT              
 I                                      254 263 USER              
                                                               
  *                                                                
0273.00      C                     MOVEL'MSGJOB'  SPC    10                  
0274.00      C                     MOVEL'TSITOOL' SPCLIB 10                  
0275.00      C                     MOVEL'*ALL '   JUSER                      
0276.00      C                     MOVEL'*ALL '   JNAME                      
0277.00      C                     MOVEL'*ALL '   JNUM                        
0278.00      C                     MOVELSPC       USRSPC                      
0279.00      C                     MOVE SPCLIB    USRSPC 20                  
0280.00      C                     Z-ADD2         ANZK                        
0281.00      C                     Z-ADD0101      K1                          
0282.00      C                     Z-ADD1906      K2                          
0283.00       *                                                              
0284.00       *  USERSPACE                                
0285.00      C                     CALL 'QUSCRTUS'             33            
0286.00      C                     PARM           USRSPC                      
0287.00      C                     PARM           EXT    10                  
0288.00      C                     PARM 10000     ISIZE          
0289.00      C                     PARM           IVAL    1          
0290.00      C                     PARM '*ALL'    AUT    10          
0291.00      C                     PARM 'PTF '    TEXT   50          
0292.00      C                     PARM '*YES '   REPL   10          
0293.00      C                     PARM           ERR    30            

In Joblog :
  CPD3C0F    Message . . . . :   Value 359658433 for starting position parameter is not  
    valid.                                                                    
  Cause . . . . . :   Value 359658433 for starting position value for this    
    operation is not valid. Recovery  . . . :   Specify a valid value greater

  CPD3C12   Message . . . . :   Length of data is not valid.                            
  Cause . . . . . :   The value 1077952576 you specified for the length of dat
    parameter is not valid. Recovery  . . . :   Specify a valid value greater
    than zero and less than the maximum allowable size for a user space for th
    length of data and try the request again.                                
                 
  CPF3C06    Escape   Message . . . . :   Information not retrieved from user space MSGJOB.      
  Cause . . . . . :   Information was not retrieved from user space MSGJOB in
    library TSITOOL. Recovery  . . . :   Display the job log to determine why
    information could not be retrieved from the user space (DSPJOBLOG command)
    Correct the errors and try the request again.                  
 
       
  CPF9999   Message . . . . :   Function check. CPF3C06 unmonitored by GETJOB at stateme
    32700, instruction X'0082'.                                              
  Cause . . . . . :   An escape exception message was sent to a program which
    did not monitor for that message. Loop about  CPD3C0F  CPD3C12  CPF3C06  CPF9999
                                                     
 Looping within:     CPD3C0F    CPD3C12  CPF3C06  CPF9999 . . . . .

how to prevent looping ?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
VP Technology / Senior Consultant
Commented:
0285.00      C                     CALL 'QUSCRTUS'             33    

That line says "call the program(api) QUSCRTUS, and if there is an error, ignore the error and turn on indicator 33."

So, if you remove the "33" from the error indicator position, the program will fail normally (with an error if you don't handle it in the RPG program somehow).

If you want it to fail silently, just test *IN33 after the call statement (line 294), and terminate the program if *IN33 is on:

*IN33 IFEQ *ON
SETON *INLR                       (Assuming you want to end with LR on - close files, fully terminate program)
RETRN
ENDIF

Or if you you have a "terminate" subroutine, you might want to call it instead:

*IN33 IFEQ *ON
EXSR MYEXIT
ENDIF

I haven't written RPGIII for a while, but that's the basic idea.

Author

Commented:
I will test - thanks a lot for your advice.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial