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