Defining

List

Entry

 

Format

Lengths

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The

example programs

in

this

topic

show how to code flexibility into y

 

 

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

 

 

the

format

length into your program. The

 

format

length

is

used

by

 

the

 

 

advance

to

the next list entry in

the user space. From release to re

 

 

length of the format may change. Therefore, when the

format

length

cha

 

 

program

can

be susceptible to being pointed to an incorrect

position i

 

 

space

and

nonsense

data

placed

in

the

receiver

variable.

 

 

 

 

 

 

The

program

has the length of the

list

entry

format

hard

coded. This

 

 

.1ð/ on page 9-16. If your program

runs

on a

Version

2

Release

2

sy

 

 

value would

work. However,

with

Version

2

Release

3,

the

 

format

size

 

 

from

52

to

56

bytes. The

correct

coding.11/ ison shownpage at9-17.

 

 

 

 

 

 

 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

 

 

 

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Program Name: PGM1

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Program Language: RPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Description: This sample program illustrates the incorr￿ect

 

 

 

 

 

 

 

 

 

\

 

 

 

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 CA￿LL

\THE QUSLJOB API TO GET A LIST OF ALL ACTIVE JOBS ON THE SYS￿TEM.

\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

USER

I

I

'\ALL'

 

21

26

JOBNUM

\FORMAT JOBLð1ðð FOR QUSLJOB API

\\ DATA STRUCTURE CONTAINING SPACE NAME/LIB

ISPCNAM DS

9-14System API Programming V4R1

Page 220
Image 220
IBM Version 4 manual Defining, Incorrect, Data Structure Containing Space NAME/LIB Ispcnam DS