× 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 Tony,

That was a slight venting as opposed to a scolding - my scoldings are a thing 
to behold :-)

Hans has already identified the solution as being to use a MONITOR group.

The INFSR keyword identifies a subroutine that is coded in the mainline of a 
module and, if there is an IO error, you cannot jump from a subprocedure to a 
subroutine in the mainline.

I usually have my PSSR subroutine in a copy member (SPSSR) and include it in 
every subprocedure as follows:-

     P AddData         B                   Export
     D AddData         PI              N
     D  Data                        100
                         
      /Free
               Monitor;   
                  OpenFile();                  // Ensure File is open
                                               // Assign Data
                  Write  Record;
               On-Error;  
                  ExSR  *PSSR;
                  Return *On;
               EndMon;    
               Return *Off;
      /Copy SPSSR        
      /End-Free           
     P                 E  

This monitor group and /COPY is in EVERY file handling subprocedure.

You can have the calling procedure call the Openfile procedure or you can have 
every file handling procedure call it (in which case it will only open the file 
if it is not already open) - whichever suits you best.

HTH

Paul "The scolder" Tuohy



----- Original Message ----- 
From: <CarollaT@xxxxxxxxxxxxxx>
To: <rpg400-l@xxxxxxxxxxxx>
Sent: Monday, June 28, 2004 6:57 PM
Subject: File operations in subprocedure


> Greetings!  
> 
> I have started using some exception/error handling techniques (due in part
> to the scolding by Mr. Tuohy in his class ;-) ), and I have run into a
> slight snag.  I have specified on an input file the USROPN keyword, and
> specified an INFSR(*PSSR) keyword also.  My *PSSR is straight forward (this
> process runs at night, non-interactively):
> 
>        BegSR *PSSR;
>        Dump(A);
>        EndSR '*CANCL';
> 
> I am also using a variable (21 Alpha) for the input file.  This file
> variable will be changed several times, and the file will be closed and
> re-opened each time.  
> 
> It's beautiful, so far.  So the catch is that I have also started using
> subprocedures, instead of subroutines.  I am attempting to resolve the
> ExtFile variables, and to do the closing/opening of the files entirely in a
> subprocedure.  I get two compiler errors in attempting this, as follows:
> 
> 
> RNF5416 The subprocedure calculation specification refers to a file that has
> the INFSR keyword specified.
> 
> RNF7062 There is no OPEN for a file that specifies user-controlled open; the
> File specification is ignored.                  
> 
> 
> The first thing I ran into was that the EXTFILE variable must be declared in
> the main procedure's D specs (makes sense), but I don't understand what the
> above 5416 error is telling me.  Can I not do an OPEN on a file within a
> subprocedure?  And do I need to trick the 7062 error by putting a dummy
> 'OPEN' op in the main procedure.  
> 
> My goal is to write non-tricky, non-complex stuff where it's unnecessary.
> What gives?
> 
> Tony Carolla
> MedAmerica Billing Services, Inc. 
> --
> This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
> To post a message email: RPG400-L@xxxxxxxxxxxx
> To subscribe, unsubscribe, or change list options,
> visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
> or email: RPG400-L-request@xxxxxxxxxxxx
> Before posting, please take a moment to review the archives
> at http://archive.midrange.com/rpg400-l.
> 

As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.