IBM i > DEVELOPER > RPG

Data Storage Options in Subprocedures

How different types of variable storage impact the behavior of local and global data in subprocedures.

How different types of variable storage impact the behavior

There are probably several more ways to accomplish this task. Another option might be to avoid using a local static field if it should be reinitialized on each call and use a global field instead. Keep in mind that our example uses an internal subprocedure. An external (exported) subprocedure residing in another module or a service program would have different considerations. Hopefully we've given you enough information on how these storage types behave so that you can design appropriate logic to meet your application's needs.

If you're skeptical, download the code for this simple program from our Web site and try it for yourself. Feel free to experiment with different scenarios to ensure you understand what's really happening.

We hope this exercise has enlightened you about some of the lesser-known idiosyncrasies of subprocedures taken from our "Subprocedures: Beyond the Basics" conference session. This is just one topic from that session and, of course, there are many more sessions about exploiting the modern features of RPG and DB2 that we'll cover at RPG & DB2 Summit in March. We look forward to seeing some of you there.

Jon Paris is a technical editor with IBM Systems Magazine and co-owner of Partner400.

Susan Gantner is a technical editor with IBM Systems Magazine and co-owner of Partner400.


comments powered by Disqus

Advertisement

Advertisement

2019 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

New and Improved XML-INTO

Namespace support makes the opcode a viable option

Authenticating on the Web

The finer points of OpenRPGUI, Part 1

The Microphone is Open

Add your voice: Should IBM i include open-source RPG tools?

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters