Você está na página 1de 88

1

1. Advantages of ILE:

RPG IV is more readable

Allows for greater application modularity with static binding which


means there are fewer external calls.

Enhances programmer productivity by allowing greater code re use

Enhances mixed language support by allowing the binding ILE languages


into a single program

Builds a foundation for the future by moving closer to object oriented


design , modular programming and code reuse

Enhancements in RPGIV

Mixed Case entry permitted


Compiler is not case sensitive
Compiler can translate mixed case to upper case.
Character names allowed
Full DDS length supported
Columns available for suscripts
Undescore allowed in names
Blank lines allowed making it more readable

Limit changes :

Limit Changes RPGIII RPGIV


Field names & Array 6 10
Names
Length of Character 256 32767
Variable
No of Possible array 9999 32767
elements
No of Possible 256 No Limit
Subroutines
No of Decimal 9 30
Positions
No of files per 50 No Limit
program

H spec :
Completely free format
Additional functions: Date and Time Format
Enhanced Readability

F-Spec:
Part of F-spec are now keyword based
No of files un limited
File definition checks have been relaxed
File names length increased to 10 characters and record lengths to 5
digits

D-Spec:
Defining the data structures
2

Defining arrays
Defining standalone fields
Indent field names to show structures
Easily define arrays within data structures
Use keywords to make your code more readable and more flexible

Keywords used in the D-Spec:


INZ
OCCURS
OVERLAY
EXTNAME
EXTFLD
PREFIX
DIM
ASCEND/DESCEND
PERRCD
FROMFILE/TOFILE
EXFMT
ALT
CTDATA

C-Spec:

RPGIII RPGIV
BITOF BITOFF
CHEKR CHECKR
COMIT COMMIT
DEFN DEFINE
DELET DELETE
EXCPT EXCEPT
LOKUP LOOKUP
OCCUR OCCUR
REDPE READPE
RETRN RETURN
SELEC SELECT
SETOF SETOFF
UPDAT UPDATE
UNLCK UNLOCK
WHXX WHENXX

Factor1,Factor2 & Result each increased to 14 characters


Extended Factor2 allows free-format expressions
Field length increased to 5 positions
Decimal Positions increased to 2.
Many opcodes increased to 6 characters
Space for opcodes plus extenders increased to 10 characters
New opcodes and operators added with extended factor 2
Conditioning indicators reduced to 1 from 3

O-Spec:
No major changes in the O specification
Names on the O spec have been expanded
Skip Before/After and Space Before/After have also been extended , to
allow 3 positions

New Opcodes:
3

ADDDUR
CALLB
CALLP
DOU
DOW
EVAL
EXTRCT
IF
SUBDUR
TEST
WHEN

RPGIV supports date,time and timestamp data types With date , time and
timestamp fields you can Calculate durations
Extract portions of dates and times
Move data from one field to another
Compare their values
Test for valid values

The data types supported are


D for Date
T for Time
Z for Timestamp

The internal format can be specified on the H spec for all fields or on
the D spec for specific fields

With the introduction of the ADDDUR & SUBDUR opcodes you can easily add
or subtract duration b/n date,time or timestamp fields.

The EXTRCT opcode easily extracts a logical portion of a date ,time or


timestamp field.

The MOVE or MOVEL opcode can be used to easily move data to and from
date,time & timestamp fields.

You can compare dates, times& timestamps & test the validity of these
fields using the TEST opcode.

EXPRESSIONS:

More precise results using expressions

RPGIV is easier to read and maintain as it handles half adjustments &


avoids usage of temporary variables

Three type of expressions :Arithmetical, conditional and string

Expressions are entered in the Extended calculation.

Precedence rules apply to the evaluation of expressions.

Expressions use DOU,DOW,IF,WHEN&EVAL opcodes.

SUBPROCEDURES & PROTOTYPES:

A subprocedure is a procedure specified after the main section.


4

It can only be called using a bound call .

Subprocedure do not use the RPG cycle while running .

All subporocedures have a corresponding prototype in the D-spec which


ensures proper procedure or program call with correct parameters .

Subprocedure without a main procedure is called a Nomain module.

You can pass parameters to a subprocedure.

Names defined in the subprocedure are not visible outside the


subprocedure.

You can call subprocedures recursively.

Advanced Functions in RPGIV:

RPGIV provides you with many advanced functions that make your code
easier to maintain . It Provides you with powerful built-in functions
that allows you to code more powerful and self-maintaining applications.

TRIM BIF allows you to trim spaces from the beginning or end of a
character variable.

SUBST allows you to take a substring of a field.

SIZE allows you to dynamically determine in size of a field,array or


data structure.

ELEM returns the number of elements in an array,table or multi-


occurance data structure.

Based variables with pointers allow you to access information stored


inside or outside your program.

Modules can be bound together and data can be shared across modules
using the IMPORT and EXPORT keywords .

Using ILE allows you to take advantage or modular programming :

ILE enables modular programming through seperately compiled pieces of


code called modules.

These modules are statistically bound. They are created using CRTxxxMOD
command.

OPM program runs in the default activation group . You can create an
RPGIV program that is OPM compatible by using CRTBNDRPG with
DFTACTGRP(*YES)

There are two ways to create an ILE program.you can create bound RPG
program using CRTBNDRPG Command or create a program binding modules
together.
5

You can create a service program to handle frequently used routines &
for better performance.

Built-in-Functions:

%ADDR
%ELEM
%PADDR
%SIZE
%SUBST
%TRIM
%TRIML
%TRIMR

Built-in Functions enables to :

Trim spaces from character fields


Refer to substring of a field
Return the size of a field
Return the number of elements in an array or multi-occurance data
structure.
Place the address of an item in a pointer
Place the address of a procedure in a pointer variable

Other advance functions include:

Pointers to base storage inside or outside your program


Data items using keywords that can be shared between bound modules.

Activation group:

An Activation group is a substructure of a job. It consists of system


resources allocated to one or more programs running in it. It is a type
of firewall that you can build around your application to protect its
resources.

ILE activation groups have many benefits over the default activation
group:

Protection of shared resources from other applications.

Resources such as shared open data paths for files, can be shared among
all programs in activation group, while being protected from other
programs running in the same job .

Scoping(Restricting) of file overrides and commitment control scope.

Easily cleanup of a group of programs. You can clean up active programs


and open files with in an activation group using the RCLACTGRP
command.Other active programs running in the same job will not be
affected.

2. Questions and Answers


1. Can a LDA be deleted.
6

We can’t delete *LDA


2. How will u see all the files that r used in a RPG program.
DSPPGMREF
3. which of these OS are not supported by AS400
a.win2000, b.winNT, c.palm2000, d.Lotus notes, e.Unix.
Palm 2000
4. what is DBCS.
Double byte Character set
5. what is DSPDBR.
It identifies physical and logical files that are dependent to
particular files.
6. How would u find the source of the object.
By service pgm wrkobj description *service
7. How to retrieve the source for the object.
If CL – RTVCLSRC
If RPG – spool file take copy by CSPLY ten deletee the lines if
‘HFELICO’ not in the 12 th poistion
8. how would u determine the end of file in CLP.
By usinf MONMSG -- CPF0809
9. how many files can be read in a CLP.
One.
10. how would u read a file in a CLP.
RCVF
11. what is the difference between reade and chain.
READE just read the current record,
CHAIN – SETLL AND READ , position and read
12. can u save a spool file.
yes
13. what are printer over rides.
Save, lines pre width, page size, over flow line no, Data
14. what are printer over rides used for.
Same as prev
15. how many lines can be printed on a printer file.
10000
16. Key words used for subfile.
SFLCTL, SFLDSPCTL, SFLNXTCHG, SFLPAG, SFLSIZ, SFLINZ, SFLRCDNBR,
SFLCLR,
17. wht is the use or SFLCTL in a subfile.
SFLCTL is used to control the header and detail part.
18. wht r the different types of loading a subfile.
SINGLE SHOT = SFLSIZ > SFLPAG
Page by Page = SFLSIZ = SFLPAG up and down we have to take care
Expanding = ‘’ ‘’ only Down we have to take care
19. what is SFLSIZ and SFLPAG.
SLFSIZ = buffer size,
SFLPAG = Records to display in screen
20. how can information be passed to another program.
DATA AREA, DATAQUEUE, USRSPACE
21. wht is *usrspace.

22. wht is data area.


Data area is to store data permanately or temporally. It can be pass
between programs also.
23. how to handle file exception and program exception.
7

File exception by INFDS (INFSR)


Program exception PSSR
24. what is *PSSR.
Program status data structure , to handle program exception errors
25. If u lock a file does all the records in the file get locked.
Yes
ALCOBJ (LOCKING FILE)
26. how will a record get locked.
If we issue Chain command to that record
27. how will a lock be removed from a locked record.
DLCOBJ – de allocate object
CHAIN with no lock
28. while doing a chain does a record get locked.
Yes in Update mode

29. how to read a record without locking it.


Chain with 53 position N
30. wht is journal.
To take both the images for physical or any other files. Changes made
to specific data base file.
For that we have to give JRNRCV,
31. wht is comittment control.
Commitment control is used to process file operations as a group
Commitment control is to save set of transactions done on a file.
32. wht is OVRDBF. - why is it used.
To override another member for reading , to read 5 th member of that PF
Temporary file creation, overridden to existing file
33. wht r the API's that u have used.
QCMDEXC
Command – len 80
FLD2 - len 15 ,5
34. how many parameters should b passed to the API - attributes of the
parameters.
2 PARAMETERS
35. what is Data queue?
Communicate or store data within the job or between jobs
36. SFLNXTCHG
If readc wants to read all the records, SFLNXTCHG should be ON. It will
on the modified data tag
To read the changed subfile record
37. SFLRCDNBR
Subfile record no Control fields take F4 to define hidden field of
length 4,0 , then select that field to seton SFLRCDNBR
38. RTNCURLOC
define two hidden field record and field name of length 10, SETON on
the RTNCURLOC field and define the two fields, in program if prompt
required then check if field name = field name , then show new select
screen
39. SUBSYSTEM
Partitioned of the CPU, in which various jobs can be executed
40. JOBQ
Overall status of job queues or detailed status of single job,
41. JOBD
8

To determine how jobs can proceed (system process) if more than one
jobs present in that jobq
42. OPNQRYF –
It will opens the file with set of database records, which satisfies
the query selection process.
Dynamic query selection
Join records from more than one file

3. Data Structures.

PSDS

A program status data structure (PSDS) can be defined to make


program exception/error information available to an RPG IV
program. The PSDS must be defined in the main source section;
therefore, there is only one PSDS per module.

A data structure is defined as a PSDS by an S in position 23 of


the data structure statement. A PSDS contains predefined
subfields that provide you with information about the program
exception/error that occurred. The location of the subfields in
the PSDS is defined by special keywords or by predefined From and
To positions. In order to access the subfields, you assign a
name to each subfield. The keywords must be specified, left-
adjusted in positions 26 through 39.

Information from the PSDS is also provided in a formatted dump.


However, a formatted dump might not contain information for
fields in the PSDS if the PSDS is not coded, or the length of the
PSDS does not include those fields. For example, if the PSDS is
only 275 bytes long, the time and date or program running will
appear as N/A. in the dump, since this information starts at
byte 276.
Link to what IBM says

o Program Status Data Structure


o D SDS
o D PROC_NAME *PROC Procedure
name
o D PGM_STATUS *STATUS Status
code
o D PRV_STATUS 16 20S 0 Previous
status
o D LINE_NUM 21 28 Src list
line nu
o D ROUTINE *ROUTINE Routine
name
o D PARMS *PARMS Num
passed parms
o D EXCP_TYPE 40 42
Exception type
o D EXCP_NUM 43 46
Exception number
9

o D PGM_LIB 81 90 Program
library
o D EXCP_DATA 91 170
Exception data
o D EXCP_ID 171 174
Exception Id
o D DATE 191 198 Date
(DATE fmt)
o D YEAR 199 200S 0 Year
(YEAR fmt)
o D LAST_FILE 201 208 Last
file used
o D FILE_INFO 209 243 File
error info
o D JOB_NAME 244 253 Job name
o D USER 254 263 User name
o D JOB_NUM 264 269S 0 Job
number
o D JOB_DATE 270 275S 0 Date
(UDATE fmt)
o D RUN_DATE 276 281S 0 Run date
(UDATE)
o D RUN_TIME 282 287S 0 Run time
(UDATE)
o D CRT_DATE 288 293 Create
date
o D CRT_TIME 294 299 Create
time
o D CPL_LEVEL 300 303 Compiler
level
o D SRC_FILE 304 313 Source
file
o D SRC_LIB 314 323 Source
file lib
o D SRC_MBR 324 333 Source
file mbr
o D PROC_PGM 334 343 Pgm Proc
is in
o D PROC_MOD 344 353 Mod Proc
is in
o D CURR_USER 358 367 Mod Proc
is in

o Status codes *STATUS


o Normal Codes
o
o Code Condition
o 00000 No exception/error occurred
o 00001 Called program returned with the LR
indicator on.
o
o Exception/Error Codes
o
o Code Condition
o 00100 Value out of range for string operation
10

o 00101 Negative square root


o 00102 Divide by zero
o 00103 An intermediate result is not large enough
to
o contain the result.
o 00104 Float underflow. An intermediate value is
too
o small to be contained in the intermediate
o result field
o 00112 Invalid Date, Time or Timestamp value.
o 00113 Date overflow or underflow. (For example,
when
o the result of a Date calculation
o results in a number greater than HIVAL or
less
o than LOVAL.)
o 00114 Date mapping errors, where a Date is
mapped from a 4
o character year to a 2 character year and
the date range
o is not 1940-2039.
o 00120 Table or array out of sequence.
o 00121 Array index not valid
o 00122 OCCUR outside of range
o 00123 Reset attempted during initialization step
of program
o 00202 Called program or procedure failed; halt
indicator
o (H1 through H9) not on
o 00211 Error calling program or procedure
o 00222 Pointer or parameter error
o 00231 Called program or procedure returned with
halt
o indicator on
o 00232 Halt indicator on in this program
o 00233 Halt indicator on when RETURN operation run
o 00299 RPG IV formatted dump failed
o 00333 Error on DSPLY operation
o 00401 Data area specified on IN/OUT not found
o 00402 PDA not valid for non-prestart job
o 00411 Data area type or length does not match
o 00412 Data area not locked for output
o 00413 Error on IN/OUT operation
o 00414 User not authorized to use data area
o 00415 User not authorized to change data area
o 00421 Error on UNLOCK operation
o 00425 Length requested for storage allocation is
out of range
o 00426 Error encountered during storage
management operation
o 00431 Data area previously locked by another
program
o 00432 Data area locked by program in the same
process
o 00450 Character field not entirely enclosed by
shift-out
o and shift-in characters
11

o 00501 Failure to retrieve sort sequence.


o 00502 Failure to convert sort sequence.
o 00802 Commitment control not active.
o 00803 Rollback operation failed.
o 00804 Error occurred on COMMIT operation
o 00805 Error occurred on ROLBK operation
o 00907 Decimal data error (digit or sign not
valid)
o 00970 The level number of the compiler used to
generate
o the program does not agree with the level
number
o of the RPG IV run-time subroutines
o 09998 Internal failure in ILE RPG/400 compiler
or in
o run-time subroutines
o 09999 Program exception in system routine.

INFDS

o File Information Data Structure

A file information data structure (INFDS) can be


defined for each file to make file exception/error
and file feedback information available to the
program. The file information data structure, which
must be unique for each file, must be defined in the
main source section. The same INFDS is used by all
procedures using the files.
Link to what IBM says

The INFDS contains the following feedback


information:

 File Feedback (length is 80)


 Open Feedback (length is 160)
 Input/Output Feedback (length is 126)
 Device Specific Feedback (length is variable)
 Get Attributes Feedback (length is variable)

* Standard RPG feedback area 1-80


DINFDS ds
D File *FILE *
File name
D OpenInd 9 9 *
File open?
D EOFInd 10 10 *
File at eof?
D FileStatus *STATUS *
Status code
12

D OpCode *OPCODE *
Last opcode
D Routinr *ROUTINE *
RPG Routine
D ListNum 30 37 *
Listing line
D SpclStat 38 42S 0 *
SPECIAL status
D RecordFmt *RECORD *
Record name
D MsgID 46 52 *
Error MSGID

D* the next 4 fields are available after POST


D Screen_P *SIZE *
Screen size
D NLSIn_P *INP *
NLS Input?
D NLSOut_P *OUT *
NLS Output?
D NLSMode_P *MODE *
NLS Mode?

* Open feedback area 81-240


* NOTE that getting data beyond column 80 is expensive
* in terms of program opens...
D ODP_TYPE 81 82 * ODP
Type
D FILE_NAME 83 92 * File
name
D LIBRARY 93 102 *
Library name
D SPOOL_FILE 103 112 * Spool
file name
D SPOOL_LIB 113 122 * Spool
file lib
D SPOOL_NUM 123 124I 0 * Spool
file num
D RCD_LEN 125 126I 0 * Max
record len
D KEY_LEN 127 128I 0 * Max
key len
D MEMBER 129 138 * Member
name
D TYPE 147 148I 0 * File
type
D ROWS 152 153I 0 * Num
PRT/DSP rows
D COLUMNS 154 155I 0 * Num
PRT/DSP cols
D NUM_RCDS 156 159I 0 * Num of
records
D ACC_TYPE 160 161 * Access
type
D DUP_KEY 162 162 *
Duplicate key?
13

D SRC_FILE 163 163 * Source


file?
D VOL_OFF 184 185I 0 * Vol
label offs
D BLK_RCDS 186 187I 0 * Max
rcds in bl
D OVERFLOW 188 189I 0 *
Overflow line
D BLK_INCR 190 191I 0 * Blk
increment
D FLAGS1 196 196 * Misc
flags
D REQUESTER 197 206 *
Requester name
D OPEN_COUNT 207 208I 0 * Open
count
D BASED_MBRS 211 212I 0 * Num
based mbrs
D FLAGS2 213 213 * Misc
flags
D OPEN_ID 214 215 * Open
identifie
D RCDFMT_LEN 216 217I 0 * Max
rcd fmt le
D CCSID 218 219I 0 *
Database CCSID
D FLAGS3 220 220 * Misc
flags
D NUM_DEVS 227 228I 0 * Num
devs defin

D* I/O feedback area 241-366


D * 241-
242 not used
D WRITE_CNT 243 246I 0 * Write
count
D READ_CNT 247 250I 0 * Read
count
D WRTRD_CNT 251 254I 0 *
Write/read count
D OTHER_CNT 255 258I 0 * Other
I/O count
D OPERATION 260 260 *
Cuurent operatio
D IO_RCD_FMT 261 270 * Rcd
format name
D DEV_CLASS 271 272 * Device
class
D IO_PGM_DEV 273 282 * Pgm
device name
D IO_RCD_LEN 283 286I 0 * Rcd
len of I/O

D* POST area 241-nnn


D* Display
D PGM_DEV_P 241 250 *
Program device
14

D DEV_DSC_P 251 260 * Dev


description
D USER_ID_P 261 270 * User ID
D DEV_CLASS_P 271 271 * Device
class
D DEV_TYPE_P 272 277 * Device
type
D REQ_DEV_P 278 278 *
Requester?
D ACQ_STAT_P 279 279 *
Acquire status
D INV_STAT_P 280 280 * Invite
status
D DATA_AVAIL_P 281 281 * Data
available
D NUM_ROWS_P 282 283I 0 * Number
of rows
D NUM_COLS_P 284 285I 0 * Number
of cols
D BLINK_P 286 286 * Allow
blink?
D LINE_STAT_P 287 287 *
Online/offline?
D DSP_LOC_P 288 288 *
Display location
D DSP_TYPE_P 289 289 *
Display type
D KBD_TYPE_P 290 290 *
Keyboard type
D CTL_INFO_P 342 342 *
Controller info
D COLOR_DSP_P 343 343 * Color
capable?
D GRID_DSP_P 344 344 * Grid
line dsp?
* The following fields apply to ISDN.
D ISDN_LEN_P 385 386I 0 * Rmt
number len
D ISDN_TYPE_P 387 388 * Rmt
number type
D ISDN_PLAN_P 389 390 * Rmt
number plan
D ISDN_NUM_P 391 430 * Rmt
number
D ISDN_SLEN_P 435 436I 0 * Rmt
sub-address
D ISDN_STYPE_P 437 438 * Rmt
sub-address
D ISDN_SNUM_P 439 478 * Rmt
sub-address
D ISDN_CON_P 480 480 *
Connection
D ISDN_RLEN_P 481 482I 0 * Rmt
address len
D ISDN_RNUM_P 483 514 * Rmt
address
15

D ISDN_ELEN_P 519 520 *


Extension len
D ISDN_ETYPE_P 521 521 *
Extension type
D ISDN_ENUM_P 522 561 *
Extension num
D ISDN_XTYPE_P 566 566 * X.25
call type
D* ICF
D PGM_DEV_P 241 250 *
Program device
D DEV_DSC_P 251 260 * Dev
description
D USER_ID_P 261 270 * User ID
D DEV_CLASS_P 271 271 * Device
class
D DEV_TYPE_P 272 272 * Device
type
D REQ_DEV_P 278 278 *
Requester?
D ACQ_STAT_P 279 279 *
Acquire status
D INV_STAT_P 280 280 * Invite
status
D DATA_AVAIL_P 281 281 * Data
available
D SES_STAT_P 291 291 *
Session status
D SYNC_LVL_P 292 292 * Synch
level
D CONV_TYPE_P 293 293 *
Conversation typ
D RMT_LOC_P 294 301 * Remote
location
D LCL_LU_P 302 309 * Local
LU name
D LCL_NETID_P 310 317 * Local
net ID
D RMT_LU_P 318 325 * Remote
LU
D RMT_NETID_P 326 333 * Remote
net ID
D APPC_MODE_P 334 341 * APPC
Mode
D LU6_STATE_P 345 345 * LU6
conv state
D LU6_COR_P 346 353 * LU6
conv
*
correlator
* The following fields apply to ISDN.
D ISDN_LEN 385 386I 0 * Rmt
number len
D ISDN_TYPE 387 388 * Rmt
number type
D ISDN_PLAN 389 390 * Rmt
number plan
16

D ISDN_NUM 391 430 * Rmt


number
D ISDN_SLEN 435 436I 0 * sub-
addr len
D ISDN_STYPE 437 438 * sub-
addr type
D ISDN_SNUM 439 478 * Rmt
sub-address
D ISDN_CON 480 480 *
Connection
D ISDN_RLEN 481 482I 0 * Rmt
address len
D ISDN_RNUM 483 514 * Rmt
address
D ISDN_ELEN 519 520 *
Extension len
D ISDN_ETYPE 521 521 *
Extension type
D ISDN_ENUM 522 561 *
Extension num
D ISDN_XTYPE 566 566 * X.25
call type

* The following information available only when


program started
* result of a received program start req. (P_ stands
for protected)
D TRAN_PGM 567 630 * Trans
pgm name
D P_LUWIDLN 631 631 * LUWID
fld len
D P_LUNAMELN 632 632 * LU-
NAME len
D P_LUNAME 633 649 * LU-NAME
D P_LUWIDIN 650 655 * LUWID
instance
D P_LUWIDSEQ 656 657I 0 * LUWID
seq num

* Below info is available only when a protected


conversation
* is started on a remote system. (U_ stands for
unprotected)
D U_LUWIDLN 658 658 * LUWID
fld len
D U_LUNAMELN 659 659 * LU-
NAME len
D U_LUNAME 660 676 * LU-NAME
D U_LUWIDIN 677 682 * LUWID
instance
D U_LUWIDSEQ 683 684I 0 * LUWID
seq num

D* Device independent area 367-nnn


D* NOTE that this area is shared with the POST
feedback area above!
D* Printer
17

D CUR_LINE 367 368I 0 *


Current line num
D CUR_PAGE 369 372I 0 *
Current page cnt
D PRT_MAJOR 401 402 * Major
ret code
D PRT_MINOR 403 404 * Minor
ret code

D* Disk
D FDBK_SIZE 367 370I 0 * Size
of DB fdbk
D JOIN_BITS 371 374I 0 * JFILE
bits
D LOCK_RCDS 377 378I 0 * Nbr
locked rcds
D POS_BITS 385 385 * File
pos bits
D DLT_BITS 384 384 * Rcd
deleted bits
D NUM_KEYS 387 388I 0 * Num
keys (bin)
D KEY_LEN 393 394I 0 * Key
length
D MBR_NUM 395 396I 0 * Member
number
D DB_RRN 397 400I 0 *
Relative-rcd-num
D KEY 401 2400 * Key
value (max
D* * size
2000)

D* ICF
D ICF_AID 369 369 * AID
byte
D ICF_LEN 372 375I 0 * Actual
data len
D ICF_MAJOR 401 402 * Major
ret code
D ICF_MINOR 403 404 * Minor
ret code
D SNA_SENSE 405 412 * SNA
sense rc
D SAFE_IND 413 413 * Safe
indicator
D RQSWRT 415 415 *
Request write
D RMT_FMT 416 425 * Remote
rcd fmt
D ICF_MODE 430 437 * Mode
name

D* Display
D DSP_FLAG1 367 368 *
Display flags
18

D DSP_AID 369 369 * AID


byte
D CURSOR 370 371 * Cursor
location
D DATA_LEN 372 375I 0 * Actual
data len
D SF_RRN 376 377I 0 *
Subfile rrn
D MIN_RRN 378 379I 0 *
Subfile min rrn
D NUM_RCDS 380 381I 0 *
Subfile num rcds
D ACT_CURS 382 383 * Active
window
D* *
cursor location
D DSP_MAJOR 401 402 * Major
ret code
D DSP_MINOR 403 404 * Minor
ret code

4. Debug a program in BATCH.

1. Hold the JobQ (Eg: QBATCH)


2. Submit the job.
3. Hold the job – Take option 3 against the job in “Work with submitted
jobs”.
4. Release the JobQ
5. Take option 5 against the job to be debugged and make a note of the
“Job Name”, “User”, and “Job Number”.
6. Execute the command STRSRVJOB – Start Service Job. Input the Job
Name, User, Job Number.
7. STRDBG – Start Debug.
8. Release the job that is on hold – Take option 6 against the job on
hold to release.
9. Once the job is released, a screen is displayed which tells u to add
the break points. Take F10 and execute the command ADDBKP.
10.Then it is the normal way of debug using STRDBG.

5. SDLC

DEFINITION: Definition System Development Life Cycle (SDLC) is the


overall process of developing information systems through a multistep
process from investigation of initial requirements through analysis,
design, implementation and maintenance. There are many different models
and methodologies, but each generally consists of a series of defined
steps or stages.

MAY 14, 2002 (COMPUTERWORLD) - Once upon a time, software development


consisted of a programmer writing code to solve a problem or automate a
procedure. Nowadays, systems are so big and complex that teams of
architects, analysts, programmers, testers and users must work together
to create the millions of lines of custom-written code that drive our
enterprises.
19

To manage this, a number of system development life cycle (SDLC) models


have been created: waterfall, fountain, spiral, build and fix, rapid
prototyping, incremental, and synchronize and stabilize.
The oldest of these, and the best known, is the waterfall: a sequence
of stages in which the output of each stage becomes the input for the
next. These stages can be characterized and divided up in different
ways, including the following:
• Project planning, feasibility study: Establishes a high-level
view of the intended project and determines its goals.
• Systems analysis, requirements definition: Refines project goals
into defined functions and operation of the intended application.
Analyzes end-user information needs.
• Systems design: Describes desired features and operations in
detail, including screen layouts, business rules, process
diagrams, pseudocode and other documentation.
• Implementation: The real code is written here.
• Integration and testing: Brings all the pieces together into a
special testing environment, then checks for errors, bugs and
interoperability.
• Acceptance, installation, deployment: The final stage of initial
development, where the software is put into production and runs
actual business.
• Maintenance: What happens during the rest of the software's life:
changes, correction, additions, moves to a different computing
platform and more. This, the least glamorous and perhaps most
important step of all, goes on seemingly forever.
But It Doesn't Work!
The waterfall model is well understood, but it's not as useful as it
once was. In a 1991 Information Center Quarterly article, Larry Runge
says that SDLC "works very well when we are automating the activities
of clerks and accountants. It doesn't work nearly as well, if at all,
when building systems for knowledge workers -- people at help desks,
experts trying to solve problems, or executives trying to lead their
company into the Fortune 100."

Another problem is that the waterfall model assumes that the only role
for users is in specifying requirements, and that all requirements can
be specified in advance. Unfortunately, requirements grow and change
throughout the process and beyond, calling for considerable feedback
and iterative consultation. Thus many other SDLC models have been
developed.

The fountain model recognizes that although some activities can't start
before others -- such as you need a design before you can start coding
-- there's a considerable overlap of activities throughout the
development cycle.

The spiral model emphasizes the need to go back and reiterate earlier
stages a number of times as the project progresses. It's actually a
series of short waterfall cycles, each producing an early prototype
representing a part of the entire project. This approach helps
demonstrate a proof of concept early in the cycle, and it more
accurately reflects the disorderly, even chaotic evolution of
technology.
20

Build and fix is the crudest of the methods. Write some code, then keep
modifying it until the customer is happy. Without planning, this is
very open-ended and can by risky.
In the rapid prototyping (sometimes called rapid application
development) model, initial emphasis is on creating a prototype that
looks and acts like the desired product in order to test its
usefulness. The prototype is an essential part of the requirements
determination phase, and may be created using tools different from
those used for the final product. Once the prototype is approved, it is
discarded and the "real" software is written.

The incremental model divides the product into builds, where sections
of the project are created and tested separately. This approach will
likely find errors in user requirements quickly, since user feedback is
solicited for each stage and because code is tested sooner after it's
written.

Big Time, Real Time


The synchronize and stabilize method combines the advantages of the
spiral model with technology for overseeing and managing source code.
This method allows many teams to work efficiently in parallel. This
approach was defined by David Yoffie of Harvard University and Michael
Cusumano of MIT. They studied how Microsoft Corp. developed Internet
Explorer and Netscape Communications Corp. developed Communicator,
finding common threads in the ways the two companies worked. For
example, both companies did a nightly compilation (called a build) of
the entire project, bringing together all the current components. They
established release dates and expended considerable effort to stabilize
the code before it was released. The companies did an alpha release for
internal testing; one or more beta releases (usually feature-complete)
for wider testing outside the company, and finally a release candidate
leading to a gold master, which was released to manufacturing. At some
point before each release, specifications would be frozen and the
remaining time spent on fixing bugs.

Both Microsoft and Netscape managed millions of lines of code as


specifications changed and evolved over time. Design reviews and
strategy sessions were frequent, and everything was documented. Both
companies built contingency time into their schedules, and when release
deadlines got close, both chose to scale back product features rather
than let milestone dates slip.

6.Joining Files Using OPNQRYF

Detailed Description :

Some customers have asked us for an Example of LANSA reading a join


file created by OPNQRYF

The example below uses OPNQRYF to join the following files:

Filename: FILE1
Fields Type Length
FIELD1 Alpha 5 (File key)
21

FIELD2 Alpha 5
Filename: FILE2
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD3 Alpha 5
Filename: FILE3
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD4 Alpha 5

An extra file is needed for OPNQRYF to use as a "result" record format


for the join...

Filename: JOINFILE
Fields Type Length
FIELD1 Alpha 5 (File key)
FIELD2 Alpha 5
FIELD3 Alpha 5
FIELD4 Alpha 5

Important notes when defining JOINFILE...

• When defining this file to LANSA, use the data base attributes
screen to define the file as SHARE..YES. Also put "SHARE(*YES)"
at the bottom of the screen in the CRTPF parameters section.
• Make sure JOINFILE has been defined as having at least one key.
The key does not have to match the keys of the result file
produced by OPNQRYF.
• All of the above files were created using LANSA so they all will
have the field @@UPID automatically added to the record formats.
Once the above files are compiled, a function can be written to
execute the OPNQRYF and read the file.

1 OPEN *ALL *ONDEMAND


2 POINT FILE(JOINFILE) TOFILE(FILE1)
3 DEF_LIST #LIST (#FIELD1 #FIELD2 #FIELD3 #FIELD4)
4 ********** Execute the OPNQRYF
5 EXEC_OS400 ('OPNQRYF FILE(FILE1 FILE2 FILE3) FORMAT
(JOINFILE) JFLD((FILE1/FIELD1 FILE2/FIELD1
)) ((FILE1/FIELD1FILE3/FIELD1)) MAPFLD((FI
ELD1’FILE1/FIELD1')(@@UPID'FILE1/@@UPID'))
6 ********** Open JOINFILE immediately so LANSA will
********** not do a "SETLL"
7 OPEN FILE(JOINFILE) USE_OPTION(*IMMEDIATE)
8 SELECT FIELDS(#LIST) FROM_FILE(JOINFILE)
9 ADD_ENTRY #LIST
10 ENDSELECT
11 CLOSE JOINFILE
12 ********** Close file created by OPNQRYF
13 EXEC_OS400 COMMAND('CLOF FILE1')
14 DISPLAY BROWSELIST(#LIST)

Important notes about the above function...


22

• The JOINFILE must be opened "*ONDEMAND" so that it is not opened


before the OPNQRYF is executed. See statement 1.
• OPNQRYF will create a file that is exactly the same as the file
specified in the FORMAT() parameter but the actual file name will
be the name of the first file specified in the FILE() parameter.
For this reason, the function SELECTs from JOINFILE but JOINFILE
is POINTed to FILE1. See statement 2.
• Just before the JOINFILE is read, open it *IMMEDIATEly. When this
is done, LANSA knows the file has just been opened so it does not
attempt to use SETLL (RPG operation) to position the file to the
beginning before the first read. See statement 7. (Using RPG's
SETLL on a file created by OPNQRYF is invalid and it will cause
the function to abort).
• After reading the JOINFILE, CLOSE it and then use the CL command
"CLOF" to close the file (FILE1) created by OPNQRYF. See
statement 13.

There is another solution, by following the instructions detailed below


LANSA can be tricked into reading the join logical file without using
OPNQRYF:

1. Create a physical file with the same name and record format as
the join logical. This will have to be created in a different
library from the join logical.
2. Load this file as an 'OTHER' file into LANSA.
3. Compile the file.
4. Rename the physical file created outside of LANSA or delete the
file. It is probably best to rename it as it may be necessary to
make changes and reload it at a later stage.
5. Do a CHGLF on the join file LVLVHK(*NO).
6. Make sure that the join logical file is in the library list.
7. It is now possible to do reads of the join logical file via the
LANSA I/O module.

7. OPNQRYF - Short explanation with some samples.

CL-PROGRAM

FUNCTION.....: RETRIEVE/SELECT DATA WITH THE CL-COMMAND OPNQRYF.


ILLUSTRATED IN SAMPLES 1 - 3.

TASK.........: RETRIEVE USERINFO ON FIELDS FROM THE USRPRF-FILE.


USE THE CL-COMMAND DSPUSRPRF *ALL OUTPUT(*OUTFILE)
FILE(LIB/QRYSLTPF). LIB IS YOUR OWN TEST-LIBRARY.
THE PROGRAM ONLY USES 2 FIELDS TO AVOID CONFUSION.

IN THIS PROGRAM THE TEST-LIBRARY IS JPHLIB.

INPUT........: DB-FILE: QRYSLTPF


FIELDS: UPUPRF 10 A
UPUID 10 P0

DISCLAIMER...: THE DATA RETRIEVED AND THE COMBINATION OF FIELDS


IS COMPLETELY NONSENSE AND INTENDED ONLY TO ILLU-
23

STRATE THE USE OF THIS COMMAND. CREATE BETTER EX-


AMPLES ON YOUR OWN !!

CREATE A FILE IN YOUR TESTLIBRARY CALLED BRUG. THIS IS THE FILE


THAT RECIEVES OUTPUT-DATA FROM THE OPNQRYF.

OUTPUT.......: DB-FILE: BRUG


FIELDS: UPUPRF 10 A
UPUID 10 P0

OPENID IN THE OPNQRYF-STATEMENT IS YOUR REFERENCE TO


THE
INTERNAL OPNQRYF-OUTPUT. USE THIS NAME AS FROM-FILE
IN THE FINAL CPYFRMQRYF WHERE YOU RETRIEVE THE
SELECTED
DATA TO A PHYSICAL FILE.

TIP..........: BE ABSOLUTELY SURE TO USE THE RIGHT NUMBER OF


QUOTES ( ' ) WHEN YOU DEFINE THE SELECT-STATEMENT.
ALL CHAR-VARIABLES IN THE OPNQRYF SELECT-LINE MUST
BE EMBEDDED IN TRIPLE-QUOTES AND *CAT:

''' *CAT &CHARVAR *CAT '''


OR
"' *CAT &CHARVAR *CAT '"

WRITTEN BY...: JENS PETER HOEJGAARD 15.04.2002


HOVEDGADEN 60
DK-8832 SKALS
DENMARK
MAIL: JEPHOJ@MAIL.DK

CHANGED BY...: JENS PETER HOEJGAARD 16.05.2002

PGM

DCL VAR(&USER) TYPE(*CHAR) LEN(10)


DCL VAR(&NR) TYPE(*DEC) LEN(10 0)
DCL VAR(&EX) TYPE(*DEC) LEN(1 0)
DCL VAR(&NRALF) TYPE(*CHAR) LEN(10)

DCL VAR(&X) TYPE(*CHAR) LEN(1) +


VALUE(' ')

DCLF FILE(QRYSLTDF) RCDFMT(*ALL)

/* THE VAR X HELPS TO LEAVE THE LIBRARY-LIST UNCHANGED */


/* WHEN THE PROGRAM HAS FINISHED PROCESSING. */

ADDLIBLE LIB(JPHLIB)
MONMSG MSGID(CPF2103) EXEC(CHGVAR VAR(&X) VALUE('X'))

/* PROMPT FOR NAME OG ID AND TYPE OF EXAMPLE */

CHOISE: SNDRCVF RCDFMT(F0)

/* QRYSLT ONLY OPERATES WITH ALFA-VARIABLES. THE NUME- */


24

/* RIC VAR. &NR IS CONVERTED TO CHAR. &NRALF */


/* USED IN SAMPLE 3. */

CHGVAR VAR(&NRALF) VALUE(&NR)

/* F3 WAS PRESSED ON THE SCREEN */

IF COND(&IN03 = '1') THEN(GOTO CMDLBL(END))

IF COND(&EX = 1) THEN(GOTO CMDLBL(ONE))


IF COND(&EX = 2) THEN(GOTO CMDLBL(TWO))
IF COND(&EX = 3) THEN(GOTO CMDLBL(THREE))

/*****************************************************************/
/* SAMPLE ONE: CHAR CONSTANT AND NUM CONSTANT */
/*****************************************************************/

ONE:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''JPH'') +
*AND +
(UPUID *EQ 338) +
') +
OPNID(BRUG)

GOTO CMDLBL(OUT)

/*****************************************************************/
/* SAMPLE TWO: CHAR VARIABLE AND NUM CONSTANT */
/*****************************************************************/

TWO:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''' *CAT &USER *CAT ''') +
*AND +
(UPUID *EQ 338) +
') +
OPNID(BRUG)

GOTO CMDLBL(OUT)

/*****************************************************************/
/* SAMPLE THREE: CHAR VARIABLE OG NUM VARIABLE. */
/* DIGITS IS A OPNQRYF KEYWORD THAT CONVERTS */
/* A FIELD FROM NUMERIC TO ALFA (CHAR.) */
/*****************************************************************/

THREE:
OPNQRYF FILE((JPHLIB/QRYSLTPF)) +
QRYSLT(' +
(UPUPRF *EQ ''' *CAT &USER *CAT ''') +
*AND +
(%DIGITS(UPUID) *EQ ''' *CAT &NRALF *CAT ''') +
') +
OPNID(BRUG)
25

GOTO CMDLBL(OUT)

/*****************************************************************/
/* MAKE A COPY OF THE OPNQRY OUTPUTFILE TO THE PF BRUG */
/*****************************************************************/

OUT: CPYFRMQRYF FROMOPNID(BRUG) TOFILE(JPHLIB/BRUG) +


MBROPT(*ADD)

CLOF OPNID(BRUG)

DLTOVR FILE(*ALL)

GOTO CMDLBL(CHOISE)

/* LIBRARY-LIST IS RESTORED */

END: IF COND(&X = ' ') THEN(RMVLIBLE LIB(JPHLIB))

RCLRSC

RETURN

ENDPGM

8. OPNQRYF and Quotation Marks

Hey, Ted:

I have to create a record selection expression for a character field


that can have values like 4" in it. When an expression like ATSIN *EQ
"4"" occurs, the Open Query File (OPNQRYF) command gives an error.

Is there a way around it?

-- Nonna

You'll have to double something in your code. In your example, you


surround the literal 4" with double quote marks ( " ). You need to
change the one double quote mark following the number 4 to two double
quote marks. Your query selection string will look like this:

ATSIN *EQ "4"""

The other way to do this is to use two single quote marks ( ' ) to
delimit the literal, like this:

ATSIN *EQ ''4"''

That's single quote single quote the numeral four a double quote single
quote single quote.
26

Here's some CL code that illustrates this concept. &DESC is the field
holding the user input. &DWORK holds the user input with doubled quote
marks.

DCL &DESC *CHAR LEN( 25)


DCL &DWORK *CHAR LEN( 50)
DCL &QRYSLT *CHAR LEN(256)
DCL &DBLQUOTE *CHAR LEN( 1) VALUE('"')

DCL &INX *DEC LEN(3 0)


DCL &OUTX *DEC LEN(3 0)

/* Get value of &DESC using some input method here */

/* Begin routine to change a double quote to two */


/* double quotes so OPNQRYF selects records properly */

CHGVAR &INX 1
CHGVAR &OUTX 1

NextChar:
CHGVAR %SST(&DWORK &OUTX 1) %SST(&DESC &INX 1)

IF (%SST(&DESC &INX 1) *EQ &DBLQUOTE) DO


CHGVAR &OUTX (&OUTX + 1)
CHGVAR %SST(&DWORK &OUTX 1) (&DBLQUOTE)
ENDDO

CHGVAR &INX (&INX + 1)


CHGVAR &OUTX (&OUTX + 1)

IF (&INX *LE 25) THEN(GOTO NextChar)

/* End routine to double quotation marks */

CHGVAR &QRYSLT VALUE('PMDESC *CT' *bcat +


&DblQuote *cat +
&DWork *tcat +
&DblQuote)

OPNQRYF FILE((PARTS)) QRYSLT(&QRYSLT)

-- Ted

OAGRPG1 :

**************************************************************
H/TITLE OAG TEST PROGRAM.
*
FOAGPF1 O E DISK
*
C Z-ADD1 COUNT 50
C COUNT DOWLE3
C MOVE COUNT SLNO
C WRITEREC1
C ADD 1 COUNT
27

C ENDDO
*
C SETON LR

9. Page by Page Build :

***************************************************************
H/TITLE OAG TEST PROGRAM
*
F*OAGPF1 IF E DISK
F* OAGPF1 KRENAMEREC1
*
C* READ REC1 90
C* MOVELSLNO SN 5
*
C* RETRN
************************************************************
FRSEDSP CF E WORKSTN
F #RRN KSFILE SFLREC
FOAGLF1 IF E K DISK
F OAGPF1 KRENAMEREC1
*
C Z-ADD*ZEROS #RRN 40
C Z-ADD*ZEROS COUNT 40
C MOVEL*BLANKS WRK 5
*
C EXSR CLEAR
C EXSR BUILD
*
C *IN03 DOWEQ*OFF
C EXFMTSFLCTL
C 03 LEAVE

C *IN09 IFEQ *ON PAGE DOWN


C SETOF 09
C 90 ITER
C Z-ADD*ZEROS #RRN
C EXSR CLEAR
C EXSR BUILD
C ITER
C ENDIF
*
C *IN10 IFEQ *ON PAGE UP
C SETOF 10
C 90 6 ADD #RRN COUNT
C N90 5 ADD #RRN COUNT
*
C *IN90 IFEQ *ON
C *HIVAL SETGTREC1
C ENDIF
*
C DO COUNT
C READPREC1 91
C *IN91 IFEQ *ON
C *LOVAL SETLLREC1
28

C LEAVE
C ENDIF
C ENDDO
C Z-ADD*ZERO #RRN
C EXSR CLEAR
C EXSR BUILD
C ITER
C ENDIF
*
C POS IFNE WRK
C POS ANDEQ*BLANKS
C EXSR CLEAR
C Z-ADD*ZEROS #RRN
C *LOVAL SETLLREC1
C EXSR BUILD
C ELSE
C MOVELPOS WRK
C EXSR CLEAR
C Z-ADD*ZEROS #RRN
C POS SETLLREC1
C EXSR BUILD
C ENDIF
*
C ENDDO
*
C SETON LR
***************************************************************
C CLEAR BEGSR
C SETON 28 C
WRITESFLCTL C SETOF
28
C ENDSR

***************************************************************
C BUILD BEGSR
C DO 5
C READ REC1 90
C 90 LEAVE
C ADD 1 #RRN C
MOVELSLNO #SLNO
C MOVELNAME #NAME
C MOVELDESC #DESC
C WRITESFLREC
C ENDDO
*
C #RRN IFGT *ZERO
C SETON 26
C ELSE
C SETOF 26
C ENDIF
C SETON 27
C ENDSR

****************************************************************

10. Procedure Basics


29

A very typical place to start with new procedures is to prototype a


system API, like the translate API. Original inline code looked like
this:

C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM TEXT
C PARM TBLNAM
C PARM LIBNAM

This code frag was in 3 places in the program: a perfect candidate for
a subroutine. There were 3 different fields being translated to upper
case: TEXT, DESC and TITLE. This meant inline code that looked like
this:

C MOVELTEXT XFIELD
C EXSR UCASE

C MOVELDESC XFIELD
C EXSR UCASE

C MOVELTITLE XFIELD
C EXSR UCASE

with a subr like:

C UCASE BEGSR
C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM XFIELD
C PARM TBLNAM
C PARM LIBNAM
C ENDSR

This subr can easily be turned into a procedure:

C CallP UCASE(Text)

* Translate lower to upper case


P UCASE B
D UCASE PI
D WorkString 50

C CALL 'QDCXLATE'
C PARM FLDLEN
C PARM WorkString
C PARM TBLNAM
C PARM LIBNAM
C Return
P UCASE E

This procedure has a problem: it isn't stand-alone because of the three


global variables FLDLEN, TBLNAM and LIBNAM. In order to use this
procedure in another program, I'd need to define and populate these
exact field names in the new program. Sounds like a perfect use for
some more parameters:
30

C CallP UCASE(Text:'QSYSTRNTBL':'QSYS')

* Translate lower to upper case


P UCASE B
D UCASE PI
D WorkString 50
D XlateTableNam 10 Value
D XlateTableLib 10 Value

D WorkStringLen S 5p 0

C Eval WorkStringLen = %len(WorkString)

C CALL 'QDCXLATE'
C PARM WorkStringLen
C PARM WorkString
C PARM XlateTableNam
C PARM XlateTableLib
C Return
P UCASE E

This is a bit better because if I decide to change the length of the


input string, I don't need to change the guts of the code - it
determines the length using the %len BIF. But still, it seems kind of
goofy to specify the translate table name for every CALLP to a
procedure named UCASE. This procedure really does the function
TRANSLATE. If I rename this one TRANSLATE, I could make a new
procedure called UCASE that will only perform the uppercase function:

C CallP UCASE(Text)

* Translate lower to upper case


P UCASE B
D UCASE PI
D WorkString 50

C CallP Translate(WorkString:'QSYSTRNTBL':'QSYS')
C Return

P UCASE E

* Translate string according to supplied table


P Translate B
D Translate PI
D WorkString 50
D XlateTableNam 10 Value
D XlateTableLib 10 Value

D WorkStringLen S 5p 0

C Eval WorkStringLen = %len(WorkString)

C CALL 'QDCXLATE'
C PARM WorkStringLen
C PARM WorkString
C PARM XlateTableNam
31

C PARM XlateTableLib
C Return
P Translate E

Difference between Procedure and Subroutine.

A procedure is encapsulated, where a subroutine is not.

That is, a procedure can see variables that it defines, but not
variables that the main program defines. This makes it a lot easier to
determine what a procedure is actually doing and where it's getting
it's return value(s).

This makes a procedure "stand alone", and can be used in other programs
with little modification (modification required for any File I/O
may be required)

It can be extremely difficult to copy a subroutine to another program,


as you have to determine all the variables the subroutine uses, and
what these are supposed to be set for, etc...

11. AS400 Questions: -

1. How can u send Parameters through LDA to another program and how
do you receive?
CHGDTAARA-CL
RCVDTARA-CL
IN and OUT in RPG

2. In P.F you are having no records and you write SFL Program. Then
how can you know that there are no records in P.F? Which make you
to show there are no records?
If the first Read returns End of file then there is no records in
the PF

3. How can u send data’s of P.F to data Queue and how to receive the
data Queue and how to copy it to your file?
Read PF
QSNDTAQ

4. Can we journel logical file and access path?


No
5. Can we use commitment control for non-join L.F?
No

6. What are the activation groups’ commands that are used?


RCLACTGRP
32

7. What is special about QTEMP library?


Specific to JOB

8. What is the purpose of QRPGOBJ library?

Library for Storing RPG Objects

9. Where is the SYS library list defined?

QSYS

10.How will you DCL a trigger in RPG?

Trigger is a Program that will execute automatically on File


Operation

11.How to call trigger?


Trigger is a Program that will execute automatically
on File Operation

12.How to lock a particular record and how to open the lock in RPG?
READ, CHAIN –To lock the record
UPDATE and DELETE for Unlock

13.Difference between RPGLE and OPM?

OPM ILE
Program Program Service program
Compilation results in a runnable Compilation results in a
program nonrunnable module object
Compile, run Compile, bind, run
Run units simulated for each Activation groups
language
Dynamic program call Dynamic program call Static
procedure call
Single-language focus Mixed-language focus
Language-specific error handling Common error handling Language-
specific error handling
OPM debuggers Source-level debugger

14.What are ARRAY mandatory key words?


DIM, if it is a compile time array then - CTDTA and PERRCD
If it is a pre run time array then we need to declare a file as
Table “T”
15.How will you override particular file during runtime?
OVRDBF
16.What is the status where copy is pending?
JOBQ
17.What are the uses of FRCDTA?
33

Use this record-level keyword to display a record format


immediately, without waiting for the next input or input/output
operation. When the buffer is partially full, the FRCDTA
keyword can be used to clear the buffer.

18.What are runtime API in RPG?


QCMDEXC, QRCVDTAQ, QSNDDTAQ, QCLRDTAQ.

19.How to define multidimensional array?


Declare a Multi occurrence data structure and declare the array
within the data structure.

20.How do you retrieve the job name from batch job currently running
in the system and the library of that job from the group data
area?

21.How will you change the printer files to different language with
out changing the code or without using additional parameters?

22.How to make display the 5th member as default in RPG program?


OVRDBF
23.Why cannot we update using Join-Logical file?

24.How to update a file without using file opcodes?


RPG Life Cycle

25.How to display a screen without using EXFMT?


WRITE
READ
26.What is API’s in Data Queue?
QSNDDTAQ
QRCVDTAQ
QCLRDTAQ

12. Design Report

RLU is used to design a report image, print prototype reports, create


printer files, and generate DDS from which the report will be created.
A prototype report is a printed copy of the report image that looks
like the report that an application program will generate.

The Design Report display is the main screen from which you edit the
report. From this display you can use function keys to go to other
displays where you can add information at the file, record and field
levels. You can also go to the Change Session Defaults display
where you can control the characteristics of your edit session.

There are two ways to print your prototype report. When you start
RLU you can specify option 6 to print from the STRRLU display. From
within the session you can specify that you want to print from the
Exit RLU display. On the Exit display choose Y=Yes for the
Prototype report prompt and the report will be printed.

There are a few things you should keep in mind during your RLU
session:
34

o Once the DDS source has been coded for your report you can edit
the image using the field line, the mark function keys that allow
you to move and copy fields and data, and the other function keys
that bring up displays that will help you edit your report.

o You must define a record format prior to defining fields. You


can use the DR command to do this.

o Ensure that all fields for a record are defined. You can use the
DF (define field) command to do this or you can define fields on the
Define Field Information display. To get to the Define Field
Information display press F11 when your cursor is not on an existing
field.

o To show overlapping fields or fields which are conditioned off,


use the VF command. This will display the field line or
multiple field lines for the line.

o You can merge records by using the CL (change line type)


command.

o There are two sets of function keys in RLU. There is a base set
and an alternate set. You can toggle between the two sets using
F22. The base function keys are RLU specific. You use them to edit
the report you are working on, and to access the other RLU displays.
The alternate function keys are more general than the base set. They
are based on the function keys for the Edit display in SEU. When the
base function keys are active, you see BASE to the left of the format
line. This is the third line from the top of the display that marks
the columns across the display. When the alternate function keys
are active, you see ALT.

o You should not move fields to filler lines. If you do, everything
you have defined for the field will be lost.

o There is a command line at the top of the Design Report display


that you can use to enter commands specific to your RLU session. You
can enter system commands by pressing F21 in the alternate set of
function keys. A system command line will appear on the display.

Columns

This field displays which columns are currently visible on the


display. The first number in this field represents the first column
of the report line that is shown. The second number represents the
last column that is shown.

Library/Source file

The name of the library and the source file containing the report
you are editing.

Command line

RLU commands provide a shortcut to the functions on the Find/Change


Options, Find Options, Exit, and Change Session Defaults displays
35

without leaving the work screen. RLU commands are free format
commands. The command parameters are either required and
positional, or optional, and they can be entered in any order.

To run an RLU command, type it on the command line and press a


positional function key: for example, Enter, Roll Up or Down,
F19=Left, F20=Right.

Some commands have abbreviations: for example, you can enter F or FIND
to run the FIND command. To retrieve the last command you entered,
type F9=Retrieve. If the cursor is in the data area, you can use
F10=Cursor to move the cursor back and forth between the data area
and the command line. RLU remembers up to 50 commands.
To see help for an RLU command, type the command on the command line
and press the Help key.

Note: You cannot enter system commands on the command line, but you
can enter a system command on the work screen by pressing F21=System
command. A window appears where you can enter a system command.

You can enter the following RLU commands on any command line on the
work screen (Edit, Browse or Split displays):
o FIND or F

o CHANGE or C
o SAVE
o CANCEL or CAN
o FILE
o TOP
o BOTTOM
o SET or S
o HIDE or H

Note: FILE, SAVE, and CHANGE commands can only be used in an Edit
session or in the top session of a Split Edit/Browse display.

The SET command has these options:

o MATCH
o CAPS
o TABS
o ROLL
o EXPERT
o SHIFT

Note: The SHIFT and TABS options can only be used in an Edit session
or in the top session of a Split dit/Browse display.

Report

The name of the report you are editing.

Active keys

BASE indicates that the base function keys are active. ALT indicates
that the alternate keys are active.
Format line
36

The ruled line at the top of the display.

Line control area

The area on the display consisting of line numbers and record format
names. You can enter line commands in this area.

The following line commands are available in RLU, in addition to most


SEU line commands:

o Define Record Format (DR)


o Change Line Type (CL)
o Create Sample Data (SD)
o View Field Line (VF)
o New Page (NP)
o Define Constants (DC)
o Define Fields (DF)
o Center Fields (CF)
o Space Fields Evenly (SP)

Work area
The work area for the report you are designing or editing. This
area consists of the following three types of lines:

Report line
A report line is any line of the report that is part of a record
format. Report lines are involved in DDS source generation.
The first report line in a record format is indicated by an R in the
line number area. Subsequent report lines, which are called
continuation lines, are indicated with a + in the line number area.

Sample line
A sample line is a line used to make the report you are editing look
more like the final report. Sample lines contain sample data that
is associated with the preceding record format. The first sample
line in a group of sample lines is indicated by an S in the line
number area. Subsequent sample lines, which are called continuation
lines, are indicated by a + sign in the line number area. These lines
are not involved in DDS source generation.

Filler line
Filler lines are lines that separate one record format from
another. They are indicated by a . (period) in the line number area.
Filler lines are involved in DDS source generation.

Field Line
A field line is a temporary record that may be displayed above the
report line and is denoted by FLDn in the sequence number area,
where n=1, 2, or 3. The field line indicates field boundaries
within the record, allows editing of fields in the record, and
accepts certain commands to facilitate field generation.

F1=Help
Press F1 for additional help about using the display.

F3=Exit
37

Press F3 to go to the Exit RLU display.

F4=Fields
Press F4 to work with a list of the fields within a DDS record format.

F5=Refresh
Press F5 to restore all entries to what they were initially.

F6=Condition display
Press F6 to go to the Condition Design Report display to set
indicators on or off to condition the fields and keywords and how
they are displayed on the work screen.

F9=Retrieve
Press F9 to retrieve the last command entered.

F10=Database fields
Press F10 to go to the Work with Database Fields display where you
can build a list of database fields to display at the bottom of the
work display for inclusion in the report.

F11=Define field
Press F11 when the cursor is not on an existing field and the Define
Field Information display appears where you can create a new field.

F12=Cancel
Press F12 to cancel the Split Edit/Browse or Split Edit/Prompt
session. You will return to a single Design Report session.

F13=Mark/Unmark data
Press F13 to mark a character, field, or block of text to be
copied or moved. If something has been marked, and you move the
cursor to another area and press F13 again, the new area will be
highlighted along with the first area you highlighted. Now you
can use F14 to copy the data to the new marked area, or F15 to move
the data to the new marked area. If you press F13 again with your
cursor on the marked area the marked text will be unmarked. You
can change the way a move or copy is performed by going to the Change
Session Defaults display.

F14=Copy marked data


Press F14 to copy a marked area to another area. Your cursor should
be in the top left corner of the area you are copying to when you
press F14.

F15=Move marked data


Press F15 to move a marked area to another area. Place your
cursor in the top left corner of the area you are moving the marked
data to and press F15.

F16=Delete field
Press F16 on a field line, report line, or sample line to delete the
field's text and the associated sample data, as well as all
associated field level information from the Design Report display.

F17=File keywords
38

Press F17 to go to the Work with File Keywords display, where you
can change the file level definition. If you used the Input Keywords
display the last time you worked with keywords then the Input File
Keywords display will appear when you press F17.

F18=Record keywords
Press F18 on a report line or sample line to go to the Work with
Record Keywords display. If you used the Input Keywords display the
last time you worked with keywords then the Input Record Keywords
display will appear when you press F18.

F19=Left
Press F19 to move the record area to the left on the display.

F20=Right
Press F20 to move the record area to the right on the display.

F21=System command
Press F21 to display an entry window where you can input system
commands.

F22=Alternative keys
Press F22 to display the alternative set of function keys.

F23=Field keywords
Press F23 with the cursor on an existing field and the Work with
Field Keywords display appears where you can change field
definitions. If you used the Input Keywords display the last time
you worked with keywords then the Input Field Keywords display
will appear when you press F23.

F24=More keys
Press F24 to view the other function keys available.

13. System Development Life Cycle Model

This is also known as Classic Life Cycle Model (or) Linear Sequential
Model (or) Waterfall Method. This has the following activities.
1. System/Information Engineering and Modeling
2. Software Requirements Analysis
3. Systems Analysis and Design
4. Code Generation
5. Testing
6. Maintenance
System/Information Engineering and Modeling
As software is always of a large system (or business), work begins by
establishing requirements for all system elements and then allocating
some subset of these requirements to software. This system view is
essential when software must interface with other elements such as
hardware, people and other resources. System is the basic and very
critical requirement for the existence of software in any entity. So if
39

the system is not in place, the system should be engineered and put in
place. In some cases to extract the maximum output, system should be
re-engineered and spiced up. Once the ideal system is engineered or
tuned up, the development team studies the software requirement for the
system.
Software Requirements Analysis
This is also known as feasibility study. In this phase, the development
team visits the customer and studies their system. They investigate the
need for possible software automation in the given system. By the end
of the feasibility study, the team furnishes a document that holds the
different specific recommendations for the candidate system. It also
includes the personnel assignments, costs, project schedule, and target
dates. The requirements gathering process is intensified and focussed
specially on software. To understand the nature of the program(s) to be
built, the system engineer ("analyst") must understand the information
domain for the software, as well as required function, behavior,
performance and interfacing. The essential purpose of this phase is to
find the need and to define the problem that needs to be solved .
System Analysis and Design
In this phase, the software's overall structure and its nuances are
defined. In terms of the client/server technology, the number of tiers
needed for the package architecture, the database design, the data
structure design etc are all defined in this phase. Analysis and Design
are very crucial in the whole development cycle. Any glitch in the
design phase could be very expensive to solve in the later stage of the
software development. Much care is taken during this phase. The logical
system of the product is developed in this phase.
Outsource your Software and Web Development Projects to Stylus
We've been in the business of Internet applications for the
past four years and our services include Internet solutions,
custom software development, web design and web application
development, web enabling legacy systems, technical support
and maintenance of web applications.
Our Value Proposition - our development methodology, our
project management skills and adherence to high- quality and
low risk solutions. Contact us here if you are interested in
outsourcing projects to Stylus.

Code Generation
The design must be translated into a machine-readable form. The code
generation step performs this task. If design is performed in a
detailed manner, code generation can be accomplished with out much
complication. Programming tools like Compilers, Interpreters, Debuggers
are used to generate the code. Different high level programming
languages like C, C++, Pascal, Java are used for coding. With respect
to the type of application, the right programming language is chosen.
Testing
Once the code is generated, the program testing begins. Different
testing methodologies are available to unravel the bugs that were
committed during the previous phases. Different testing tools and
methodologies are already available. Some companies build there own
40

testing tools that are tailor made for there own development
operations.
Maintenance
Software will definitely undergo change once it is delivered to the
customer. There are many reasons for the change. Change could happen
because of some unexpected input values into the system. In addition,
the changes in the system could directly affect the software
operations. The software should be developed to accommodate changes
that could happen during the post implementation period.

14. The OPENQRY file:

The Open Query File (OPNQRYF) command is a CL command that allows you
to perform many data processing functions on database files.
Essentially, the OPNQRYF command acts as a filter between the
processing program and the database records. The database file can be a
physical or logical file.

Unlike a database file created with the Create Physical File (CRTPF)
command or the Create Logical File (CRTLF) command, the OPNQRYF command
creates only a temporary file for processing the data, it does not
create a permanent file.

To understand the OPNQRYF command support, you should already be


familiar with database concepts such as physical and logical files, key
fields, record formats, and join logical files.

The OPNQRYF command has functions similar to those in DDS, and the
CRTPF and CRTLF commands. DDS requires source statements and a separate
step to create the file. OPNQRYF allows a dynamic definition without
using DDS. The OPNQRYF command does not support all of the DDS
functions, but it supports significant functions that go beyond the
capabilities of DDS.

In addition, Query/400 can be used to perform some of the function the


OPNQRYF command performs. However, the OPNQRYF command is more useful
as a programmer's tool.

The OPNQRYF command parameters also have many functions similar to the
SQL SELECT statements. For example, the FILE parameter is similar to
the SQL FROM statement, the QRYSLT parameter is similar to the SQL
WHERE statement, the GRPFLD parameter is similar to the SQL GROUP BY
statement, and the GRPSLT parameter is similar to the SQL HAVING
statement. For more information about SQL, see DB2 UDB for AS/400 SQL
Programming Concepts .

The following is a list of the major functions supplied by OPNQRYF.


Each of these functions is described later in this section.

• Dynamic record selection


• Dynamic keyed sequence access path
41

• Dynamic keyed sequence access path over a join


• Dynamic join
• Handling missing records in secondary join files
• Unique-key processing
• Mapped field definitions
• Group processing
• Final total-only processing
• Improving performance
• Open Query Identifier (ID)
• Sort sequence processing

To understand the OPNQRYF command, you must be familiar with its two
processing approaches: using a format in the file, and using a file
with a different format. The typical use of the OPNQRYF command is to
select, arrange, and format the data so it can be read sequentially by
your high-level language program.

See the CL Reference for OPNQRYF command syntax and parameter


descriptions.

CRTPF QTEMP/TEST RCDLEN(198)


CPYFRMSTMF FROMSTMF('/QOPT/26600/README.TXT')
TOMBR('/QSYS.LIB/QTEMP.LIB/TEST.FILE/TEST.MBR')
MBROPT(*REPLACE)
CVTDTA(*AUTO)
ENDLINFMT(*FIXED)
TABEXPN(*NO)
DSPPFM QTEMP/TEST

http://mcpressonline.com/mc?224@164.jLqjbD6xxde.0@b4a97@.214a2c4d

Function to center a field.


$GetComNam b
D $GetComNam pi 30a
D LenStr s 3 0 inz(0)
D ComNum s 3 0 inz(1)
D ComNam s 30 inz(*blanks)
D TmpComNam s 30 inz(*blanks)
*
C if not %open(CCFILEL)
C open CCFILEL
C endif
*
C eval ComNum = 001.
C ComNum Chain CCFILEL
C if %found(CCFILEL)
C eval TmpComNam = %trim(CCCONM)
C endif
*
C if %open(CCFILEL)
C close CCFILEL
C endif
42

*
C eval LenStr = ((%len(TmpComNam) -
C %len(%trim(TmpComNam))) / 2) + 1
C eval %subst(ComNam:LenStr) =
%trim(TmpComNam)
*
C return ComNam
*
P$GetComNam e

Create user space

* Standard API error data structure


d ErrorDs DS INZ
d BytesProvd 1 4B 0 inz(116)
d BytesAvail 5 8B 0
d MessageId 9 15
d Err### 16 16
d Message 17 116
* Name and location of the Output Queue
d UserSpace DS
d QSName 10 Inz('SPOOL1')
d QSLibrary 10 Inz('QTEMP')

* Create the user space

c CALL 'QUSCRTUS'
c PARM UserSpace
c PARM *BLANKS SpaceAttr 10
c PARM 4096 SpaceLen
c PARM *BLANKS SpaceVal 1
c PARM '*CHANGE' SpaceAuth 10
c PARM *BLANKS SpaceText 50
c PARM '*YES' SpaceRepl 10
c PARM ErrorDs

To find the position of the cursor on the display file.

File info DS for the DSPF


D DSPFInfo DS
D LinPos# 370 371B 0
D RequestDev 197 206
D SaveLin# S 3 0
D SavePos# S 3 0

Select
When i_cmd ='SAVE'
Eval SaveLin#=LinPos#/256
Eval SavePos#=LinPos#-(SaveLin#*256)
When i_cmd ='SET '
Eval S0Lin#= SaveLin#
Eval S0Pos#= SavePos#
When i_cmd ='CLEAR'
Eval S0Lin#= *zero
Eval S0Pos#= *zero
43

Other

15. Questions Bank:

AS/400 SYSTEM

QS30001 What is the Configuration of the AS/400 system on which you


have worked?
AS30001 System E35(Model 9406), 24MB main memory, 3.2GB of HD and
supports 49 terminals (7 Port).

QO20002 How many terminals can be connected to a port?


AO20002 7 terminals

QS20003 What do the terms CUA and SAA stand for?


AS20003 Common User Access Systems Application Architecture

QL40004 What are the communication protocols supported by AS/400?


AL40004 APPC (Advanced Program to Program Communication) BSCEL
(Binary Synchronous Link)
ASYNCH (Asynchronous Communication)
RETAIL
TCP IP
FINANCE
SNUF SNA Upline facility
INTRA Intrasystem communication.

QS30005 What are the different ways of connecting a terminal to a


system?
AS30005 Twinnax, Workstation, ASCII and OS/2 Workstation.

QL30006 Why AS/400 is called an Object Oriented Machine?


AL30006 Everything on the AS/400 system that can be stored or
retrieved is contained in an Object. Object exist to make
users independent of the implementation techniques used in the
machine.

QS30007 What is SAA ?


AS30007 Systems Application Architecture (SAA) is a collection of
selected software
Interfaces, Conventions and Protocols that will provide a
consistent framework
across the System/370, AS/400 and PS/2.

QS30008 What are the different AS/400 rack models supplied by IBM?
AS30008 9402, 9404 and 9406.
44

QL10009 What are the different high-level languages available on


AS/400?
AL10009 RPG/400, CL/400, BASIC, PL/1, C/400, PASCAL, FORTRAN/400
and RM/COBOL-85, COBOL/400 etc..

Q1S2001 What are all the IBM Mid range machines prior to AS/400?
A1S2001 S/38, S/36, S/34, S/32 &S/3.

Q1O2002 What is the Operating System on AS/400?


A1O2002 OS/400.

Q1S2003 What are office tasks available on AS/400?


A1S2003 Office Vision/400 & PC Support/400.

Q1S2004 What are the graphic utilities available on AS/400?


A1S2004 BGU & GDDM.
OS/400

QO20010 What is the version of OS/400 that you have used?


AO20010 Ver 2.2

QS40011 What is DDM ?


AS40011 Distributed Data Management is a function of the OS/400
that allows an application program or user on one system to
use database files stored on remote system.

QS30012 What are the facilities available on AS/400 for self-learning?


AS30012 on-line education, Q&A Database and Help.

QS20013 What is an Object?


AS20013 An object is any thing that exist in and occupies space in
storage and on which operation can be performed.

QS20014 What are the different types of Objects available in the


AS/400?
AS20014 Libraries, Folders, Files, Programs, Combined definitions,
Queues, User Profiles.

QL50015 How are the objects stored in AS/400?


AL50015 All objects are stored on AS/400 in a single level storage.
In this
method all objects are referenced by one virtual address which is
translated into a physical address whether it is an auxiliary
storage or main memory.

QS30016 What is a library in AS/400?


AS30016 A library in AS/400 is an object that serves as a
repository for other objects.

QS20017 Name few IBM supplied libraries?


AS20017 QGPL, QTEMP, QUSRTOOL, QSYS, QRPG & QCBL.

QS10018 What is a library list?


AS10018 A list that indicates libraries used for the process and
the order in which it has to be searched. System identifies it in
*LIBL.
45

QO30019 How many libraries can be there in a library list?


AO30019 Total 40 (15 system and 25 application).

QO30020 Where is the system part of the library list stored?


AO30020 In SYSVAL

QS40021 What is a Folder?


AS40021 A Folder is a named object that is used as a directory for
documents and other
folders. Folders can be filed with in another folder.

QS20022 What are the different Application Development Tools


available on AS/400?
AS20022 SEU, RLU, PDM, SDA, QUERY

QO30023 What are the levels of security on AS/400?


AO30023 10,20,30,40,50

QS30024 What is error severity?


AS30024 Error severity determines the level of severity that is
required to terminate the job.

QL50025 What is a User Profile? What are the various classes?


AL50025User profile is an object which identifies a user to the system.
It contains user
name, Password, Owned objects, Authorized objects, Scheduling
priority, Special
authority, Initial program Job description.
Security officer, Programmer, Workstation, System operator,
Programmer services Rep & Customer engineer.

QS40026 What is Group Profile?


AS40026 It is similar to User Profile, but the attributes specified
is applicable to an entire group.

QS20027 What are the different types of queues in AS/400?


AS20027 Job queue, Message queue, Output queue, Data queue.

QL20028 What are JobQ and PrintQ ?


AL20028 JobQ : An object that contains a list of batch jobs
waiting to be processed by the system.
PrintQ: An object that contains a list of spool files to be
written to a printer device.

QL20029 What is a Spool file? Why is it required?


AL20029 A file that holds output data to be processed, such as
information waiting to be printed.

QL30030 What is a Job? What are the attributes of a job?


AL30030 A job is the basic unit of work on AS/400
The attributes are:
Job Number: Unique system generated sequential number
Job Name : Any user defined name (Max. 10 char)
User Name: Who initiated the job?

QS20031 What is job description?


46

AS20031 A job description defines the environment in which a


batch/interactive job is to be executed.

QL20032 What is the difference between Interactive & Batch job?


AL20032 Interactive Job: Job started for a person who signon to a
workstation.
Batch Job: A predefined group of processing actions submitted to
the system to be performed.

QL30033 What is a Group Job?


AL30033A Group Job is attached to one workstation and a user. There
should be an initial
group job and it can be branched to many other group jobs. The
group jobs can have
different library lists and different output, message queues.
Group Job is useful
in enhancing the programmer’s productivity. It is as though
logging into the same
user-id many times.

QO20034 What are the two main attributes which govern the execution
of a job?
AO20034 Run time priority and Time slice.

QL20035 What is a sub-system?


AL20035 Sub-Systems are specific user defined partitions of the CPU
where various jobs may be executed. One subsystem can have more
than one active job at a time.

QL20036 What is a device file?


AL20036 A device file contains the description of how data is to be
presented to a
program from a device or vice versa. Device file can be Printer,
Disk, Tape or
Remote system.

QS30037 What is an ICF file?


AS30037 A device file that allows a program on the system to
communicate with program in
other system.

QS30038 What is a message file?


AS30038 It is a file which contains the messages of an application.
For example all RPG/400 messages are stored in a file; all
COBOL/400 messages are stored in a file.

QL30039 What is a job log?


AL30039 A record of request submitted to system is a job. The
message related to the requests, and the action performed by the
system on the log. It is maintained by the system program

QL20040 What is the purpose of OPNQRYF (Open Query File)?


AL20040 OPNQRYF is used to select certain records of the database
file based on the QRYSLT (Query select) condition.

QS10041 How do you create files dynamically without DDS?


AS10041 through OPNQRY.
47

QO10042 What command must be executed before executing OPNQRYF


command?
AO10042 OVRDBF.

QL30043 What is a data area?


AL30043 A data area is an object used to hold data for access by
any job running on the system.
A data area can be locked to a single user, thus preventing other
users from processing at the same time.

QS20044 What are the types of data areas?


AS20044User defined Data Area, Local Data Area (LDA), Group Data Area
(GDA), and Program
Initialization Parameter (PIP) Data Area.

QS20045 What is LDA?


AS20045 An LDA is created by the system for each job in the system,
including autostart jobs, jobs started on the system by a reader,
and subsystem monitor jobs.

QS10046 What is the type and length of an LDA?


AS10046 *CHAR, 1024 bytes.

QS20047 What is GDA?


AS20047The system creates a GDA when an interactive job becomes group
jobs.Only one GDA
can exist for a group.

QS10048 How can you create a user defined data area?


AS10048 Using CRTDTAARA command.

QS10049 What are the different ways to input data into a data area?
AS10049 CHGDTAARA (using CL)
Using OUT opcode in RPG

QS10050 How do you retrieve data from data area?


AS10050 Using RTVDTAARA command in CL Using IN opcode in RPG.

QS10051 What are the valid user defined data area types?
AS10051 CHAR, NUMARIC and LOGICAL.

QS20052 How can a data area are locked after being updated?
AS20052 Using OUT *LOCK.

QS20053 what is the use of data queues?


AS20053 Data queue is a type of system object that you can create.
Data queues are used in program to program communication.

QO10054 How do you create data queues?


AO10054 Using CRTDTAQ command.

QS10055 What are the valid data types for a data queue?
AS10055 Char, Numeric, and Logical.

QS20056 What are the two types of read performed on data queues ?
AS20056 Read with lock, and read without lock.
48

QS20057 How do you use DEBUG utility ?


AS20057 STRDBG program-name UPDPROD(*YES)

QS30058 What is an authorization list ?


AS30058 A list of two or more user Ids & their authorities for
system resources. The system identifies it as an object
type *AUTL.

QO10059 How do you grant authority for an object?


AO10059 Using GRTOBJAUT command.

QL30060 What are the types of object authorities ?


AL30060 *USE, *CHANGE, *ALL, *EXCLUDE, *AUTL, *OBJEXIST, *OBJMGT,
*OBJOPR, *ADD, *DLT, *READ, *UPD.

QO20061 How do you execute jobs in batch mode?


AO20061 SBMJOB

QL40062 What is the use of OVRDBF ?


AL40062 You can use the Override with Database file (OVRDBF)
command to replace the database file named in a CL program or to
change certain parameters of the existing database file.

QL30063 What is the use of OVRPRTF ?


AL30063 Override with Printer file (OVRPRTF) command is used to
override certain parameters of the printer files used in the
program or to replace the printer file.

QO30064 How do you change file attributes such as size, file wait
time, record wait time etc., permanently ?
AO30064 Using CHGPF command.

QO10065 What is the purpose of CRTCMD ?


AO10065 To create user defined command.

QS30066 What is class of service ?


AS30066 A set of link and node characteristics associated with a
session.

QO10067How to see active jobs of the system ?


AO10067 Using WRKACTJOB command.

QS30068 How do you detect unused spool storage ?


AS30068 Using Reclaim Spool Storage.

QS50069 What are the functions of Remote Job Entry (RJE) ?


AS50069 Allows user of AS/400 system to submit jobs and receive
jobs from a host system.

QL50070 What is the function of RJE Conversion Utility ?


AL50070It converts compressed data written to an AS/400 database file
to decompressed
data written to another AS/400 database, diskette, or device file.

QS40071 What is the function of the SBMRJEJOB command?


AS40071 Sends RJE input stream to host system.
49

QL40072 What is journaling and commitment control?


AL40072 Journaling is a function which records the changes in a
file in a journal. These record images are used to recover the
changes in the file should the system ends abnormally. Commitment
control is a function that allows you to define and process a no
of changes to database files as a single unit (transaction).

QS30073 What is the purpose of STRCMTCTL command ?


AS30073 Starts commitment control for files that are being journal
led.

QS40074 What are the system objects required for journaling?


AS40074 Journal receiver, journal and PFs to be journal led.

Q2S4001 What is CPF ?


A2S4001 Control Program Facility (CPF) is an operating system on
S/38.

Q2S4002 What is invocation stack ?


A2S4002List of programs maintained by the system as one program calls
another in a series
of calls within a single task or job.

Q2S3003 What is time slice ?


A2S3003A finite amount of time in which a job is granted system
resources while other
jobs are queued.

Q2S4004 What is IPL ?


A2S4004Initial Program Loading (IPL) is run by OS/400 when the system
is started.

Q2S3005 What does V2R2M0 mean ?


A2S3005Ver. 2, Release 2 & Modification level 0. This refers to the
version of OS/400.

Q2S3006 Name the commands used to duplicate a file?


A2S3006CPYF - Copy File & CRTDUPOBJ - Create Duplicate Object.

Q2S3007 Name the command for changing the attributes of a spool


file?
A2S3007CHGSPLFA - Change Spool file Attributes.

Q2S3008 Name the command which gives the attributes of a job ?


A2S3008RTVJOBA - Retrieve Job Attributes.

Q2S2009 What is the function of PDM ?


A2S2009Productivity tool for copying, deleting, scanning, changing &
creating source
files.

Q2S2010 What is the function of SEU ?


A2S2010A utility for editing programming language source code.
50

DATABASE FILES

QL30075 What are the different definition levels in Data


Description specifications ?
AL30075 File level, Record level, Field level, Join level, Keyfield
level, Select/Omit level.

QL30076 What is difference between Source Physical File and


Physical File ?
AL30076 A Source Physical File contains the source for the various
objectscreated. This file has a specific structure. A Physical
File contains data, and the record format can be different for
different physical files.

QS20077 What is the difference between Physical and Logical files ?


AS20077 Physical file contains data, where as Logical file serves as a
access path
to database.

QS20078 What is an access path ?


AS20078 The order in which the database fields are organized for
processing in the program.

QS30079 What are all the different types of access paths ?


AS30079 Arrival sequence access path, Keyed sequence access path.

QS30080 How many record formats can you have in a Physical file and
in a Logical file ?
AS30080 Physical file can contain only one record format, Logical
file can contain more than one record format.

QS20081 What is a field reference file ?


AS20081 A field reference file is a physical file which contains no
data, contains field description. this is used as a reference
file by other physical files.

QO20082 What is the default value for the number of increments for
the physicalfile ?
AO20082 Three.

QS10083 When is the DFT keyword in PF used for?


AS10083 To specify the default value it a field.

QS20084What is Multi-format logical file ?


AS20084 Logical which uses fields from two or more physical files.

QL30085 What is dynamic select ?


AL30085 Selection and omission of LF records performed during
processing, instead of
access path is maintained. This can be used when key access path
does not exist.
QL20086 What is the Select and Omit criteria in logical file ?
51

AL20086 This is used to specify rules for the Selection/Omission of


records from a Physical File.

QS20087 Can fields be concatenated at the logical file level ?


AS20087 Yes, by using CONCAT keyword.

QS30088 When would the ALL keyword be used ?


AS30088 Use with Select or Omit, to select/omit records.

QS30089 What is a Join Logical File, Can it be used for Update ?


AS30089 Logical file that combines more than one physical
file.Update is not possible through JLF.

QL30090 How many files can be joined at a time, What is the max.
no. of files ?
AL30090 At a time you can join two files. The max. no. of files is
32.Only one primary
file and the remaining are secondary files, The primary file and
at least one secondary file must be physical files.

QO20091 Is it possible to join the same file to itself ?


AO20091 Yes.

QS10092 What is FCFO, FIFO, LIFO in Database environment ?


AS10092These are file level keywords which are used to access the
records in the order
FCFO : First Changed First Out
FIFO : First In First Out
LIFO : Last In Fist Out

QL40093If a file layout is changed, how do you generate new PF and


retain data?
AL40093Copy the file and change the structure of Physical file, later
copy old file with
drop option.

QS50094 What is the overhead on logical file ? How can it be


improved ?
AS50094 Maintaining access path and storage space. We can improve
the performance by using *DELAYED, *REBUILD keywords to enhance the
speed.

QS40095 How can the sign of a numeric be ignored when sequencing a


logical file ?
AS40095 By specifying the record level keyword UNSIGNED.

QS40096 If a field references a field that has an EDTCDE or an EDTWRD


keyword specified,
can the EDTCDE or EDTWRD from the referenced field ignored ?
AS40096 Yes, by using DLTEDT keyword.

Q3S2001 What does the keyword UNIQUE mean ?


A3S2001Records with duplicate key values are not allowed.

Q3S4002 State three different methods of maintaining access paths ?


A3S4002Immediate, Rebuild & Delay.
52

DISPLAY FILES

QS20097 What are the different types of keywords in display files ?


AS20097 File level, Record format level, Field level.

QO30098 What is the maximum number of records you can specify in a


display file ?
AO30098 1024.

QS40099 How can a screen field that has changed since the last
output operation be detected ?
AS40099 Attach the MDT attribute to the field, to detect whether
field has been changed as a result of user input.

QS50100 What would be the effect on the field where reverse image,
underline and highlight display attributes are active ?
AS50100 The result is same as if you had specified ND.

QL40101 What is the use of DSPATR(MDT) keyword ?


AL40101 Sets on the modified Data Tag of the field. This Data Tag
detects whether the field has been changed as a result of user
input.

QO30102 If DSPATR(PC) and CSRLOC were specified for a format, which


keyword would have priority ?
A030102 CSRLOC gains priority.

QS40103 Can error messages as a result of a COMP, RANGE or VALUES


keyword be overridden ?
AS40103 Yes, through CHKMSGID keyword.

QL40104 What is the purpose of OVRDTA and OVRATA keywords ?


AL40104 OVRDTA keyword (field or record level) can be used to
override the existing data contents of a field or record already
on the display. OVRATA keyword (field or record level) can be
used to override the existing display attributes of a field or
record already on the display.

QS30105 How can a message from a message file appear as a constant


on the screen ?
AS30105 By using MSGCON (message constant) keyword.

QS30106In conjunction with what other keyword must OVRDTA and OVRATA be
used ?
AS30106 PUTOVR keyword must be used.

QS50107 How can a field that is larger than what could fit onto one
line be truncated from the last blank rather than from the
last character position?
AS50107 Using BLKFOLD keyword.

QS40108 What is the purpose of the INDARA keyword ?


AS40108This File-level keyword is used to remove option and response
indicators from the
buffer and places them in 99-byte separate indicator area.
53

QL40109 Explain the purpose of KEEP and ASSUME keywords ?


AL40109 KEEP : Keep the display from being deleted when the display
file is closed.
ASSUME : It is used to specify that the OS/400 program is to
assume that this record is already shown on the display when this
file is opened.

QS30110Explain the use of DFRWRT display keyword ?


AS30110 No records will be displayed until there is an I/O
operation.

QS30111 What is the purpose of FRCDTA keyword ?


AS30111 Immediately display a record format without waiting for the
next I/O operation.

QS10112 What keyword must be used with PROTECT keyword ?


AS10112 OVERLAY

QS30113 Where is the variable for the SLNO(*VAR) keyword be defined


?
AS30113 At run time before displaying the record format.

QS50114Under what conditions would a field where the ERRMSG keyword was
active would
not be displayed in reverse image ?
AS50114 If it is an output-only field or input capable field with
display attributes UL, HI are active.

QS50115 When will the message for field that has the ERRMSG keyword
active not be displayed ?
AS50115 If more than one ERRMSG keywords are active then the first
will be active, because only one error message will be
displayed at a time.

QL50116 What is CHGINPDFT keyword, and what will be the effect if


you define this keyword at file with out any parameter values ?

AL50116 This file, record or field level keyword is used to change


one or more input defaults for input capable fields. If you
define this keyword at file level without any parameter then the
underline will be suppressed.

QS30117 In what case control will be passed back to the program


when the last character of the field is keyed ?
AS30117 CHECK(ER) ER - End of Record.

SUBFILES :

QL10118 What is a subfile ?


AL10118 Subfile is a group of records of same record format and can
be read from or write to the display in a single operation.

QL30119 What are the contents of subfile ?


54

AL30119 Subfile Record Format, Subfile Control Record Format,


Relative Record Number, Subfile Record Number, Associated Subfile
Keywords.

QS20120 What are the two record formats that a subfile contains ?
AS20120Subfile record format(SFL), and subfile control record
format(SFLCTL).

QL30121 What is SFLPAG and SFLSIZ ?


AL30121 SFLPAG : it is an attribute which specifies the number of
records that can be displayed in a screen.
SFLSIZ : it is an attribute which specifies the number of
records can be stored in the subfile.

QO30122What is the maximum number of subfiles that can specified in a


display file ?
AO30122 512

QO30123 The maximum number of subfiles that can defined in a RPG


program for one display file is ___ .
AO30123 24

QO30124 The maximum number of subfiles that can be active for a


single file is____ .
AO30124 12

QL20125 What are the different opcodes used for file operation on a
subfile in a RPG Program ?
AL20125READ, READC, CHAIN,UPDAT and WRITE

QS30126 Can more than one subfile record be displayed on one line ?
AS30126 Yes, by using SFLLIN keyword.

QS30127 How do you specify the number of records to roll in a


subfile ?
AS30127 Use SFLROLVAL keyword in DDS along with the number, which
specifies the number of records to scroll at a time.

QL30128 How will you display a particular page in subfile ?


AL30128 Move a valid relative record number(RRN) in the field
specified using SFLRCDNBR keyword in DDS.

QS30129 How to pick up the changed records every time in a subfile


after the first change made ?
AS30129 Seton SFLNXTCHG keyword indicator and update the subfile
record.

QS30130 What is the use of the SFLEND keyword ?


AS30130 By specifying this keyword, the Bottom/More message could
be displayed at end of screen.

QS30131 How do you toggle between single line and multi-line


display of a particular record in a subfile ?
AS30131 Using SFLDROP keyword.

QL40132 Explain the difference between defining Subfile and


Message-subfile ?
55

AL40132 A subfile record is defined by SFL keyword, whereas a


message subfile is defined by SFLMSG keyword.

QO30133 Can a single screen format occupy a screen area above and
below a subfile format ?
AO30133 Not possible.

QS50134 How can a program be prevented from failing over when READC
is performed on an empty subfile ?
AS50134 Check indicator placed in position LO, which will be seton
if EOF if reached.

CONTROL LANGUAGE (CL/400)

QO10135How to start a CL program ?


AO10135 PGM.

QO20136 How many files can be declared in CL ?


AO20136 One.

QO30137 Which precedes, the file declaration or variable


declaration ?
AO30137 Variable declaration and then File declaration.

QS10138 What are the different types of variables available in CL ?


AS10138 DEC, CHAR, LGL

QO10139 In CL Program '&' precedes ____ .


AO10139 Variables.

QO10140 How do you pass parameters in CL ?


AO10140 Using PARM keyword.

QO20141 Can libraries be added to the library list through CL ?


AO20141 Yes, using ADDLIBL.

QL50142 What is the difference between CAT, TCAT and BCAT ?


AL50142 CAT : Concatenate two variables or constants into one
continuous string.
BCAT : Truncates all trailing blanks in the first character
string ; one blank is inserted , then the two character strings
are concatenated.
TCAT : Truncates all trailing blanks in the first character
string, thetwo character strings are concatenated.

QO10143 How do you end a CL program ?


AO10143 ENDPGM

QS30144 What are the different types of messages in CL ?


AS30144 Immediate message, Break message, Program message, User
message.

QS30145 How can errors be trapped in a CL program?


AS30145 By using Monitor Message Command ( MONMSG )

QO30146 What is the maximum length of a variable name in CL ?


56

AO30146 Maximum 11 characters (including '&')

QL50147 What are the limitations of CL (compare to RPG) ?


AL50147 You cannot use CL program to :
. ADD or UPDATE records in database files
. Use Printer or ICF files
. Use Program described files
. Use the concept of subfile (to display more than one
record), but a single output message subfile is a
special type of subfile that is supported well in
CL
. Use subroutines.
You cannot declare more than one object (file) in a CL
programme.

RPG/400

QS10148 What is RPG ?


AS10148 Report Program Generator.

QL30149 What are the positive points of RPG Language ?


AL30149 Contains opcodes which makes it flexible with OS/400 Can
access the externally described file.

QL50150 Explain RPG Program Logic Cycle ?


AL50150

START

Perform detail calculation Perform header, detail output

Read a record
Move data from selected Set ON LR if EOF
record into processing area If change in control field, set
ON control level indicators.

Perform total calculations


Perform total output
If LR is ON then END program

QS30151 When is it efficient to make use of RPG Cycle ?


AS30151 When the file is arranged in sequence and output is based
on control break.

QS20152 Can you call a program in your RPG program, which is coded
in some other language?
AS20152 Yes, Any program object available on AS/400.
57

QL20153 What are the different types of specification available in


RPG/400 ?
AL20153 Control Spec.( H )
File Spec.( F )
Extension Spec.( E )
Line counter Spec.( L )
Input Spec.( I )
Calculation Spec.( C )
Output Spec.( O )

QO40154 Is it necessary to define all formats? Which are mandatory


and which are Optional?
AO40154 No, all are Optional.

QS20155 What is the use of H spec. in RPG ?


AS20155 It identifies by H in column 6, Provides information about
generating and running programs.

QS50156 When will DUMP and DEBUG opcodes be ignored ?


AS50156 If blank is specified in position 15 of H specs.

QS20157 What are the valid file types ( position 15 ) in F


specification ?
AS20157 I(Input file).
O (Output file).
U (Update file).
C (Combined (I/O) file).

QL40158 Specify different indicators used in RPG ?


AL40158 Overflow indicators.
Record Identifying Indicators.
Field Indicators.
Resulting Indicators.
Control Level Indicators.

QL40159 What are Control level indicators ?


AL40159L1 to L9 used to identify certain fields on control fields and
then used to
condition which operations are to be processed at detail or total
calculation or
output time.

QS20160 What is the use of E specification in RPG ?


AS20160 Extension Specs describes all record address files, arrays
and tables.

QS30161 What is the use of L specs in RPG ?


AS30161Line counter specification can be used to describe printer file
to indicate the
length of the form and number of lines per page.

QS10162 In which specification can a report layout be defined ?


AS10162 O Specification.

QO30163 How many files can be defined in F specs ?


AO30163 A maximum of 50 files.
58

QO30164 How many printer files can be defined in F specs ?


AO30164 A maximum of 8 files.

QS20165 Give three main purposes of File specification ?


AS20165 To define files, to describe the files, to assign the
files to specified devices.

QS20166 How do you specify page overflow indicator for printer


files in RPG ?
AS20166 Specify an indicator in positions 33-34 of F specification.

QS20167 What is a Primary File ?


AS20167 It is used in RPG Program Cycle to automatically read
records in a cycle.

QO30168 Can an indexed file be accessed in arrival sequence in RPG


program ?
AO30168 Yes.

QS20169 What is a program described file in RPG ?


AS20169 The field name and length of the fields are defined with in
the RPG program.

QS20170 What is an externally described file ?


AS20170 All information about the fields is specified in DDS and
the RPG program can use them with in the program.

QO30171 Can you specify a display file to be used in the following


modes:Input, Output or Combined modes?
AO30171 Yes.

QL40172 What are match fields indicators ?


AL40172 Matching record indicator is seton when all the matching
fields in the record of a secondary file matches with all the
matching fields of a record in a primary file.

QO20173 What is the length of a variable in RPG ?


AO20173 6 Characters.

QS10174 What are the different arithmetic Opcodes ?


AS10174 ADD, SUB, MULT, DIV, MVR, SQRT, XFOOT, Z-ADD, Z-SUB.

QS10175 When is a TAG statement used in RPG ?


AS10175 It is used as a Label.

QL30176 What are the different Opcodes available in RPG for


Database access ?
AL30176READ, CHAIN, WRITE, UPDAT, DELET, SETLL, SETGT, READE, READP,
REDPE, OPEN, CLOSE,
FORCE, NEXT, UNLCK.
QS10177 What is READP opcode ?
AS10177 Read previous record.

QS10178 What is REDPE opcode ?


AS10178 Read Prior equal record.

QO30179 How do you check if a division was whole division ?


59

AO30179 Check the EQ indicator be set to '1'

QO30180 What opcode could be used to test an alphanumeric field


for all numeric values?
AO30180 TESTN.

QO30181 What opcode will be used to test the zone of a character


field ?
AO30181 TESTZ.

QS40182 How do you specify Half Adjust ?


AS40182It should be specified in the column 53 of C specs as 'H' to
indicate half adjust.
It will be effective only if the resultant value is having more
decimals than the result field.

QL30183 Explain the difference between READ, CHAIN and SETLL ?


AL30183 READ operation reads the record currently pointed to, from
a full procedural file.

CHAIN operation retrieves a record from a full Procedural file,


sets a record identifying indicator ON and places the data in the
input fields.

SETLL operation position a file at the next record that has a key
or relative
record number that is greater than or equal to the search
argument specified. The
file must be fully procedural for all three opcodes.

QL30184 What does LO and EQ indicators signify in READ, WRITE and


CHAIN operations ?
AL30184 LO indicator specifies the error status on the above
operations.EQ indicator specifies the EOF, Record not found.

QS30185 How can database records be read without lock ?


AS30185 Put 'N' in position 53 of C specs.

QL20186 What is the difference between MOVE and MOVEL ?


AL20186 MOVE operation will transfer characters from the factor 2
to the result field, the move starts from rightmost character of
factor
2.MOVEL operation will transfer characters from factor 2 to the
result field, the move starts from leftmost character of factor 2.

QS20187 How do you concatenate two string variables in RPG ?


AS20187 Using CAT opcode or with MOVE followed by MOVEL.

QL30188 What are the string operations possible in RPG/400 ?


AL30188 CHECK, CHEKR, SUBST, CAT, XLATE, SCAN.

QS10189 What does SUBST do ?


AS10189 Extracts a specified character string from a base character
string.

QS20190 What does CHECK opcode do ?


60

AS20190The check operation verifies that each character in the base


string (factor 2) is
among the character indicated in the comparator string(factor 1).

QS10191In conjunction with which statements can ORxx and ANDxx


conditions be used ?
AS10191 DOUxx, DOWxx, IFxx, and WHxx.

QS10192 What is the difference between DOU and DOW ?


AS10192 DOU checks after entering into the loop, it is performed at
least once.DOW check before entering into the loop.

QL20193 What is ITER and LEAVE opcodes do ?


AL20193 ITER transfers control from within a DO group to the
ENDDOstatement of the DO
group. It causes the next iteration of the loop to be executed
immediately
LEAVE operation transfers control from within a DO group to
thestatement following the ENDDO operation.

QL20194 Which instructions support structured programming in RPG ?


AL20194 ANDxx, CASxx, DO group, ELSE, ENDyy, IFxx, ITER, LEAVE,
ORxx, OTHER, SELEC, WHxx.

QS10195 What does 'SR' in columns 7-8 of C specs mean ?


AS10195 Calculation operation is a part of RPG subroutine.

QL20196 Explain CASxx, and CABxx statements ?


AL20196 CASxx operation allows you to conditionally select a
subroutine for processing. The condition is based on the
relationship between factor 1 and factor 2 as specified by xx.If
the relationship is true the subroutine specified in the result
field is processed.

CABxx operation compares factor 1 with factor 2 , if the condition


specified by xx is true, the program branches to the TAG
operation associates with the label specified in the result field.

QL30197 What is CLEAR and RESET ?


AL30197CLEAR operation sets the elements in a structure (record format,
array/table, data
structure) or a variable (field, subfield or indicator) to zero ,
blank or '0'
depending on the field type (numeric, character, indicator)

RESET operation sets the elements in a structure (record format,


array/ table,data
structure) or a variable (field, subfield or indicator) to its
initial value.

QL40198 What is SCAN and XLATE ?


AL40198 SCAN operation scans a character string (base string)
contained infactor 2 for a substring (compare string) contained
in factor 1.
61

XLATE operation translates characters in source string (factor 2)


to the from and to strings(factor 1) and put into the result
field.

QL40199 How do you use commitment control in RPG program ?


AL40199 Using COMIT operation.
Makes all changes to the files that have been specified in
output operation since the previous COMIT or the beginning
of operations under commitment control(if there has been no
previous COMIT or ROLBK operation).

QS30200 How do you use exceptional write in C specs ?


AS30200 Using EXCPT opcode.

QL30201 What does the opcode FREE do ?


AL30201 The FREE operation removes a program from the list of
activated programs, frees static storage and ensures program
initialization (first cycle processing) the next time program is
called. It does not close file or unlock data area.

QS30202 What does opcode POST do ?


AS30202 Puts information in IFNDS.

QS20203 What is the difference between WRITE and EXFMT of a display


file ?
AS20203 WRITE displays a record format on workstation,
EXFMT displays and accepts from the workstation.

QS20204 What is the difference between PLIST and KLIST ?


AS20204PLIST operation defines a unique symbolic name for a parameter
list to be
specified in a CALL operation.

KLIST is a declarative operation that gives a name to a list of


key fields

QO30205 Can you have multiple key lists for a single file ?
AO30205 Yes.

QS40206 What are the different types of arrays available in RPG ?


AS40206 Pre-execution time array.
Compile time array.
Execution time array.

QL40207 How do you specify data for a compile time array ?


AL40207You can specify in E specs about the no of entries per record,
no of elements,
length of each element with the corresponding data entered at the
end of the RPG
program starting with **.

QO30208 What is the maximum number of elements in an array ?


AO30208 9999.

QO30209 Can we define Multi-dimensional arrays in RPG ?


AO30209 No.
62

QS20210 What is XFOOT opcode ?


AS20210 Adds all the elements in a numeric array, and places the
sum in the result field.

QS20211 How can we sort an array ?


AS20211 By using SORTA opcode.

QS20212 What is MOVEA opcode do ?


AS20212 Transfer character to numeric values from factor 2 to
result field.
MOVEA can be possible to ARRAY-ARRAY, ARRAY-FIELD, or FIELD-ARRAY.

QS20213 How to initialize an array ?


AS20213 CLEAR or MOVEA *blanks to array.

QS20214 What is LOKUP opcode do ?


AS20214 LOKUP opcode search for a particular element in an array /
table.

QS20215 Can LOKUP operation be used for unsorted array?


AS20215 Yes.

QL20216 What is the difference between an array and a table ?


AL20216 An array elements can be referred by array name.Elements in
array can be accessed by their position relative to other
elements.

Table name does not refer to the entire set of table elements.
Elements in a table can not be accessed by their position
relative to the other elements.

QO30217 What is the maximum length of a table name ?


AO30217 6 characters.

QO20218 What is the syntax of a table name ?


AO20218 Table name should start with TAB.

QS30219 How can the user implicitly open and close the files in RPG
program ?
AS30219 Enter UC in position 71-72 of F specs.Use OPEN and CLOSE
opcodes in RPG program to open and close files.

QO20220 During input operation which indicator position is seton if


there is a record lock?
AO20220 LO indicator position is seton.

QS20221 What is the significance of DEFN opcode on RPG ?


AS20221 To define fields based on the attributes of another field.
To define a field as a data area.

QS20222 What are different ways by which you define working storage
field ?
AS20222 Explicitly define or use *Like DEFN.

QO30223 How many parameters can be defined in a RPG program?


AO30223 Max. 255.
63

QL40224 What are the different ways of ending an RPG program


without a primary file ?
AL40224 SETON LR.
SETON H1 to H9 (halt indicators).
SETON RT.
RETRN.
By allowing an exception / error to end the program if
. No exception / error subroutine is specified
. No return point is specified on an exception or error
subroutine
. The user's response is to cancel the program.

QL40225 Specify different ways by which RPG program can give error
message to user?
AL40225 By calling the SUBR23R3 program as passing message id. By
defining the error message in DSPF.

QL50226 If you are trying to add a record in a file and an error


is displayed,where do you look for error ?
AL50226 Check whether you have opened the file in Update mode.Check
whether you have specified 'A' in position 72 of F specs.

QL50227 What is a File Information Data Structure ?


AL50227 File Information Data structure (INFDS) can be defined for
each file tomake file exception/error information available to
the program. A file information data structure contains
predefined subfields that identify:
. The name of the file for which the exception/error
occurred
. The record being processed when the exception/error
occurred or the record that caused the exception/error
. The last operation being processed when the
exception/error
occurred
. The status code
. The RPG routine in which the exception/error occurred.

QL50228 What is Program Status Data Structure ?


AL50228 A program status DS can defined to make program
exception/error information available to an RPG program.DS is
defined as a program status DS by an S in position 18 of the DS
statement.
*STATUS contains status code
*ROUTINE contains name of routine in which the
exception/error occurred.
*PARMS contains the number parameters passed to this
program from the calling program.
Specify heading information/TITLE.
Specify to begin on a fresh page/EJECT.
To control line spacing/SPACE.
Records to be inserted from other files at the point where
it is specified/COPY.

QO30229What is the maximum no. of times multiple occurrence DS can


occur in a program ?
AO30229 9999.
64

QL30230 What is the difference between *LIKE and *NAMVAR ?


AL30230 *LIKE defines the variables as in database.
*NAMVAR is used to define variables as data area.

QL30231 How is embedded SQL used in RPG ?


AL30231 /EXEC SQL
+ SQL statements
+ --------------------
+ --------------------
/END EXEC

QS30232 What are all the compiler directive statements ?


AS30232 /TITLE, /EJECT, /SPACE, /COPY.

QS40233 How can RPG program send message to System Operator ?


AS40233 Use QCMDEXC as called program in the CALL statements, and
use SNDPGMMSG to the operator.

QL50234 Where DBCS data will be used in RPG ?


AL50234 In any comment statement
. In comment field of E and C Specs
. In literals and constants
. As data in any character field, subfield, array or table.

QS40235 Where will control be passed after the execution of the


*PSSR subroutine if the factor 2 of the ENDSR is
blank ?
AS40235 Control will return to the next sequential instruction.

QS40236 How can the CPF error-id be retrieved when a program error
occurs ?
AS40236 CPF error codes are placed in the subfield location *STATUS
for the program status DS.

QS30237 How could indicators 50 to 99 be set to '0' in one


instruction ?
AS30237 Using 'MOVEA *ZEROS IN,50' .

QL30238 What are the figurative constants ?


AL30238 *BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL, *ALL 'X..'
are implied literals that can be supplied without a length, because the
implied length and decimal positions of a figurative constant are The
same as those of the associated field.

QO30239 What is the maximum error severity for which the


compilation of RPG program stops?
AO30239 50, if LR is not seton.

Q6S2001 What are the earlier versions of RPG ?


A6AS2001RPG II & RPG III.

Q6L4002 Name the different ways by which RPG source program can be
entered ?
65

A6L4002Interactively with SEU, In batch by using either OS/400 or


Spooling functions.

Q6O3003During input operation which indicator position is seton if the


record is locked ?
A6O3003Position 56 - 57 (LO).

Q6O5004 What is the record lock status value ?


A6O5004Status value is 01218.

MISCELLANEOUS

QO30240 How do you combine two record formats in RLU ?


AO30240 Using CLC.

QO30241 How do you split record formats in RLU?


AO30241 Using CLR.

QO20242 What is the use of SDA?


AO20242 Screen Design Aid is used to create display files
interactively.

QO40243 How do you define overlapping fields in SDA ?


AO40243 They can be defined through condition indicators.

QS40244 Mention different ways of specifying user help.


AS40244 Through SDA and Panel Group.

QS30245 To which member type does help text for panel belong ?
AS30245 PNLGRP

QO20246 Can Printer files be externally described or program


described ?
AO20246 Yes.

QS20247 What are the valid file operation codes for a PRINTER file ?
AS20247 WRITE, OPEN, CLOSE, FEDO.

QS50248 If you use INDARA keyword for a program-described PRINTER


file, what will be the result ?
AS50248 You will get run-time error.

QL50249 What is PRTCTL, and where will you define it ?


AL50249 The PRTCTL (Printer Control) option allows you to change
forms control information and to access the current line value
within the program for a program-described PRINTER file.
PRTCTL option will be specified on a F specifications
continuation line for the PRINTER file.

Q8S2001 What is the function of RLU ?


A8S2001To design & prototype a report.

Q8S2002 What are the three types of keywords associated with


printer file?
A8S2002File level, Record level & Field level.

Q8S2003 What are the three line types in RLU ?


66

A8S2003Report line, Filler line & Sample line.

Q8O1004 Which option number is used to invoke RLU ?


A8O1004Option 19.

Q8L4005 What are the different commands used in RLU ?


A8L4005DR - Define Record, CLC - Change Line for Continuation, CLR -
Change Line for
Record, SD - Create Sample Data, VF - View Fields, NP - New Page,
DC - Define
Constants, DF - Define Fields, CF - Centre Fields & SP - Space
Fields evenly.

Q8O1006 What is the command used to invoke RLU ?


A8O1006 STRRLU.

Q8S1007 What are different record spacing keywords in RLU ?


A8S1007 SKIPA, SKIPB, SPACEA & SPACEB.

Q8L4008 What is job description ?


A8L4008A job is an unit of work on the AS/400. Jobs run in a subsystem
using system
resources viz. memory, disk, etc. A job can be either
interactive or batch. For
interactive jobs JOD in User profile is used and for batch jobs
JOBD along with

SBMJOB is submitted with an object type of job description is


*JOBD. Job
description is a set of characteristics that define how the
system handles a job.
It contains: Job queue (only for batch), job priority, printer to
be used, OUTQ &
its priority, time slice & run priority. If none of the above is
specified the
system used the default job description.

Q8L4009 Define a sub system?


A8L4009Sub system is an operating environment, defined by a sub system
description. All
user jobs are processed in the sub system. Eg.QBASE, QBATCH,
QCTL, QINTER, etc.
Sub system description defines the characteristics of a sub
system. ROUTING
ENTRY: Specifies the program to be called to control a routing
step. WORK ENTRY:
Source from which jobs can be accepted. WORK STATION ENTRY:
Display stations from
which users can log into the sub system.

Q8L4010 Open query file [OPNQRYF]?


A8L4010Open query file (OPNQRYF) selection can be on:
* Dynamic record selection
* Dynamic keyed sequence
* Dynamic join
* Unique key processing
* Group processing
67

* Final total processing


* Improve performance
Query access path will be implemented through the following
objects
* CL program containing an OPNQRYF to open access path at
runtime
* OS/400 physical file used to compile programs [dummy PF]
used at runtime
* OS/400 logical file defines the key to OPNQRYF command

Q8L4011 Override database [OVRDBF] ?


A8L4011Override database [OVRDBF] lets to override the filenames or
attributes of file
selected when we compile/run program. Overrides can be used to
change most of the
attributes. To cancel the override database command we shall
have to give delete
override databases DLTOVR.

Q8L4011 How do you pass numeric parameters for submit job?


A8L4011Convert numeric parameters to character and pass, or.pass in
hexadecimal
format(x’0nf’ if ‘n’ contains odd number of digits x’nf’ if ‘n’
contains even number of digits)

APPENDIX - A

The coding methodology to be followed to code questions & answers that


are to be added to this question bank is described below.

CODE STRUCTURE : ABCDnnn.

A - A indicates whether the code is a question or an answer. The


possible values are:

Q - Question.
A - Answer.

B - B indicates the topic under which the question/answer falls. The


possible values are:

1 - AS/400 SYSTEM.
2 - OS/400
3 - DATABASE FILES
4 - DISPLAY FILES
5 - CL/400
6 - RPG/400
7 - COBOL/400
8 - MISCELLANEOUS

C - C indicates the question/answer type. The possible values are:

O - Objective type.
S - Short answers.
L - Long answers.
68

D - D indicates the complexity level of the question/answer. The possible


values are:

Complexity levels 1/2/3/4/5 (Where complexity level increases from 1


- 5)

nnn - These represent the numeric sequence.

SQLRPG Statements:
C+ SELECT MIN(G4EDAM) INTO :WUAMT1 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
*
C/EXEC SQL
C+ SELECT MAX(G4EDAM) INTO :WUAMT2 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
C/EXEC SQL
C+ SELECT AVG(G4EDAM) INTO :WUAMT3 FROM G4AGEDP WHERE G4EDCD =
C+ :A1EDCD AND G4EMGR = :WUGR01
C/END-EXEC
*
C/EXEC SQL
C+ SELECT MIN(G4EDAM) INTO :WUAMT4 FROM G4AGEDP WHERE G4EDCD =

Table 33. Built-In Functions


Name Arguments Value Returned
Function Example
%DATE {value {: date format}} the date that Syntax :- %DATE(expression :{Date
corresponds to the specified value,or the Format})
current system date if none is specified
Description :- This Built in
function converts value from
Character, numeric or time Stamp
to Date

Example :-
D String S 8A
inz(‘04/05/96)
D Fld1 S 6P 0
inz(112001)
D Date S D
datfmt(*ISO)
69

D TimeStam S Z

/free
Date = %DATE(String
:*MDY);
// Date now contains
1996-04-05
Date = %DATE(Fld1
:*MDY);
// Date now contains
2001-11-20
Clear TimeStam;
Date = %DATE(TimeStam);
// Date now contains
0001-01-01
/end-free
%DAYS number of days number of days as a Syntax :- %DAYS(Number)
duration
Description: - This built in
function converts a number into a
duration that can be added to a
date or time Stamp

Example :-
D Date1 S D
inz(D’2001-11-20’)
D Result S D
/free
Result = Date1 +
%DAYS(15);
// Result is now 2001-
12-05
Result = Date1 -
%DAYS(10);
// Result is now 2001-
11-10
/end-free

%DECH numeric expression :digits:decpos Syntax :- %DECH(numeric expression


half-adjusted value in packed numeric :precision :decimal places)
format

Description: - This built in


function is same as %DEC except
that if numeric expression is a
decimal or flat value than half
adjust is applied to the value of
numeric expression when converting
to the desired position.

Example :-
D Fld1 S 9s 5
inz(73.73642)
70

D Result S 15p 5

/free
Result = %DECH(Fld1 :5
:2);
// Result is now
73.74000
/end-free
%DIFF date or time expression: date or time Syntax :- %DIFF(Op1 :Op2 :*MS| *s|
expression: unit *MN| *H| *D| *M| *Y)
difference between the two dates, times, or
timestamp Description: - This Built in
in the specified unit function calculates difference
(Duration) between two date or
time values.
The first and second parameter
must have the same or compatible
type.

The following Combination are


possible :-
Date and Date
Time and Time
TimeStamp and TimeStamp
Date and TimeStamp
Time and TimeStamp

Example :-
D Date1 S D inz(D’2001-11-
20’)
D Date2 S D inz(D’2001-10-
15’)
D Time1 S T
inz(T’12.30.54’)
D Time2 S T
inz(T’01.30.54’)
D Result S 15p 0
/free
Result = %DIFF(Date1
:Date2 :*D);
// No. of Days difference
between two Dates 36
Result = %DIFF(Date1
:Date2 :*M);
// no. of month Difference between
two Dates 1
Result = %DIFF(Time1
:Time2 :*H);
// No. of Hour difference between
two times 11
Result = %DIFF(Time1
:Time2 :*MN);
// No. of minutes difference
between two times 660
/end-free
71

%DIV dividend: divisor the quotient from Syntax :- %DIV(N :M)


the division of the two arguments
Description :- This Built in
function returns the integer
portion of the quotient that
result from dividing operands n by
m

Example :-
D Fld1 S 8p 0 inz(123)
D Fld2 S 8p 0 inz(23)
D Result S 15p 0
/free
Result = %DIV(Fld1
:Fld2);
// Result is now 5
/end-free
%ELEM array, table, or multiple occurrence Syntax :- %ELEM(Array Name)
data structure name
number of elements or occurrences Description: - This Built in
function returns number of
elements in the specified array,
table or multiple occurrence data
structure.

Example :-
D Arr1 S 5A dim(10)
varying
D Result S 2p 0
/free
Arr1(1) = ‘Se’;
Arr1(2) = ‘En’;
Result = %ELEM(Arr1);
// Result is now 10
/end-free
%EOF {file name} ’1’ if the most recent Syntax :- %EOF(File Name)
file input operation or write to a
subfile (for a particular file, if Description: - This built in
specified) ended in an function returns ‘1’, if the most
end-of-file or beginning-of-file condition recent read operation or write to
’0’ otherwise subfile ended in an end of file or
beginning of the file condition,
otherwise it return ‘0’.

Example :-
F Infile IF E K Disk
/free
Read Infile;
Dow not %EOF(Infile);
72

Read Infile;
Enddo;

%FOUND {file name} ’1’ if the most recent Syntax :- %FOUND(File Name)
relevant operation (for a particular
file, if specified) found a record (CHAIN, Description: - This Built in
DELETE, function returns ‘1’, if the most
SETGT, SETLL), an element (LOOKUP), or a recent relevant file operation
match found a record, a string operation
(CHECK, CHECKR, SCAN) found a match, or a Search
’0’ otherwise operation found an element.

Example :-
F CustFile IF E K Disk
/free
// Check if the customer
is in the file
Chain Cust CustFile
If %FOUND(CustFile);
Exsr Handle;
Endif;
/end-free
%HOURS number of hours number of hours as a Syntax :- %HOUR(number)
duration
Description: - This Built in
function converts a number into a
duration that can be added to a
Time or Time Stamp value.

Example :-
D Time1 S T inz(T’11.12.10’)
D Time2 S T
/free
Time2 = Time1 +
%HOURS(1);
// Time2 is now 12.12.10
/end-free
%LOOKUPxx argument: array{:start index Syntax :- %LOOKUP(arg :array
{:number {:Starting Index {:number of
of elements}} elements }})
array index of the matching element
Description: - This Built in
functions returns the array index
of the item in array.

Example :-
D Array1 S 2A dim(5)
ascend
D Index S 2p 0
/free
Array(1) = ‘A’;
Array(2) = ‘C’;
73

Array(3) = ‘E’;
Array(4) = ‘G’;
Array(5) = ‘I’;
Index = %LOOKUP(‘C’
:Array1);
// Index is now 2
Index = %LOOKUPLT(‘F’
:Array1);
//Index is now 3
Index = %LOOKUPGT(‘H’
:Array1);
// Index is now 5
/end-free
%MINUTES number of minutes number of Syntax :- %MINUTES(number)
minutes as a duration
Description: - This built in
function converts a number into a
duration that can be added to a
time or time stamp value.

Example :-
D Time1 S T
inz(T’11.12.10’)
D Time2 S T
/free
Time2 = Time1 +
%MINUTES(10);
// Time2 is now
11.22.10
/end-free
%MONTHS number of months number of months Syntax :- %MONTHS(Number)
as a duration
Description: - This built in
function converts a number into a
duration that can be added to a
date or time Stamp

Example :-
D Date1 S D
inz(D’2001-11-20’)
D Result S D
/free
Result = Date1 +
%MONTHS(2);
// Result is now 2002-
01-20
Result = Date1 -
%MONTHS(2);
// Result is now 2001-
09-20
/end-free

%PARMS none number of parameters passed to


procedure Syntax
74

%PARMS

Description
%PARMS returns the number of
parameters that were to the
procedure in which %PARMS is used.

Example
C *ENTRY PLIST
C PARMS COUNT
2 0

C IF %PARMS<1
C ‘No Parms’ DSPLY
C ENDIF

In the above example since the


received parameters count is one
the message ‘No Prams' is not
displayed.
%REM dividend: divisor the remainder from
the division of the two arguments Syntax
%REM(n:m)

Description
%REM returns the remainder that
results from dividing operand n by
m. The two operands must be
numeric values with zero decimal
positions.

Example

D A S 10I 0 INZ(123)
D B S 10I 0 INZ(27)
D DIV S 10I 0 INZ
D REM S 10I 0 INZ
/free
DIV = %DIV(A:B) // DIV is now
4
REM = %REM(A:B) // REM is now
15
/end-free
In the above example the variable
REM has a value 15 that is arrived
using built-in-function %REM.
%REPLACE replacement string: source string
{:start position {:source length to Syntax
replace}} %REPLACE(replacement string:
string produced by inserting replacement source string {:start position
string into {:source length to replace}})
source string, starting at start position
75

and replacing the


specified number of characters Description
%REPLACE returns the character
string produced by inserting a
replace string into the source,
starting at the start position and
replacing the specified number of
characters.

Example
D VAR1 S 10I 0
INZ(‘Windsor’)
VARYING
D RESULT S 10I 0
VARYING
/free
result = var1 + ‘,’ + ‘ON’
// result = ‘Windsor, ON’
//%Replace with 2 parameters to
replace text at beginning of
string.
Result = %replace(‘Toronto’;
result);
//result = ‘Toronto, ON)
/end-free
In the above example the variable
RESULT is replace with ‘Toronto’
of first string var1.
%SQRT numeric value square root of the
numeric value Syntax
%SQRT (numeric expression)

Description
%SQRT returns the square root of
the specified numeric expression.

Example
D P S 5P0
/free

P = %SQRT (81);
/end-free
In the above example the variable
P has value of 9 since square root
of 81 is 9.
%TIME {value {: time format}} the time that
corresponds to the specified value,or the Syntax
current system time if none is specified %TIME {(expression {:time-
format})}

Description
%TIME converts the value of the
76

expression from character,


numeric, or timestamp data to type
time.

Example
/free

string = ’12:34 PM’;

time = %time(string:*USA);

// time variable has a value


t’12.34.00
/end-free
In the above example the function
%TIME converts the string which is
of character to a time field.
%TRIM string string with left and right
blanks trimmed Syntax
%TRIM (string)

Description
%TRIM returns the given string
less any leading and trailing
blanks.

Example
D Location S 16A

/free
Location = %trim(‘ Toronto,
Ontario ‘);

// Location will have value


‘Toronto,Ontario’
/end-free
In the above example the function
%TRIM trims the string ‘Toronto,
Ontario’ and stores it in variable
Location.
%TRIML string string with left blanks
trimmed Syntax
%TRIML(string)

Description
%TRIML returns the given string
less any leading blanks.

Example
77

D Location S 16A

/free
Location = %triml(‘ Toronto,
Ontario ‘);

// Location will have value


‘Toronto,Ontario ’
/end-free
In the above example the function
%TRIML trims the string ‘Toronto,
Ontario ’ and stores it in
variable Location.
%TRIMR string string with right blanks
trimmed Syntax
%TRIMR(string)

Description
%TRIMR returns the given string
less any trailing blanks.

Example
D Location S 16A
varying

/free
Location = %trimr(‘ Toronto,
Ontario ‘);

// Location will have value


‘ Toronto,Ontario’
/end-free
In the above example the function
%TRIMR trims the string
‘ Toronto, Ontario’ and
stores it in variable Location.
%XFOOT array expression sum of the elements
Syntax
%XFOOT(array-expression)

Description
%XFOOT results in the sum of all
elements of the specified numeric
array expression.

Example
D result S 15P5
/free
result = %xfoot(ARR);
// result will have the sum of all
78

elements of array ARR


/end-free
In the above example the function
%XFOOT is used to sum of all
elements of array ARR.
%XLATE from-characters: to-characters:
string Syntax
{: start position} %XLATE(from :to :string
the string with from-characters replaced by {:startpos})
to-characters

Description
%XLATE translates string according
to the values of from, to, and
startpos. The first parameter
contains a list of characters that
should be replaced, and the second
parameter contains their
replacements.

Example
D up C
‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’
D lo C
‘abcdefghijklmnopqrstuvwxyz’
D String S 10A

/free

string = %XLATE(lo:up: ‘rpg


dept’)

// result will have the value


‘RPGT DEPT’

/end-free
In the above example the function
%XLATE translates the string from
lower to upper case.
%YEARS number of years number of years as a
duration Syntax
%YEARS(number)

Description
%YEARS converts a number into a
duration that can be added to a
date or time-stamp value.

Example
/free

newdate = date + %YEARS(3)


79

/end-free
In the above example the function
%YEARS will add 3 years to date
variable which is of type date.

What is the difference between subroutine & sub procedure


A subprocedure is similar to a subroutine, except that a subprocedure
offers the following improvements:
You can pass parameters to a subprocedure, even passing by value.
Parameters can be passed by reference also The parameters passed to a
subprocedure and those received by it are checked at compile time for
consistency. This helps to reduce run-time errors, which can be more
costly. You can use a subprocedure like a built-in function in an
expression. It allows to return a value to the caller.
Names defined in a subprocedure are not visible outside the
subprocedure. You can call the subprocedure from outside the module, if
it is exported. You can call subprocedures recursively.
The processing of a subroutine is much faster than a call to a
subprocedure.

CL Program to find the number of lines of code for all the source that
is available in the input library.

*************** Beginning of data *************************************


/*-------------------------------------------------------------------*/
/* Author : S.Raja */
/* */
/* Company : Scandent */
/* */
/* Input : Library Name */
/* */
/* Output : Lines of code in each source. */
/* */
/* Compling Instructions : The object OUTSPF will not be available */
/* in the system. Execute the below command and complie the source */
/* interactively. */
/* */
/* DSPFD FILE(QGPL/QRPGSRC) TYPE(*BASATR) + */
/* OUTPUT(*OUTFILE) OUTFILE(QTEMP/OUTSPF) */
/* */
/*-------------------------------------------------------------------*/

PGM PARM(&LIB)

DCL VAR(&LIB) TYPE(*CHAR) LEN(10)


DCLF FILE(OUTSPF)

/* Checks if the library in the input is a valid library. */


/* If not gives error message and program ends noramally. */
CHKOBJ OBJ(&LIB) OBJTYPE(*LIB)
80

MONMSG MSGID(CPF9801) EXEC(DO)


SNDPGMMSG MSG('Invalid Library name.')
GOTO CMDLBL(END)
ENDDO

/* Deletes work files if any in the QTEMP. */


DLTF FILE(QTEMP/OUTMBR)
MONMSG MSGID(CPF0610 CPF2105)
DLTF FILE(QTEMP/OUTSPF)
MONMSG MSGID(CPF0610 CPF2105)

/* Gets all file objects in the library. This is done to get all */
/* source physical files in the library and stores them in OUTSPF */
DSPFD FILE(&LIB/*ALL) TYPE(*BASATR) +
OUTPUT(*OUTFILE) OUTFILE(QTEMP/OUT1)
CPYF FROMFILE(QTEMP/OUT1) TOFILE(QTEMP/OUTSPF) +
CRTFILE(*YES) INCREL((*IF ATDTAT *EQ 'S'))

/* Reads the source physical file and gets all the source */
/* available in the source PF and the inout library. */
READ: RCVF RCDFMT(QWHFDBAS)
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))

DSPFD FILE(&LIB/&ATFILE) TYPE(*MBRLIST) +


OUTPUT(*OUTFILE) OUTFILE(QTEMP/OUTMBR) +
OUTMBR(*FIRST *ADD)

GOTO CMDLBL(READ)

/* Query reads the file OUTMBR and groups them according to the */
/* source type and the number of line of code. */
END: RUNQRY QRY(RTVMBRQ)
MONMSG MSGID(CPA0701)

ENDPGM
****************** End of data ****************************************

Note : Code the above program without the query(RTVMBRQ). Compile the
program and execute the program once. The outfile OUTMBR will be
created in QTEMP. Then create the below query. Code this query in the
above CL program. Complie and execute.

Query defnition for RTVMBRQ.

Specify File Selections

Type choices, press Enter. Press F9 to specify an additional


file selection.

File . . . . . . . . . OUTMBR Name, F4 for list


Library . . . . . . QTEMP Name, *LIBL, F4 for list
Member . . . . . . . . *FIRST Name, *FIRST, F4 for list
Format . . . . . . . . QWHFDML Name, *FIRST, F4 for list
81

Select and Sequence Fields

Type sequence number (0-9999) for the names of up to 500 fields to


appear in the report, press Enter.

Seq Field Text


Len Dec
10 MLNAME Member
10
20 MLSEU Source type for S/38 View as it appeared o
4
30 MLNRCD Current number of records
10 0
40 MLMTXT Text 'description'
50
50 MLFILE File
10
60 MLLIB Library
10
MLRCEN Retrieval century: 0=19xx, 1=20xx
1
MLRDAT Retrieval date: year/month/day
6
MLRTIM Retrieval time: hour/minute/second
6
MLFTYP P=PF, L=LF, R=DDM PF, S=DDM LF
1
MLFILA File attribute: *PHY or *LGL
4
MLMXD Reserved
3

Select Sort Fields

Type sort priority (0-999) and A (Ascending) or D (Descending) for


the names of up to 32 fields, press Enter.

Sort
Prty A/D Field Text
Len Dec
10 A MLSEU Source type for S/38 View as it appeared
4
MLNAME Member
10
MLNRCD Current number of records
10 0
MLMTXT Text 'description'
50
MLFILE File
10
MLLIB Library
10
82

Select Report Summary Functions

Type options, press Enter.


1=Total 2=Average 3=Minimum 4=Maximum 5=Count

---Options--- Field Text


Len Dec
5 MLNAME Member
10
MLSEU Source type for S/38 View as it app
4
1 MLNRCD Current number of records
10 0
MLMTXT Text 'description'
50
MLFILE File
10
MLLIB Library
10

Define Report Breaks

Type break level (1-6) for up to 9 field names, press Enter.


(Use as many fields as needed for each break level.)

Break Sort
Level Prty Field Text
Len Dec
MLNAME Member
10
1 10 MLSEU Source type for S/38 View as it app
4
MLNRCD Current number of records
10 0
MLMTXT Text 'description'
50
MLFILE File
10
MLLIB Library
10

How to call CL program with parameters:

CALL PGM(DATE_DIFF) PARM(X'030082004F' X'030082004F' X'00000F')

SQL Example:
83

DSTMT s 200A
C *entry plist
c parm lib 10
c parm fil 10
c parm fld 10
c parm val 2
C*
c Eval stmt = 'delete from '+%trim(lib)+'/'
c + %trim(fil) + ' where '
c + %trim(fld) + ' = '
c + '?'
C*
C/Exec Sql
C+ whenever sqlerror goto Errortrap
C/End-Exec
*
C/Exec Sql
C+ PREPARE S1 FROM :stmt
C/End-Exec
C*
C/Exec Sql
C+ EXECUTE S1 using :val
C/End-Exec
c Goto End
c Errortrap Tag
c 'Error' Dsply
c sqlcod Dsply
c sqlerrd(3) dsply
c End Tag
C Eval *INLR=*On

IFS folder- Display Image from IFS folder...


PGM
DCL VAR(&STR1) TYPE(*CHAR) LEN(100)
DCL VAR(&S1) TYPE(*CHAR) LEN(20)
DCLF DSPFIL1
L1: SNDRCVF
IF COND(&IN01='1') THEN(GOTO CMDLBL(L2))
ELSE CMD(DO)
CHGVAR VAR(&STR1) VALUE('\\SCANMAC\DIR1\' *TCAT &VAR1 +
*TCAT '.JPG')
STRPCO
MONMSG MSGID(CPF0000)
STRPCCMD PCCMD(&STR1) PAUSE(*NO)
GOTO L1
ENDDO
L2: ENDPGM

To Debug the Batch PGM's

First step: compile all the modules with parameter DBGVIEW(*ALL)


84

To debug a batch program:


1° The job has to be hold in the JOBQ.
2° Take note of the job attributes (DSPJOB option 1)
3° STRSRVJOB with the attributes of the work (these are noted at 2°)
4° STRDBG of the program, then release the job
5° F10, then DSPMODSRC for see the source to place a execution stop (F6)
6° F12, F3, ENTER and F12 to go to the execution stop.

Is there a way to monitor abnormal terminations when compiling RPG or ILE


RPG programs within a CL program?

Yes, you can programmatically determine whether a compile was successful for both
RPG and ILE RPG members. The compiler generates data area RETURNCODE in
library QTEMP. This is a 400-byte character data area containing information about
the compile. The short answer to your question is that the first byte of this data area
will contain '1' for a successful compile or '0' for an unsuccessful compile. Your CL
program containing the compile commands can retrieve the data area and check this
value.

Send Mail to Mail id Pgm

SNDDST TYPE(*LMSG)
TOINTNET(('johnsonhenry.kulandaisamy@scandent.com'))
DSTD('Henry from AS/400 Dev Box')
LONGMSG('Hai from henry , Now i am into the DEV Box.He he he....')
IMPORTANCE(*HIGH) PTY(*HIGH)

Steps involved in implementing commitment control.

Step1

First create the journal receiver:

CRTJRNRCV JRNRCV(MYJRNRCLIB/MYJRNRCV)

Step2

Next, create the journal specifying the journal receiver created above:

CRTJRN JRN(MYLIB/MYJRN) JRNRCV(MYJRNRCLIB/MYJRNRCV)

Step3

And, finally, start journaling on the physical file:


85

STRJRNPF FILE(*LIBL/CCTESTPF) JRN(MYLIB/MYJRN)


PGM

Precautions to be taken while doing the above steps

CRTJRNRCV

1. Be sure to:
o Place the journal receiver in a library that is saved regularly.
o Choose a journal receiver name that can be used to create a naming
convention for future journal receivers, such as RCV0001. You can use
the *GEN option to continue the naming convention when you change
journal receivers. This type of naming convention is also useful if you
choose to let the system manage the changing of your journal
receivers

CRTJRN

1. Be sure to:
o Specify the name of the journal receiver that you created in the first
step.
o Use the Manage receiver (MNGRCV) parameter to have the system
change the journal receiver and attach a new one when the attached
receiver becomes too large. If you choose this option, you do not need
to use the CRTJRN command to detach receivers and create and attach
new receivers manually.
o Specify DLTRCV(*NO) only if you have overriding reasons to do so (for
example, if you need to save these journal receivers for recovery
reasons). If you specify DLTRCV(*YES), these receivers might be
deleted before you have a chance to save them.

You can use two values on the RCVSIZOPT parameter of the CRTJRN command
(*RMVINTENT and *MINFIXLEN) to optimize your storage availability and
system performance. See the AS/400 Programming: Performance Tools Guide
for more information.

STRJRNPF

1. Start journaling the source table using the Start Journal Physical File
(STRJRNPF) command, as in the following example:
2. STRJRNPF FILE(library/file)
3. JRN(JRNLIB/DJRN1)
4. OMTJRNE(*OPNCLO)
5. IMAGES(*BOTH)
6.
86

Specify the name of the journal that you created in step 2. The Capture
program requires a value of *BOTH for the IMAGES parameter.

The data integrity can be maintained using commitment control

Step4 (Last step) - (Starting commitment control)

STRCMTCTL LCKLVL(*CHG)

CALL PGM(*LIBL/CCTEST2)
COMMIT
CALL PGM(*LIBL/CCTEST2)
ROLLBACK
ENDCMTCTL
RETURN
ENDPGM

Points of concern while implementing commitment control in


Bastion

1. If any ILE or RPG program is performing any file operation such as Update,
add or delete, then Fspec has to be continued for the particular file to
incorporate KCOMIT.
2. Study has to be done if to COMIT the changes individually after every file
operation or collectively after processing all records.
3. Study has to be done if to call the program STRCMTCTL as an IPL or invoke
the program that implements commitment control before a particular
maintenance program is called.
4. A decision has to be made if to journal the files in all environments or to
journal only the files in development box. If we journal the files only in
development box, then the changed programs may not produce consistent
results during testing.
5. If a decision has been made to journal all the files then space might be a
constaint
6. Till the completion of bastion code consolidation , JHL environment and
BASTION objects must be attached to to different journals.

Brief notes on commitment control

Commitment control lets you define and process a number of changes to database
files in a single unit (transaction). Commitment control can ensure that complex
application transactions are logically synchronized, even if the job or system ends.
Two-phase commitment control ensures that committable resources, such as
database files on multiple systems, remain synchronized.

Transactions
87

A transaction is a group of changes that appear as a single change, such as the


transfer of funds from a savings account to a checking account. Transactions can be
classified as follows:

• Inquiries in which no file changes occur.


• Simple transactions in which one file is changed each time you press the Enter
key.
• Complex transactions in which two or more files are changed each time you
press the Enter key.
• Complex transactions in which one or more files are changed each time you
press the Enter key. These changes represent only part of a logical group of
transactions.

Revisions made to files during transaction processing are journalled when using
commitment control.

If the system or job ends abnormally, journaling alone can ensure that, at most, only
the very last record change is lost. However, if the system or job ends abnormally
during a complex transaction, the files reflect an incomplete logical transaction. For
example, the job may have updated a record in file A, but before it updated a
corresponding record in file B, the job ended abnormally. In this case, the logical
transaction consisted of two updates, but only one update completed before the job
ended abnormally.

Benefits of using commitment control

Recovering a complex application requires detailed application knowledge. Programs


cannot be restarted. For example, record changes may have to be made with an
application program or data file utility to reverse the files to just before the last
complex transaction began. This task becomes more complex if multiple users were
accessing the files at the same time.

Commitment control helps solve these problems. Commitment control locks records
from other users during a complex transaction. This ensures that other users do not
use the records until the transaction is complete. At the end of the transaction, the
program issues the commit operation, freeing the records. However, should the
system end abnormally before performing the commit operation, all record changes
for that job since the last time a commit operation occurred are rolled back. Any
affected records that are still locked are then unlocked. In other words, database
changes roll back to a clean transaction boundary.

Map Field –OPNQRYF

CHGVAR VAR(&QRYSLT) VALUE('ENTRYDATE *EQ %RANGE("' +


*CAT &STARTDATE *CAT '" "' *CAT &ENDDATE +
*CAT '") *and smbchp *eq "ALP" *and +
smtrcd *le "17"')

OPNQRYF FILE((ALSTMF15)) QRYSLT(&QRYSLT) +


KEYFLD((SMCONR) (SMPRFX) (SMPLNR) +
(SMTECN) (SMTEYY) (SMTEMM) (SMTEDD) +
(SMEFCN) (SMEFMM) (SMEFMM) (SMEFDD) +
(SMREFN)) MAPFLD((ENTRYDATE +
88

'%digits(smetcn) *cat %digits(smetyy) +


*cat %digits(smetmm) *cat +
%digits(smetdd)' *CHAR 8))

Você também pode gostar