Page 3 - AS/400 Advanced Series; IBM; System API Programming; Version 4
AS/400 Advanced Series IBM System API Programming Version 4 SC41-5800-00
Page 5 - Contents; iii
Contents Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi Programming Interface Information . . . . . . . . . . . . . . . . . . . . . . . . . xii Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii About System AP...
Page 6 - iv
APIs and Internal System Objects . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Performance Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-31 Chapter 3. Common Information across APIs—Basic (OPM) Example . . 3-1 Original Program Model (OPM) API–Scenario . . . . . . ...
Page 9 - vii
Accessing the HOLD Attribute—ILE RPG Example . . . . . . . . . . . . . B-21 Accessing a Field Value (Initial Library List)—ILE C Example . . . . . . . B-22 Accessing a Field Value (Initial Library List)—ILE COBOL Example . . . . B-25 Accessing a Field Value (Initial Library List)—ILE RPG Example . ....
Page 10 - viii
Page 11 - Figures; ix
Figures 1-1. How APIs Fit into the AS/400 Business Computing System Structure 1-2 2-1. OPM and ILE API Verbs and Abbreviations . . . . . . . . . . . . . . . 2-2 2-2. Language Selection Considerations — Data Types . . . . . . . . . . . 2-3 2-3. Language Selection Considerations — Call Conventions . ....
Page 13 - xi
Notices References in this publication to IBM products, programs, or services do not imply that IBM intends tomake these available in all countries in which IBM operates. Any reference to an IBM product, program,or service is not intended to state or imply that only that IBM product, program, or ser...
Page 14 - xii
Programming Interface Information This publication is intended to help experienced programmers create application programs. This publica-tion documents General-Use Programming Interface and Associated Guidance Information provided by theOperating System/400 (OS/400) licensed program. General-Use pro...
Page 15 - Who Should Use This Book; xiii
About System API Programming (SC41-5800) This book provides introductory, conceptual, andguidance information about how to use OS/400application programming interfaces (APIs) withyour application programs. It includes examplesand discusses the following: Benefits of using APIs When to use APIs v...
Page 16 - xiv
Page 17 - Chapter 1. Application Programming Interface—Overview; API Compatibility
API Compatibility Chapter 1. Application Programming Interface—Overview Application programming interfaces (APIs) that are used on AS/400 business com-puting systems provide paths into system functions. APIs are intended for experi-enced application programmers who develop system-level applications ...
Page 18 - Using APIs—Benefits
Commands Licensed Programs High-LevelLanguages OS/400 Licensed Internal Code MachineInterface CL ProgramApplication Calls Exits HLLProgramApplication UserExitApplication ILE C for AS/400 or MI Application RV3W217-1 CL commands Callable programs Exit programs Machine Interface Instructions (accessibl...
Page 19 - System APIs or CL Commands—When to Use Each
Your application is more straightforward if you are coding in a programming lan-guage other than CL, which is not a fully defined language (it does not havethe full capabilities of a high-level language). For example, you may have tocode separate CL programs to perform specific functions. You ca...
Page 20 - Related Information
Defining, creating, distributing, and maintaining your own software products.See “Packaging Your Own Software Products” on page A-1 for an example ofpackaging a product similar to the way IBM packages products. Controlling systems and networks, which can include configuration, spooledfiles, netw...
Page 21 - Chapter 2. Getting Started with APIs; Locating the API to Use
Chapter 2. Getting Started with APIs You may find the information in this chapter helpful as you start to work with APIs;for example, locating the API that you want to use. It also tells you about informa-tion that you will need when using the APIs. Other topics covered are: Language selection con...
Page 23 - Selecting the High-Level Language To Use
Selecting the High-Level Language To Use You can use APIs with all the languages available on AS/400 business computingsystems, except for the ILE APIs. ILE APIs that are implemented as service pro-grams (*SRVPGM) can be accessed only by ILE languages. In some cases, aprogram (*PGM) interface is pro...
Page 24 - API Environments; APIs for the Original Program Model Environment
Figure 2-3 on page 2-4 shows the languages available on the AS/400 system andthe parameter support that they provide. For more information, see the referencemanual for the specific programming language that you plan to use. Figure 2-3. Language Selection Considerations — Call Conventions Language 1 ...
Page 25 - APIs for the Integrated Language Environment; APIs for the ILE Common Execution Environment (CEE)
Related Information System API Reference, SC41-5801 CL Reference, SC41-5722 Chapter 3, “Common Information across APIs—Basic (OPM) Example” onpage 3-1 APIs for the Integrated Language Environment The Integrated Language Environment (ILE) model is a set of tools and associatedsystem support des...
Page 26 - APIs for the UNIX Environment; API Parameters
Math functions Message services Program or procedure call management and operational descriptor access Storage management Related Information “Integrated Language Environment (ILE) CEE APIs” on page 8-7 ILE Concepts, SC41-5606, for conceptual information about ILE SAA CPI Language Envi...
Page 27 - Parameter Passing
ters (A through Z, 0 through 9, $, #, @, ), or _). The system uses an object nameas is, and it does not change or check the object name before locating the object.This improves the performance of the API. An incorrect name usually results in an Object not found error. Parameter Passing With the exce...
Page 28 - Parameter Classification
cedure passes parameters in the manner expected by the called API. The OPM orILE HLL programmer's guides contain more information on passing parameters todifferent languages. The ILE languages support the following parameter-passing styles: ILE C passes and accepts parameters by value (directly an...
Page 30 - Using the Job Log to Diagnose API Errors; Receiving Error Messages from the Job Log—Example
Field INPUT OUTPUT Exception ID Ignored CPF7B03 Reserved Ignored 0 Exception data Ignored USRMSG QGPL Using the Job Log to Diagnose API Errors Sometimes an API may issue one or more messages that state that the API failed,and the messages may direct you to see the previously listed messages in the j...
Page 32 - Internal Identifiers
C Z-ADDð RETCOD C ELSE C 'CPF1Fð2' IFEQ ERRID C 'CPF1F22' OREQ ERRID C\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\C\ THERE IS NO NEED TO REINITIALIZE THE ERROR CODE PARAMETER.C\ ONLY BYTES PROVIDED IS INPUT TO THE API; IT WILL RESET THEC\ ERROR CODE PARAMETER FOR US. AFTER THE CAL...
Page 33 - User Spaces
User Spaces internal job ID to access a spooled file for a job with the Retrieve Spooled FileAttributes (QUSRSPLA) API. User Spaces APIs that return information to a caller generally return the information in a userspace (used by list APIs) or a receiver variable (used by retrieve APIs). 1 The list ...
Page 34 - User Space Format—Example
User Spaces User Space Format—Example Following is an example of the format of a user space. This example does notcontain all of the fields in the fixed portion of a user space. User Space Fixed locations ┌────────────────────────┐ in the user space │ │ ────────────────── │ │ │ │ │ XXXX ─────┼───5 O...
Page 35 - Logic Flow of Processing a List of Entries
User Spaces Logic Flow of Processing a List of Entries When you process a list containing multiple entries, the logic flow looks as follows: ┌────────────────────────┐ │ │ │ Initialize the next │ │ entry with 'Where │ │ the list begins' │ └────────────┬───────────┘ │ 6 ┌────────────────────────┐ │ │...
Page 36 - Manipulating a User Space with Pointers; Synchronizing between Two or More Jobs
Manipulating a User Space with Pointers Manipulating a User Space with Pointers Some languages, such as ILE C', VisualAge C ++ for OS/400, ILE COBOL, ILE RPG, COBOL, Pascal, and PL/I, support pointers. Pointers allow you to manipulateinformation more rapidly from the user space. To use pointers with...
Page 37 - Manipulating a User Space without Pointers; Position Values
Manipulating a User Space without Pointers Manipulating a User Space without Pointers When programming in a language that does not support pointers, you can use theChange User Space (QUSCHGUS) and Retrieve User Space (QUSRTVUS) APIsto manipulate data. However, you must first understand how to use po...
Page 40 - Changing a User Space with an ILE RPG Program—Example
Manipulating a User Space without Pointers Changing a User Space with an ILE RPG Program—Example To change the user area of a user space as shown in the previous example with acall from an ILE RPG program, specify the following: H\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ H\H\...
Page 41 - Changing a User Space with an OPM RPG Program—Example
Manipulating a User Space without Pointers Changing a User Space with an OPM RPG Program—Example To change the user area of a user space with a call from an OPM RPG program,specify the following: H\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ H\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 44 - Keyed Interface
returned on this API call. If both values are the same, the API returned all theinformation. Depending on the capabilities of your high-level language, some API users takeadvantage of the following technique to avoid guessing the appropriate size for thereceiver variable: 1. Call the API with a rece...
Page 46 - Domain Concepts
4. If the continuation handle field in the receiver variable is not set to blanks, do the following steps until the continuation handle equals blanks: a. Copy the continuation handle from the receiver variable to the continuation handle parameter. b. Call the API again by using the continuation hand...
Page 47 - Exit Programs
Note: On a system configured for C2 2 system security, QALWUSRDMN is set to QTEMP (only the QTEMP library can contain user-domain user objects). For more information about C2 security, refer to the Guide to Enabling C2 Security book, SC41-0103. Related Information “Using Data Queues versus User Qu...
Page 48 - APIs and the QSYSINC Library
The exit point provider is responsible for defining the exit point information,defining the format in which the exit program receives data, and calling the exitprogram. Related Information For more information about the registration facility, see the Registration Facilitypart in the System API Ref...
Page 50 - User Index Considerations; APIs and the QUSRTOOL Library
User Index Considerations Related Information Chapter 2 in the System API Reference, SC41-5801 APIs and the QUSRTOOL Library QUSRTOOL, an optionally installable library, has several tools that use APIs andinclude files (header files) for APIs. You can use the code as a model for yourprogramming. A...
Page 51 - Performance Considerations; APIs and Internal System Objects
Performance Considerations APIs and Internal System Objects APIs retrieve information from internal system objects. Some of the informationcontains special values. For example, the list object API returns the object type asa special value (*PGM, *LIB, and so on). However, special values may be added...
Page 54 - Description of an API; Parameters; Authorities and Locks
nonobject information that represents data known to the system, such as job infor-mation or system status. Description of an API Most APIs have similar topic headings. The following lists the API topic headings,each with an overview and details on how to use the information. Parameters The Parameter...
Page 55 - Required Parameter Group
Locks are based on the objects that the API uses. The type of locking that occurs,such as whether the object can be used by more than one user at the same time,is based on what actions the API performs on the object. For the QWDRJOBD API, you must have *USE authority to both the job descriptionobjec...
Page 57 - Optional Parameter Group; Format
with a value of zero ( .6/ on page 3-7) must be passed. This indicates to the API that you want exception messages sent. Optional Parameter Group Some of the APIs have optional parameters; the optional parameters form a group.You must either include or exclude the entire group. You cannot use one of...
Page 60 - Handling Error Conditions—OPM RPG Example
qualifier .9/ . A 20-character variable must be used, and the simple name must begin in byte 1 with the library qualifier in byte 11. Because CAT is used, a simpleconcatenation of two 10-byte variables occurs so that the names are in the correctplace for the LFNAM parameter. The QWDRJOBD API is call...
Page 64 - Format of an Error Code Structure
Format of an Error Code Structure The format of the error code structure (QUSBN) is: The error code structure can be found in the QSYSINC library in the memberQUSEC (see .14/ on page 3-12). Which of the files you use depends on the lan- guage. For more information on the QSYSINC library, see “APIs a...
Page 69 - Accessing the HOLD Attribute—OPM RPG Example
exception. You cannot receive a diagnostic message (if one were sent in additionto the escape message) in the error-code data structure. You can use the messagehandling APIs to receive messages from your program message queue and toaccess the other messages that may be issued from the API. Appendix ...
Page 71 - Accessing a Field Value (Initial Library List)—OPM RPG Example
variable data structure if information is found. The API places the information in theerror-code data structure if an error occurred and if enough space was provided toreceive the information. The program prints one of two different lines depending on whether any errors werefound: HOLD value - \NO ....
Page 76 - Using Keys with List Spooled Files API—Example
libraries, you may begin to access information in the format for the next setof information (in this example, it may be the request data value). The output for this program example is as follows: à ð Display Messages System: GENSYS9ð Queue . . . . . : QPGMR Program . . . . : \DSPMSG Library . . . : ...
Page 84 - Field Descriptions
Field Descriptions Accounting code. An identifier assigned to jobs that use this job description.This code is used to collect system resource use information. If the special value*USRPRF is specified, the accounting code used for jobs using this job descriptionis obtained from the job's user profile...
Page 88 - Error Messages
Routing data. The routing data that is used with this job description to start jobs.The possible values are: QCMDI The default routing data QCMDI is used by the IBM-supplied interactive sub-system to route the job to the IBM-supplied control language processorQCMD in the QSYS library. *RQSDTA Up to ...
Page 91 - Integrated Language Environment (ILE) APIs—Introduction
Chapter 4. Common Information across APIs—Advanced(ILE) Example Through the use of several examples, this chapter provides information about howto use more advanced or more complex API concepts in your programs. Theexample programs in this chapter use ILE APIs. These examples are also shownin additi...
Page 93 - Variable-Length Structure—Example; Keyed Interface—Example; Exit Program Attributes Parameter
#include <stdio.h> #include <signal.h> #include <string.h> #include <stdlib.h> #include <qusrgfa1.h> #include <qusec.h> Variable-Length Structure—Example Many of the structures needed are provided by the QSYSINC (system include)library. However, any fields of a st...
Page 94 - Exit Program Attribute Keys
The number of variable-length records field .3/ is the first 4 bytes, and this field tells the API how many variable-length records have been specified. The fieldsdefined in .4/ are repeated (contiguously) immediately following the number of variable-length records for each record that is sent to th...
Page 95 - Error Handling; Error Handling through the Error Code Parameter
Qus_Vlen_Rec_4_t CCSID_rec; int CCSID; } addep_attributes; The num_rec field is set to the value of 2 because the example specifies twovariable-length records. The replace_rec field contains the length of the variable-length record (value of 16), the key (value of 4), and the length of the data (val...
Page 96 - Error Handling Signaled by API
if (error_code.ec_fields.Bytes_Available != ð) { printf("ATTEMPT TO REGISTER EXIT POINT FAILED WITH EXCEPTION: %.7s", error_code.ec_fields.Exception_Id); exit(1); } Message Data—Example: If your program needs to handle different exceptions indifferent ways, you may need to make use of both t...
Page 97 - Receiver Variables—Examples; Repeating Entry Type with Fixed-Length Fields—Example
Receiver Variables—Examples As discussed in “Receiver Variables” on page 2-23, receiver variables are generallyused by retrieve APIs to return information to a caller. This topic provides codingexamples of repeating entry types and of the use of offsets to go from one entry tothe next in the receive...
Page 98 - Repeating Entry Type with Variable-Length Fields—Example
Repeating Entry Type with Variable-Length Fields—Example In this example, the EXTI0200 format is defined in the qusreg.h header file, whichis included by the qusrgfa2.h header file in the QSYSINC library. This format is of the repeating entry type with some variable-length fields. Therepeating porti...
Page 99 - Registration Facility Using ILE APIs—Examples; Register Exit Point and Add Exit Program—ILE C Example
memcpy(exit_pgm_lib, ((Qus_EXTIð2ðð_Entry_t \)rcv_ptr)→Program_Library,1ð); /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\ Resolve to the exit program. If an error occurs on the \/ /\ resolve operation to the library, the rsl_ok indicator is \/ /\ set to failed in the RSL_PGM_H...
Page 103 - Retrieve Exit Point and Exit Program Information—ILE C Example
"EXAMPLEPGMEXAMPLELIB","EXAMPLE EXIT PROGRAM DATA", 25, &attrib_keys, &error_code); /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ /\ If an exception occurs, the API returns the exception in the \/ /\ error code parameter. The bytes available field is se...
Page 109 - Remove Exit Program and Deregister Exit Point—ILE C Example
} /\ End program \/ Remove Exit Program and Deregister Exit Point—ILE C Example The following program removes an exit program from an exit point and deregistersthe exit point from the registration facility. /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\ PROGRAM: Remove an E...
Page 113 - Chapter 5. List APIs; Characteristics of a List API; User Area
Chapter 5. List APIs This chapter contains an overview of list APIs, which are those APIs that return alist unique to a given API. The chapter discusses the characteristics of a list APIand provides information that you should be aware of when you use list APIs. The List Objects That Adopt Owner Aut...
Page 114 - Offset to Header Section; Offset to List Data Section
Header ┌────────────────────────────────────┐ ┌─────────────────────────┐ +ðð│ │ │ │ │ 64─Byte User Area │ │ │ │ │ │ │ ├────────────────────────────────────┤ ┌───5│ Input Parameter Section │ +4ð│ Size of Generic Header │ │ │ │ ├────────────────────────────────────┤ │ ' ' │ │ │ ' ' │ Generic Header │...
Page 115 - Other Fields of Generic Header
of each entry field is ð , the entries have different lengths and the format tells the length of each entry. The list data sections for the QSYLOBJP API are shown in the “OBJP0100 Format”on page 5-14 and the “OBJP0200 Format” on page 5-14. This API has two pos-sible formats. For more information abo...
Page 116 - Processing a List; List Object API—OPM RPG Example
Processing a List This is the preferred method for processing lists. To correctly process through alist, do the following: 1. Use the offset to list data section field (see .5/ on page 5-9) 2. Look at the number of list entries field in the list (see .6/ on page 5-10) 3. Add the size of each entry f...
Page 124 - List Objects That Adopt Owner Authority API—Example
O 'Text: ' O QSYB6J O\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\O\ Function: ENDLST O\O\ Description: This function prints the end of listing print O\ line and returns to the caller. O\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\OQSYSPRT E 1ð6 ENDLST O '\\\ ...
Page 126 - User Space Variables; Input Parameter Section
User Space Variables The following tables describe the order and format of the data returned in the userspace. For detailed descriptions of the fields in the tables, see “Field Descriptions”on page 5-15. Input Parameter Section Offset Type Field Dec Hex 0 0 CHAR(10) User space name specified 10 0A C...
Page 130 - Pointers
The Dynamic Screen Manager (DSM) supports returned values in addition tothe error code parameter. The errnos are provided as include files in the QSYSINC library. Pointers Due to the greater availability of pointer support in ILE languages, there is a muchgreater use of pointers in ILE APIs. The u...
Page 135 - Reporting Software Error (ILE API with Pointers)—ILE C Example
num_objs, &ErrorCode, ile_mod_name); } /\ UNEXPECTED_HDLR \/ Reporting Software Error (ILE API with Pointers)—ILE C Example This program calls the Report Software Error (QpdReportSoftwareError) API toperform FFDC, and uses pointers. The ILE program sets a pointer (shown at .2/ on page 6-10) to p...
Page 141 - Machine Interface Instructions—Introduction
Chapter 7. Machine Interface Programming This chapter is for programmers interested in creating machine interface (MI) pro-grams. While some MI instructions are discussed within the context of how todevelop MI programs, this chapter makes no attempt to review the full range of MIinstructions. The go...
Page 143 - Starting the Instruction Stream
To associate these three space pointers with the parameters being passed to theprogram, the following operand list (OL) is declared: DCL OL PARM_LIST /\ Name of OL is PARM_LIST \/ (ARG1@, /\ The first parameter \/ ARG2@, /\ The second parameter \/ RESULT@) /\ The third parameter \/ PARM EXT; /\ Exte...
Page 144 - MI01 Program—Complete Code Example; Compiling a Program
ITS2: CPYNV RESULT,ARG2; The program has now finished processing and ends: RETURN: RTX \; PEND; The previous return external (RTX) instruction is not needed because it is impliedby the PEND directive. The RTX instruction is included to add clarity to theprogram flow. MI01 Program—Complete Code Examp...
Page 145 - Using CLCRTPG to Create an MI Program
Using CLCRTPG to Create an MI Program Assume that the source is in a member named MI01 in the source file MISRC,which is created with a default record length (RCDLEN) of 92. The followingCLCRTPG CL program can be used to create an MI program called MI01. (An MIprogram to call the Create Program (QPR...
Page 146 - Creating the MI Example Program
MONMSG MSGID(CPFð864) EXEC(GOTO CMDLBL(CRTPGM)) CHGVAR VAR(%SST(&MIPGMSRC &OFFSET 8ð)) VALUE(&SRCDTA) CHGVAR VAR(&OFFSET) VALUE(&OFFSET + 8ð) GOTO CMDLBL(LOOP) CRTPGM: CHGVAR VAR(%SST(&PGMNAM 1 1ð)) VALUE(&SRCMBR) CHGVAR VAR(%BIN(&MIPGMSRCSZ)) VALUE(&OFFSET) CALL ...
Page 147 - Debugging the MI Program
RTVJOBA USER(&USR) CALL PGM(MIð1) PARM(&ARG1 &ARG2 &RESULT) CHGVAR VAR(&MSG) VALUE(&RESULT) SNDMSG MSG(&MSG) TOUSR(&USR) ENDPGM The following statement calls the CL01 program: CALL CLð1 (-5 6) This test should cause a message to be sent to your user message queue with...
Page 149 - Handling Exceptions in the MI Program
DCL DD RESULT PKD(15,5) BAS(RESULT@); BRK "ðððð1"; CMPNV(B) ARG1,ARG2 / LO(ITS2); CPYNV RESULT,ARG1; B RETURN; ITS2: CPYNV RESULT,ARG2; BRK "ðððð2";RETURN: RTX \; PEND; This allows the HLL programmer to use the following to debug the HLL program byusing the statement identifiers of t...
Page 151 - Creating an MI Version of CLCRTPG
DCL DD RC CHAR(1) BAS(RC@); DCL EXCM DATAERROR EXCID(H'ðCð2') BP (M12ð2) IMD; CMPNV(B) ARG1,ARG2 / LO(ITS2); CPYNV RESULT,ARG1; B RETURN; ITS2: CPYNV RESULT,ARG2; RETURN: CPYBLA RC,'ð'; RTX \; M12ð2: CPYBLA RC,'1'; RTX \; PEND; The following example updates CL01 to support the new return code parame...
Page 153 - Source for the CL03 Program; Source for the CL04 Program
Source for the CL03 Program The source for CL03 follows: /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\ \/ /\ Program Name: CLð3 \/ /\ \/ /\ Programming Language: CL \/ /\ \/ /\ Description: Main driver p...
Page 154 - Source for the CL05 Program
/\ \/ /\ Description: Load a source physical file member into the \/ /\ \USRSPC named &MBR. \/ /\ \/ /\ \/ /\ Header Files Included: None \/ /\ \/ /\ \/ /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ PGM PARM(&MBR &BINOFFSET) DCLF FILE(MISRC) DCL VAR(&MBR) TYP...
Page 155 - Source for the MICRTPG Program
DCL VAR(&PRTFNAM) TYPE(\CHAR) LEN(2ð) + VALUE('QSYSPRT \LIBL ') DCL VAR(&PRTSTRPAG) TYPE(\CHAR) LEN(4) + VALUE(X'ððððððð1') DCL VAR(&PGMPUBAUT) TYPE(\CHAR) LEN(1ð) + VALUE('\ALL ') DCL VAR(&PGMOPTS) TYPE(\CHAR) LEN(22) + VALUE('\LIST \REPLACE ') DCL VAR(&NUMOPTS) TYPE(\CHAR) LEN(...
Page 156 - Understanding the MICRTPG Program (by Sections of Code); Declaring the Structure
Understanding the MICRTPG Program (by Sections of Code) You will recognize some of these statements from the MI01 example, but othersare new. The following statements, which you have seen, for example, in “MI01Program—Complete Code Example,” define the entry point to this program and theparameters b...
Page 158 - Enhanced Version of the MICRTPG Program
Calling the CL05 Program Now the program will call the CL05 program (CALLX CL05) and pass the addressof the *USRSPC as a parameter (along with the member name, program name,and the size of the source stream). When you call CL05 with the operand listCL05OL, CL05 passes the actual space pointer USRSPC...
Page 162 - Beginning the Instruction Stream; Using Static Storage to Your Advantage
Beginning the Instruction Stream Begin the instruction stream definition by doing the following: 1. Use the store parameter list length (STPLLEN) instruction to determine the number of parameters that were passed to the program: STPLLEN NUM_PARMS; 2. If the number of parameters is 1, assign FILNAM t...
Page 163 - MICRTPG2 Complete Program—MI Code Example
1. Fall into a loop (the MORE label) until all source records are loaded as the source physical file member position is overridden: MORE: CALLX QCMDEXC, QCMDOVROL, \; 2. Instruct the CL06 program to load source records from the start of the input buffer, which is actually the BINOFFSET into the spac...
Page 166 - Updated CL06 Program
DCL SPCPTR NUMOPTS@ INIT(NUMOPTS);DCL OL QPRCRTPGOL (USRSPC, BINOFFSET@, PGM@, PGMTXT@, PGMSRCF@, PGMSRCM@, PGMSRCCHG@, PRTFNAM@, PRTSTRPAG@,PGMPUBAUT@, PGMOPTS@, NUMOPTS@) ARG; DCL SYSPTR QPRCRTPG INIT("QPRCRTPG", CTX("QSYS"), TYPE(PGM)); /\ Start of instruction stream \/ STPLLEN NU...
Page 167 - Creating the MICRTPG2 Program; Handling Exceptions in the MICRTPG2 Program
MONMSG MSGID(CPFð864 CPF4137) EXEC(GOTO CMDLBL(DONE)) CHGVAR VAR(%SST(&BUFFER &OFFSET 8ð)) VALUE(&SRCDTA) CHGVAR VAR(&OFFSET) VALUE(&OFFSET + 8ð) IF COND(&OFFSET \GT 16ðð) THEN(GOTO CMDLBL(DONE)) GOTO CMDLBL(LOOP) DONE: ENDPGM Creating the MICRTPG2 Program To create the MICRT...
Page 168 - MICRTPG2 Complete Program (Enhanced)—MI Code Example
DCL PTR INV_PTR2 DEF(RTNTMPLT) POS(1);DCL DD \ CHAR(1) DEF(RTNTMPLT) POS(17) INIT(X'ðð');DCL DD ACTION CHAR(2) DEF(RTNTMPLT) POS(18); DCL SPCPTR RTNTMPLT@ INIT(RTNTMPLT); 4. Retrieve the exception data associated with the MCH1401 exception: RETEXCPD EXCPDBUF@, X'ð1'; 5. Compare the exception data ob...
Page 172 - MI Common Programming Techniques—Examples
B E14ð1; SAME: CPYBWP USRSPC@, EXC_OBJ@;CPYBLA ACTION, X'ð1ðð'; E14ð1: CPYBWP INV_PTR2, INV_PTR; RTNEXCP RTNTMPLT@; PEND; MI Common Programming Techniques—Examples With the completion of the MICRTPG2 program, the following example MI programdemonstrates some additional programming techniques: /\\\\\...
Page 176 - AS/400 Program Storage
CALLX SEPT(4267), QMHSNDMOL, \; /\ resume normal array constraint \/ OVRPGATR 1,4; /\ and move on to the next entry \/ ADDN(S) NUM_DONE, 1; ADDSPP OBJ_ENTRY@, OBJ_ENTRY@, 32; CMPNV(B) NUM_DONE, SIZE / LO(MORE); /\ When all entries are processed, end the program. \/ /\ \/ /\ Note that this program ma...
Page 177 - Backup and Recovery APIs; Client Support APIs
Chapter 8. Use of OS/400 APIs This chapter discusses the various groups of OS/400 APIs and how they may be ofuse to you. Some APIs are discussed as a group, similar to the parts in theSystem API Reference, while others are discussed individually. The API discussions in this chapter are presented in ...
Page 178 - Communications APIs
With the exception of the Get Client Handle API, which is available only through theIntegrated Language Environment (ILE), the client software management and con-figuration APIs are available as both the original program model (OPM) and ILEAPIs. Add Client (QZCAADDC, QzcaAddClient) API To manage a...
Page 179 - OptiConnect APIs; Configuration APIs
using these APIs range from dedicated point-to-point file transfer to local-area-network client/server applications. OptiConnect APIs The OptiConnect APIs are used to move user data between two or more AS/400systems that are connected by the OptiConnect fiber-optic bus. The OptiConnectAPIs require t...
Page 180 - Dynamic Screen Manager APIs
Original program model (OPM) APIs – Retrieve Program Variable API You can use these sets of source debugger APIs independently of each other ortogether as needed. The source debugger APIs can be used to write debuggersfor the AS/400 system. The users of these APIs include: The source debugger th...
Page 181 - Edit Function APIs
Session services The session services APIs provide a general scrolling interface that can beused to create, query, and manipulate sessions, and to perform input andoutput operations to sessions. Edit Function APIs The edit function APIs are used to create and use edit masks. An edit mask is abyte ...
Page 182 - Application Development Manager APIs
The Retrieve File Override Information (QDMRTVFO) API retrieves the name of thefile that will be referenced after file overrides have been applied to the file specified.A user program can retrieve the actual name of the file that will be used when thespecified file is referenced. SQL-related APIs pr...
Page 183 - COBOL APIs; Integrated Language Environment (ILE) CEE APIs; Naming Conventions of the ILE CEE APIs
Development Manager feature does not need to be installed on your system for youto use these APIs. The Application Development Manager APIs are: Get Space Status Read Build Information Set Space Status Write Build Information The Get and Set Status APIs are used to query and initialize the b...
Page 184 - Journal and Commit APIs; Journal APIs; Message Handling APIs
Journal and Commit APIs This section includes the journal and commitment control APIs. Journal APIs The journal APIs allow you to: Obtain information about some of the journal’s attributes or the journalreceiver’s attributes Obtain journal information based on the journal identifier Send an en...
Page 185 - National Language Support APIs; Network Management APIs
National Language Support APIs These APIs provide the capability to retrieve cultural values, to convert sortsequence to different CCSIDs, to convert and truncate character strings, and towork with data that uses CCSIDs. National Language Support APIs This set of APIs gives you the capability to wor...
Page 186 - Alert APIs
The APPN local topology for an APPN node consists of the following: The local node Adjacent nodes (network nodes, end nodes, or virtual nodes to which the localnode has a direct connection) Transmission groups from the local node to adjacent nodes Both end nodes and network nodes can report lo...
Page 187 - Node List API; Registered Filter APIs; Change Request Management APIs; Object APIs
fied as yes.) The retrieve API allows your application, in conjunction with alert fil-tering, to perform user-defined actions based on the contents of the alert. Node List API A node list is either or both of the following: A list of SNA nodes (network ID and control point name) Internet protoco...
Page 188 - Data Queue APIs
Data Queue APIs Data queues are a type of system object that you can create, to which one high-level language (HLL) program can send data, and from which another HLL programcan receive data. The receiving program can be waiting for the data, or canreceive the data later. The advantages of using data...
Page 191 - Office APIs; AnyMail/400 Mail Server Framework APIs
list of objects with only a certain status, which you cannot do with theDSPOBJD command. Rename Object (QLIRNMO) API This API combines the functions of the Rename Object (RNMOBJ) and theMove Object (MOVOBJ) commands. The API allows you to rename and movein one step, and replace the existing target...
Page 193 - Print APIs
This exit program passes control to the application enabler where a registeredalternate administration program will be called. Operational Assistant APIs Most functions on the AS/400 Operational Assistant menu can be accessed individ-ually by calling APIs found in the QSYS library. The Operational A...
Page 194 - Spooled File APIs; Problem Management APIs; Filtering
Twinaxial ASCII printing LAN ASCII printing TCP/IP printing through the Send TCP/IP Spooled File command (known asLPR or line printer requester in UNIX TCP/IP) The API provides a programming interface to the same transform. The QWPZHPTR API goes along with another function, the Print Driver ex...
Page 195 - Program and CL Command APIs
Working with a Problem Problem analysis is the process of finding the cause of a problem and identifyingwhy the system is not working. Often this process identifies equipment or datacommunications functions as the source of the problem. The Work with Problem(QPDWRKPB) API allows you to perform probl...
Page 196 - Security APIs; Network Security APIs; Software Product APIs
The registration facility APIs provide the capability to: Register and deregister exit points with the registration facility Add and remove exit programs to and from the repository Retrieve exit point and exit program information from the repository Designate the order in which exit programs...
Page 197 - Environment Variable APIs
The CD-ROM premastering APIs could be used if you currently produce distributedsystems license option (DSLO) distribution tapes at a central site. If you would nowlike to distribute on CD-ROM rather than tape, you would use the CD-ROM pre-mastering APIs. You would use the Handle CD-ROM Premastering ...
Page 198 - Integrated File System APIs; Interprocess Communication APIs
strings, is NULL (not initialized) until environment variables are associated withthe job. On a UNIX system, the exec() function creates a new process and extends theenvironment variables of the original process to the new process. Although theAS/400 has no exec() function, environment variables a...
Page 199 - Signal APIs
sends one, or that a message exist on the queue before a process requests toreceive one. A semaphore is a synchronization mechanism similar to a mutex or a machineinterface (MI) lock. It can be used to control access to shared resources, or usedto notify other processes of the availability of resour...
Page 201 - Simple Network Management Protocol (SNMP) APIs
The signal options specify an additional set of attributes for the signal monitor.The primary use of these options is to specify an additional set of actions to betaken by the system when a signal-catching function is called. A signal is generated by sending a request to a signal monitor. The proces...
Page 202 - Sockets APIs
delivers this information or times out. The communications mechanism betweenthe manager APIs and agents uses the User Datagram Protocol (UDP). Therefore,both systems need to support UDP. Sockets APIs Sockets provides an API for applications that require program-to-program commu-nications. This inter...
Page 203 - Process-Related APIs; User Interface APIs; UIM Advantages
Process-Related APIs The process-related APIs perform process-related or other general operations.Using these APIs, a process can get the process ID of itself, its parent process, orthe process group. A process can also check the status for itself, its child pro-cesses, or the process group. For inf...
Page 204 - DDS Advantages; Virtual Terminal APIs
DDS Advantages The advantages of using DDS over UIM follow: Provides more flexibility in screen design The user defines in what row and column a field should appear. Provides initial formatting with Screen Design Aid (SDA) Has the ability to use UIM help or help in folders Has the ability to...
Page 205 - Miscellaneous APIs
tion key is treated as any other key. If attention key buffering is not on, pressingthe Attention key results in sending the information to the system even when otherwork station input is inhibited. Miscellaneous APIs The miscellaneous part of the System API Reference includes the following miscel- ...
Page 207 - Chapter 9. Common API Programming Errors
Chapter 9. Common API Programming Errors This chapter contains information identified as common programming errorsencountered when using APIs within application programs. The chapter designprovides two program examples for each common error. The first programexample is incorrectly coded and is follo...
Page 209 - Using the Error Code Parameter—Example of Correct Coding
\ calling an API, the bytes provided field should be the first field \ you examine as part of problem determination.C Z-ADD16 QUSBNB .1/ \ \ CREATE THE SPACE TO HOLD THE DATAC CALL 'QUSCRTUS' C PARM SPCNAM C PARM 'EXT_ATTR'EXTATR 1ð C PARM SIZ C PARM INTVAL C PARM '\ALL 'PUBAUT 1ð C PARM 'NO TEXT 'T...
Page 213 - Defining A Data Structure—Example of Correct Coding
C PARM RECVR C PARM QUSBN \ \ DISPLAY THE JOB NAMEC DSPLY JNAME >>> When displayed,JNAME \ will look something like \ 'QCPF QS' \ DELETE THE SPACE THAT HELD THE DATAC CALL 'QUSDLTUS' C PARM SPCNAM C PARM QUSBN \\C SETON LR Defining A Data Structure—Example of Correct Coding The following pr...
Page 218 - Defining Receiver Variables—Example of Correct Coding
\ DELETE THE SPACE THAT HELD THE DATAC CALL 'QUSDLTUS' C PARM SPCNAM C PARM QUSBN \C SETON LR Defining Receiver Variables—Example of Correct Coding The following example program defines a larger receiver variable: 60 bytes. Thisis shown at position .9/ on page 9-13. This increase in the receiver var...
Page 222 - Defining List Entry Format Lengths—Example of Correct Coding
\ DISPLAY THE INFORMATION RETURNEDC MOVELQUSDD RECVR 52 C DSPLY RECVR C ADD 52 START .1ð/ C ADD 1 X C END \ \ DELETE THE SPACE THAT HELD THE DATAC CALL 'QUSDLTUS' C PARM SPCNAM C PARM QUSBN \C SETON LR Defining List Entry Format Lengths—Example of Correct Coding The following program correctly uses ...
Page 225 - Using Null Pointers with OPM APIs—Example of Correct Coding
/\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\ initialize program data elements \/ /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ char initial_value = ðxðð;char text_description[5ð] = "test of QDBLDBR API "; char qualified_usrspc_name[2ð] = "GETLDBR QTEMP ...
Page 231 - Defining Byte Alignment—Example of Correct Coding
if (error_code.ec_fields.Bytes_Available != ð) { printf("ATTEMPT TO ADD AN EXIT PROGRAM FAILED WITH EXCEPTION:%.7s", error_code.ec_fields.Exception_Id); exit(1); } } /\ end program \/ Defining Byte Alignment—Example of Correct Coding The following example program shows a CHAR(3) bytes reserv...
Page 233 - Using Offsets in a User Space; Using Offsets in a User Space—Example of Incorrect Coding
Using Offsets in a User Space An offset indicates where in a structure that specific information should start. Whenoffsets are correctly used, programs can extract specific pieces of data from astructure and perform actions on that data. Incorrectly working with offsets can produce errors by API use...
Page 237 - Using Offsets in a User Space—Example of Correct Coding
C ENDIF C\C\ Delete the user space called APIUG1 in library QGPL.C\C CALL 'QUSDLTUS' C PARM USERSP C PARM QUSBN C\ See if any errors were returned in the error code parameter.C EXSR ERRCOD C\C SETON LR C RETRN C\C\ End of MAINLINEC\C\ Subroutine to handle errors returned in the error codeC\ paramete...
Page 249 - Coding for New Function—Example of Correct Coding
C\C\ Get a resolved pointer to the user space for performanceC\C CALL 'QUSPTRUS' C PARM SPC_NAME C PARM SPCPTR C PARM QUSEC C\C\ Check for errors on QUSPTRUSC\C QUSBAVL IFGT ð C MOVEL 'QUSPTRUS' APINAM 1ð C EXSR APIERR C END C ENDSR C\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\C...
Page 257 - Appendix A. Performing Tasks Using APIs—Examples; Packaging Your Own Software Products
Appendix A. Performing Tasks Using APIs—Examples This appendix contains the following examples of using multiple APIs to performtasks: Packaging your own software products Retrieving a file description to a user space Using data queues versus user queues Packaging Your Own Software Products Yo...
Page 259 - Program for Packaging a Product—OPM RPG Example
CRTDSPF ABC/ABCDSPF ABCDEV/QDDSSRC + TEXT('Display File for ABC Product') CRTPF ABC/ABCPF ABCDEV/QDDSSRC + TEXT('Physical File for ABC Product') CRTMSGF ABC/ABCMSG TEXT('Message File')ADDMSGD ABCððð1 ABC/ABCMSG MSG('ABC Product')CRTCMD ABC/ABC ABC/ABCPGM ABCDEV/QCMDSRC + TEXT('Command for ABC Produc...
Page 267 - Retrieving a File Description to a User Space—ILE C Example
ABCPF \FILE ðððð2924ðABCABCV3R1Mð ABCMSG \MSGF ðððð2924ðABCABCV3R1Mð ABC \CMD ðððð2924ðABCABCV3R1Mð ABCPNLGRP \PNLGRP ðððð2924ðABCABCV3R1Mð ABCðð5ð \PRDDFN ðððð5ðð1ðABCABCV3R1Mð ABCðð5ð \PRDLOD ðððð5ðð1ðABCABCV3R1Mð ABCðð29 \PRDLOD ðððð2924ðABCABCV3R1Mð ABC \LIB ðððð5ðð1ðABCABCV3R1Mð Before you can ...
Page 271 - Using Data Queues versus User Queues
Using Data Queues versus User Queues Data queues and user queues both provide a means for one or more processes tocommunicate asynchronously. The queues can be processed FIFO (first-infirst-out), LIFO (last-in first-out), or by key. If user queues and data queues supplythe same function, which one s...
Page 272 - Data Queue—ILE C Example
– You do not need the additional performance of MI instructions for directly manipulating entries. – You need to create queues into a library that is not listed in the QALWUSRDMN system value. Data Queue—ILE C Example The following program illustrates how to use APIs to create and manipulate a dataq...
Page 273 - User Queue—ILE C Example
system("CRTLIB LIB(QUEUELIB)"); /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ /\ Create a data queue called EXAMPLEQ in library QUEUELIB. The \/ /\ queue will have a maximum entry length set at 1ð, and will be \/ /\ FIFO (first-in first-out). \/ /\\\\\\\\\\\\\\\\\\\\\...
Page 279 - Appendix B. Original Examples in Additional Languages
Appendix B. Original Examples in Additional Languages This appendix contains examples from the following areas of this book. The program examples in thisappendix are rewritten from the original examples into other programming languages. Chapter 3, “Common Information across APIs—Basic (OPM) Exampl...
Page 280 - Original Program Model (OPM) APIs—Examples
Figure B-4 (Page 2 of 2). Pointer API Examples from Chapter 6 Task Programming Language and Location of Example ILE C OPM COBOL ILE COBOL OPM RPG ILE RPG Reporting Software Error (ILE API withPointers) 6-7 N/A B-122 N/A B-126 Figure B-5. Performing Tasks Using API Examples from Appendix A Task Progr...
Page 286 - Handling Error Conditions—ILE RPG Example
Handling Error Conditions—ILE RPG Example Refer to “Handling Error Conditions—OPM RPG Example” on page 3-8 for the ori-ginal example. This example can be written only in OPM RPG and ILE RPG. D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ D\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 288 - Retrieving the Hold Parameter (Error Code Structure)—ILE C Example
Retrieving the Hold Parameter (Error Code Structure)—ILE C Example Refer to “Retrieving the Hold Parameter (Error Code Structure)—OPM RPGExample” on page 3-11 for the original example. /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 294 - Accessing the HOLD Attribute—ILE C Example
C\C EVAL \INLR = '1' C RETURN C\C\ End of MAINLINE C\C\ Subroutine to handle errors received on the CALL C\ C ERROR BEGSR C\C\ Process errors returned from the API C\ C MOVEL QUSEI MSG_ID C CALL 'QCMDEXC' C PARM CMD_STR2 C PARM LENSTR2 C ENDSR Accessing the HOLD Attribute—ILE C Example Refer to “Acc...
Page 296 - Accessing the HOLD Attribute—ILE COBOL Example
39ð, /\ Receiver Length \/ "JOBDð1ðð", /\ Format Name \/ qual_job_desc, /\ Qualified Job Description \/ &error_code); /\ Error Code \/ /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ /\ If an error was returned, print the error message to the QPRINT \/ /\ spool fi...
Page 299 - Accessing the HOLD Attribute—ILE RPG Example
WRITE LIST-LINE FROM MESSAGE-TEXT. STOP RUN. Accessing the HOLD Attribute—ILE RPG Example Refer to “Accessing the HOLD Attribute—OPM RPG Example” on page 3-17 forthe original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 300 - Accessing a Field Value (Initial Library List)—ILE C Example
C\ C CALL QWDRJOBD C PARM QWDDð1ðð C PARM RCVLEN C PARM FORMAT C PARM LFNAM C PARM QUSEC C\C\ If no bytes available, API was successful; print HOLD value C\C IF QUSBAVL = ð C EXCEPT GOOD C ELSE C\C\ If some bytes available, API failed; print Error message ID C\C IF QUSBAVL > ð C EXCEPT BAD C END ...
Page 303 - Accessing a Field Value (Initial Library List)—ILE COBOL Example
rec_ptr += 11;if((offset + 1ð) >= rec_len) break; offset += 11; } } } /\ main \/ Accessing a Field Value (Initial Library List)—ILE COBOL Example Refer to “Accessing a Field Value (Initial Library List)—OPM RPG Example” onpage 3-19 for the original example. The following program also works for OP...
Page 307 - Accessing a Field Value (Initial Library List)—ILE RPG Example
\ STOP RUN. \\ End of Mainline \ \\ Subroutine to handle errors returned in the error code \ parameter. \ ERRCOD. \ IF BYTES-AVAILABLE OF QUS-EC > ð \\ Process errors returned from the API. \ STOP RUN. \\ Subroutine to check to see if there is enough room in the\ receiver variable for the next li...
Page 311 - Using Keys with List Spooled Files API—ILE C Example
C IF QUSBAVL > ð C\C\ If there was an error, exit to ERROR subroutine C\ C EXSR ERROR C ELSE C\C\ Else, add 1 to the Initial library list offset because RPGC\ is a Base 1 language C\ C QWDOILL ADD 1 X 5 ð C DO QWDNLILL C EVAL LIBRARY = %SUBST(QWDDð1ðð:X:1ð) C\C\ Let's tell everyone what the libra...
Page 316 - Using Keys with List Spooled Files API—ILE COBOL Example
Using Keys with List Spooled Files API—ILE COBOL Example Refer to “Using Keys with List Spooled Files API—Example” on page 3-24 for theoriginal example. The following program also works for OPM COBOL. IDENTIFICATION DIVISION. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\...
Page 320 - Using Keys with List Spooled Files API—ILE RPG Example
\ extract age of spooled file for report \ IF KEY-FIELD-FOR-FIELD-RETD OF QUS-LSPL-KEY-INFO = 216 .24/.25/ MOVE SPACES TO OPNDAT,MOVE DATA-FIELD OF QUS-LSPL-KEY-INFO( 1:DATA-LENGTH OF QUS-LSPL-KEY-INFO) TO OPNDAT. \\ address next variable length entry \ SET ADDRESS OF STRING-SPACE TO ADDRESS OF QUS-...
Page 328 - Register Exit Point and Add Exit Program—ILE COBOL Example
MOVE 1 TO LENGTH-DATA OF QUS-VLEN-REC-4.MOVE 1 TO VAR-RECORDS((VAR-OFFSET + 12):1). PERFORM CALCULATE-NEXT-OFFSET.MOVE 3 TO CONTROL-KEY OF QUS-VLEN-REC-4.MOVE 4 TO LENGTH-DATA OF QUS-VLEN-REC-4.MOVE 37 TO BINARY-NUMBER.MOVE BINARY-CHAR TO VAR-RECORDS((VAR-OFFSET + 12):4). PERFORM CALCULATE-NEXT-OFFS...
Page 332 - Register Exit Point and Add Exit Program—OPM RPG Example
BY CONTENT LENGTH OF EXIT-PGM-DATA OF MISC, VARREC, QUS-EC. \\ If an exception occurs, the API returns the exception in the\ error code parameter. The bytes available field is set to \ zero if no exception occurs and greater than zero if an\ exception does occur. \ IF BYTES-AVAILABLE OF QUS-EC > ...
Page 336 - Register Exit Point and Add Exit Program—ILE RPG Example
O\OQPRINT E 1ð6 ERREPT O 'Attempt to register exit' O ' point failed: ' O QUSBND OQPRINT E 1ð6 ERRPGM O 'Attempt to add an exit' O ' program failed: ' O QUSBND Register Exit Point and Add Exit Program—ILE RPG Example Refer to “Register Exit Point and Add Exit Program—ILE C Example” on page 4-9for th...
Page 349 - Retrieve Exit Point and Exit Program Information—OPM RPG Example
TO EXCEPTION-ID OF BAD-EXIT-PGM, WRITE LIST-LINE FROM BAD-EXIT-PGM, STOP RUN. \\ If the call to retrieve exit program information is successful,\ check to see if there are any exit programs to call. \\ The receiver variable offers enough room for a minimum of one\ exit program entry because the rece...
Page 353 - Retrieve Exit Point and Exit Program Information—ILE RPG Example
C ENDSR C\C\ Return to programs caller C DONE BEGSR C SETON LR C RETRN C ENDSR O\OQPRINT E 1ð6 ERREPT O 'Attempt to retrieve infor' O 'mation failed: ' O QUSBND OQPRINT E 1ð6 ERRPGM O 'Attempt to retrieve Exit' O ' Programs failed: ' O QUSBND Retrieve Exit Point and Exit Program Information—ILE RPG ...
Page 365 - Remove Exit Program and Deregister Exit Point—ILE COBOL Example
MOVE 16 TO BYTES-PROVIDED OF QUS-EC. \\ Call the API to remove the exit program. \ CALL "QUSRMVEP" USING EXIT-POINT-NAME, FORMAT-NAME, PGM-NBR, QUS-EC. \\ If an exception occurs, the API returns the exception in the\ error code parameter. The bytes available field is set to \ zero if no exce...
Page 368 - Remove Exit Program and Deregister Exit Point—OPM RPG Example
Remove Exit Program and Deregister Exit Point—OPM RPG Example Refer to “Remove Exit Program and Deregister Exit Point—ILE C Example” onpage 4-19 for the original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 370 - Remove Exit Program and Deregister Exit Point—ILE RPG Example
Remove Exit Program and Deregister Exit Point—ILE RPG Example Refer to “Remove Exit Program and Deregister Exit Point—ILE C Example” onpage 4-19 for the original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 379 - List Object API—ILE COBOL Example
if (((argc - 1) < 2) || ((argc - 1 > 2))) /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ /\ We did not receive all of the required parameters so exit the \/ /\ program. \/ /\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/ { exit(1); } else /\\\\\\\\...
Page 384 - List Object API—ILE RPG Example
\ MOVE SPACES TO CONTIN-HDL. PERFORM GETLST. \\ Get a resolved pointer to the User Space for performance \ CALL "QUSPTRUS" USING SPC-NAME, SPCPTR, QUS-EC. \\ Check for errors on QUSPTRUS \ IF BYTES-AVAILABLE OF QUS-EC > ð MOVE "QUSPTRUS" TO APINAM, PERFORM APIERR. \\ If no error, ...
Page 390 - OPM API without Pointers—Examples; CBLERR1 Program
C\ C APINAM DSPLY C QUSEI DSPLY C EXSR DONE C ENDSR C\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ C DONE BEGSR C\C\ Exit the program C\ C EXCEPT END_LIST C EVAL \INLR = '1' C RETURN C ENDSR OQPRINT E OBJ_ENTRY 1 O 'Object: ' O QSYNAMEð6 O ' Library: ' O QSYBRARYð6 O ' Type: ' O ...
Page 392 - ERRHDL1 Program
PRIOR-ERROR-HANDLER OF MISC, QUS-EC. \\ If an exception occurs, the API returns the exception in the\ error code parameter. The bytes available field is set to \ zero if no exception occurs and greater than zero if an\ exception does occur. \ IF BYTES-AVAILABLE OF QUS-EC > ð DISPLAY "Error se...
Page 397 - Logging Software Error (OPM API without Pointers)—ILE RPG Example
C Z-ADD5 DTALEN C Z-ADD1 DATA# C\C\ For illustration purposes also dump the program object asC\ part of logging the software error C\ C MOVELPGMNAM OBJ1N .1/ C MOVELLIBNAM OBJ1L C MOVEL'\PGM' OBJ1T C Z-ADD1 OBJS# C\C\ Call the Log Software Error API C\ C CALL 'QPDLOGER' C PARM PGMNAM C PARM EXCPID M...
Page 400 - CBLERR2 Program
ILE API with Pointers—Examples This section includes the examples in “Reporting Software Error (ILE API withPointers)—ILE C Example” on page 6-7. Reporting Software Error (ILE API with Pointers)—ILE COBOL Example Refer to “Reporting Software Error (ILE API with Pointers)—ILE C Example” onpage 6-7 fo...
Page 402 - ERRHDL2 Program
\ ERRHDL2 Program PROCESS NOMONOPRC. IDENTIFICATION DIVISION. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\ Program: Log a software error \ \ Language: ILE COBOL \\ Description: This program receives control for exc...
Page 404 - Reporting Software Error (ILE API with Pointers)—ILE RPG Example
\\ For illustration purposes, dump the program object \ MOVE 3ð2 TO KEY-FIELD OF QPD-NAMED-SYSTEM-OBJECT.MOVE PGM-NAME OF PGM-IN-ERROR TO OBJECT-NAME OF QPD-NAMED-SYSTEM-OBJECT. MOVE LIB-NAME OF PGM-IN-ERROR TO OBJECT-LIBRARY OF QPD-NAMED-SYSTEM-OBJECT. MOVE "\PGM" TO OBJECT-TYPE OF QPD-NAME...
Page 414 - Program for Packaging a Product—ILE COBOL Example
Program for Packaging a Product—ILE COBOL Example Refer to “Program for Packaging a Product—OPM RPG Example” on page A-3 forthe original example. The following program also works for OPM COBOL. IDENTIFICATION DIVISION. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\...
Page 422 - Program for Packaging a Product—ILE RPG Example
Program for Packaging a Product—ILE RPG Example Refer to “Program for Packaging a Product—OPM RPG Example” on page A-3 forthe original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\F\Program Name: SFTW...
Page 433 - Retrieving a File Description to a User Space—ILE RPG Example
DISPLAY EXCEPTION-ID OF QUS-EC. PERFORM PROGRAM-DONE. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ PROGRAM-DONE. \\ Exit the program \ STOP RUN. Retrieving a File Description to a User Space—ILE RPG Example Refer to “Retrieving a File Description to a User Space—ILE C Example” o...
Page 447 - Data Queue—OPM RPG Example
\ Print the error and the API that received the error \ MOVE EXCEPTION-ID OF QUS-EC TO EXCEPTION-ID OF BAD-NEWS.WRITE LIST-LINE FROM BAD-NEWS. Data Queue—OPM RPG Example Refer to “Data Queue—ILE C Example” on page A-16 for the original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 450 - Data Queue—ILE RPG Example
C\ C EXCPTBADNEW C\ C ENDSR OQPRINT E 1ð6 BADNEW O 'Failed in API ' O APINAM O 'with error ' O QUSBND Data Queue—ILE RPG Example Refer to “Data Queue—ILE C Example” on page A-16 for the original example. F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ F\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\...
Page 453 - UNIX-Type APIs—Examples; Using the Integrated File System—ILE C Example
C\C\ Print the error and the API that received the error C\ C EXCEPT BAD_NEWS C\ C ENDSR OQPRINT E BAD_NEWS 1 O 'Failed in API ' O API_NAME O 'with error ' O QUSEI UNIX-Type APIs—Examples The simple example program on the following pages illustrates the use of severalintegrated file system functions...
Page 456 - Using the Integrated File System—ILE COBOL Example
perror("open Error"); CleanUpOnError(5); return ð; } printf("Opened %s for reading.\n",TEST_FILE); .7/ /\ Read from the TEST_FILE file, via FilDes, into Buffer. \/ BytesRead = read(FilDes,Buffer,sizeof(Buffer));if ( -1 == BytesRead ) { perror("read Error"); CleanUpOnError(6);...
Page 461 - Using the Integrated File System—ILE RPG Example
\ return errno; \ } \\ To activate this C module remove the comment identifiers\ following the WRITE statement and remove the comment\ identifier from the geterrno declaration in the Configuration\ Section. Definitions for the returned errno are found in \ file QSYSINC/SYS member ERRNO. \ ERROR-FOUN...
Page 467 - Bibliography; General-Purpose Books
Bibliography Bibliography This bibliography lists printed information that you needto use the OS/400 APIs, background information for thefunctions the APIs perform, and other information rele-vant to specific types of applications. The books aregrouped in these categories: General-purpose books ...
Page 468 - Programming Language Books
Bibliography print descriptors used by the PrintManager inter-face. REXX/400 Programmer’s Guide, SC41-5728,explains REXX/400 programming concepts and dis-cusses considerations in using this language on theAS/400 system. It also describes REXX APIs andprovides examples that you can use to learnREXX...
Page 471 - Index
Index Index Special Characters *EXT (external) format type example A-14 *INT (internal) format type example A-14 Numerics 5250 pass-through session 8-29 A accessing field value (initial library list) ILE C example B-22 ILE COBOL example B-25 ILE RPG example B-29 OPM COBOL example B-25 field value in...
Page 501 - Reader Comments—We'd Like to Hear from You!
Reader Comments—We'd Like to Hear from You! AS/400 Advanced SeriesSystem API ProgrammingVersion 4 Publication No. SC41-5800-00 Overall, how would you rate this manual? Very Satisfied Satisfied Dissatis- fied Very Dissatis- fied Overall satisfaction How satisfied are you that the information in this ...
Page 502 - BUSINESS REPLY MAIL
Cut or FoldAlong Line Cut or FoldAlong Line Reader Comments—We'd Like to Hear from You!SC41-5800-00 IBM Fold and Tape Please do not staple Fold and Tape NO POSTAGENECESSARYIF MAILED IN THEUNITED STATES BUSINESS REPLY MAIL FIRST-CLASS MAIL PERMIT NO. 40 ARMONK, NEW YORK POSTAGE WILL BE PAID BY ADDR...