IBM
Page
IBM
1997
First
Contents
Across
Chapter
Hold
RPG
MICRTPG2
Programming
APIs
Cobol
OPM
OPM API
Vii
Index
Viii System API Programming V4R1
Micrtpg
System API Programming V4R1
Implied Warranties of Merchantability and Fitness for
IBM
Disclaimed
Trademarks
Programming Interface Information
HLL
Use
Xiii
Prerequisite
Xiv System API Programming V4R1
API Compatibility
API Compatibility
Exit programs That are documented Systemin
You Not Have To go Through
Using APIs-Benefits
Saved Overhead Processing When You Call
Because
Cobol ILE RPG
System APIs or CL Commands-When Use
APIs
Functions
OS/400 APIs Are documented Following books
Related Information
Environments
Besides the OS/400 APIs that are
Unix
Started
Locating the API to
Socket Network Functions This
Verb
Language Selection Considerations Data Types
Selecting the High-Level Language To Use
API Environments
APIs for the ILE Common
APIs for the Integrated Language Environment
Environment CEE
Related Information
API Parameters
APIs for the Unix Environment
Integrated Language Environment ILE CEE APIs
Langua
Parameter Passing
Value of the data object is placed directl
Parameter List
Parameter Classification
Error Code Parameter
Code
Receiving Error Conditions as Exceptions-Example
Error
With Exception Data-Example
From
Errors
Getting Started with2-11APIs
Spooling
Internal Identifiers
Security Uses
Used by
User Spaces
User Spaces
Space
Xxxx
User Space Format-Example
+NO
Logic Flow of Processing a List of Entries
Synchronizing between Two or More Jobs
Using Offset Values with Pointers
With
Manipulating a User
Space APIs
Manipulating a User Space without Pointers
Position Values
Lengths
Quschgus API
Following is a user space after you change it with one
\ Program Changusptr
Changing a User Space with an ILE RPG Program-Example
RPG
Changing a User Space with an OPM RPG Program-Example
Additional Information about
List
User
Listing
A receiver variable or the beginning of a
Receiver Variables
Bytes Returned Fields
Beginning
Qusljob API
Keyed Interface
Qlicobjd API
Using a Continuation Handle
User Space Alternative
Continuation Handle
API
Domain Concepts
More information
Exit Programs
Security, Qalwusrdmn Set to System configured forsystemC2
Exit Points
Library
APIs and the Qsysinc
Compile Program Specific
Ccsid
Include File
InSystthem API Reference, SC41-5801
APIs and the Qusrtool Library
User Index Considerations
User Index Considerations
Performance Considerations
Performance Considerations
System
32System API Programming V4R1
First Step Finding the correct API is to Identify Part That
Information
Original Program Model OPM API-Scenario
Job Held Queue
Authorities
Description of an API
Parameters
Locks
Format You Can See fromDecthedecimal Offset Column
Are Based Objects That
Performs Object For
Are described in Required Parameter Group
This Name
Because the field is a binary
Would Make Binary Value
Can Place Format Name Pass Literal
Optional Parameter Group
Error Messages
Format
Field Descriptions
Only Possible values For Hold Job Queue Field Are
Example
Hold Parameter
Perspective
APIs-Examples
Call Jobdapi Parmxyz \LIBL
Handling Error Conditions-OPM RPG Example
Call Jobdapi Parmqbatch Qgpl
Call Jobdapi Parmqbatch \LIBL
OPM RPG
Ipgmsts SDS Msgidd
ITOUSRQPGMR36 47 MSG3B
Parameter
Error
Error Code Structure Can Found
Format Error code structure Qusbn is
Common Information across APIs-Basic OPM 3-Example13
Qgpl
Library Does Not Exist. Use the following call statement
XYZ
Call Jobdapi Qpgmr XYZ
Level Date Pgmr Change Description
Value Placed
Diagnostic Message exists Job Log Can Received
Accessing the Hold Attribute-OPM
Code used to access the Hold attribute. T
Structure
Error-code data structure
Following data structures are used
Retrieve job description data structure
Information across APIs-Basic OPM 3-Example
Initial
\$Að= D2862ððð
Common Information across APIs-Basic OPM 3-Example21
Icmdstr
\ENTRY
Spooled
With List
Jobdapi
Ispcnam
Outq
Common Information across APIs-Basic OPM 3-Example27
Qusptrus
Qusrtvus
Parameters
API-Example
Processing
Job Description Information
JOBD0100 Format
CHAR8
Bytes Returned
Bytes
End Severity
Library
Reply
Job date
Job
MSG
YES
Offset
Text Description
Data
RQD
Common Information across APIs-Basic OPM 3-Example37
38System API Programming V4R1
Integrated Language Environment
Across
ILE API
Generic Header Files
APIs-Concepts
Point
Variable-Length Structure-Example
Keyed Interface-Example
Exit Program Attributes Parameter
Key Type Field
Exit Program Attribute Keys
Initialize Bytes provided Field Number Parameter
Error Handling
Error Handling through the Error Code Parameter
Ccsid
Exception handling is by having All Exceptions Signa
Second
Entry
Receiver Variables-Examples
Fields-Example
With
Add Exit Program-ILE
Registration Facility Using ILE APIs-Examples
ILE C
\EXCLUDE
Description
Exit Point Example
API
12System API Programming V4R1
Program
EXAMPLEPGMEXAMPLELIB, Example Exit Program Data
Language ILE C
Input
Rslvsppgmhdlr Function
Output None
Information retrieved
16System API Programming V4R1
Common Information across APIs-Advanced ILE4-17Example
18System API Programming V4R1
Language ILE C Description
Remove Exit Program and Deregister Exit Point-ILE C Example
20System API Programming V4R1
Errorcode.ecfields.ExceptionId Exit1 \ End program \
22System API Programming V4R1
General Data Structure
Characteristics of a List
General Data Structure
Offset to List Data Section
Can Locate Remaining Information Place
Other Fields of Generic Header
On page 5-14 and the OBJP0200 Format on 5-14. This
Qsylobjp API
List Object API-OPM RPG Example
Processing a List
See Add Size Each Entry Field Get .7/ starton
\FLAG Reason Level Date Pgmr Change Description
\/COPY QSYSINC/QRPGSRC,QUSEC
Iqusbn
Quskyf
Qusbnf
Qusbng
Iqusky
Call Qsylobjp
\ENTRY Plist Parm
Exsr Init Exsr Proces Exsr Done
Begsr
Qusbnc
Parm Rjobdf
Parm Spcnam
Parm Spctyp
QSYB6
ADD Qusbpq Strpos
PROC2
Sizent
Movelqusrtvusapinam Exsr Apierr Endif
Nument Exsr PROC2
Qusbpj Ifeq
ADD Qusbpl Strpos
Oreq Exsr PROC1
Endif USRSPC=P/C Endsr
Begsr Movelqusbpj Lststs
Doueqc
Required Parameter Group
Authorities and Locks
Object type
OBJP0100
OBJP0200
User name
Section
User Space Variables
User
Field Descriptions
Attribute
Input
User space &4 in &9 damaged
Service Program Library &2 ended. Reason cod
Continuation handle not valid for
Object Type Not Valid
Parameters
Error Conditions
OPM
Without Pointers-ILE
This Program Calls Log Software Error Qpdloger
Pointers
Ffdc
Output None Exceptions
Ffdc Input
Unexpectedhdlr Function
\HANDLE
6System API Programming V4R1
QCLE/H
Software Error ILE
API with Pointers-ILE C Example
\ Unexpectedhdlr \
Function
SymptommsgkeywordMSGSYMPTOMLEN
\HANDLE
Numberofkeys, &ErrorCode
12System API Programming V4R1
Interface Instructions-Introduction
Interface
Machine
Section Discussing
Setting the Entry Point
Setting the Declare Statements
Writing an MI Program-Example
Result
ITS2
ARG2
Cpynv
MI01 Program-Complete Code Example
Compiling a Program
Rexx
Using Clcrtpg to Create
Creating the MI Example Program
Testing MI01
RST
Program
Debugging the MI Program
SAV
Language Statement Such
Are Compilers HLLs. Break
BRK
Directive allows users
Handling Exceptions in the MI Program
Hexadecimal representation of the message id
String 1202 Where 0C12 =andX 02 02= .X While most
Following is an updated view of the MI01 program
Excid
Creating an MI Version of Clcrtpg
Program Flow for Creating the Micrtpg Program
Qprcrtpg .API
Source for CL04 follows
Source for CL03 follows
Source for CL05 follows
Source for Micrtpg follows
Source for the Micrtpg Program
Following, however, are new statements
Code
Declaring the Structure
Understanding the Micrtpg Program by
Usrspcobj
Declaring Pointers
Usrspc
Enhanced Version
Understanding the MICRTPG2 Program by Sections of Code
Creating the Micrtpg Program
Calling
Instruction stream, create the space
Establish addressability to the Crts template
Ovrdbf
Binoffset
Qcmdexc API
CLOVRLNG@ ARG
DCL DD Cldltcmd CHAR12 Initdltovr Misrc
DCL Spcptr CLOVRLNG@ Initclovrlng
DCL Spcptr CLDLTLNG@ Initcldltlng
To Your Advantage
Beginning the Instruction Stream
Storage
Indicate that the program is done
MICRTPG2 Complete Program-MI Code Example
Delete the previous Ovrdbf
Call the Qprcrtpg API to create the MI program
DCL Spcptr Usrspc DCL Sysptr USRSPC@
DCL DD Numparms BIN
Crts MI
DCL Sysptr QTEMP@ Baspco
DCL Spcptr PGMOPTS@ Initpgmopts DCL DD Numopts BIN4 INIT3
DCL VAR&OFFSET TYPE\DEC LEN15 Loop Rcvf
Updated CL06 Program
Following is the updated CL06 program
PGM PARM&BUFFER &OFFSET Dclf Filemisrc DCL
Handling Exceptions
Creating the MICRTPG2
Qtemp
Its Consolidated State This Is the new MICRTPG2 program
Example
Machine Interface Programming7-29
CTXQSYS, Typepgm
Retexcpd
INT
DCL Sysptr QTEMP@ Defpco
MI Common Programming Techniques-Examples
Entry \ EXT
DCL Spcptr SEPT@ Defpco
DCL DD Sbytavl
DCL DD Matctxopts CHAR44 DCL DD Matctxctl
POS
DCL DD Sreceiver CHAR8 BDRY16 DCL DD Sbytprv
DCL DD Objentry
DCL DD Lextattr
Deflreceiver
DCL DD Lentry
Cpynv LBYTPRV, Sbytavl
SRECEIVER@, QTEMP@, Matctxopts
Cmpnvb SBYTAVL, 96 / Eqdone
LRECEIVER@, Sbytavl
Process Allo Cating Initializing automatic Storage
AS/400 Program Storage
API before Developing Your Cations
APIs
Backup Recovery
Communications APIs
Is only provided Service Program
Provides Way to That
OptiConnect APIs
Configuration APIs
Returns a list of configuration descriptions, based on a
Debugger APIs
Debugger
Low-level services
Window services
Dynamic Screen Manager APIs
An edit Code
Session services
Edit Function APIs
File APIs
Hardware Resource APIs
Hierarchical File System
Qdls
ILE CEE APIs
Cobol APIs
Commitment Control APIs
Journal and Commit APIs
Message Handling APIs
Journal APIs
Data
National Language Support APIs
Network Management APIs
National Language Support APIs
Alert APIs
SNA/Management Services Transport SNA/MS Transport APIs
Change Request Management APIs
Object APIs
Node List API
Filter
Lifo
Clear Data Queue Qclrdtaq Retrieve Description
Following describes
8APIs-13
User Index APIs
Usridx
Chglibl
Object APIs
Conversion Exit Programs Which Are Discussed Under Office
Office APIs
Movobj
Allows you to rename and mov
Office Exit Programs
File Server APIs
MSF
Most Functions
Performance Collector APIs
Print APIs
Print APIs
Filtering
Problem Management APIs
Error Reporting APIs
Program and CL Command APIs
Working with a Problem
Problem Log Entry APIs
Software Product APIs
Security APIs
Environment Variable APIs
UNIX-Type APIs
Getenv
Queues
Integrated File System APIs
Interprocess Communication APIs
Has Exec Function
Are identifie
Signal APIs
An X/Open Specification As a mechanism by which a process
Semaphore
Action
Signal
MIB
IDa
Server Client
Sockets APIs
UIM
User Interface APIs
Process-Related APIs
UIM Advantages
Support
DDS Advantages
Work
Work Management APIs
Process
Miscellaneous APIs
Miscellaneous APIs
List APIs
Find Field Numbers List
Qgyoljbl API
Task
Programming errors and refers you to
That show you how to avoid Errors
Using the error code
Is shown at .2/locationinthe incorrect and correct coding
Using the Error Code Parameter
Incorrect
Xxxxxxx
Csetonlr
Using the Error Code Parameter-Example of Correct Coding
Call Quscrtus Parm Spcnam
Parm SIZ Intval Parm \ALL
Parm Extattrextatr 1ð
Length Through This
Defining Data Structures
Incorrect Coding
Length is Defined Through
Jstat
\ SET UP to Accept Exceptions ADD\ZEROS
Jobnbr
Jobid
Defining a Data Structure-Example
Coding
List Entry from the Space
Intval \ SET UP to Accept Exceptions ADD\ZEROS
\ Create the Space to Hold the Data Call Quscrtus
\ Call the API to List the Active Jobs Qusljob
\ Delete the Space That Held the Data
RPG
When Defining Receiver Variables
When Run Lists All Active Jobs System
May Written Over with These extra characters. On Call
Qusbn \ Retrieve the List Entries Qusbpq ADD Start
Qusbn \ Call the API to List the Active Jobs Qusljob
Qusbn \ Retrieve the Offset
ADD1 Start
\\ JOB Name Structure for Calling Qusljob Ijobnam \ALL
Qusgen
Qusbn \ Retrieve List Entries Qusbpq ADD Start
Incorrect
Defining
\\ Data Structure Containing Space NAME/LIB Ispcnam DS
ADD1 Dowlequsbps
Qusbn \ Call the API to List the Active Jobs
Format Lengths-Example Correct
Coding
Movelqusdd Recvr
Recvr ADD Start END \ Delete the Space That Held the Data
ADD\ZEROS
Null
Null
ILE
Using Null Pointers with OPM APIs-Example of Correct Coding
20System API Programming V4R1
\CURLIB
Correct Byte Alignment ensures that data used With an
Byte
QusVlenRec4t descrec Char Desc5ð Addepattributes
This is a Test Exit PROGRAM,27
ILE C
Defining Byte Alignment-Example Correct
EXAMPLEPGMEXAMPLELIB, Example Exit Program Data
Point For Beginning Read User
Using Offsets in a User Space
Using Offsets in a User
Incorrect
\FLAG Reason Level Date Pgmr
Iobject \ALL
Copy QSYSINC/QRPGSRC,QUSLOBJ
Iusersp APIUG1
Qgpl
Lendta
Qusbpj Ifeq C Oreq P
Qusbps
ADD1 Count Addqusbpq Strpos
Correct Coding
Using Offsets in a
User Space-Example
\FLAG Reason Level Date Pgmr
Iobject \ALL Objnam Qgpl Objlib
Iusersp APIUG1 Usrspc Qgpl Spclib
Call Quscrtus Parm
Qusbpq ADD Strpos
Oreq
Exsr Errcod Seton Retrn
For
Coding for New Function
Dspcinit
Dspcname Inzadopts Qtemp Dspcsize
\FLAG Reason
Qusfn
Qusua
Qussgh
Qussrl
QSYOBJT12
QSY
Pgmr Change Description
Dqsyobjph Basedlstptr
Qusis Ifeq Oreq
Proces Begsr
Move Qusis
Lststatus Doueq
Exsr Done END
Qusis Ifeq
Eval Lstptr = %ADDRARRQUSOIP +
END Else
Qusei Ifeq
Eval Qusbprv = %SIZEQUSEC
Call Qusrobjd Parm Rcvvar Rcvvarsiz
Robjdfmt Parm Spcname \USRSPC Objtype Qusec
Does Not match
Coding for New Function-Example Correct
PGM, or
9B ð INZ1
Basedspcptr
Lupa
46System API Programming V4R1
Dsply Else
Else QSYOBJT12 Ifeq
Ifeq \BLANKS Move
QSYOBJT12 Ifeq \SRVPGM
Eval Lstptr = Addrarrqussee + END
Eval Lstptr = Addrarrqusoip +
Parm Qusec
Call Qsylobjp Parm Spcname
Mbrlist Parm \CURRENT Usrprf
Objtype Parm
Parm \USER Spcdomain
Software products
Packaging Your Own Software Products
RPG Example on page A-3
Dltlib ABC
Packaging a
Object Description
CL Program for
Crtpnlgrp ABC/ABCPNLGRP ABCDEV/QPNLSRC +
Crtdspf ABC/ABCDSPF ABCDEV/QDDSSRC +
Crtpf ABC/ABCPF ABCDEV/QDDSSRC +
Crtcmd ABC/ABC ABC/ABCPGM ABCDEV/QCMDSRC +
Copy QSYSINC/QRPGSRC,QSZCRTPD
Phone
Copy QSYSINC/QRPGSRC,QSZCRTPL
Copy QSYSINC/QRPGSRC,QSZPKGPO
Textd
Qszbcb
Exsr Cobjd
Exsr Pkgpo
Prddfn Begsr
Parm Qszbf
Movelqszcrtpdapi
Parm Qszbc
Parm Qszbd
Qszbk
Movelqszcrtplapi Call Qszcrtpl
Qszbh
Qszbj
Pkgpo
Cobjd
Move OBJ,I Objds Name CAT ABC
Cobji
Parm \NO
MOVEL\ALL Qszbrf
Movelqszpkgpoapi Call Qszpkgpo Parm Qszbr
Parm \YES Repkg
Qszrtvpr API
Command B-129
Retriev
Rtvfd
\CHANGE
\INT
\LCL
User
Using Data Queues versus
Queue entries are manipulated. F
Data Queue-ILE C Example
Queuelib
User Queue-ILE C Example
Example
18System API Programming V4R1
Valid
\USER
Appendix A. Performing Tasks Using APIs-ExamplesA-21
22System API Programming V4R1
Additional Languages
Appendix
Jobdapi
Original Program Model OPM APIs-Examples
Hold Parameter Exception Message-ILE C
Example on For the original
Appendix Original Examples in Additional
Identification Division
Message-ILE Cobol
Copy Qusec of QSYSINC-QLBLSRC
Procedure Division Using JOBD, JOBDL. .8/ MAIN-LINE
Cobol
PROGRAM-ID. Jobdapi Environment Division
Move HOLD-JOB-QUEUE to Hold
Move Jobd to JOB-DESC. Move Jobdl to JOB-DESC-LIB
Copy QSYSINC/QRPGLESRC,QUSEC
Dformat
Dcmdstring
INZ Tousrqpgmr
Drcvlen
Handling Error
Call Qwdrjobd
Exsr Error
Error Begsr
Jobd CAT Jobdlib Lfnam
Jobdapi
Appendix B. Original Examples in Additional BLanguages-11
Identification Division
Move 16 to BYTES-PROVIDED
Procedure Division Using JOBD, JOBDL. MAIN-LINE
Perform Errcod
Copy QSYSINC/QRPGLESRC,QWDRJOBD
Call Qcmdexc Using MESSAGE-TWO, COMMAND-LENGTH, Stop RUN
Call Qwdrjobd Parm
DCMDSTR2
Msgid INZ Tousrqpgmr
Dlenstr INZ%SIZECMDSTRING DLENSTR2 INZ%SIZECMDSTR2
Movel Qusei Msgid Call Qcmdexc Parm
Accessing the Hold Attribute-ILE C Example
Parm LENSTR2 Endsr
File
PROGRAM-ID. Jobdapi
Hold Attribute-ILE
LIST-LINE
Data Division File Section
Label Records are Standard
Data Record is LIST-LINE
BAD Open Output Listing Move EXCEPTION-ID to Msgid
Attribute-OPM RPG Example On page 3-17 f Original
Refer To Accessing
Oqprint BAD
Except Good Else
Except BAD END
Oqprint Good
Appendix B. Original Examples in Additional
24System API Programming V4R1
List-ILE Cobol Example
Refer Accessing Field Value Initial Library List-OPM
For Original example. The following program also
Value Qwdrjobd
Roch
BYTES-AVAILABLE
JOB-SWITCHES PIC
DEVICE-RECOVERY-ACTION PIC
BYTES-RETURNED
Perform NUMBER-LIBS-IN-LIB-LIST Times
Call Qcmdexc Using COMMAND-STRING, COMMAND-LENGTH, ADD 11 to
Reclen
List-ILE RPG
Qwdbavl
Qwdbrtn
Qwdjd
Qwdjdn
Qwdjdln
Qwdun
Qwdjmqfa
Qwdord
Qwdlrd
Qwdjmqms
Call Qcmdexc Parm Cmdstring Lenstr ADD
Using Keys with List
Exsr Error Else
Qwdoill ADD Qwdnlill Eval
Quslspl
Appendix B. Original Examples in Additional BLanguages-35
36System API Programming V4R1
Appendix B. Original Examples in Additional BLanguages-37
Pages
Using Keys with List Spooled Files API-ILE Cobol Example
Prtfil PIC
Filler PIC
Misc SPC-NAME PIC
Opndat PIC
Lsterr TEXT1 PIC
Hdrerr TEXT2 PIC
Call Qusptrus Using SPC-NAME, SPCPTR, QUS-EC
Procedure DIVISION. MAIN-LINE
KEY-INFO
Perform Proces
SET
STRING-SPACE Spcptr SET
STRING-SPACEOFFSET-LIST-DATA
Dlstptr DLSTPTR2 Dspcptr
Using Keys with List Spooled Files API-ILE RPG Example
To Opndat
Inzspcname Qtemp Dspcsize
Appendix B. Original Examples in Additional BLanguages-43
\ QUSERVED35
Dqussplki
BASEDLSTPTR2
\QUSERVED34
Format Parm \CURRENT Usrprf
Parm \BLANKS Spctext
Parm Qusec \USER
Call Quslspl Parm Spcname
Move \BLANKS Prtfil Eval
AGE CAS Error END
Eval LSTPTR2 = %ADDRARRX END Except Prtlin
Filnam Begsr
Integrated
APIs-Examples
Exit
Cobol Example
VAR-OFFSET
BAD-REG TEXT1 PIC
EXCEPTION-ID PIC
BAD-ADD TEXT1 PIC
Move 4 to CONTROL-KEY of QUS-VLEN-REC-4
Move 2 to NBR-RECORDS
Move 3 to CONTROL-KEY of QUS-VLEN-REC-4
Move Exit Point Example
Register Exit Point
By Content Length of EXIT-PGM-DATA of MISC, VARREC, QUS-EC
TEXT1 PIC
X1ððð Ð1 Misc
EXIT-POINT-NAME of MISC, FORMAT-NAME of MISC, VARREC, QUS-EC
RPG
Iovrlay
Printer \ Compile Time Array REC
Copy QSYSINC/QRPGSRC,QUS I\
Ivarrec
Binary ADD Moveabinc REC,OF Exsr Calcvo ADD8
ADD2
ADD3
ADD4
Qusbnc Ifgt Open
REC,OF Exsr
ADD37 Binary Moveabinc REC,OF Exsr
Call Qusaddep
Copy QSYSINC/QRPGLESRC,QUS
Errept
Errpgm
Printer OFLIND\INOF Usropn
Doverlays Binary
Dvarrec Nbrrecs
Recs
Dvoffset
Open Qprint Except Erraepnt Exsr Done Endif
Callb
Parm Epntname
Format Parm Varrec Qusec
Information-OPM Cobol
Misc EXIT-POINT-NAME PIC
PROGRAM-ID. REGFAC2 Environment Division
EXCEPTION-ID
BAD-CREATE TEXT1
Value Rcvvar Qtemp SPACE-ATTR PIC
FORMAT-NAME-1 PIC
FORMAT-NAME-2 PIC
BASE-POINTER Pointer INFO-POINTER SPACE-NAME PIC
Move Spaces to CONTINUATION-HDL
Call Qusptrus Using SPACE-NAME, BASE-POINTER, QUS-EC
CALL-EXIT-PROGRAMS
Else Stop RUN
Perform CALL-EXIT-PROGRAMS
To CONTINUATION-HDL
CALL-PGMS
Write LIST-LINE from BAD-EXIT-PGM, Stop RUN
To Address of RCVVAROFFSET-PROGRAM-ENTRY
Perform CALL-PGMS
EXIT-PGM-NBR
Value Exampleexitpoint
Value -1 Binary
68System API Programming V4R1
Appendix B. Original Examples in Additional BLanguages-69
Open Output Listing Move EXCEPTION-ID of QUS-EC
Appendix B. Original Examples in Additional BLanguages
Call Qusrtvei Parm Conthd RCV Rcvsz
Copy QSYSINC/QRPGSRC,QUSREG
Ircv
Move \BLANKS
SUBSTRCV1
Parm Epntnm
Parm Epgmnb
Qusccb
Quscjg
Parm RCV Rcvsz
Quscj
ADD Quscjf Substrcvy
\ Based
Information-ILE RPG Example
Done Begsr Seton Retrn Endsr Oqprint
Qusbnd Oqprint
Qusppf
Dquspe
Qusppn
Quspplib
Qusco
Qusmlib
Qusmi
Dqusse
Qusacc
Qusmep
Qusnbrep
Qusad
Quspgml
Qusone
Qusce
Quspgmn
Quslpgme
Qusled
\QUSPD
Qusopgme
Quslpd
QUSFN12
Qusmfill
Qusopd
Depntname Inzexampleexitpoint Depgmnbr
\ QUSFN13
\ QUSERVED11
Qusrei
Epntfmt Parm Epgmnbr Qusnbrsc Qusec
Move \BLANKS Continhdl
Callb Qusrei Parm Continhdl Rcvvar Rcvvarsz
Format Parm Epntname
Exsr Cusrei Enddo Endif Done
DOW
Cusrei Begsr
Begsr Eval
Remove Exit Program
Parm Exitparms
Eval Infspcptr = %ADDRRCVVARQUSONE+1 Enddo Endsr
PGM-NBR
Call Qusdrgpt Using EXIT-POINT-NAME, FORMAT-NAME, QUS-EC
PROGRAM-ID. REGFAC3 Environment Division
EXIT-POINT-NAME, FORMAT-NAME, QUS-EC
Exampleexitpoint Epntnm
Call Qusdrgpt
Parm Pgmnbr Qusbn
Dpgmnbr
Qusrepgm
Format Parm Pgmnbr Qusec
Callb Qusrepgm Parm Epntname
Callb Qusdep Parm Epntname
Object
API-ILE C
Appendix B. Original Examples in Additional BLanguages-95
96System API Programming V4R1
Appendix B. Original Examples in Additional BLanguages-97
98System API Programming V4R1
Appendix B. Original Examples in Additional BLanguages-99
100
PROGRAM-ID. Listadopt Environment Division
List Object API-ILE Cobol Example
INPUT-OUTPUT Section
102
Address of STRING-SPACE
Procedure Division Using USR-PRF, OBJ-TYPE. MAIN-LINE
OBJ-TYPE PIC
Copy Qsylobjp of QSYSINC-QLBLSRC
To LST-STATUS, END-IF END-IF, END-IF Else
Perform PROCES2
Perform DONE, END-IF PROCES2
Move Qusrobjd to APINAM, Perform Apierr
Move Qsylobjp to APINAM, Perform Apierr
Move Length of QUS-EC to BYTES-PROVIDED of QUS-EC
Move Quscrtus to APINAM, Perform Apierr
Write LIST-LINE from END-LIST. Stop RUN
106
Move Qusptrus to APINAM, Perform Apierr
Display Apinam Display EXCEPTION-ID of QUS-EC. Perform Done
Dlstptr Dspcptr Darr Basedlstptr DIM32767 Drcvvar
Inzadopts Qtemp Dspcsize
QSYOBJT14
108
QSYOBJT13
QSYOBJA11
Eval Lstptr = %ADDRARRQUSSEE + 1 END
Qusnbrle Except Objentry
Lststatus
Mbrlist Parm Usrprf Objtype Continhdl Qusec
Exsr Getlst Move Qusis Lststatus END Else
Robjdfmt Parm Spcname \USRSPC Spctype Qusec
CPF98ð1
Logging
Pointers-Examples
CBLERR1 Program
Without
PROGRAM-ID. CBLERR1
ERROR-HANDLER PIC
ERRHDL1 \LIBL Scope PIC
PROGRAM-ID. ERRHDL1
PRIOR-ERROR-HANDLER of MISC, QUS-EC
ERRHDL1 Program
ADD X to Y
Binary Value PRINT-JOBLOG PIC
Misc LOG-EXCEPTION-ID PIC
MESSAGE-KEY PIC
POINT-OF-FAILURE PIC
Move C to SYS-OPTION. Stop RUN
Logging Software Error OPM
Move 1 to MSG-OFFSET
LIBRARY-NAME
Imisc
SRC TGT
Ipsds
Excpid
FACT1 DIV FACT2 Result
Switch
FACT1
FACT2
API without Pointers-ILE C Example
Logging Software Error OPM API without Pointers-ILE
Dpsds SDS
120
Appendix B. Original Examples in Additional BLanguages-121
Reporting
This section includes the examples Reporting Software Error
Refer to Reporting Software Error ILE
CBLERR2 Program
Copy Qusec of QSYSINC-QCBLLESRC
ERROR-HANDLER
NUMERIC-GROUP PIC
PROGRAM-ID. ERRHDL2
ERRHDL2 Program
Copy Qpdsrvpg of QSYSINC-QCBLLESRC
CBL-PGM-NAME
Procedure Division Using CBL-EXCEPTION-ID
MESSAGE-LENGTH
SYS-OPTION PIC
126
RPG Example
Software
Inzrc
Copy QSYSINC/QRPGLESRC,QPDSRVPG D\
Dpsds
128System API Programming V4R1
Software Produ
This Section Includes the examples Packaging Your
Sftwprdex
130System API Programming V4R1
Object ABCðð29 MRI object For Product
132System API Programming V4R1
Qclsrc ABC
ABCPGMMRM2ABC
ABCPGMMRI1ABC
ABCPGMMRI2ABC
134
Appendix B. Original Examples in Additional BLanguages-135
PROGRAM-ID. Sftwprdex Environment Division
Program for Packaging a Product-ILE Cobol Example
Qszcrtpd
Qszpkgpo
API-NAME PIC
Copy Qszcrtpd of QSYSINC-QLBLSRC
Copy Qszcrtpl of QSYSINC-QLBLSRC
Copy Qszpkgpo of QSYSINC-QLBLSRC
PID13 PIC
Numkey
KEY13
LEN13
Prddfn
Perform Prdlod
Perform Cobjd
Perform Pkgpo
Prdlod
Call Qszcrtpd Using PROD-NAME, QSZ-PRD-INF, QSZ-PRD-OPT
Move Spaces to Reserved of QSZ-LNG-LOD
Move Qszcrtpd to API-NAME, Perform Errcod
Move ABCPGMMRI2 to POST-EXIT-PGM of QSZ-LIB-INF
Move Qszcrtpl to API-NAME, Perform Errcod
Move ABCPGMMRI1 to PRE-EXT-PGM of QSZ-PRE-EXT
Move Qlicobjd to API-NAME, Perform Errcod
Move Qszpkgpo to API-NAME, Perform Errcod
Call Qszpkgpo Using QSZ-PRD-OPT-INF, REPKG, ALWCHG, QUS-EC
Open Output LISTING, Move 1 to FIRST-ERR
Product-OPM RPG Example on page A-3 fo Original
144
Packaging a
Refer To Program For
Dapiname Dfirsterr
Dcobji Numkey
PID13 KEY12
LID12 KEY5
Parm Prodname Qszpi Qszpo
146
Eval Qszamr = \NO Qszridt = \PHONE
Eval Qszadn = \NODYNNAM
Eval Qszlt = \CODE Qszlid = \CODEDFT
Parm Qszll
Parm Pubaut Qusec
Exsr Errcod Endif Endsr
148
Parm Qszpe Nbrpe Qszfl
Parm Qszal
Cobjd Begsr
150
Qusei \\CTDATA Objinfo
Open Qprint Eval Firsterr = Endif
Endsr Oqprint Badnews
Apiname
SPACE-INIT PIC
Space-Examples
Space-ILE Cobol Example
FILE-USED PIC
EXT-ATTR PIC
Overrides PIC
System PIC
FORMAT-1 PIC
Display API-NAME
Call Qusptrus Using SPACE-NAME, SPACE-POINTER, QUS-EC
API-ERROR-FOUND
SET Address of QDB-QDBFH to SPACE-POINTER
To a User Space-ILE RPG Example
156
Qdbfwtfi
Qdbfhupl
Qdbfhmxm
\NOMAX
QDBRSV11
Qdbfhfrt
Frcratio
Qdbhmnum
Qdbfhcrt
Qdbfvrm
\QDBQAAF2 QDBBITS31
QDBRSV17
160
QDBRSV24
QDBRSV23
Qdbffigl
Qdbfmxrl
Qdbpfof
Fcfo Fifo Lifo
Qdbfhrls
QDBRSV27
Dsystem INZ\LCL DFORMAT1 INZ\INT Dchgattr Nbrattr
QDBRSV28
Dspcname Dfilename Dfmtname Dfileused Dlibname Dspcsize
Dspcptr Dformat Doverrides
Qusbavl Ifgt Movel Quscusat Apinam Exsr Apierr END
Call Quscrtus Parm Spcname \BLANKS Extattr
Spcsize Parm Spcinit \CHANGE Spcaut Qdbrtvfd Spctext
Call Quscusat Parm Libname Spcname Chgattr Qusec
Data Queue-ILE Cobol Example
Data Queue-Examples
Crtlib
FIRST-ERROR PIC
PROGRAM-ID. Dqueuex Environment Division
Copy Qcapcmd of QSYSINC-QLBLSRC
MSG PIC
WAIT-TIME
MSG-BACK PIC
Move 1 to FIRST-ERROR
ERROR-FOUND
Display MSG-BACK
Data Queue-OPM RPG Example
170
Qcabc
Exsr Exccmd
Moveldltlib Cmdstr
Exsr Exccmd Seton Retrn
172
Data
Parm Exampleq
Eval Qcamk = \BLANKS Qcaerved = \LOVAL
Eval Cmdstr = Crtlib Lenstr = %SIZECRTLIB Exsr Execcmd
Eval Cmdstr = Crtdq Lenstr = %SIZECRTDQ Exsr Execcmd
174
Theread
UNIX-Type APIs-Examples
176System API Programming V4R1
Appendix B. Original Examples in Additional BLanguages-177
Using the Integrated File System-ILE Cobol Example
Curdir PRT-TEXT PIC
PROGRAM-ID. IFS Environment Division
PRT-TEXT PIC
User PIC
Oflag PIC
Procedure DIVISION. MAIN-LINE Open Output Listing
Testfile
Value LOW-VALUE
If RETURN-INT
Perform ERROR-FOUND
To LIST-LINE Write LIST-LINE
Giving RETURN-INT
To LIST-LINE Perform ERROR-FOUND Else
To LIST-LINE Perform ERROR-FOUND
Write LIST-LINE. Stop RUN
Fqsysprt
ERROR-FOUND Write LIST-LINE
184System API Programming V4R1
BLanguages-185
186
Appendix B. Original Examples in Additional BLanguages-187
Oqsysprt
Books
Bibliography
Books
Bibliography H-3
4System API Programming V4R1
Index
Numerics
API application programming interface
Index
ILE RPG
Index
Chgenvvar
CEE
Dspjobd
Display
Example
Qusrtvei API
Exception
Type EXT
ILE
IPC
Listing
Message key
Management APIs
Assistant Exit Program OptiConnect APIs
PL/I
PL/I API
Retrieve
Qlpcdinf Generate CD-ROM Premastering Infor- mation API
Qusdrgpt Deregister Exit Point API
Qearmvbm API
SAA
Controls
MI instruction
Station
Page
Other countries+1+507+253-5192
How satisfied
Please tell us how we can improve this manual
To return this form
SC41-5800-00
Reader Comments-Wed Like to Hear from You
Page
IBM
IBM