You can do a lot more with Variables these days:
In ILE Static variables get stored in static storage/memory opposed to automatic. This means unless you intentionally clear them when exiting a procedure, the procedure will retain those values. Eg you’re running through Invoices sequenced by Customer so your little procedure goes off and gets His address 30 times because He has 30 invoices.
If the Address variables are static then you can check if the Customer changed as step 1 in the procedure and if it hasn’t just return what’s already in the address variables to save a little overhead.
Dcl-s nShortItemNumber Like(##ItemShort) Static Inz;
The Thread keyword can have *SERIALIZE or *CONCURRENT and they also impact static variables, using THREAD means it is assumed the module is intended to run safely in a multithreaded environment. *SERIALIZE means you consider the variables won’t change much because all the threads will share them, *CONCURRENT means each thread gets it’s own static variables because you as the smarty programmer know the variables will change a lot (100 people placing orders at the same time etc.)
Ctl-Opt NoMain Thread(*SERIALIZE) option(*srcstmt: *nodebugio)