RPGIV @ Work

A unique site for RPG and System i Lovers

Welcome!

Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Retrieve Job Description Print E-mail
User Rating: / 1
PoorBest 
Written by Chamara Withanachchi   

This was published on the code400 site, I thought to republish here as it was a good example. Thanks for them


     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 RtvJobD         PR
     D  szJobD                       20A   Const
     D  rtnLIBL                    2750A
     D  rtnLIBLCount                  5I 0

     D RtvJobD         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

User Comments

Please login or register to add comments

<Previous   Next>