PDA

View Full Version : SQL Libarlist info von einer JOBD



tarkusch
28-06-17, 07:25
Hallo,

die aktuelle Bibliotheksliste kann ich mir ja mit Sql holen:


SELECT ORDINAL_POSITION AS POS, SYSTEM_SCHEMA_NAME AS LIBRARY,
TYPE, CAST(TEXT_DESCRIPTION AS CHAR(50)) AS TEXT
FROM QSYS2.LIBRARY_LIST_INFO




Wie kann ich eine bestimmte Jobdescription abfragen?

lg

Robi
28-06-17, 08:08
ist zwar kein SQL aber geht seit Jahren ...

DCL &UL *CHAR 2750
DCL &ANZ *CHAR
RTVJOBD JOBDT(LIB/JOBD) RTNLIB(&UL) RTNANZ(&ANZ)

Robi

Fuerchau
28-06-17, 08:25
Und die SQL-Funktion gibt es noch nicht so lange und für jedes Release (respektive TR).

Robi
28-06-17, 08:25
Oh, das ding ist gar nicht vom OS



H DFTACTGRP(*NO) OPTION(*SRCSTMT : *NODEBUGIO)
H COPYRIGHT('(c) 2006 - Robert Cozzi, Jr. - All rights reserved.')

************************************************** ***********
** RTVJOBD - Retrieve Job Description Command Proc Pgm.
** This program returns the library list
** of the specified Job Description ("jobd").
** In addition, the number of library names
** in the jobd's library lis is also returned.
** See the associated RTVJOBD CMD source for use
** in CL. TIP: The return variables in your CL
** program should be defined as follows:
** DCL &LIBL TYPE(*CHAR) LEN(2750)
** DCL &LIBLCNT TYPE(*INT) LEN(2)

D RtvJobDCL PR
D szJobD 20A Const
D rtnLIBL 2750A
D rtnLIBLCount 5I 0

D RtvJobDCL PI
D szJobD 20A Const
D rtnLIBL 2750A
D rtnLIBLCount 5I 0

/COPY QSYSINC/QRPGLESRC,QWDRJOBD
/COPY QSYSINC/QRPGLESRC,QUSEC
** Retrieve Job Description
D*QWDRJOBD PR ExtPgm('QWDRJOBD')
D RtvJobDAPI PR ExtPgm('QWDRJOBD')
D szRtnBuffer 65535A OPTIONS(*VARSIZE)
D nRtnBufLen 10I 0 Const
D** Specify 'JOBD0100'
D apiFormat 8A Const
D JobD 20A Const
D api_error LikeDS(QUSEC)

D JobD DS LikeDS(QWDD0100)
D Based(pJobD)

D JobDInfo DS LikeDS(QWDD0100)

D LibList S 11A Based(pLIBL) DIM(250)
D LibL S 2750A Based(pLIBL)
D APIErrDS DS LikeDS(QUSEC)

C eval *INLR = *ON
** Sadly, with this API, we need to call it twice when
** the LIBL is needed.
** First call: Get the length of the data to be returned.
C eval APIErrDS= *ALLX'00'
C eval APIErrDS.QUSBPRV = %size(APIErrDS)
C eval JobDInfo = *ALLX'00'
C callp RtvJobDAPI(JobDInfo : %size(JobDInfo):
C 'JOBD0100': szJOBD : APIErrDS)

C if APIErrDS.QUSBAVL = 0
C eval pJobD = %Alloc(JobDInfo.QWDBAVL)
C eval JOBD = *ALLX'00'
** Second call: Get the library list.
C callp RtvJobDAPI(JOBD : JobDInfo.QWDBAVL :
C 'JOBD0100': szJOBD : APIErrDS)
C if %Parms >= 3
C eval rtnLIBLCount = JobD.QWDNLILL
C endif
C if %Parms >= 2
/free
pLibl = pJobD + JobD.QWDOILL;
rtnLibl = %subst(LIBL:1:JobD.QWDNLILL*%size(LibList));
/end-free
C endif
C deAlloc pJobD
C endif



und


