[NEWSboard IBMi Forum]
  1. #1
    Registriert seit
    Nov 2001
    Beiträge
    96

    Spooldateinummer in einen CLP ermitteln

    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

  2. #2
    Registriert seit
    May 2002
    Beiträge
    2.642

    QUSRSPLA API

    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

  3. #3
    Registriert seit
    Aug 2001
    Beiträge
    54
    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

  4. #4
    Registriert seit
    Dec 2000
    Beiträge
    450
    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.

  5. #5
    Registriert seit
    Nov 2001
    Beiträge
    96

    Spooldateinummer in einen CLP ermitteln

    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

Similar Threads

  1. Programmbibliothek in einem Cobol oder CL Programm ermitteln
    By schatte in forum NEWSboard Programmierung
    Antworten: 19
    Letzter Beitrag: 10-01-07, 11:32
  2. Dateigröße ermitteln und anzeigen
    By Bratmaxxe in forum NEWSboard Programmierung
    Antworten: 9
    Letzter Beitrag: 08-01-07, 09:50
  3. LPAR Prozessor Leistung Ermitteln
    By Weki in forum NEWSboard Server Software
    Antworten: 6
    Letzter Beitrag: 29-08-06, 09:09
  4. nach Insert neu gen. Datensatz ermitteln
    By M.Kasper in forum IBM i Hauptforum
    Antworten: 6
    Letzter Beitrag: 25-08-06, 07:32
  5. SQL Select mit SUM aus einer DB
    By JonnyRico in forum NEWSboard Programmierung
    Antworten: 14
    Letzter Beitrag: 30-03-06, 12:33

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •