Example in ILE RPG: Accessing the HOLD attribute

This program retrieves the HOLD value from a job description and then prints the value. It expects errors to be returned via the error code parameter.

Note: Read the Code license and disclaimer information for important legal information.

Refer to Example in OPM RPG: Accessing the HOLD attribute for the original example.

     F***************************************************************
     F***************************************************************
     F*
     F*  Program Name: JOBDAPI
     F*
     F*  Programming Language: ILE RPG
     F*
     F*  Description:  This program retrieves the HOLD value from
     F*                a job description and then prints the value.
     F*                It expects errors to be returned via the
     F*                error code parameter.
     F*
     F*  Header Files Included: QUSEC - Error Code Parameter
     F*                         QWDRJOBD - Retrieve Job Description API
     F*
     F***************************************************************
     F***************************************************************
     F*
     FQPRINT    O    F  132        PRINTER OFLIND(*INOF)
     D*
     D* Error Code parameter include
     D*
     D/COPY QSYSINC/QRPGLESRC,QUSEC
     D*
     D* Retrieve Job Description API Include
     D*
     D/COPY QSYSINC/QRPGLESRC,QWDRJOBD
     D*
     D* Miscellaneous data structure
     D*
     DRCVLEN           S              9B 0 INZ(%SIZE(QWDD0100))
     DFORMAT           S              8    INZ('JOBD0100')
     C*
     C* Beginning of mainline
     C*
     C* Two parameters are being passed into this program
     C*
     C     *ENTRY        PLIST
     C                   PARM                    JOBD             10
     C                   PARM                    JOBD_LIB         10
     C*
     C* Move the two parameters passed into LFNAM
     C*
     C     JOBD          CAT       JOBD_LIB      LFNAM            20
     C*
     C* Error Code Bytes Provided is set to 16
     C*
     C                   EVAL      QUSBPRV = %SIZE(QUSEC)
     C*
     C* Call the API.
     C*
     C                   CALL      QWDRJOBD
     C                   PARM                    QWDD0100
     C                   PARM                    RCVLEN
     C                   PARM                    FORMAT
     C                   PARM                    LFNAM
     C                   PARM                    QUSEC
     C*
     C* If no bytes available, API was successful; print HOLD value
     C*
     C                   IF        QUSBAVL = 0
     C                   EXCEPT    GOOD
     C                   ELSE
     C*
     C* If some bytes available, API failed; print Error message ID
     C*
     C                   IF        QUSBAVL > 0
     C                   EXCEPT    BAD
     C                   END
     C                   END
     C*
     C* End of program
     C*
     C                   EVAL      *INLR = '1'
     C                   RETURN
     C*
     C* End of MAINLINE
     C***************************************************************
     O*
     OQPRINT    E            GOOD           1  6
     O                                              'HOLD value - '
     O                       QWDHJQ
     OQPRINT    E            BAD            1  6
     O                                              'Failed. Error ID - '
     O                       QUSEI
Related reference
Example in OPM RPG: Accessing the HOLD attribute