× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Gregory,

I believe *DUPVAR will give you whichever data structure is the *first* one it finds when binding.

You seem to be expecting that if you give the data structures the same name, they'll all be "the same structure", and therefore will be shared across all modules. This is not the case. They are all separate structures.

Personally, I do not like exporting variables (including data structures) from modules. I consider this to be a bad practice, and if someone in my shop does it, I'll put a stop to it, and get very cranky with that programmer. Instead, I recommend calling procedures to set/retrieve values. That way, there's a well-defined interface to these parameters, and it's very easy to follow the chain of logic to access them.

But, if you wanted to solve this problem while still importing/exporting variables, the easiest solution would be to give a unique name to each module's data structure. Personally, I would prefix the data structure name with the module name, so you'd have:

MODULE1_structureName
MODULE2_structureName
etc

Not only does eliminate the ambiguity of the name, but it makes it crystal clear to whomever is reading your code which module's data they are referring to.

IMHO, anything exported from a module should be prefixed like this, including subprocedures. And, as mentioned above, I would prefer procedures instead of the data structures.

On 3/15/2012 12:58 PM, Schmidtberger, Gregory P wrote:

I have several modules compiled into a service program. They each
control inserts/updates/and deletes to specific tables. And all these
modules export a data structure with exactly the same name. Because
they all export a data structure with the same name I have compiled
the service program with *DUPVAR. This service program is like a
database service. And then I have an RPGLE program that binds to this
service program and uses the exported sub procedures from those
modules for database updates. This RPGLE program also IMPORTS the
data structure being exported by the modules. All are compiled and
bound correctly so it appears. When I tested this with a single
module I was able to get to the imported data in that data structure.
But I'm having a problem. Now that I have several modules compiled
the imported data structure is always coming back to the RPGLE
program empty. I would like to keep a single name for the exported
data structure so that my upstream programs can always

count on importing a single data structure. Does anyone know if what
I'm attempting to do should work or not? Or is the fact that all the
modules exporting the same data structure name is causing a problem?
Thanks.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.