RPG passes parameters by reference, IE the memory address. If you are calling a program there is a potential that the calling program can modify the value at that address.
If you do not want the value to change then set the parameter in the program or procedure to use the CONST keyword.
This simple keyword will prevent any chance of unwanted modifications.
D DOTHISBUSINESSLOGIC PR D CONOOM 2A CONST.. D ORDNOM 7A CONST D ORDLOM 3P 0 CONST D SLMNOM 5A
In this example SLMNOM is the only parameter which can be changed when returning from the *called* procedure….
in modern RPG this would look like this
dcl-pi doThisBusinessLogic char(5); inp_company_code char(2) const; inp_order_number char(7) const; inp_order_line packed(3:0) const; end-pr;
returning the value as part of the return variable “char(5)” is a neater way of designing it. This means that the RETURN statement will simply show the value being returned:
dcl-s rtn_salesman char(5);
// mainline code could have logic that processes the input constants and then populates the return value for it to be returned at the end of the subprocedure. For example:
rtn_salesman = get_orderproc ( inp_company_code : inp_order_number : inp_order_line );
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
What is IBM i Email and SPF?
Updating Numeric DTAARA in RPGLE
How to capture IBM-i job info for submitted jobs
Register license key in SOFTLANDING SOFTMENU
Going the (Levenshtein) Distance in RPG Free
Don’t hardcode library names in your TURNOVER SQL source #youbigsilly
How to Install IBM Access Client Solutions (ACS)
5733XJ1 IBM i Access Client Solutions – QuickStartGuide
Install LANSA AXES – Automatic Web Interface for IBM i (AS/400) 5250 Applications