How to ESCAPE RPG-program in error-case ?

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           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  
  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 ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gary PattersonVP 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:

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

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


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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
asdf13Author Commented:
I will test - thanks a lot for your advice.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.