Defining List Entry Format Lengths
The example programs in this topic show how to code flexibility into your program
as it works its way through the formats used by an API.
Defining List Entry Format Lengths—Example of Incorrect Coding
A common error, or trap, when working with list entry format lengths is to hard code
the format length into your program. The format length is used by the program to
advance to the next list entry in the user space. From release to release, the
length of the format may change. Therefore, when the format length changes, your
program can be susceptible to being pointed to an incorrect position in the user
space and nonsense data placed in the receiver variable.
The program has the length of the list entry format hard coded. This is shown at
1 on page 9-16. If your program runs on a Version 2 Release 2 system, that
value would work. However, with Version 2 Release 3, the format size increased
from 52 to 56 bytes. The correct coding is shown at 11 on page 9-17.
ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
ᑍ
ᑍProgram Name: PGM1
ᑍ
ᑍProgram Language: RPG
ᑍ
ᑍDescription: This sample program illustrates the incorrect
ᑍ way of using list entry length formats.
ᑍ
ᑍHeader Files Included: QUSEC - Error Code Parameter
ᑍ QUSLJOB - List Job API
ᑍ QUSGEN - User Space Format for Generic Header
ᑍ
ᑍAPIs Used: QUSCRTUS - Create User Space
ᑍ QUSLJOB - List Job
ᑍ QUSRTVUS - Retrieve User Space
ᑍ QUSDLTUS - Delete User Space
ᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍᑍ
ᑍ
ᑍ THIS PROGRAM WILL CREATE THE NECESSARY SPACE AND THEN CALL
ᑍ THE QUSLJOB API TO GET A LIST OF ALL ACTIVE JOBS ON THE SYSTEM.
ᑍ THE FIRST JOB NAME/USER WILL BE DISPLAYED TO THE USER.
I/COPY QSYSINC/QRPGSRC,QUSGEN
I/COPY QSYSINC/QRPGSRC,QUSLJOB
ᑍ
ᑍ BRING IN THE ERROR STRUCTURE FROM QSYSINC
I/COPY QSYSINC/QRPGSRC,QUSEC
ᑍ
ᑍᑍ JOB NAME STRUCTURE FOR CALLING QUSLJOB
IJOBNAM DS
I I 'ᑍALL ' 1 1 JOB
I I 'ᑍALL ' 11 2 USER
I I 'ᑍALL' 21 26 JOBNUM
ᑍ FORMAT JOBL1 FOR QUSLJOB API
ᑍ
ᑍᑍ DATA STRUCTURE CONTAINING SPACE NAME/LIB
ISPCNAM DS
9-14 System API Programming V4R1