PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).

Join the forum, it's quick and easy

PMS Information Systems
Welcome to PMS Information Systems - IBM i (AS/400) Forum !!!

Get Answers for all your queries on IBM i (AS/400).
PMS Information Systems
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Procedure returns PARM instead of value. HOW?

Go down

Procedure returns PARM instead of value. HOW?  Empty Procedure returns PARM instead of value. HOW?

Post  maran Wed Jun 26, 2013 12:01 am

Procedure returns PARM instead of value. HOW? Use RTNPARM keyword then.


When procedure  returns the large  value for example 65000  bytes the performance of the program will come down. To overcome this performance issue D spec keyword RTNPARM is used.


When this keyword Is used the return value is copied into temporary field and this temporary field is passed as a hidden parameter and this hidden parameter is the first in the parameter list.


Without this keyword the return value is copied into STACK memory and calling procedure end the system will retrieve the return value from the STACK  and put that into the temporary field then this temporary field is assigned to target field by the system at the back stage. That is why the performance issue occurs.    
This keyword must be coded on the prototype declaration and  procedure interface as well.
 


D Proc1         PR         65000 A    ExtProc('Proc1')     
D                                     Varying RTNPARM
D  INP                      65000 A   Const Varying
P Proc1           B                   EXPORT      
D  Proc1         PI         65000 A   Varying RTNPARM     
D  INP                      65000 A   Const Varying
                           
OTHER CODE GOES HERE
 
                 IF %PARM = 2; // This will be true
 
Notes:
When we call an RPG program that uses RTNPARM from another language (ex CL, COBOL)  then we must add one more parameter to handle the extra hidden parameter.


%PARMS and %PARMNUM built-in functions returns one more parameter 
maran
maran
Admin

Posts : 442
Join date : 2009-07-24

https://pmsinformationsystem.forumotion.net

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum