Defining Receiver Variables

 

 

 

 

 

 

 

 

 

 

 

When

defining

receiver

variables,

the

most common

error is

to

create

small

for

the

amount

of

data

that

they are

to

receive.

Both

example

coded in

RPG

and,

when

run,

lists

all

active

jobs

on the

system.

Defining Receiver Variables—Example

of

Incorrect

Coding

 

 

 

 

 

 

 

 

 

The following example program will

fail because the receiver variable

h

defined

as

50

bytes

.(shown7/

atpage

9-11), but 60

bytes

are being

reque

to be passed

back

from

the

 

API.8/

(showninthe atincorrect and

correct

pro-

 

grams

on

pages

9-11

and

9-13,

respectively). The

correct.9/coding

is

show

on page 9-13.

 

 

 

 

 

 

 

 

 

 

 

 

When

this

happens, other

variables are overwritten with unintended data

causes the other variables to

 

be incorrect. For example, the first

1

QUSBN

may

be

written

over with

these extra characters. On the

call

t

API,

the

error

code

parameter

may appear to contain meaningless

charac

would cause the next call to an API to fail.

 

 

 

 

 

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

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Program Name: PGM1

 

 

 

 

 

 

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Program Language:

RPG

 

 

 

 

 

 

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\Description: This sample program illustrates the incorr￿ect

 

 

 

 

 

\

 

way of defining receiver variables.

 

 

 

 

 

\

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

\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.

\BRING IN THE GENERIC USER SPACE HEADER FROM QSYSINC

I/COPY QSYSINC/QRPGSRC,QUSGEN

\

\BRING IN THE ERROR STRUCTURE FROM QSYSINC I/COPY QSYSINC/QRPGSRC,QUSEC

\\ JOBLð1ðð FORMAT RETURNED FROM QUSLJOB API I/COPY QSYSINC/QRPGSRC,QUSLJOB

\\ 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

ISPCNAM

DS

 

 

 

I I

'SPCNAME

'

1

1ð SPC

I I

'QTEMP

'

11

2ð LIB

9-10System API Programming

V4R1

 

 

 

Page 216
Image 216
IBM Version 4 manual When Defining Receiver Variables, When Run Lists All Active Jobs System, Rpg