ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Consolidating spool files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Consolidating spool files

    We have a program that runs multiple times in a CL program, passing the location number to the RPGLE program and printing a report. So we get a separate report for each location. I have been charged with modifying the programs so there all locns appear on one report. What I would like to do is call the RPG program from the CL program in a loop passing the locn as a parm (as it is doing now) but not create a separate spool file for each call. Isn't there a way to keep the printer file open at the end of each call and the close it after the last locn is passed.

  • #2
    Try this.
    In the CL program (A) you add an override to the spool file with SHARE(*YES)
    OVRPRTF FILE(mySPLF) SHARE(*YES)
    This must be done BEFORE the spool file is opened.

    Then create a new RPG program (B) that opens the printer file mySPLF.
    This program is called from the CL program and must NOT close the spool file when returning to the CL program.
    It is called with a parameter with the location number.

    Program (B) calls your existing RPG program (C) that also opens the printer file mySPLF
    It is OK for program (C) to close the spool file when finishing.
    This means you don't have to make any changes to program (C)


    So now we have the situation that program (A) calls program (B) that opens mySPLF and keeps it open.
    Program (C) is called from program (B) and also opens mySPLF but because SHARE(*YES) is in effect all records written to it
    willl end in the same spool file.
    And you keep calling program (B) for every location number you want.

    In the end you call program (B) without parameters and if %parms = 0 you set *INLR on and returns.
    This closes the printer file.
    Now everything is in one spool file.




    PS: Don't forget to describe this very well for the next programmer.
    Last edited by Peder Udesen; May 17, 2023, 01:27 AM.

    Comment


    • #3
      There is (as of V6) an alternative approach that can simplify the process and make what is happening a little more obvious to the programmers who come after you. Basically rather than sharing the open you pass the printer file as a parameter. I wrote about it here https://www.itjungle.com/2012/03/21/fhg032112-story01/ so I won't go into any more detail.

      Comment

      Working...
      X