CMD PROMPT('Liblist v.Jobd lesen RTBJOBD')
PARM KWD(JOBDT) TYPE(QUAL1) +
PROMPT('JOBD')
PARM KWD(RTNLIB) TYPE(*CHAR) LEN(2750) +
RTNVAL(*YES) CHOICE('VAR FÜR LIBL (CHAR +
2750)')
PARM KWD(RTNANZ) TYPE(*INT2) RTNVAL(*YES) +
CHOICE('VAR FÜR ANZAHL (*CHAR )')
QUAL1: QUAL TYPE(*NAME)
QUAL TYPE(*NAME) PROMPT('LIB') DFT(' ')

tarkusch
28-06-17, 08:49
Und die SQL-Funktion gibt es noch nicht so lange und für jedes Release (respektive TR).

Hätten Sie ein Beispiel von so einer Abfrage?

Fuerchau
28-06-17, 09:21
Das war die falsche Antwort, da ich auch überlesen hatte, dass eine JOBD und nicht der aktuelle Job gemeint war.
Nimm einfach die Quellen von Robi (s.o.).

tarkusch
28-06-17, 09:41
Brauche ich eigentlich den CMD dazu?

ich habe das Programm aufgerufen und bei mir ist immer

[/CODE]APIErrDS.QUSBAVL = 26
389
[/CODE]




H DFTACTGRP(*NO) OPTION(*SRCSTMT : *NODEBUGIO)

//************************************************** **********
// RTVJOBD - Retrieve Job Description Command Proc Pgm.
// This program returns the library list
// of the specified Job Description ("jobd").
// In addition, the number of library names
// in the jobd's library lis is also returned.
// See the associated RTVJOBD CMD source for use
// in CL.

** D/COPY HJISRC/QCpySrc,GetLibLR

D GETLIBLR PR ExtPgm('GETLIBLR')
D szJobD 20A Const
D rtnLIBL 2750A Options
D rtnLIBLCount 5I 0 (*Nopass : *Omit)
D*
D GetLibLR PI
D szJobD 20A Const
D**rtnLIBL 2750A Options(*Nopass : *Omit)
D rtnLIBL 2750A
D rtnLIBLCount 5I 0

D/COPY QSYSINC/QRPGLESRC,QWDRJOBD
D/COPY QSYSINC/QRPGLESRC,QUSEC

// Retrieve Job Description
D RtvJobDAPI PR ExtPgm( 'QWDRJOBD' )
D szRtnBuffer 65535A OPTIONS( *VARSIZE )
D nRtnBufLen 10I 0 Const

// Specify 'JOBD0100'
D apiFormat 8A Const
D JobD 20A Const
D api_error LikeDS( QUSEC )

D JobD DS LikeDS( QWDD0100 )
D Based( pJobD )

D JobDInfo DS LikeDS( QWDD0100 )

D LibList S 11A Based( pLIBL ) DIM( 250 )
D LibL S 2750A Based( pLIBL )
D APIErrDS DS LikeDS( QUSEC )

/FREE
*INLR = *ON;

// Sadly, with this API, we need to call it twice to get the LibL
// First call: Get the length of the data to be returned.

APIErrDS = *ALLX'00';
APIErrDS.QUSBPRV = %size( APIErrDS );
JobDInfo = *ALLX'00';
RtvJobDAPI( JobDInfo
: %size( JobDInfo )
: 'JOBD0100'
: szJOBD
: APIErrDS );

If APIErrDS.QUSBAVL = 0;

pJobD = %Alloc( JobDInfo.QWDBAVL );
JOBD = *ALLX'00';

// Second call: Get the library list.
RtvJobDAPI( JOBD
: JobDInfo.QWDBAVL
: 'JOBD0100'
: szJOBD
: APIErrDS );
If %Parms >= 3;
rtnLIBLCount = JobD.QWDNLILL;
EndIF;

If %Parms >= 2;
pLibl = pJobD + JobD.QWDOILL;
rtnLibl = %subst( LIBL : 1 : JobD.QWDNLILL * %size( LibList ) );

EndIF;
DeAlloc pJobD;
EndIF;

Fuerchau
28-06-17, 10:27
Mach mal eine DSPMSGD CPF9810, ich meine das heißt "Objekt nicht gefunden".
Bedenke die Aufrufparameter!
Die JOBD wird in der Form "JOBDxxxxxxLIBNAMExxx" übergeben.
Der letzte Parameter muss 2750 Zeichen lang sein!
Von der Kommandozeile geht das nicht.

tarkusch
28-06-17, 10:42
Danke, das war es.
Mit dem Libname habe ich das völlig übersehen