× 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, David:

This has to do with how the RPG compiler generated code resolves the name of the program to call (whether RPG/400 or RPG IV).

When you hard-code a program name as a literal on the CALL statement (as you have shown), the RPG compiler generates code to "resolve" the name into a program pointer, just once, at program initialization time (think of an internal *INZSR). This is done because the "resolve" is relatively "expensive". Then, whenver the compiler "sees" a CALL to that same hard-coded name in the source program, it can just use the already resolved pointer to the program, so the CALL is much faster.

However, if you code something like this (in RPGLE):

c eval pgmNam = 'MyCLLE'
c call pgmNam

where pgmNam is a 10 character local variable, the compiler understands that you want to do a full dynamic call, and does the resolve, and then the call, in-line.

But, there is still one more "trick" to consider -- to try to further improve the performance, the RPG generated code keeps track of the name of the last program called in this way, so if the program name in that variable did not change since the last time it was used, the compiler will use the pointer to the program with that name, that it has already resolved. You can "fool" the compiler, in this situation, by making sure that you use the same "pgmNam" variable and do a full dynamic call for both 'myCLP' and 'myCLLE'. This way, whenever you call MYCLP (which changes the library list), the next time you call MYCLLE, the compiler checks the last value used for "pgmNam" and sees that it is no longer the same as "MYCLP" and so it will then re-resolve the address of MYCLLE, and you should get the behavior you desire.

Another way to avoid this is to "library qualify" the call, as follows:

Declare a variable named QualPgm as character 20, with two fields, pgmNam and pgmLib, defined as char 10, starting at position 1 and 11 respectively in the QualPgm "data structure". Fill in the pgmNam at runtime, as we did previously, but also "plug in" the correct library name in the pgmLib field (as it appears your program may already know this library name, since your program is dynamically changing the library list.)

Then, use the qualified name on the CALL, as follows:

c call qualPgm

I hope this explanation makes sense.

Regards,

Mark S. Waterbury

> David FOXWELL wrote:
Hi all,

I'm hoping someone can help with this problem.

I have an RPGLE that calls a CLP :
C CALL 'MyCLP' // This does a CHGLIBL

Then
C CALL 'MyCLLE' // MyCLLE exists in several libraries.


When I call MyCLLE a second time, it's the first instance of MyCLLE that is called, even if it is no longer in the library list.

How do I get my RPGLE to call the first object called MyCLLE in the library list after each CHGLIBL?


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.