Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to variable file names

Status
Not open for further replies.

nschroeder

Programmer
Apr 2, 2013
2
0
0
US
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:

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:

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.

 
Have you already solved this? I only just noticed it.

Do you actually have an externally defined printer file called INVPRT? If so you can create copies called OTHPRT, OTHKSPRT, FMFMPRT, and FMFMKSPRT (probably using CRTDUPOBJ) then in your RPG you can add the keywords EXTFILE (I think) and USROPN to the F-spec for the printer. Then try something like
Code:
FINVPRT   O    E             PRINTER 
F                            ExtFile(FileName)
F                            UsrOpn

D FileName        S             21

/free
  FileName = '*LIBL/' + %Trim( FMFM );
  Open INVPRT;
  // Do your printer stuff
  .
  .
  .
  Close INVPRT;
  *InLR = *On;
  Return;
I'm assuming you are using the same name for the input parameter &FMFM that you have passed to the RPG. This is off the top of my head so so may need to check I've got the syntax right.

PeteJ
(Contract Code-monkey)

It's amazing how many ways there are to skin a cat
(apologies to the veggies)
 
Thanks for the suggestion. Since I'd gotten no replies, I went to another forum. The answer was to make an adjustment to my OVRPRTF. Instead of OVRPRTF FILE(INVPRT) TOFILE(&DVDTO), it needed to be OVRPRTF FILE(INVPRT) SPLFNAME(&DVDTO)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top