如何取得某個 Job 中執行哪些程式(Job call stack), (使用 API QWVRCSTK -- Retrieve Call Stack )
從 OS/400 V5R1 系統提供一個新的 API API QWVRCSTK -- Retrieve Call Stack,
讓使用者能存取正在執行的 Job call stack, 結果類似 WRKJOB 選項 11 的畫面,
Display Call Stack
System: xxxxxxx
Job: QPADEV0003 User: USER01 Number: 004157
Thread: 00000004
Program
Rqs or
Lvl Procedure Library Statement Instruction
QCMD QSYS 0488
QUICMENU QSYS 00C2
1 QUIMNDRV QSYS 055F
2 QUIMGFLW QSYS 04BA
3 QUICMD QSYS 048B
QUOCPP QPDA 0680
QUOMAIN QPDA 0068
QUYLIST QSYS 0821
QWSGET QSYS 05A9
QT3REQIO QSYS 01A9
Bottom
F3=Exit F10=Update stack F11=Display activation group F12=Cancel
F16=Job menu F17=Top F18=Bottom F22=Display entire name
因為 WRKACTJOB 畫面上所看到 Function 欄位, 並無法顯示正在執行的程式, 你需要使用
WRKJOB 選項 11, 才可以看到, 當要檢查多個 Job 時, 很不方便,所以可以利用 API QWVRCSTK 取得相關資訊.
File : QRPGLESRC
Member: RTVJOBSTKR
Type : RPGLE
Usage : CRTBNDRPG RTVJOBSTKR
CALL RTVJOBSTKR ('jobname' 'user' 'jobnbr')
jobname, user, jobnbr 依照實際的 Job而定, 您可利用另一個 API QUSLJOB
(可參考前期"如何檢查系統中每個 Job 的 Temporary Storage(qtemp sapce) 大小?(使用 API QUSLJOB)")
取得 Job 的資訊, 結合 RTVJOBSTKR 使用.
OS version: V5R1 and later.
H DFTACTGRP(*NO) ACTGRP(*CALLER) BNDDIR('QC2LE') EXPROPTS(*RESDECPOS)
H DATFMT(*ISO) TIMFMT(*ISO) OPTION(*SRCSTMT:*NODEBUGIO) DEBUG
**********************************************************************************************
* *
* Module - RTVJOBSTK *
* By - Vengoal Chang *
* Purpose - Retrieve Call Stack *
* Note - These procedures will only work on V5R1 and later systems. *
**********************************************************************************************
H
********************************
* Retrieve job information API *
********************************
DAPIQWVRCSTK PR EXTPGM('QWVRCSTK') Rtv job information.
D PR_RtnStk 32767A OPTIONS(*VARSIZE) Return information.
D PR_RtnStkSiz 10I 0 CONST Information length.
D PR_RtnFmt 8A CONST Information format.
D PR_JobInf CONST LIKE(QWCF0100) Qualified job.
D PR_JobInfFmt 8A CONST Information format.
D PR_APIErr like(vApiErrDS) Options(*NOPASS) Error structure.
**********************************************************************************************
* RtvJobStk Retrieve Job Stack. (Call RtvJobStkEnt and DlcJobStk when done) *
* Input: *
* Job Job to return information about, the special value * is supported for the *
* currently executing job. The default value is *. *
* Usr Job user to return information about. *
* Nbr Job number to return information about. *
* Thr Thread to return stack for. Default is current thread. *
* Return: *
* ErrFlg Stack entry count. Zero indicates an error. *
**********************************************************************************************
DRtvJobStk PR EXTPGM('RTVJOBSTKR')
D PR_OptJob 10A CONST OPTIONS(*NOPASS: *OMIT)
D PR_OptUsr 10A CONST OPTIONS(*NOPASS: *OMIT)
D PR_OptNbr 6A CONST OPTIONS(*NOPASS: *OMIT)
D PR_OptThr 8A CONST OPTIONS(*NOPASS: *OMIT)
DRtvJobStk PI
D OptJob 10A CONST OPTIONS(*OMIT:*NOPASS)
D OptUsr 10A CONST OPTIONS(*OMIT:*NOPASS)
D OptNbr 6A CONST OPTIONS(*OMIT:*NOPASS)
D OptThr 8A CONST OPTIONS(*OMIT:*NOPASS)
*************************
* Global Work Variables *
*************************
DRtnStk S 32767A BASED(pRtnStk)
DpStkEnt S * INZ(*NULL)
DTmpStr S 50
DRtnStkSiz S 10I 0
*----------------------------------------------------------------
* Receiver Ds to get Avaiable bytes
*----------------------------------------------------------------
D RcvDS ds
D bytpv 10i 0 inz(%size(RcvDs))
D bytav 10i 0 inz(0)
*----------------------------------------------------------------
* Error return code parm for APIs.
*----------------------------------------------------------------
D vApiErrDs ds
D vbytpv 10i 0 inz(%size(vApiErrDs))
D vbytav 10i 0 inz(0)
D vmsgid 7a
D vresvd 1a
D vrpldta 50a
*/COPY QSYSINC/QRPGLESRC,QWCATTR Define API format.
DQWCF0100 DS
D* Qwc JIDF0100
D QWCJN02 1 10
D* Job Name
D QWCUN 11 20
D* User Name
D QWCJNBR00 21 26
D* Job Number
D QWCIJID 27 42
D* Int Job ID
D QWCERVED06 43 44
D* Reserved
D QWCTI00 45 48B 0
D* Thread Indicator
D QWCTI01 49 56
D* Thread Id
*/COPY QSYSINC/QRPGLESRC,QWVRCSTK
D*****************************************************************
D*Type Definition for the CSTK0100 format.
D*****************************************************************
DQWVCSTKE DS Based(pStkEnt)
D* Qwv RCSTK Entry
D QWVEL 1 4B 0
D* Entry Length
D QWVSD 5 8B 0
D* Stmt Displacement
D QWVSRTN 9 12B 0
D* Stmt Returned
D QWVPD 13 16B 0
D* Proc Displacement
D QWVPL 17 20B 0
D* Proc Length
D QWVRL01 21 24B 0
D* Request Level
D QWVPGMN 25 34
D* Program Name
D QWVPGML 35 44
D* Program Library
D QWVCTION 45 48B 0
D* Instruction
D QWVMN 49 58
D* Module Name
D QWVMLIB 59 68
D* Module Library
D QWVCB 69 69
D* Control Bdy
D QWVERVED01 70 72
D* Reserved
D QWVAGNBR 73 76U 0
D* Act Group Number
D QWVAGN 77 86
D* Act Group Name
D*QWVSI 87 96 DIM(00001)
D*
D* Varying length
D*QWVPN 97 97
D*
D* Varying length
DQWVK0100 DS
D* Qwv CSTK0100
D QWVBRTN 1 4B 0
D* Bytes Returned
D QWVBAVL 5 8B 0
D* Bytes Available
D QWVEAVL 9 12B 0
D* Entry Available
D QWVEO 13 16B 0
D* Entry Offset
D QWVERTN 17 20B 0
D* Entry Returned
D QWVRTNTI 21 28
D* Returned Thread Id
D QWVIS 29 29
D* Information Status
D*QWVENTRY 97 DIM(00001)
D* QWVEL00 9B 0 OVERLAY(QWVENTRY:00001)
D* QWVSD00 9B 0 OVERLAY(QWVENTRY:00005)
D* QWVSRTN00 9B 0 OVERLAY(QWVENTRY:00009)
D* QWVPD00 9B 0 OVERLAY(QWVENTRY:00013)
D* QWVPL00 9B 0 OVERLAY(QWVENTRY:00017)
D* QWVRL02 9B 0 OVERLAY(QWVENTRY:00021)
D* QWVPGMN00 10 OVERLAY(QWVENTRY:00025)
D* QWVPGML00 10 OVERLAY(QWVENTRY:00035)
D* QWVCTION00 9B 0 OVERLAY(QWVENTRY:00045)
D* QWVMN00 10 OVERLAY(QWVENTRY:00049)
D* QWVMLIB00 10 OVERLAY(QWVENTRY:00059)
D* QWVCB00 1 OVERLAY(QWVENTRY:00069)
D* QWVERVED02 3 OVERLAY(QWVENTRY:00070)
D* QWVAGNBR00 10U 0 OVERLAY(QWVENTRY:00073)
D* QWVAGN00 10 OVERLAY(QWVENTRY:00077)
D* QWVSI00 10 OVERLAY(QWVENTRY:00087)
D* QWVPN00 1 OVERLAY(QWVENTRY:00097)
D*
D* Varying length
C EVAL QWCJN02 = OptJob
C EVAL QWCUN = OptUsr
C EVAL QWCJNBR00 = OptNbr
C EVAL QWCTI01 = *LOVAL
C EVAL QWCTI00 = 1
C
C EVAL QWCERVED06 = x'0000'
C EVAL bytav = 8
C IF pRtnStk <> *NULL
C DEALLOC(N) pRtnStk
C ENDIF
C* Get return available bytes
C CALLP APIQWVRCSTK(
C RcvDS :
C bytav :
C 'CSTK0100':
C QWCF0100:
C 'JIDF0100':
C vApiErrDS)
C EVAL RtnStkSiz = bytav
C ALLOC RtnStkSiz pRtnStk
C CALLP APIQWVRCSTK(
C RtnStk:
C RtnStkSiz:
C 'CSTK0100':
C QWCF0100:
C 'JIDF0100':
C vApiErrDS)
C EVAL QWVK0100 = RTNSTK
C EVAL pStkEnt = pRtnStk + QWVEO First entry.
C Do QWVEAVL
C Eval tmpStr = %Editc(QWVRL01:'Z') + ' ' +
C %trim(QWVPGML) + '/' +
C %trim(QWVPGMN)
C TmpStr DSPLY
C
C EVAL pStkEnt = pStkEnt + QWVEL Add prior entry.
C EndDO
C Eval *InLr = *On
C IF pRtnStk <> *NULL
C DEALLOC(N) pRtnStk
C ENDIF
C*
A blog about IBM i (AS/400), MQ and other things developers or Admins need to know.
星期四, 11月 02, 2023
2002-11-05 如何取得某個 Job 中執行哪些程式(Job call stack), (使用 API QWVRCSTK -- Retrieve Call Stack )
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言