Example in OPM RPG: Program for packaging a product

The following program creates objects 12 through 14.

     F*****************************************************************
     F*****************************************************************
     F*
     F*Program Name: SFTWPRDEX
     F*
     F*Language:  OPM RPG
     F*
     F*Descriptive Name: Software Product Example
     F*
     F*Description: This example contains the steps necessary to
     F*             package your product like IBM products.
     F*
     F*Header Files Included: QUSEC - Error Code Parameter
     F*                               (Copied into Program)
     F*                       QSZCRTPD - Create Product Definition API
     F*                       QSZCRTPL - Create Product Load API
     F*                       QSZPKGPO - Package Product Option API
     F*
     F*****************************************************************
     F*****************************************************************
     FQPRINT  O   F     132     OF     PRINTER
     E* COMPILE TIME ARRAY
     E                    OBJ   001  15 41
     I*
     I* Error Code Parameter Include for the APIs
     I*
     I* The following QUSEC include has been copied into this program
     I* so that the variable length field can be defined as a fixed
     I* length.
     I*** START HEADER FILE SPECIFICATIONS ****************************
     I*
     I*Header File Name: H/QUSEC
     I*
     I*Descriptive Name: Error Code Parameter.
     I*
     I*5763-SS1  (C) Copyright IBM Corp. 1994,1994
     I*All rights reserved.
     I*US Government Users Restricted Rights -
     I*Use, duplication or disclosure restricted
     I*by GSA ADP Schedule Contract with IBM Corp.
     I*
     I*Licensed Materials-Property of IBM
     I*
     I*
     I*Description: Include header file for the error code parameter.
     I*
     I*Header Files Included: None.
     I*
     I*Macros List: None.
     I*
     I*Structure List: Qus_EC_t
     I*
     I*Function Prototype List: None.
     I*
     I*Change Activity:
     I*
     I*CFD List:
     I*
     I*FLAG REASON       LEVEL DATE   PGMR      CHANGE DESCRIPTION
     I*---- ------------ ----- ------ --------- ----------------------
     I*$A0= D2862000     3D10  931201 DPOHLSON: New Include
     I*
     I*End CFD List.
     I*
     I*Additional notes about the Change Activity
     I*End Change Activity.
     I*** END HEADER FILE SPECIFICATIONS ******************************
     I*****************************************************************
     I*Record structure for error code parameter
     I****                                                          ***
     I*NOTE: The following type definition only defines the fixed
     I*   portion of the format.  Varying length field exception
     I*   data will not be defined here.
     I*****************************************************************
     IQUSBN       DS
     I*                                             Qus EC
     I                                    B   1   40QUSBNB
     I*                                             Bytes Provided
     I                                    B   5   80QUSBNC
     I*                                             Bytes Available
     I                                        9  15 QUSBND
     I*                                             Exception Id
     I                                       16  16 QUSBNF
     I*                                             Reserved
     I*                                      17  17 QUSBNG
     I*
     I*                                      Varying length
     I                                       17 100 QUSBNG
     I*
     I* Create Product Definition API Include
     I*
     I/COPY QSYSINC/QRPGSRC,QSZCRTPD
     I*
     I* Create Product Load API Include
     I*
     I/COPY QSYSINC/QRPGSRC,QSZCRTPL
     I*
     I* Package Product Option API Include
     I*
     I/COPY QSYSINC/QRPGSRC,QSZPKGPO
     I*
     I*
     I            DS
     I I            1                     B   1   40NUMPOP
     I I            1                     B   5   80NUMLAN
     I I            'ABC0050   ABC       '    9  28 PDFN
     I I            'ABC Product'            29  78 TEXTD
     I I            '5072535010    '         79  92 PHONE
     I I            '*NODYNNAM '             93 102 ALWDYN
     I I            '*USE      '            103 112 PUBAUT
     I I            'ABCPGMMRM2'            113 122 POSTM
     I I            'ABCPGMMRM1'            123 132 PREM
     I I            'ABCPGMMRI2'            133 142 POSTI
     I I            'ABCPGMMRI1'            143 152 PREI
     I*
     I* Change Object Information Parameter
     ICOBJI       DS                             49
     I I            3                     B   1   40NUMKEY
     I I            13                    B   5   80KEY13
     I I            4                     B   9  120LEN13
     I                                       13  16 PID13
     I I            12                    B  17  200KEY12
     I I            4                     B  21  240LEN12
     I                                       25  28 LID12
     I I            5                     B  29  320KEY5
     I I            13                    B  33  360LEN5
     I                                       37  49 LP5
     I*
     I* Object Data Structure - Breakdown of fields in Array OBJ
     IOBJDS       DS
     I                                        1  10 NAME
     I                                       11  20 TYP
     I                                       21  24 PID
     I                                       25  28 LID
     I                                       29  41 LP
     I            DS
     I                                    B   1   40RCVLEN
     I I            0                     B   5   80NUMBK
     I I            1                     B   9  120NUMBL
     I I            0                     B  13  160NUMBM
     C*
     C* Beginning of Mainline
     C*
     C* Create Product Definition Object - ABC0050
     C*
     C                     EXSR PRDDFN    (1)
     C*
     C* Create Product Load Objects - ABC0050 (MRM) and ABC0029 (MRI)
     C*
     C                     EXSR PRDLOD    (2)
     C*
     C* Change Object Description for all objects associated with
     C* the ABC Product.
     C*
     C                     EXSR COBJD     (3)
     C*
     C* Package the ABC Product so that all the SAVLICPGM, RSTLIBPGM,
     C* and DLTLICPGM commands work with the product.
     C*
     C                     EXSR PKGPO     (4)
     C*
     C* Complete; product is ready to ship.
     C*
     C                     SETON                     LR
     C                     RETRN
     C*
     C* End of MAINLINE
     C*
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C* Subroutine: PRDDFN
     C*
     C* Descriptive Name: Create product definitions.
     C*
     C* Description: This subroutine creates the product definition
     C*              ABC0050 for the ABC Product.
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C           PRDDFN    BEGSR
     C* Setup for Product Definition
     C* Fill Product Definition Information Parameter
     C                     Z-ADD100       QUSBNB
     C                     MOVEL'0ABCABC' QSZBCB           Product ID
     C                     MOVEL'V3R1M0'  QSZBCC           Release Level
     C                     MOVEL'ABCMSG'  QSZBCD           Message File
     C                     MOVEL'*CURRENT'QSZBCF           First Copyright
     C                     MOVEL'*CURRENT'QSZBCG           Current Copyright
     C                     MOVEL'941201'  QSZBCH           Release Date
     C                     MOVEL'*NO'     QSZBCJ           Allow multiple rel.
     C                     MOVEL'*PHONE'  QSZBCK           Registration ID Value
     C                     MOVELPHONE     QSZBCL           Registration ID Value
     C* Fill Product Load Parameter
     C                     MOVEL'0000'    QSZBDB           Product Option Number
     C                     MOVEL'ABC0001' QSZBDC           Message ID
     C                     MOVELALWDYN    QSZBDD           Allow Dynamic Naming
     C                     MOVEL'5001'    QSZBDF           Code Load ID
     C                     MOVEL*BLANKS   QSZBDG           Reserved
     C* Fill Language Load List Parameter
     C                     MOVEL'2924    'QSZBFB           Language Load ID
     C                     MOVEL'0000'    QSZBFC           Product Option Number
     C                     MOVEL*BLANKS   QSZBFD           Reserved
     C*
     C* Create the Product Definition for the ABC Product
     C*
     C                     MOVEL'QSZCRTPD'API    10
     C                     CALL 'QSZCRTPD'
     C                     PARM           PDFN             Qual. Prod. Defn.
     C                     PARM           QSZBC            Prod. Defn. Info.
     C                     PARM           QSZBD            Prod. Option List
     C                     PARM           NUMPOP           # Prod. Options
     C                     PARM           QSZBF            Lang. Load List
     C                     PARM           NUMLAN           # Lang. Load List
     C                     PARM           TEXTD            Text Description
     C                     PARM           PUBAUT           Public Authority
     C                     PARM           QUSBN            Error Code
     C* Check for errors returned in the error code parameter.
     C                     EXSR ERRCOD
     C                     ENDSR
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C* Subroutine: PRDLOD
     C*
     C* Descriptive Name: Create product loads.
     C*
     C* Description: This subroutine creates the product loads,
     C*              ABC0050 and ABC0029, for the ABC Product.
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C           PRDLOD    BEGSR
     C*
     C* Setup for Product Load for MRM Objects
     C* Fill Product Load Information Parameter
     C                     MOVEL'0ABCABC' QSZBHB           Product ID
     C                     MOVEL'V3R1M0'  QSZBHC           Release Level
     C                     MOVEL'0000'    QSZBHD           Product Option
     C                     MOVEL'*CODE'   QSZBHF           Product Load Type
     C                     MOVEL'*CODEDFT'QSZBHG           Load ID
     C                     MOVEL'*PRDDFN' QSZBHH           Registration ID Type
     C                     MOVEL*BLANKS   QSZBHJ           Registration ID Value
     C                     MOVEL'*CURRENT'QSZBCK           Min. Target Release
     C                     MOVEL*BLANKS   QSZBCL           Reserved
     C*
     C* Fill Principal Library Information Parameter
     C                     MOVEL'ABC'     QSZBJB           Prin. Dev. Lib. Name
     C                     MOVEL'ABC'     QSZBJC           Prin. Prim. Lib. Name
     C                     MOVELPOSTM     QSZBJD           Post-Exit Prog. Name
     C*
     C* Fill Preoperation Exit Programs Parameter
     C                     MOVELPREM      QSZBLB           Pre-Exit Prog. Name
     C                     MOVEL'ABC'     QSZBLC           Dev. Lib. Name
     C*
     C* Fill Additional Library List Parameter
     C*       None
     C*
     C* Fill Folder List Parameter
     C*       None
     C*
     C* Create the product load for the ABC Product - MRM Objects
     C*
     C                     MOVEL'QSZCRTPL'API
     C                     CALL 'QSZCRTPL'
     C                     PARM 'ABC0050' PRDIDN 10        Prod. ID Name
     C                     PARM           QSZBH            Prod. Defn. Info.
     C                     PARM *BLANKS   SECLIB 10        Sec. Lang. Lib
     C                     PARM           QSZBJ            Principal Lib Info
     C                     PARM           QSZBK            Add. Library List
     C                     PARM 0         NUMBK            # Add. Lib. List
     C                     PARM           QSZBL            Pre-Exit Programs
     C                     PARM 1         NUMBL            # Pre-Exit Programs
     C                     PARM           QSZBM            Folder List
     C                     PARM 0         NUMBM            # Folder List
     C                     PARM           TEXTD            Text Description
     C                     PARM '*USE'    PUBAUT           Public Authority
     C                     PARM           QUSBN            Error Code
     C* Check for errors returned in the error code parameter.
     C                     EXSR ERRCOD
     C*
     C* Setup for Product Load for MRI Objects
     C* Fill Product Load Information Parameter
     C                     MOVEL'*LNG '   QSZBHF           Product Load Type
     C                     MOVEL'2924    'QSZBHG           Load ID
     C*
     C* Fill Principal Library Information Parameter
     C                     MOVELPOSTI     QSZBJD           Post-Exit Prog. Name
     C*
     C* Fill Preoperation Exit Programs Parameter
     C                     MOVELPREI      QSZBLB           Pre-Exit Prog. Name
     C*
     C* Fill Additional Library List Parameter
     C*       None
     C*
     C* Fill Folder List Parameter
     C*       None
     C*
     C* Create the product load for the ABC Product - MRI Objects
     C*
     C                     MOVEL'QSZCRTPL'API
     C                     CALL 'QSZCRTPL'
     C                     PARM 'ABC0029' PRDIDN 10        Prod. ID Name
     C                     PARM           QSZBH            Prod. Defn. Info.
     C                     PARM 'ABC2924 'SECLIB           Sec. Lang. Lib
     C                     PARM           QSZBJ            Principal Lib Info
     C                     PARM           QSZBK            Add. Library List
     C                     PARM 0         NUMBK            # Add. Lib. List
     C                     PARM           QSZBL            Pre-Exit Programs
     C                     PARM 1         NUMBL            # Pre-Exit Programs
     C                     PARM           QSZBM            Folder List
     C                     PARM 0         NUMBM            # Folder List
     C                     PARM           TEXTD            Text Description
     C                     PARM '*USE'    PUBAUT           Public Authority
     C                     PARM           QUSBN            Error Code
     C* Check for errors returned in the error code parameter.
     C                     EXSR ERRCOD
     C                     ENDSR
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C* Subroutine: COBJD
     C*
     C* Descriptive Name: Change object descriptions for the
     C* ABC Product.
     C*
     C* Description: This subroutine changes the object
     C*              descriptions for all objects that make up the
     C*              ABC Product.  Currently, 15 objects exist.  They
     C*              are listed at the end of this program.
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C           COBJD     BEGSR
     C*
     C* Need to associate all objects with the ABC Product
     C           1         DO   15        I       30
     C                     MOVE OBJ,I     OBJDS
     C           NAME      CAT  'ABC'     QOBJNM 20
     C                     MOVELLP        LP5
     C                     MOVELPID       PID13
     C                     MOVELLID       LID12
     C                     MOVELTYP       TYPE   10
     C                     MOVEL'QLICOBJD'API
     C                     CALL 'QLICOBJD'
     C                     PARM           RTNLIB 10        Returned Lib. Name
     C                     PARM           QOBJNM           Qual. Object Name
     C                     PARM           TYPE             Object Type
     C                     PARM           COBJI            Chg'd Object Info.
     C                     PARM           QUSBN            Error Code
     C* Check for any errors returned in the error code parameter.
     C                     EXSR ERRCOD
     C                     ENDDO
     C                     ENDSR
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C* Subroutine: PKGPO
     C*
     C* Descriptive Name: Package software ABC Product.
     C*
     C* Description: This subroutine packages the ABC Product.
     C*              It makes sure that all objects exist that are
     C*              associated with the product.
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C           PKGPO     BEGSR
     C*
     C* Setup for packing the ABC Product.
     C* Fill Product Option Information Parameter
     C                     MOVEL'0000'    QSZBRB           Product Option
     C                     MOVEL'0ABCABC' QSZBRC           Product ID
     C                     MOVEL'V3R1M0'  QSZBRD           Release Level
     C                     MOVEL'*ALL    'QSZBRF           Load ID
     C                     MOVEL*BLANKS   QSZBRG           Reserved
     C*
     C* Package the ABC Product.
     C*
     C*
     C                     MOVEL'QSZPKGPO'API
     C                     CALL 'QSZPKGPO'
     C                     PARM           QSZBR            Prod. Option Info.
     C                     PARM '*YES'    REPKG   4        Repackage
     C                     PARM '*NO  '   ALWCHG  5        Allow Object Change
     C                     PARM           QUSBN            Error Code
     C* Check for any errors returned in the error code parameter.
     C                     EXSR ERRCOD
     C                     ENDSR
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C* Subroutine: ERRCOD
     C*
     C* Descriptive Name: Process API errors.
     C*
     C* Description: This subroutine prints a line to a spooled
     C*              file if any errors are returned in the error code
     C*              parameter.
     C*
     C*****************************************************************
     C*****************************************************************
     C*
     C           ERRCOD    BEGSR
     C           QUSBNC    IFNE 0
     C*
     C* Process errors returned from the API.
     C*
     C                     EXCPTBADNWS
     C                     END
     C                     ENDSR
     OQPRINT  E  106           BADNWS
     O                                      'Failed in API '
     O                         API
     O                                      'with error '
     O                         QUSBND
     O* The information below is for array OBJ.
     O*111 represents the object name.
     O*2222222222 represents the object type.
     O*3333 represents the product option ID.
     O*4444 represents the product option load ID.
     O*5555555555555 represents the licensed program.
     O*1112222222222333344445555555555555
**
ABCPGMMRM1*PGM      000050010ABCABCV3R1M0
ABCPGMMRM2*PGM      000050010ABCABCV3R1M0
ABCPGMMRI1*PGM      000029240ABCABCV3R1M0
ABCPGMMRI2*PGM      000029240ABCABCV3R1M0
ABCPGM    *PGM      000050010ABCABCV3R1M0
QCLSRC    *FILE     000029240ABCABCV3R1M0
ABCDSPF   *FILE     000029240ABCABCV3R1M0
ABCPF     *FILE     000029240ABCABCV3R1M0
ABCMSG    *MSGF     000029240ABCABCV3R1M0
ABC       *CMD      000029240ABCABCV3R1M0
ABCPNLGRP *PNLGRP   000029240ABCABCV3R1M0
ABC0050   *PRDDFN   000050010ABCABCV3R1M0
ABC0050   *PRDLOD   000050010ABCABCV3R1M0
ABC0029   *PRDLOD   000029240ABCABCV3R1M0
ABC       *LIB      000050010ABCABCV3R1M0

Before you can build PTFs for the product, you need to save the product and install the product by using the Save Licensed Program (SAVLICPGM) and Restore Licensed Program (RSTLICPGM) commands.

Once the product is built, you can do the following: