INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Printing to variable file names

Printing to variable file names

(OP)
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.

RE: Printing to variable file names

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)

RE: Printing to variable file names

(OP)
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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close