ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Printing to variable file names

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

  • Printing to variable file names

    I am trying to call an RPGLE program from a CL four times. The RPG program has one output file defined and, based on the parameters passed, determines from the input file which records to write. It works fine, but I need it to write to four different spool file names (OTHPRT, OTHKSPRT, FMFMPRT, and FMFMKSPRT), and it's just creating four spool files with the same name (INVPRT). Can someone please tell me what I'm doing wrong? Here's the CL code:

    Code:
    CHGVAR VAR(&FMFM) VALUE(0) 
    CHGVAR VAR(&KS) VALUE(0) 
    CHGVAR VAR(&DVDTO) VALUE('OTHPRT') 
    CALLSUBR SUBR(DVDSUB) 
    
    CHGVAR VAR(&FMFM) VALUE(0) 
    CHGVAR VAR(&KS) VALUE(1) 
    CHGVAR VAR(&DVDTO) VALUE('OTHKSPRT')
     CALLSUBR SUBR(DVDSUB) 
    
    CHGVAR VAR(&FMFM) VALUE(1) 
    CHGVAR VAR(&KS) VALUE(0) 
    CHGVAR VAR(&DVDTO) VALUE('FMFMPRT') 
    CALLSUBR SUBR(DVDSUB) 
    
    CHGVAR VAR(&FMFM) VALUE(1) 
    CHGVAR VAR(&KS) VALUE(1) 
    CHGVAR VAR(&DVDTO) VALUE('FMFMKSPRT')
     CALLSUBR SUBR(DVDSUB) 
    
    SUBR SUBR(DVDSUB) 
    OVRPRTF FILE(INVPRT) TOFILE(&DVDTO) + 
    PAGESIZE(66 85) OVRFLW(65) PAGRTT(0) +
     OUTQ(&OUTQ) FORMTYPE(&FORMTYPE) + 
    HOLD(*YES) USRDTA(&USRDTA) 
    
    CALL PGM(*LIBL/DVDINVSPLR) PARM(&FMFM &KS) 
    ENDSUBR
    And here's the RPG file spec:

    Code:
    Finvprt o f 132 printer oflind(*inog)
    I'm sure it's simple, but I'm rather limited on my CL/RPG skills. Also my first post to this forum.
    Thanks much for any help.

  • #2
    Re: Printing to variable file names

    It's Friday and that is way too much for me to read...
    but could you try an USROPN on the print file and do a manual open and close on it?

    Jamie
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

    Comment


    • #3
      Re: Printing to variable file names

      Thanks for the suggestion Jamie. Not that much code, really. Just calling a subroutine 4 times, passing a couple of parameters and changing the filename.

      If I use USROPN, would I pass the filename as a third parameter then, instead of using OVRPRTF to change it? Why doesn't OVERPRTF change it as it's coded now?

      Comment


      • #4
        Re: Printing to variable file names

        Hi NateFarm:

        I'm missing the point of your exercise....
        Who cares what the print file is called.....
        weather it's 'OTHPRT'...'OTHKSPRT'...'FMFMPRT'...or 'FMFMKSPRT'
        It's going to print on the selected printer....Users shouldn't even see that detail
        And it's all the same detail or am I missing something with the parms being passed to the rpg?

        Just curious

        GLS
        The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

        Comment


        • #5
          Re: Printing to variable file names

          The spool files are processed by subsequent programs based on their name.

          Comment


          • #6
            Re: Printing to variable file names

            Hi NateFarm:

            Please tell me you are not copying the spool file (cpysplf) to extract data....
            If that is the case you really really really REALLY need to output that detail in file format and process the subsequent programs using FILES....NOT spool files.

            GLS
            The problem with quotes on the internet is that it is hard to verify their authenticity.....Abraham Lincoln

            Comment


            • #7
              Re: Printing to variable file names

              You are specifying the file name, doing an OVERRIDE to the printer file of the new file name, then calling your RPG, which generates the report.

              4 overrides - 4 calls - 4 reports

              Comment


              • #8
                Re: Printing to variable file names

                No. The input file contains customer letters. It's split by the dvdinvsplr program into two different customer types (FMFM and OTH), and also by in-state, out-of-state (KS and not KS). Of the four resulting reports, two go by certified mail, and a program reads them (identified by name) to create the cert file that goes to a vendor.

                Since no one is answering my question, I'm getting the feeling that there's not an easy answer after all. Anyone?

                Comment


                • #9
                  Re: Printing to variable file names

                  The above response was to GLS400. Yes dandevoe, you summarized what I'm trying to do. Do you have a solution?

                  Comment


                  • #10
                    Re: Printing to variable file names

                    wait for it....... OVRPRTF FILE(THISFILE) SPLFNAME(NEWFILENM)
                    done.
                    Hunting down the future ms. Ex DeadManWalks. *certain restrictions apply

                    Comment


                    • #11
                      Re: Printing to variable file names

                      Please read my first post code. That's what I am doing ......... It doesn't work.
                      Not done.

                      Comment


                      • #12
                        Re: Printing to variable file names

                        Oooo, my bad. I was using TOFILE, not SPLFNAME. My apologies for the misplaced sarcasm I'll give that a try. Thanks!

                        Comment


                        • #13
                          Re: Printing to variable file names

                          Worked perfectly, deadmanwalks. I THOUGHT it had to be simple. Thanks!

                          Comment


                          • #14
                            Re: Printing to variable file names

                            You don't ever delete the override (that I can see). Also, make sure the RPG program is closing the printer file and re-opening. Remember, an override only goes into effect when the RPG program does an OPEN. Except at open-time, the override is ignored.

                            Comment


                            • #15
                              Re: Printing to variable file names

                              I only showed a small segment of the CL. The override is deleted later. And the RPG just spins through the file -- no intrinsic open or close.

                              Comment

                              Working...
                              X