Procedure returns PARM instead of value. HOW?
Page 1 of 1
Procedure returns PARM instead of value. HOW?
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
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
Similar topics
» Problem with display - Header area is not displayed
» Stored Procedure
» Stored Procedure
» Procedure to apply PTF
» Procedure to APYPTF
» Stored Procedure
» Stored Procedure
» Procedure to apply PTF
» Procedure to APYPTF
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|