IBM AS/400 manual Example of Subprocedure *PSSR Subroutine with GOTO

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 258
Image 258

 

*-----------------------------------------------------------------

 

*

 

* Start of subprocedure definition

 

 

*-----------------------------------------------------------------

 

*

P SubProc

B

 

 

D SubProc

PI

5P 0

 

 

...

 

 

 

 

*-----------------------------------------------------------------

 

*

 

* Body of code goes here including recovery code.

 

*-----------------------------------------------------------------

 

*

C

TryAgain

TAG

 

 

C

X

DIV

Divisor

Result

C

 

Return

Result

 

 

*-----------------------------------------------------------------

 

*

 

* An error occurs when division by zero takes place.

 

* Control is passed to the *PSSR subroutine.

 

*-----------------------------------------------------------------

 

*

C

*PSSR

BEGSR

 

 

 

*-----------------------------------------------------------------

 

*

 

* If this is a divide-by-zero error, add 1 to the divisor

 

* and try again

 

 

 

 

*-----------------------------------------------------------------

 

*

C

 

IF

Err = 102

 

C

 

ADD

1

Divisor

C

 

GOTO

TryAgain

 

C

 

ENDIF

 

 

 

*-----------------------------------------------------------------

 

*

 

* If control reaches ENDSR, the procedure will fail

 

*-----------------------------------------------------------------

 

*

C

 

ENDSR

 

 

P

 

E

 

 

 

 

Figure

113. Example of Subprocedure *PSSR Subroutine with GOTO

234 ILE RPG for AS/400 Programmer's Guide

Page 258
Image 258
IBM manual Example of Subprocedure *PSSR Subroutine with GOTO, ILE RPG for AS/400 Programmers Guide