PDA

View Full Version : Spooldateinummer in einen CLP ermitteln



Schnichels
18-09-03, 14:35
Hallo,

kann man in einem CLP die Spooldateinummer einer SPLF ermitteln, so etwa wie RTVSPLFA. Den befehl gibt es aber leider nicht. :( Hat irgend jemand eine Idee ?

mfg

Jürgen Schnichels

TARASIK
18-09-03, 14:51
Hallo Jürgen,
vielleicht hilft dies ?

Retrieve a Spool File
Number
Hey, Ted:
Is there a way to retrieve the number the system assigns to a spooled file? Some commands, such as the Copy Spooled File (CPYSPLF) command, allow me to use the special value *LAST to access the highest-numbered spooled file of a certain name. But if I could retrieve the spooled file number, I could do other good things, such as allow other jobs to retrieve and use the spooled file.
-- Moe






Sure, Moe. It's possible. Use the Retrieve Spooled File Attributes API, QUSRSPLA. It returns a data structure packed full of goodies, including the spooled file number.
The following CL program produces two reports, both of which are named QSYSPRT. That is, the RPG programs that produce these reports write to printer file QSYSPRT. After the first RPG program runs, the CL program retrieves the spooled file number. After the second RPG program runs, the CL submits program SPLF03C (given below) to batch, passing parameters containing the job information, spooled file name, and spooled file number. The batch job uses this information to retrieve the spooled file.
PGM

DCL &SPLFNBR *CHAR 4
DCL &WHICHSPLF *CHAR 4
DCL &RCVLEN *CHAR 4
DCL &RECEIVER *CHAR 80
DCL &JOBNAME *CHAR 10
DCL &JOBUSER *CHAR 10
DCL &JOBNBR *CHAR 6

/* Get identifying info for this job */
RTVJOBA JOB(&JOBNAME) USER(&JOBUSER) NBR(&JOBNBR)

/* Generate first report */
CALL PGM(RPGPGM1)

/* Get spool file number of report just produced */
CHGVAR VAR(%BIN(&WHICHSPLF)) VALUE(-1)
CHGVAR VAR(%BIN(&RCVLEN)) VALUE(80)
CALL PGM(QUSRSPLA) PARM(&RECEIVER &RCVLEN +
'SPLA0100' '*' ' ' ' ' QSYSPRT &WHICHSPLF)
CHGVAR VAR(&SPLFNBR) VALUE(%BIN(&RECEIVER 77 4))

/* Generate second report */
CALL PGM(RPGPGM2)

/* Tell another program about the first report */
SBMJOB CMD(CALL PGM(SPLF03C) PARM(&JOBNAME &JOBUSER +
&JOBNBR QSYSPRT &SPLFNBR)) JOB(THOLTTEST)
ENDPGM

Here's SPLF03C, the CL program that runs in batch and accesses the report generated in the other CL program:
PGM PARM(&JOBNAME &JOBUSER &JOBNBR &FILENAME +
&SPLFNBR)

DCL VAR(&SPLFNBR) TYPE(*CHAR) LEN(4)
DCL VAR(&FILENAME) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNAME) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBUSER) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6)

CPYSPLF FILE(&FILENAME) TOFILE(SPOOLFILE) +
JOB(&JOBNBR/&JOBUSER/&JOBNAME) +
SPLNBR(&SPLFNBR) CTLCHAR(*PRTCTL)
ENDPGM

If there's a possibility that the spooled file won't be there, monitor for message CPF34C0. However, the best way to handle such a situation is to make sure that the Retrieve Spooled File Attributes (QUSRSPLA) API doesn't run if the report is not produced. To find out more about the QUSRSPLA API, visit the iSeries 400 Information Center. Click on the following topics in the navigation pane (located on the left side of the Web page):
Programming
CL and APIs
APIs
APIs by category
In the APIs by category list, choose the Print link. On the Print APIs page, click on the Spooled file APIs link. QUSRSPLA is the last API on the Spooled Files API page.
-- Ted

Gruss TARASIK

Heinz Bretthauer
18-09-03, 14:56
Hallo,

in einem CL wüßte ich nicht, wie das geht. In COBOL holen wir die Nummer direkt nach dem Open der Printerfile aus dem OPEN-FEEDBACK Bereich. Von dort geben wir Sie dann an ein CL weiter, um dort dann mit CHGSPLFA solche Sachen wie PAGERANGE zu steuern oder Attribute an der Spooldatei zu ändern, die das Programm vor dem Open noch nicht weiß.

Viele Grüße

Heinz Bretthauer

Bruno Jakob
19-09-03, 06:45
Hallo Heinz,

die APIs QUSLSPL und QUSRSPLA sind da sehr hilfreich. Dazu gibt es ein Beispielprogramm von der IBM (Deleting old Spooled Files). Das Beispiel gibt es in RPG, COBOL, C und damit kommst du bestimmt klar.

Gruß
Bruno


Hatte ich vergessen: In einem CLP geht das bestimmt auch, aber empfehlen würde ich das nicht unbedingt.

Schnichels
19-09-03, 09:08
Super Tarasik,

hat funktioniert. Mit dem unter stehenden CLP kann ich jetzt die zuletzt vergebene Spooldateinummer der SPFL QSYSPRT, die ich hier als Beispiel genommen habe, ermitteln. Diese steht dann in der Variable &SPLFNBR.


PGM
DCL &SPLFNBR *CHAR 4
DCL &WHICHSPLF *CHAR 4
DCL &RCVLEN *CHAR 4
DCL &RECEIVER *CHAR 80
CHGVAR VAR(%BIN(&WHICHSPLF)) VALUE(-1)
CHGVAR VAR(%BIN(&RCVLEN)) VALUE(80)
CALL PGM(QUSRSPLA) PARM(&RECEIVER &RCVLEN +
'SPLA0100' '*' ' ' ' ' QSYSPRT &WHICHSPLF)
CHGVAR VAR(&SPLFNBR) VALUE(%BIN(&RECEIVER 77 4))
ENDPGM


Vielen Dank

Jürgen Schnichels