ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

wrkactjob [pls help ]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • wrkactjob [pls help ]

    hi all,
    i have a web using cgidev2. i want to show wrkactjob to the web.
    so my way is call a program then a program will save wrkactjob to a file
    then the web read from that file to display wrkactjob


    this is my code. this code i've copy from jamief code
    and i've a problem.


    this is my code :
    PHP Code:
     *  CLOSE the physical file                                 
     
    *                                                          
    c                   if        %open(TEMP)                   
    c                   close     TEMP                          
    c                   
    endif                                   
                                                                
    c                   eval      jobnbrt = %char(@jobnumber)   
    c                   select                                  
    c                   when      
    %len(%trim(jobnbrt)) = 1      
    c                   
    eval      jobnbrt '00000' jobnbrt   
    c                   when      
    %len(%trim(jobnbrt)) = 2      
    c                   
    eval      jobnbrt '0000' jobnbrt    
    c                   when      
    %len(%trim(jobnbrt)) = 3      
    c                   
    eval      jobnbrt '000' jobnbrt     
    c                   when      
    %len(%trim(jobnbrt)) = 4      
    c                   
    eval      jobnbrt '00' jobnbrt      
    c                   when      
    %len(%trim(jobnbrt)) = 5                
    c                   
    eval      jobnbrt '0' jobnbrt                 
    c                   endsl                                             
                                                                          
     
    Hold the wrkactjob spooled file so we can read it.                 
     * 
    OVRPRTF FILE(QPDSPAJBHOLD(*YES)                                  
    c                   eval      cmdstring 'OVRPRTF FILE(QPDSPAJB) ' 
    c                             %trim('HOLD(*YES) SPLFNAME(ACTJOB) ') + 
    c                             ' SECURE(*YES) '                        
    c                   eval      cmdlength = %len(%trim(cmdstring))      
    c                   call(e)   'QCMDEXC'                               
    c                   parm                    CmdString                 
    c                   parm                    CmdLength                 
    c                   
    if        %error                                        
    c                   
    eval      #FLg = 'Y'                                    
    c                   endif  
     * 
    until this step Qcmdexec didnot return error (@msgid is blanks)                                            
                                                                          
     * 
    Now print WRKACTJOB                                                
     
    WRKACTJOB   SBS(DATAW_SBS)   OUTPUT(*PRINT) SEQ(*STS)             
    c                   eval      cmdstring 'WRKACTJOB SBS(DATAW_SBS) '+     
    c                                         'OUTPUT(*PRINT) ' +               
    c                                         'SEQ(*STS)'                       
    c                   eval      cmdlength = %len(%trim(cmdstring))            
    c                   call(e)   'QCMDEXC'                                     
    c                   parm                    CmdString                       
    c                   parm                    CmdLength                       
    c                   
    if        %error                                        
    c                   
    eval      #FLg = 'Y'                                    
    c                   endif                                                   
     * 
    until this step Qcmdexec didnot return error (@msgid is blanks)                                                                          

              
                                                                                
     *  
    check file TEMP at library QTEMP                                        
     
    *  CHKOBJ OBJ(QTEMP/TEMPOBJTYPE(*FILE)                                   
    c                   eval      cmdstring 'CHKOBJ OBJ(QTEMP/TEMP' +         
    c                             %trim(') OBJTYPE(*FILE) ')                  
    c                   eval      cmdlength = %len(%trim(cmdstring))          
    c                   call(e)   'QCMDEXC'                                   
    c                   parm                    CmdString                     
    c                   parm                    CmdLength                     
    c                   
    if        %error                                      
    c                   
    eval      #FLg = 'Y'                                  
    c                   select                                                
    c                   when      
    @MsgId 'CPF9801'                          
     
    *create file QTEMP/TEMP                                                  
    c                   
    eval      cmdstring 'CRTPF FILE(QTEMP/TEMP' +       
    c                                         %trim(') RCDLEN(198)')          
    c                   eval      cmdlength = %len(%trim(cmdstring))          
    c                   call(e)   'QCMDEXC'                                   
    c                   parm                    CmdString                     
    c                   parm                    CmdLength                     
    c                   endsl                                                 
     
    until this step Qcmdexec return @msgid 'CPF9801'                                                                                       
    c                   Endif                                           

                                                                        
     *  
    Copy the spooled file into out physical so we can read it       
     
    *  CPYSPLF FILE(QPDSPAJBTOFILE(QTEMP/TEMPSPLNBR(*LAST)         
    c                   eval      cmdstring 'CPYSPLF FILE(ACTJOB) ' 
    c                                         %trim(' TOFILE(QTEMP/') + 
    c                                         'TEMP) JOB('+jobnbrt+     
    c                                         '/'+%trim(@userid)+'/'+   
    c                                          %trim(@JobName) +') '+   
    c                                         %trim('SPLNBR(*LAST)')  
     * 
    i added JOB(jobnbrt/@userid/@jobnameoption at CPYSPLF but this is error too   
    c                   
    eval      cmdlength = %len(%trim(cmdstring))    
    c                   call(e)   'QCMDEXC'                             
    c                   parm                    CmdString               
    c                   parm                    CmdLength               
    c                   
    if        %Error                                
    c                   
    eval      #FLg = 'Y'                            
    c                   endif                                           
     * 
    until this step Qcmdexec return @msgid 'CPF3303' (spool file not found)                                                                
     *  
    OPEN the physical file                   
    c                   
    if        not%open(TEMP
    c                   open      TEMP           
    c                   
    endif 
    this my job log :
    Code:
    Printer device PRT01 not found. Output queue changed to QPRINT in library 
      QGPL.                                                                   
    Object TEMP in library QTEMP not found.                                   
    File TEMP created in library QTEMP.                                       
    Member TEMP added to file TEMP in QTEMP.                                  
    File ACTJOB not found in job 009794/QTMHHTTP/DATAWEB.
    until now i don't know why spool file is not found.
    if run this program interactively ex. CALL ACTJOB0R PARM('DATAW_SBS' 'N') this program work perfectly
    but if i call from the web cgidev2 this is always says "File ACTJOB not found in job 009794/QTMHHTTP/DATAWEB"

    please help me
    what wrong with my code ???

    thx u all

  • #2
    Re: wrkactjob [pls help ]

    Hi,
    I am not sure, but let me make a guess ! I think it's the problem with the job name and job number and job name value that u r giving. How do u retrieve this? From program status DS ?

    Could you please check this without giving the job name, spool number etc.

    CPYSPLF FILE(ACTJOB) TOFILE(QTEMP/TEMP) SPLNBR(*LAST)

    It may sometime work. Please let me know or lets hear from the experts!!

    Comment


    • #3
      Re: wrkactjob [pls help ]

      Originally posted by Jerry View Post
      Hi,
      I am not sure, but let me make a guess ! I think it's the problem with the job name and job number and job name value that u r giving. How do u retrieve this? From program status DS ?

      Could you please check this without giving the job name, spool number etc.

      CPYSPLF FILE(ACTJOB) TOFILE(QTEMP/TEMP) SPLNBR(*LAST)

      It may sometime work. Please let me know or lets hear from the experts!!
      i get from this

      PHP Code:
       Program Info                         
       
      *                                      
      d PgmInfo        SDS                    
      d  
      @PgmName               1     10      
      d  
      @Parms                37     39  0   
      d  
      @MsgID                40     46      
      d  
      @JobName             244    253      
      d  
      @UserId              254    263      
      d  
      @JobNumber           264    269  0 
      i ever try without JOB option but get the same error ???

      Comment


      • #4
        Re: wrkactjob [pls help ]

        what's up with this?
        Code:
        c                   eval      jobnbrt = %char(@jobnumber)   
        c                   select                                  
        c                   when      %len(%trim(jobnbrt)) = 1      
        c                   eval      jobnbrt = '00000' + jobnbrt   
        c                   when      %len(%trim(jobnbrt)) = 2      
        c                   eval      jobnbrt = '0000' + jobnbrt    
        c                   when      %len(%trim(jobnbrt)) = 3      
        c                   eval      jobnbrt = '000' + jobnbrt     
        c                   when      %len(%trim(jobnbrt)) = 4      
        c                   eval      jobnbrt = '00' + jobnbrt      
        c                   when      %len(%trim(jobnbrt)) = 5                
        c                   eval      jobnbrt = '0' + jobnbrt                 
        c                   endsl
        just use
        Code:
        c                   eval      jobnbrt = %editc(@jobnumber:'X')
        on the OVRPRTF add the OVRSCOPE(*JOB) keyword
        I'm not anti-social, I just don't like people -Tommy Holden

        Comment


        • #5
          Re: wrkactjob [pls help ]

          i have a web using cgidev2. i want to show wrkactjob to the web.
          so my way is call a program then a program will save wrkactjob to a file
          then the web read from that file to display wrkactjob ...
          Why not simply use the version that IBM supply in the new Browser version of Ops Navigator?

          Not sure what version the equivalent of WRKACTJOB was supported - it is certainly in there at 6.1


          Jon P.

          Comment


          • #6
            Re: wrkactjob [pls help ]

            hi all, thx for reply

            now i am using API QUSLJOB and QUSRJOBI API. and it's working

            and now i have a question :

            PHP Code:

             
            job info ds                        
            d Job_Inf         DS                  
            D  BYTRTN                 1      4I 0 
            D  BYTVAL                 5      8I 0 
            D  QJOBNM                 9     34    
            D  JOBNAM                 9     18    
            D  USRNAM                19     28    
            D  JOBNBR                29     34    
            D  INTID                 35     50    
            D  JOBSTS                51     60    
            D  JOBTYP                61     61    
            D  SUBTYP                62     62    
            D  SBSNAM                63     72    
            D  RUNPRI                73     76B 0 
            D  POOLID                77     80B 0 
            D  CPUUSE                81     84B 0 
            D  AUXREQ                85     88B 0 
            D  INTRAN                89     92B 0 
            D  RSPTIM                93     96B 0 
            D  FNCTYP                97     97    
            D  FNCNAM                98    107     
            D  ACTJOB               108    111     
            D  ThreadCnt            141    144B 0  
            D  procunitm            145    152U 0  
            D  proctot              161    168U 0  
            D  ACTjend              177    180 
            if WRKACTJOB have CPU%, how to convert CPUUSE from ds JOB_INF to CPU in percentage ???
            and
            how to know all possible value in FNCTYP and the meaning from value in FNCTYP

            ex. i only know if FNCTYP = 'P' it mean PGM

            thx u all

            Comment


            • #7
              Re: wrkactjob [pls help ]

              Use the QGYOLJOB Work management API, OLJB0300 format and keys 314, 601, 602 instead :
              • Key 314 = percent used during the elapsed time (job)
              • Key 601 = function name
              • Key 602 = function type
              Philippe

              Comment


              • #8
                Re: wrkactjob [pls help ]

                Originally posted by Mercury View Post
                Use the QGYOLJOB Work management API, OLJB0300 format and keys 314, 601, 602 instead :
                • Key 314 = percent used during the elapsed time (job)
                • Key 601 = function name
                • Key 602 = function type
                hi mercury, thanx for reply,

                i got the link example using this API



                PHP Code:
                     **   Open list APIs are located in library QGY.
                     **
                     **-- 
                Control spec:  
                     
                H Option( *SrcStmt: *NoDebugIo )  BndDir'QC2LE' )
                     **-- 
                API error data structure:
                     
                D ApiError        Ds
                     D  AeBytPrv                     10i 0 Inz
                ( %SizeApiError ))
                     
                D  AeBytAvl                     10i 0
                     D  AeExcpId                      7a
                     D                                1a
                     D  AeExcpDta                   128a
                     
                **-- API parameters
                     
                D JlRtnRcdNbr     s             10i 0 Inz)
                     
                D JlNbrFldRtn     s             10i 0 Inz( %ElemJlKeyFld ))
                     
                D JlKeyFld        s             10i 0 Dim)
                     **-- 
                Job information:
                     
                D JlJobInf        Ds           512
                     D  JbJobId                      26a
                     D   JbJobUsd                    10a   Overlay
                JbJobId)
                     
                D   JbUsrUsd                    10a   OverlayJbJobId: *Next )
                     
                D   JbNbrUsd                     6a   OverlayJbJobId: *Next )
                     
                D  JbActSts                      4a
                     D  JbJobTyp                      1a
                     D  JbJobSubTyp                   1a
                     D  JbDtaLen                     10i 0
                     D                                4a
                     
                **-- Key information:
                     
                D JlKeyInf        Ds
                     D  KiFldNbrRtn                  10i 0
                     D  KiKeyInf                     20a   Dim
                ( %ElemJlKeyFld ))
                     
                D   KiFldInfLen                 10i 0 OverlayKiKeyInf :  )
                     
                D   KiKeyFld                    10i 0 OverlayKiKeyInf :  )
                     
                D   KiDtaTyp                     1a   OverlayKiKeyInf :  )
                     
                D                                3a   OverlayKiKeyInf 10 )
                     
                D   KiDtaLen                    10i 0 OverlayKiKeyInf 13 )
                     
                D   KiDtaOfs                    10i 0 OverlayKiKeyInf 17 )
                     **-- 
                Sort information:
                     
                D JlSrtInf        Ds
                     D  SiNbrKeys                    10i 0 Inz
                )
                     
                D  SiSrtInf                     12a   Dim10 )
                     
                D   SiKeyFldOfs                 10i 0 OverlaySiSrtInf :  )
                     
                D   SiKeyFldLen                 10i 0 OverlaySiSrtInf :  )
                     
                D   SiKeyFldTyp                  5i 0 OverlaySiSrtInf :  )
                     
                D   SiSrtOrd                     1a   OverlaySiSrtInf 11 )
                     
                D   SiRsv                        1a   OverlaySiSrtInf 12 )
                     **-- List 
                information:
                     
                D JlLstInf        Ds
                     D  LiRcdNbrTot                  10i 0
                     D  LiRcdNbrRtn                  10i 0
                     D  LiHandle                      4a
                     D  LiRcdLen                     10i 0
                     D  LiInfSts                      1a
                     D  LiDts                        13a
                     D  LiLstSts                      1a
                     D                                1a
                     D  LiInfLen                     10i 0
                     D  LiRcd1                       10i 0
                     D                               40a
                     
                **-- Selection information:
                     
                D JlSltInf        Ds
                     D  SiJobNam                     10a   Inz
                '*ALL' )
                     
                D  SiUsrNam                     10a   Inz'*ALL' )
                     
                D  SiJobNbr                      6a   Inz'*ALL' )
                     
                D  SiJobTyp                      1a   Inz'*' )
                     
                D                                1a
                     D  SiOfsPriSts                  10i 0 Inz
                60 )
                     
                D  SiNbrPriSts                  10i 0 Inz)
                     
                D  SiOfsActSts                  10i 0 Inz70 )
                     
                D  SiNbrActSts                  10i 0 Inz)
                     
                D  SiOfsJbqSts                  10i 0 Inz78 )
                     
                D  SiNbrJbqSts                  10i 0 Inz)
                     
                D  SiOfsJbqNam                  10i 0 Inz88 )
                     
                D  SiNbrJbqNam                  10i 0 Inz)
                     **
                     
                D  SiPriSts                     10a   Dim)
                     
                D  SiActSts                      4a   Dim)
                     
                D  SiJbqSts                     10a   Dim)
                     
                D  SiJbqNam                     20a   Dim)
                     **-- 
                Job information key fields:
                     
                D JbKeyDta        Ds
                     D  JbPrcUniTim                  20u 0
                     D  JbPrcUniPct                  10i 0
                     D  JbPrcUniTimE                 20u 0
                     
                **-- General return data:
                     
                D JlGenDta        Ds
                     D  GdBytRtn                     10i 0
                     D  GdBytAvl                     10i 0
                     D  GdElpTim                     20u 0
                     D                               16a
                     
                **-- Global variables:  
                     
                D Ix              s              5i 0
                     D Msg             s            256a   Varying
                     D MsgKey          s              4a
                     D PgmNam_q        s             20a
                     
                **-- API constants:  
                     
                D JOB_RESET_STAT  c                   '1'
                     
                D JOB_KEEP_STAT   c                   '0'
                     
                **-- Open list of jobs
                     
                D LstJobs         Pr                  ExtPgm'QGYOLJOB' )
                     
                D  LjRcvVar                  65535a          Options( *VarSize )
                     
                D  LjRcvVarLen                  10i 0 Const
                     
                D  LjFmtNam                      8a   Const
                     
                D  LjRcvVarDfn               65535a          Options( *VarSize )
                     
                D  LjRcvDfnLen                  10i 0 Const
                     
                D  LjLstInf                     80a
                     D  LjNbrRcdRtn                  10i 0 
                Const
                     
                D  LjSrtInf                   1024a   Const  Options( *VarSize )
                     
                D  LjJobSltInf                1024a   Const  Options( *VarSize )
                     
                D  LjJobSltLen                  10i 0 Const
                     
                D  LjNbrFldRtn                  10i 0 Const
                     
                D  LjKeyFldRtn                  10i 0 Const  Options( *VarSize )  
                     
                D                                            Dim32 )
                     
                D  LjError                    1024a          Options( *VarSize )
                     **
                     
                D  LjJobSltFmt                   8a   Const  Options( *NoPass )
                     **
                     
                D  LjResStc                      1a   Const  Options( *NoPass )
                     
                D  LjGenRtnDta                  32a          Options( *NoPass:*VarSize)
                     
                D  LjGenRtnDtaLn                10i 0 Const  Options( *NoPass )
                     **-- 
                Get list entry:  
                     
                D GetLstEnt       Pr                  ExtPgm'QGYGTLE' )
                     
                D  GlRcvVar                  65535a          Options( *VarSize )
                     
                D  GlRcvVarLen                  10i 0 Const
                     
                D  GlHandle                      4a   Const
                     
                D  GlLstInf                     80a
                     D  GlNbrRcdRtn                  10i 0 
                Const
                     
                D  GlRtnRcdNbr                  10i 0 Const
                     
                D  GlError                    1024a          Options( *VarSize )
                     **-- 
                Close list:  
                     
                D CloseLst        Pr                  ExtPgm'QGYCLST' )
                     
                D  ClHandle                      4a   Const
                     
                D  ClError                    1024a          Options( *VarSize )
                     **-- 
                Copy memory
                     
                D MemCpy          Pr              *   ExtProc'_MEMMOVE' )
                     
                D  pOutMem                        *   Value
                     D  pInpMem                        
                *   Value
                     D  iMemSiz                      10u 0 Value
                     
                **-- Delay job:  
                     
                D sleep           Pr            10i 0 ExtProc'sleep' )
                     
                D  seconds                      10u 0 Value
                     
                **-- Get job program:  
                     
                D GetJobPgmX      Pr            20a
                     D  PxJobId                      26a   
                Const

                     **-- 
                Mainline:  
                     
                C*                  Eval      SiNbrActSts SiNbrActSts 1
                     C
                *                  Eval      SiActSts(SiNbrActSts) = 'HLD '
                     
                **
                     
                C                   Eval      JlKeyFld(1) = 312
                     C                   
                Eval      JlKeyFld(2) = 314
                     C                   
                Eval      JlKeyFld(3) = 315
                     
                **
                     
                C                   Eval      SiNbrKeys      1
                     C                   
                Eval      SiKeyFldOfs(1) = 49
                     C                   
                Eval      SiKeyFldLen(1) = 4
                     C                   
                Eval      SiKeyFldTyp(1) = 0
                     C                   
                Eval      SiSrtOrd(1)    = '2'
                     
                C                   Eval      SiRsv(1)       = x'00'
                     
                **
                     
                C                   CallP     LstJobsJlJobInf
                     C                                    
                : %SizeJlJobInf )
                     
                C                                    'OLJB0300'
                     
                C                                    JlKeyInf
                     C                                    
                : %SizeJlKeyInf )
                     
                C                                    JlLstInf
                     C                                    
                0
                     C                                    
                JlSrtInf
                     C                                    
                JlSltInf
                     C                                    
                : %SizeJlSltInf )
                     
                C                                    JlNbrFldRtn
                     C                                    
                JlKeyFld
                     C                                    
                ApiError
                     C                                    
                'OLJS0100'
                     
                C                                    JOB_RESET_STAT
                     C                                    
                JlGenDta
                     C                                    
                : %SizeJlGenDta )
                     
                C                                    )
                     **
                     
                C                   CallP     sleep30 )
                     **
                     
                C                   CallP     LstJobsJlJobInf
                     C                                    
                : %SizeJlJobInf )
                     
                C                                    'OLJB0300'
                     
                C                                    JlKeyInf
                     C                                    
                : %SizeJlKeyInf )
                     
                C                                    JlLstInf
                     C                                    
                1
                     C                                    
                JlSrtInf
                     C                                    
                JlSltInf
                     C                                    
                : %SizeJlSltInf )
                     
                C                                    JlNbrFldRtn
                     C                                    
                JlKeyFld
                     C                                    
                ApiError
                     C                                    
                'OLJS0100'
                     
                C                                    JOB_KEEP_STAT
                     C                                    
                JlGenDta
                     C                                    
                : %SizeJlGenDta )
                     
                C                                    )
                     **
                     
                C                   If        AeBytAvl    =  *Zero
                     
                **
                     
                C                   DoW       LiLstSts    <> '2'           Or
                     
                C                             LiRcdNbrTot >  JlRtnRcdNbr
                     
                **
                     
                C                   If        JbJobTyp   <> 'X'
                     
                C                   ExSr      GetKeyDta
                     C                   ExSr      GetJobPgm
                     C                   
                EndIf
                     **
                     
                C                   Eval      JlRtnRcdNbr JlRtnRcdNbr 1
                     
                **
                     
                C                   CallP     GetLstEntJlJobInf
                     C                                      
                : %SizeJlJobInf )
                     
                C                                      LiHandle
                     C                                      
                JlLstInf
                     C                                      
                1
                     C                                      
                JlRtnRcdNbr
                     C                                      
                ApiError
                     C                                      
                )
                     **
                     
                C                   If        JbPrcUniTimE <= *Zero
                     C                   Leave
                     C                   
                EndIf
                     **
                     
                C                   EndDo
                     
                **
                     
                C                   CallP     CloseLstLiHandle
                     C                                     
                ApiError
                     C                                     
                )
                     **
                     
                C                   EndIf
                     **
                     
                C                   Eval      *InLr       = *On
                     
                **
                     
                C                   Return
                     **-- 
                Get Key Field Data:  
                     
                C     GetKeyDta     BegSr
                     
                **
                     
                C                   Clear                   JbKeyDta
                     
                **
                     
                C                   For       Ix 1  To KiFldNbrRtn
                     
                **
                     
                C                   Select
                     C                   When      KiKeyFld
                (Ix)= 312
                     C                   CallP     MemCpy
                ( %AddrJbPrcUniTim )
                     
                C                                   : %AddrJlJobInf ) +
                     
                C                                     KiDtaOfs(Ix)
                     
                C                                   KiDtaLen(Ix)
                     
                C                                   )
                     **
                     
                C                   When      KiKeyFld(Ix)= 314
                     C                   CallP     MemCpy
                ( %AddrJbPrcUniPct )
                     
                C                                   : %AddrJlJobInf ) +
                     
                C                                     KiDtaOfs(Ix)
                     
                C                                   KiDtaLen(Ix)
                     
                C                                   )
                     **
                     
                C                   When      KiKeyFld(Ix)= 315
                     C                   CallP     MemCpy
                ( %AddrJbPrcUniTimE )
                     
                C                                   : %AddrJlJobInf ) +
                     
                C                                     KiDtaOfs(Ix)
                     
                C                                   KiDtaLen(Ix)
                     
                C                                   )
                     
                C                   EndSl
                     
                **
                     
                C                   EndFor
                     **
                     
                C                   EndSr
                     
                **-- Get job program:  
                     
                C     GetJobPgm     BegSr
                     
                **
                     
                C                   Eval      PgmNam_q   =  GetJobPgmXJbJobId )
                     **
                     
                C                   EndSr


                     
                **-- Get job program
                     
                P GetJobPgmX      B                   Export
                     D                 Pi            20a
                     D  PxJobId                      26a   
                Const

                     **-- 
                API error data structure
                     
                D ApiError        Ds
                     D  AeBytPrv                     10i 0 Inz
                ( %SizeApiError ))
                     
                D  AeBytAvl                     10i 0
                     D  AeExcpId                      7a
                     D                                1a
                     D  AeExcpDta                   128a
                     
                **-- Retrieve call stack API parameters:  
                     
                D CsRcvVar        Ds
                     D  CsBytRtn                     10i 0
                     D  CsBytAvl                     10i 0
                     D  CsNbrStkE                    10i 0
                     D  CsOfsStkE                    10i 0
                     D  CsNbrEntRtn                  10i 0
                     D  CsThrId                       8a
                     D  CsInfSts                      1a
                     D  CsCalStk                  32767a
                     
                **
                     
                D CsCalStkE       Ds                  BasedpCalStkE )
                     
                D  CsStkEntLen                  10i 0
                     D  CsOfsStmIds                  10i 0
                     D  CsNbrStmIds                  10i 0
                     D  CsOfsPrcNam                  10i 0
                     D  CsLenPrcNam                  10i 0
                     D  CsRqsLvl                     10i 0
                     D  CsPgmNam                     10a
                     D  CsPgmLib                     10a
                     D  CsMiInst                     10i 0
                     D  CsModNam                     10a
                     D  CsModLib                     10a
                     D  CsCtlBdy                      1a
                     D  CsRsv                         3a
                     D  CsActGrpNbr                  10u 0
                     D  CsActGrpNam                  10a
                     D  CsAddInf                   4096a
                     
                **
                     
                D  CsStmIds                     10a   Dim16 )
                     
                D  CsPrcNam                    512a
                     
                **
                     
                D CsJobId         Ds
                     D  JiJobId                      26a
                     D   JiJobNam                    10a   Overlay
                JiJobId)
                     
                D   JiUsrNam                    10a   OverlayJiJobId: *Next )
                     
                D   JiJobNbr                     6a   OverlayJiJobId: *Next )
                     
                D  JiIntId                      16a
                     D  JiRsv                         2a   Inz
                ( *Allx'00' )
                     
                D  JiThrInd                     10i 0 Inz)
                     
                D  JiThrId                       8a   Inz( *Allx'00' )
                     **
                     
                D RtvCalStk       Pr                  ExtPgm'QWVRCSTK' )
                     
                D  RcRcvVar                  32767a
                     D  RcRcvVarLen                  10i 0 
                Const
                     
                D  RcRcvInfFmt                   8a   Const
                     
                D  RcJobId                      56a   Const
                     
                D  RcJobIdFmt                    8a   Const
                     
                D  RcError                   32767a          Options( *VarSize )
                     **
                     
                D EntNbr          s              5u 0
                     
                **
                     **-- 
                Mainline:  
                     **
                     
                C                   Eval      JiJobId     =  PxJobId
                     
                **
                     
                C                   CallP     RtvCalStkCsRcvVar
                     C                                      
                : %SizeCsRcvVar )

                     
                C                                      'CSTK0100'
                     
                C                                      CsJobId
                     C                                      
                'JIDF0100'
                     
                C                                      ApiError
                     C                                      
                )
                     **
                     
                C                   If        AeBytAvl    = *Zero
                     C                   
                Eval      pCalStkE    = %AddrCsRcvVar ) + 
                     
                C                                                  CsOfsStkE
                     
                **
                     
                C                   For       EntNbr 1  to CsNbrEntRtn
                     
                **
                     
                C                   If        EntNbr      1
                     
                **
                     
                C                   Eval      CsStmIds    = *Blanks
                     C                   
                Eval      CsPrcNam    = *Blanks
                     
                **
                     
                C                   If        CsOfsStmIds > *Zero
                     C                   CallP     MemCpy
                ( %AddrCsStmIds )
                     
                C                                   : %AddrCsCalStkE ) +
                     
                C                                     CsOfsStmIds
                     C                                   
                CsNbrStmIds * %SizeCsStmIds )
                     
                C                                   )
                     
                C                   EndIf
                     **
                     
                C                   If        CsOfsPrcNam > *Zero
                     C                   CallP     MemCpy
                ( %AddrCsPrcNam )
                     
                C                                   : %AddrCsCalStkE ) +
                     
                C                                     CsOfsPrcNam
                     C                                   
                CsLenPrcNam
                     C                                   
                )
                     
                C                   EndIf
                     **
                     
                C                   Leave
                     C                   
                EndIf
                     **
                     
                C                   If        EntNbr      CsNbrEntRtn
                     C                   
                Eval      pCalStkE    PCalStkE    CsStkEntLen
                     C                   
                EndIf
                     **
                     
                C                   EndFor
                     
                C                   EndIf
                     **
                     
                C                   Return    CsPgmNam CsPgmLib
                     
                **
                     
                P GetJobPgmX      E 
                this code is make complex, i just want get a CPU percentage
                if i send parameter like jobname,username dan jobnumber i get the cpu percentage ....

                do you a simple example using QGYOLJOB API???

                thx u all

                Comment


                • #9
                  Re: wrkactjob [pls help ]

                  Hi,

                  For a specific job to get those attributes, you don't need the QGYGTLE API. You can tweak the program or turn it into a service program in order to meet your needs.
                  This sample below is here to show you what to do.

                  Code:
                       **   Open list APIs are located in library QGY.
                       **
                       **-- Control spec:
                       H Option( *SrcStmt: *NoDebugIo )  BndDir( 'QC2LE' )
                  
                       **-- API error data structure:
                       D ApiError        Ds
                       D  AeBytPrv                     10i 0 Inz( %Size( ApiError ))
                       D  AeBytAvl                     10i 0
                       D  AeExcpId                      7a
                       D                                1a
                       D  AeExcpDta                   128a
                  
                       **-- API parameters:
                       D JlRtnRcdNbr     s             10i 0 Inz( 1 )
                       D JlNbrFldRtn     s             10i 0 Inz( %Elem( JlKeyFld ))
                       D JlKeyFld        s             10i 0 Dim( 3 )
                  
                       **-- Job information:
                       D JlJobInf        Ds           512
                       D  JbJobId                      26a
                       D   JbJobUsd                    10a   Overlay( JbJobId: 1 )
                       D   JbUsrUsd                    10a   Overlay( JbJobId: *Next )
                       D   JbNbrUsd                     6a   Overlay( JbJobId: *Next )
                       D  JbActSts                      4a
                       D  JbJobTyp                      1a
                       D  JbJobSubTyp                   1a
                       D  JbDtaLen                     10i 0
                       D                                4a
                       **-- Key information:
                       D JlKeyInf        Ds
                       D  KiFldNbrRtn                  10i 0
                       D  KiKeyInf                     20a   Dim( %Elem( JlKeyFld ))
                       D   KiFldInfLen                 10i 0 Overlay( KiKeyInf :  1 )
                       D   KiKeyFld                    10i 0 Overlay( KiKeyInf :  5 )
                       D   KiDtaTyp                     1a   Overlay( KiKeyInf :  9 )
                       D                                3a   Overlay( KiKeyInf : 10 )
                       D   KiDtaLen                    10i 0 Overlay( KiKeyInf : 13 )
                       D   KiDtaOfs                    10i 0 Overlay( KiKeyInf : 17 )
                  
                       **-- Sort information:
                       D JlSrtInf        Ds
                       D  SiNbrKeys                    10i 0 Inz( 1 )
                       D  SiSrtInf                     12a   Dim( 10 )
                       D   SiKeyFldOfs                 10i 0 Overlay( SiSrtInf :  1 )
                       D   SiKeyFldLen                 10i 0 Overlay( SiSrtInf :  5 )
                       D   SiKeyFldTyp                  5i 0 Overlay( SiSrtInf :  9 )
                       D   SiSrtOrd                     1a   Overlay( SiSrtInf : 11 )
                       D   SiRsv                        1a   Overlay( SiSrtInf : 12 )
                  
                       **-- List information:
                       D JlLstInf        Ds
                       D  LiRcdNbrTot                  10i 0
                       D  LiRcdNbrRtn                  10i 0
                       D  LiHandle                      4a
                       D  LiRcdLen                     10i 0
                       D  LiInfSts                      1a
                       D  LiDts                        13a
                       D  LiLstSts                      1a
                       D                                1a
                       D  LiInfLen                     10i 0
                       D  LiRcd1                       10i 0
                       D                               40a
                       **-- Selection information:
                       D JlSltInf        Ds
                       D  SiJobNam                     10a   Inz( '[I][COLOR=Red]JobName[/COLOR][/I]')
                       D  SiUsrNam                     10a   Inz( '[I][COLOR=Red]UserName[/COLOR][/I]' )
                       D  SiJobNbr                      6a   Inz( '[I][COLOR=Red]JobNumber[/COLOR][/I]' )
                       D  SiJobTyp                      1a   Inz( '*' )
                       D                                1a
                       D  SiOfsPriSts                  10i 0 Inz( 60 )
                       D  SiNbrPriSts                  10i 0 Inz( 0 )
                       D  SiOfsActSts                  10i 0 Inz( 70 )
                       D  SiNbrActSts                  10i 0 Inz( 0 )
                       D  SiOfsJbqSts                  10i 0 Inz( 78 )
                       D  SiNbrJbqSts                  10i 0 Inz( 0 )
                       D  SiOfsJbqNam                  10i 0 Inz( 88 )
                       D  SiNbrJbqNam                  10i 0 Inz( 0 )
                       **
                       D  SiPriSts                     10a   Dim( 1 )
                       D  SiActSts                      4a   Dim( 2 )
                       D  SiJbqSts                     10a   Dim( 1 )
                       D  SiJbqNam                     20a   Dim( 1 )
                       **-- Job information key fields:
                       D JbKeyDta        Ds
                       D  JbPrcUniPct                  10i 0
                       D  JbFuncName                   10a
                       D  JbFuncType                    1a
                  
                       **-- General return data:
                       D JlGenDta        Ds
                       D  GdBytRtn                     10i 0
                       D  GdBytAvl                     10i 0
                       D  GdElpTim                     20u 0
                       D                               16a
                  
                       **-- Global variables:
                       D Ix              s              5i 0
                       D Msg             s            256a   Varying
                       D MsgKey          s              4a
                       D PgmNam_q        s             20a
                  
                       **-- API constants:
                       D JOB_RESET_STAT  c                   '1'
                       D JOB_KEEP_STAT   c                   '0'
                  
                       **-- Open list of jobs:
                       D LstJobs         Pr                  ExtPgm( 'QGYOLJOB' )
                       D  LjRcvVar                  65535a          Options( *VarSize )
                       D  LjRcvVarLen                  10i 0 Const
                       D  LjFmtNam                      8a   Const
                       D  LjRcvVarDfn               65535a          Options( *VarSize )
                       D  LjRcvDfnLen                  10i 0 Const
                       D  LjLstInf                     80a
                       D  LjNbrRcdRtn                  10i 0 Const
                       D  LjSrtInf                   1024a   Const  Options( *VarSize )
                       D  LjJobSltInf                1024a   Const  Options( *VarSize )
                       D  LjJobSltLen                  10i 0 Const
                       D  LjNbrFldRtn                  10i 0 Const
                       D  LjKeyFldRtn                  10i 0 Const  Options( *VarSize )
                       D                                            Dim( 32 )
                       D  LjError                    1024a          Options( *VarSize )
                       **
                       D  LjJobSltFmt                   8a   Const  Options( *NoPass )
                       **
                       D  LjResStc                      1a   Const  Options( *NoPass )
                       D  LjGenRtnDta                  32a          Options( *NoPass:*VarSize)
                       D  LjGenRtnDtaLn                10i 0 Const  Options( *NoPass )
                  
                       **-- Close list:
                       D CloseLst        Pr                  ExtPgm( 'QGYCLST' )
                       D  ClHandle                      4a   Const
                       D  ClError                    1024a          Options( *VarSize )
                  
                       **-- Copy memory:
                       D MemCpy          Pr              *   ExtProc( '_MEMMOVE' )
                       D  pOutMem                        *   Value
                       D  pInpMem                        *   Value
                       D  iMemSiz                      10u 0 Value
                  
                       **-- Delay job:
                       D sleep           Pr            10i 0 ExtProc( 'sleep' )
                       D  seconds                      10u 0 Value
                  
                       **--------------*
                       **-- Mainline --*
                       **--------------*
                  
                        * Key 314 = percent used during the elapsed time (job)
                        * Key 601 = function name
                        * Key 602 = function type
                       C                   Eval      JlKeyFld(1) = 314
                       C                   Eval      JlKeyFld(2) = 601
                       C                   Eval      JlKeyFld(3) = 602
                       **
                       C                   Eval      SiNbrKeys      = 1
                       C                   Eval      SiKeyFldOfs(1) = 49
                       C                   Eval      SiKeyFldLen(1) = 4
                       C                   Eval      SiKeyFldTyp(1) = 0
                       C                   Eval      SiSrtOrd(1)    = '2'
                       C                   Eval      SiRsv(1)       = x'00'
                       **
                       C                   CallP     LstJobs( JlJobInf
                       C                                    : %Size( JlJobInf )
                       C                                    : 'OLJB0300'
                       C                                    : JlKeyInf
                       C                                    : %Size( JlKeyInf )
                       C                                    : JlLstInf
                       C                                    : 0
                       C                                    : JlSrtInf
                       C                                    : JlSltInf
                       C                                    : %Size( JlSltInf )
                       C                                    : JlNbrFldRtn
                       C                                    : JlKeyFld
                       C                                    : ApiError
                       C                                    : 'OLJS0100'
                       C                                    : JOB_RESET_STAT
                       C                                    : JlGenDta
                       C                                    : %Size( JlGenDta )
                       C                                    )
                       **
                       C                   CallP     sleep( 30 )
                       **
                       C                   CallP     LstJobs( JlJobInf
                       C                                    : %Size( JlJobInf )
                       C                                    : 'OLJB0300'
                       C                                    : JlKeyInf
                       C                                    : %Size( JlKeyInf )
                       C                                    : JlLstInf
                       C                                    : 1
                       C                                    : JlSrtInf
                       C                                    : JlSltInf
                       C                                    : %Size( JlSltInf )
                       C                                    : JlNbrFldRtn
                       C                                    : JlKeyFld
                       C                                    : ApiError
                       C                                    : 'OLJS0100'
                       C                                    : JOB_KEEP_STAT
                       C                                    : JlGenDta
                       C                                    : %Size( JlGenDta )
                       C                                    )
                       **
                       C                   If        AeBytAvl    =  *Zero
                       C                   ExSr      GetKeyDta
                  
                       ** At this point all the 3 keydta are populated :
                       **  JbPrcUniPct
                       **  JbFuncName
                       **  JbFuncType
                  
                       C                   CallP     CloseLst( LiHandle
                       C                                     : ApiError
                       C                                     )
                  
                       **
                       C                   EndIf
                       **
                       C                   Eval      *InLr       = *On
                       **
                       C                   Return
                  
                       **-- Get Key Field Data:
                       C     GetKeyDta     BegSr
                       **
                       C                   Clear                   JbKeyDta
                       **
                       C                   For       Ix = 1  To KiFldNbrRtn
                       **
                       C                   Select
                       C                   When      KiKeyFld(Ix)= 314
                       C                   CallP     MemCpy( %Addr( JbPrcUniPct )
                       C                                   : %Addr( JlJobInf ) +
                       C                                     KiDtaOfs(Ix)
                       C                                   : KiDtaLen(Ix)
                       C                                   )
                       **
                       C                   When      KiKeyFld(Ix)= 601
                       C                   CallP     MemCpy( %Addr( JbFuncName )
                       C                                   : %Addr( JlJobInf ) +
                       C                                     KiDtaOfs(Ix)
                       C                                   : KiDtaLen(Ix)
                       C                                   )
                       **
                       C                   When      KiKeyFld(Ix)= 602
                       C                   CallP     MemCpy( %Addr( JbFuncType )
                       C                                   : %Addr( JlJobInf ) +
                       C                                     KiDtaOfs(Ix)
                       C                                   : KiDtaLen(Ix)
                       C                                   )
                       C                   EndSl
                       **
                       C                   EndFor
                       **
                       C                   EndSr
                  Change the job name, job user and job number in red in the program above or pass a parameter instead then compile in 2 steps :
                  1. CRTRPGMOD
                  2. CRTPGM
                  You can play with the sleep duration which is required to give a CPU percent within a 30 sec delay on the example above. If you want to know the percent used within the last 30 sec, keep the delay as it is in the source program.

                  It is that easy.
                  Last edited by Mercury; July 10, 2009, 09:36 AM.
                  Philippe

                  Comment


                  • #10
                    Re: wrkactjob [pls help ]

                    Originally posted by Mercury View Post
                    Hi,

                    For a specific job to get those attributes, you don't need the QGYGTLE API. You can tweak the program or turn it into a service program in order to meet your needs.
                    This sample below is here to show you what to do.

                    Code:
                         **   Open list APIs are located in library QGY.
                         **
                         **-- Control spec:
                         H Option( *SrcStmt: *NoDebugIo )  BndDir( 'QC2LE' )
                    
                         **-- API error data structure:
                         D ApiError        Ds
                         D  AeBytPrv                     10i 0 Inz( %Size( ApiError ))
                         D  AeBytAvl                     10i 0
                         D  AeExcpId                      7a
                         D                                1a
                         D  AeExcpDta                   128a
                    
                         **-- API parameters:
                         D JlRtnRcdNbr     s             10i 0 Inz( 1 )
                         D JlNbrFldRtn     s             10i 0 Inz( %Elem( JlKeyFld ))
                         D JlKeyFld        s             10i 0 Dim( 3 )
                    
                         **-- Job information:
                         D JlJobInf        Ds           512
                         D  JbJobId                      26a
                         D   JbJobUsd                    10a   Overlay( JbJobId: 1 )
                         D   JbUsrUsd                    10a   Overlay( JbJobId: *Next )
                         D   JbNbrUsd                     6a   Overlay( JbJobId: *Next )
                         D  JbActSts                      4a
                         D  JbJobTyp                      1a
                         D  JbJobSubTyp                   1a
                         D  JbDtaLen                     10i 0
                         D                                4a
                         **-- Key information:
                         D JlKeyInf        Ds
                         D  KiFldNbrRtn                  10i 0
                         D  KiKeyInf                     20a   Dim( %Elem( JlKeyFld ))
                         D   KiFldInfLen                 10i 0 Overlay( KiKeyInf :  1 )
                         D   KiKeyFld                    10i 0 Overlay( KiKeyInf :  5 )
                         D   KiDtaTyp                     1a   Overlay( KiKeyInf :  9 )
                         D                                3a   Overlay( KiKeyInf : 10 )
                         D   KiDtaLen                    10i 0 Overlay( KiKeyInf : 13 )
                         D   KiDtaOfs                    10i 0 Overlay( KiKeyInf : 17 )
                    
                         **-- Sort information:
                         D JlSrtInf        Ds
                         D  SiNbrKeys                    10i 0 Inz( 1 )
                         D  SiSrtInf                     12a   Dim( 10 )
                         D   SiKeyFldOfs                 10i 0 Overlay( SiSrtInf :  1 )
                         D   SiKeyFldLen                 10i 0 Overlay( SiSrtInf :  5 )
                         D   SiKeyFldTyp                  5i 0 Overlay( SiSrtInf :  9 )
                         D   SiSrtOrd                     1a   Overlay( SiSrtInf : 11 )
                         D   SiRsv                        1a   Overlay( SiSrtInf : 12 )
                    
                         **-- List information:
                         D JlLstInf        Ds
                         D  LiRcdNbrTot                  10i 0
                         D  LiRcdNbrRtn                  10i 0
                         D  LiHandle                      4a
                         D  LiRcdLen                     10i 0
                         D  LiInfSts                      1a
                         D  LiDts                        13a
                         D  LiLstSts                      1a
                         D                                1a
                         D  LiInfLen                     10i 0
                         D  LiRcd1                       10i 0
                         D                               40a
                         **-- Selection information:
                         D JlSltInf        Ds
                         D  SiJobNam                     10a   Inz( '[I][COLOR=Red]JobName[/COLOR][/I]')
                         D  SiUsrNam                     10a   Inz( '[I][COLOR=Red]UserName[/COLOR][/I]' )
                         D  SiJobNbr                      6a   Inz( '[I][COLOR=Red]JobNumber[/COLOR][/I]' )
                         D  SiJobTyp                      1a   Inz( '*' )
                         D                                1a
                         D  SiOfsPriSts                  10i 0 Inz( 60 )
                         D  SiNbrPriSts                  10i 0 Inz( 0 )
                         D  SiOfsActSts                  10i 0 Inz( 70 )
                         D  SiNbrActSts                  10i 0 Inz( 0 )
                         D  SiOfsJbqSts                  10i 0 Inz( 78 )
                         D  SiNbrJbqSts                  10i 0 Inz( 0 )
                         D  SiOfsJbqNam                  10i 0 Inz( 88 )
                         D  SiNbrJbqNam                  10i 0 Inz( 0 )
                         **
                         D  SiPriSts                     10a   Dim( 1 )
                         D  SiActSts                      4a   Dim( 2 )
                         D  SiJbqSts                     10a   Dim( 1 )
                         D  SiJbqNam                     20a   Dim( 1 )
                         **-- Job information key fields:
                         D JbKeyDta        Ds
                         D  JbPrcUniPct                  10i 0
                         D  JbFuncName                   10a
                         D  JbFuncType                    1a
                    
                         **-- General return data:
                         D JlGenDta        Ds
                         D  GdBytRtn                     10i 0
                         D  GdBytAvl                     10i 0
                         D  GdElpTim                     20u 0
                         D                               16a
                    
                         **-- Global variables:
                         D Ix              s              5i 0
                         D Msg             s            256a   Varying
                         D MsgKey          s              4a
                         D PgmNam_q        s             20a
                    
                         **-- API constants:
                         D JOB_RESET_STAT  c                   '1'
                         D JOB_KEEP_STAT   c                   '0'
                    
                         **-- Open list of jobs:
                         D LstJobs         Pr                  ExtPgm( 'QGYOLJOB' )
                         D  LjRcvVar                  65535a          Options( *VarSize )
                         D  LjRcvVarLen                  10i 0 Const
                         D  LjFmtNam                      8a   Const
                         D  LjRcvVarDfn               65535a          Options( *VarSize )
                         D  LjRcvDfnLen                  10i 0 Const
                         D  LjLstInf                     80a
                         D  LjNbrRcdRtn                  10i 0 Const
                         D  LjSrtInf                   1024a   Const  Options( *VarSize )
                         D  LjJobSltInf                1024a   Const  Options( *VarSize )
                         D  LjJobSltLen                  10i 0 Const
                         D  LjNbrFldRtn                  10i 0 Const
                         D  LjKeyFldRtn                  10i 0 Const  Options( *VarSize )
                         D                                            Dim( 32 )
                         D  LjError                    1024a          Options( *VarSize )
                         **
                         D  LjJobSltFmt                   8a   Const  Options( *NoPass )
                         **
                         D  LjResStc                      1a   Const  Options( *NoPass )
                         D  LjGenRtnDta                  32a          Options( *NoPass:*VarSize)
                         D  LjGenRtnDtaLn                10i 0 Const  Options( *NoPass )
                    
                         **-- Close list:
                         D CloseLst        Pr                  ExtPgm( 'QGYCLST' )
                         D  ClHandle                      4a   Const
                         D  ClError                    1024a          Options( *VarSize )
                    
                         **-- Copy memory:
                         D MemCpy          Pr              *   ExtProc( '_MEMMOVE' )
                         D  pOutMem                        *   Value
                         D  pInpMem                        *   Value
                         D  iMemSiz                      10u 0 Value
                    
                         **-- Delay job:
                         D sleep           Pr            10i 0 ExtProc( 'sleep' )
                         D  seconds                      10u 0 Value
                    
                         **--------------*
                         **-- Mainline --*
                         **--------------*
                    
                          * Key 314 = percent used during the elapsed time (job)
                          * Key 601 = function name
                          * Key 602 = function type
                         C                   Eval      JlKeyFld(1) = 314
                         C                   Eval      JlKeyFld(2) = 601
                         C                   Eval      JlKeyFld(3) = 602
                         **
                         C                   Eval      SiNbrKeys      = 1
                         C                   Eval      SiKeyFldOfs(1) = 49
                         C                   Eval      SiKeyFldLen(1) = 4
                         C                   Eval      SiKeyFldTyp(1) = 0
                         C                   Eval      SiSrtOrd(1)    = '2'
                         C                   Eval      SiRsv(1)       = x'00'
                         **
                         C                   CallP     LstJobs( JlJobInf
                         C                                    : %Size( JlJobInf )
                         C                                    : 'OLJB0300'
                         C                                    : JlKeyInf
                         C                                    : %Size( JlKeyInf )
                         C                                    : JlLstInf
                         C                                    : 0
                         C                                    : JlSrtInf
                         C                                    : JlSltInf
                         C                                    : %Size( JlSltInf )
                         C                                    : JlNbrFldRtn
                         C                                    : JlKeyFld
                         C                                    : ApiError
                         C                                    : 'OLJS0100'
                         C                                    : JOB_RESET_STAT
                         C                                    : JlGenDta
                         C                                    : %Size( JlGenDta )
                         C                                    )
                         **
                         C                   CallP     sleep( 30 )
                         **
                         C                   CallP     LstJobs( JlJobInf
                         C                                    : %Size( JlJobInf )
                         C                                    : 'OLJB0300'
                         C                                    : JlKeyInf
                         C                                    : %Size( JlKeyInf )
                         C                                    : JlLstInf
                         C                                    : 1
                         C                                    : JlSrtInf
                         C                                    : JlSltInf
                         C                                    : %Size( JlSltInf )
                         C                                    : JlNbrFldRtn
                         C                                    : JlKeyFld
                         C                                    : ApiError
                         C                                    : 'OLJS0100'
                         C                                    : JOB_KEEP_STAT
                         C                                    : JlGenDta
                         C                                    : %Size( JlGenDta )
                         C                                    )
                         **
                         C                   If        AeBytAvl    =  *Zero
                         C                   ExSr      GetKeyDta
                    
                         ** At this point all the 3 keydta are populated :
                         **  JbPrcUniPct
                         **  JbFuncName
                         **  JbFuncType
                    
                         C                   CallP     CloseLst( LiHandle
                         C                                     : ApiError
                         C                                     )
                    
                         **
                         C                   EndIf
                         **
                         C                   Eval      *InLr       = *On
                         **
                         C                   Return
                    
                         **-- Get Key Field Data:
                         C     GetKeyDta     BegSr
                         **
                         C                   Clear                   JbKeyDta
                         **
                         C                   For       Ix = 1  To KiFldNbrRtn
                         **
                         C                   Select
                         C                   When      KiKeyFld(Ix)= 314
                         C                   CallP     MemCpy( %Addr( JbPrcUniPct )
                         C                                   : %Addr( JlJobInf ) +
                         C                                     KiDtaOfs(Ix)
                         C                                   : KiDtaLen(Ix)
                         C                                   )
                         **
                         C                   When      KiKeyFld(Ix)= 601
                         C                   CallP     MemCpy( %Addr( JbFuncName )
                         C                                   : %Addr( JlJobInf ) +
                         C                                     KiDtaOfs(Ix)
                         C                                   : KiDtaLen(Ix)
                         C                                   )
                         **
                         C                   When      KiKeyFld(Ix)= 602
                         C                   CallP     MemCpy( %Addr( JbFuncType )
                         C                                   : %Addr( JlJobInf ) +
                         C                                     KiDtaOfs(Ix)
                         C                                   : KiDtaLen(Ix)
                         C                                   )
                         C                   EndSl
                         **
                         C                   EndFor
                         **
                         C                   EndSr
                    Change the job name, job user and job number in red in the program above or pass a parameter instead then compile in 2 steps :
                    1. CRTRPGMOD
                    2. CRTPGM
                    You can play with the sleep duration which is required to give a CPU percent within a 30 sec delay on the example above. If you want to know the percent used within the last 30 sec, keep the delay as it is in the source program.

                    It is that easy.
                    hi Mercury,
                    i've try this and when i compare with percentage in WRKACTJOB the percentage is different .

                    example pct in WRKACTJOB CPU% = 1.3
                    and trying this code always return cpu% = 0

                    why this code always return percentage = 0 ??????

                    Comment


                    • #11
                      Re: wrkactjob [pls help ]

                      Not sure to grasp the meaning of your question.
                      Do you want to get the percentage of CPU used for the whole machine or for a specific job ?
                      Check out again the QGYOLJOB API web page and read on.
                      Last edited by Mercury; July 13, 2009, 07:03 AM.
                      Philippe

                      Comment


                      • #12
                        Re: wrkactjob [pls help ]

                        Originally posted by Mercury View Post
                        Not sure to grasp the meaning of your question.
                        Do you want to get the percentage of CPU used for the whole machine or for a specific job ?
                        Check out again the QGYOLJOB API web page and read on.
                        hi mercury, cpu percentage like WRKACTJOB
                        WRKACTJOB display information for a specific job

                        Comment


                        • #13
                          Re: wrkactjob [pls help ]

                          You could avoid to reset the status statistics on the first call to QGYOLJOB replacing JOB_RESET_STAT by JOB_KEEP_STAT to get the CPU % as is.
                          If you want to list all jobs in the system, you can use and tweak the example I published on post #8.

                          Check out also iSeries Access for the Web.
                          Philippe

                          Comment

                          Working...
                          X