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