|
I have encountered some live code which has a somewhat unusual configuration. The work happens in a bound module. That module has some subprocedures in it. The main program does a callb and the bound module then does a test with %open to see if the files should be opened or not. Works as expected. Over the course of time, one of those subprocedures was deemed useful to someone who did not want to make a service program and then go back and remove the proc from the bound module and recompile and re-distribute everything. So she put 'export' on the useful procedure and bound the module to her program. Her main program now calls the bound module via callb, and invokes a subprocedure in that bound module via callp. The subprocedure needs access to the file, so there's a test for %open in there. The original test for %open remains in the *inzsr. %open mis-reports the state of the file if the procedure is called before the module PEP. In other words, if the code does callp someProc callb 'boundModule' %open thinks the file is still closed in the callb. I've extracted enough code to make a small test bed, if anyone is interested. I understand that this is probably unique, but I do not believe this is the correct behaviour. AG09 (main program) h debug option(*srcstmt: *nodebugio) * dbgview(*list) d someProc pr c callp someProc c callb 'AG09B' c eval *inlr = *on AG09B (bound module) h debug option(*srcstmt: *nodebugio) alwnull(*inputonly) * dbgview(*list) fsystables if e k disk usropn rename(systables: tables) d testAndOpen pr d someProc pr c read systables c 'read' dsply c return c eval *inlr = *on c *inzsr begsr c 'inzsr' dsply c callp testAndOpen c endsr p testAndOpen b d testAndOpen pi c if not %open(systables) c 'not open' dsply c open systables c endif c return p e p someProc b export d someProc pi c 'some proc' dsply c callp testAndOpen c return p e Create the two modules, then CRTPGM PGM(AG09) MODULE(AG09 AG09B) ACTGRP(*NEW) > call ag09 DSPLY some proc DSPLY not open DSPLY inzsr DSPLY not open File SYSTABLES in library QSYS2 member SYSTABLES already open or has an error. OPEN was issued to opened file SYSTABLES. If the callb goes before the callp, it works as expected. --buck
As an Amazon Associate we earn from qualifying purchases.
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.