× 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.



On 2012/7/12 1:09 PM, Gerald Kern wrote:
This is the meat of the code - I asked the programmer who wrote this what
was missing, and his response was 'clearing the rest of the fields... but I
thought closing the file would take care of it'.

Begsr UpdateRfmast;

Chain %KDS(RF_KEY) RFMAST;
IF %FOUND(RFMAST);
AST402_DS=AST402;
RFPCPNPI= ast402_DS.NPI;

The CHAIN is not using a result DS, so that means that the fields must be global*. The fields used in RPG I/O statements are only loosely associated with the file. Opening or closing the file has no effect on the content of the fields. When the subprocedure returns, the global fields will retain whatever value they got during the subprocedure.

If the fields aren't needed outside the subprocedure (and you're on 6.1), you could code a result DS on the I/O operations. If you code that DS local to the subprocedure, and don't code the STATIC keyword, then you'd get a fresh copy of the DS on every call.

If the file isn't needed outside the subprocedure, you could even code the file local to the subprocedure. If you don't code the STATIC keyword on the file, it would get opened and closed on every call to the subprocedure.

* How do I know that the fields must be global? Because when an I/O operation is done to a file and a result DS isn't coded, then the I specs or O specs control which fields are used by the I/O operation. And RPG only allows global files to have I specs and O specs, so fields coded on I and O specs are always global.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.