RPG/RPGLE 400 INTERVIEW QUESTIONS & ANSWERS
RPG/400 or RPGLE
Advantages of ILE or RPG?
Answer :
§ In RPG it is one step compilation (we will get *PGM
object) while in ILE-RPG it is two step compilation (we have to
create a *MODULE and then bind that module to a program.
§ In RPG we cannot call a program i.e. recursive
call is not supported. While in ILERPG it is supported.
§ Extended Factor 2
§ Length of Factor 1 & 2 is increased to 14 as
well as Length of OP-CODE is 10
§ Free format is allowed
§ Built-in-functions are available.
§ In case of ILE we have the concept of ACTIVATION
GROUP.
§ In ILE EPM (Extended Program Model) is
implemented while in RPG OPM (original program model)
What is sub-file?
Answer : It is group of records
read from or written to display file in a column format. It is always a
subset of records from physical file hence the name subfile.
SFL and SFLCTL ?
Answer : There are the two
mandatory key words for subfile program /design. While SFL is used to define Subfile
record format while SFLCTL is used to define Subfile Control Record format. And
this two are the different parts of sub-file.
What are the Sub file Types?
Answer: There are three types
of sub file
Load All - In which all the records from the
Physical file or at max. 9999 records are written to subfile. Here sub file
size should 9999 or the number of records form PF which ever is less. In this
case PAGEUP AND PAGEDOWN is taken care by system. SFLPAG should be less than
SFLSIZ.
Single Page/non-elastic – In this case sub file size
(SFLSIZ) must be equal to sub file page (SFLPAG). For example, if SFLSIZ = 10
and SFLPAG = 10, then 10 records from file are written to subfile. In this case
PAG
Expandable/elastic/growing – In this case SFLSIZ
should be grater at least by 1 than SFLPAG.(this is applicable to Load all type
also). For example, SFLSIZ = 10 and SFLPAG=9, then 10 records from written the
sub file from physical file but only 9 are displayed on screen.
What is SFLDROP and SFLFOLD?
Answer: These are the two
key-words used in sub-file for displaying additional information which cannot
fit one line. SFLFOLD will give view in folded form and SFLDROP will
give view in truncated form.
What is SFLCSRRRN and
SFLRCDNBR ?
Answer:
§ SFLCSRRRN will give the RRN of the record where
the cursor is positioned.
§ SFLRCDNBR will give the RRN of the First record
displayed on the screen at a given time.
What is SFLNXTCHG?
Answer: Whenever a record is changed on display file.
An MDT is set ON. If an indicator is associated with SLFNXTCHG and it is
SETON then READC will read only the changed record. And if the indicator is
not associated and it is seton it READC reads all the records from sub-file
Reading records
from a subfile using READC?
Answer: With the help of READC
op-code we can read only changed records from subfile.
Required key words for
subfile?
Answer: SFL, SFLCTL, SFLDSP,
SFLSIZ, SFLPAG are the mandatory key words. SFLDSPCTL, SFLCLR, SFLINZ,
SFLEND are the optional key words used in subfile.
PLIST and KLIST ?
Answer: PLIST is a list of
parameter and KLIST is the list of KEY fields.
Position to particular
record?
Answer: With help of op-code
SETLL from RPG/RPGLE, it will position the record pointer just before the
required record. Next READ will read that particular record.
LR indicator and RETURN
operation?
Answer:
LR indicator – It close all the open files, Frees the space
and release ODP.
Return – It dose not close files and dose not
release the ODP and passes the control to the calling program /
command prompt if the program is called from command prompt.
Different operations on
indicator?
Answer: There are only two
operations on indicator those are SETON and SETOFF.
What is the operation /
op-code to change in file?
Answer: In RPG/RPGLE with the
help of UPDAT / UPDATE op-code.
How do I insert a record
into a database file?
Answer: In RPG / RPGLE with the
help of WRITE op-code.
In
CL/CLLE we can not insert a record into database file.
Two way of deleting
records from file?
Answer: One is DELETE and other
with the help of O-Specs ADD/DEL specify DEL.
How to define a
subroutine ?
Answer: With help of two op-code
BEGSR(Begin subroutine) ENDSR (End subroutine) and between these two
op-codes write the instruction. The whole construct is defined as subroutine.
In case of Load all
sub-file, if we type options and then PGDN,PGUP , will options be there on
the display / in subfile.
Answer: Yes. It will retain all
the options entered in the previous page.
How will you take care
of multiple options in case sub-file?
Answer: We will have to handle
it within the program using a READC in a loop.
If we type some options
on screen out of which some are invalid and pressed enter, what should happen?
Answer: It should process all
the valid options before invalid options encounter. Once invalid options is encountered
program should stop processing and display error message at the bottom of
the screen.
How will you achieve
POSITION TO in Load all subfile?
Answer: While loading subfile
move RRN, KEYVALUE in to a two dimensional array. When a key value is
entered into POSITION TO field, having a LOOKUP into an array we can get a
corresponding RRN. Assigning RRN value to SFLRCDNBR and then
displaying the sub-file.
What are the built in
function in RPGLE ?
Answer: %SIZE -
Gives the size of the variable or literal
%PARM – Gives the number of parameter passed to parameter
%PADDR - Gives the address of the procedure
%ADDR - Gives address of the variable
%TRIM - Trims the right blanks of the string
%TRIML - Trims the Left blanks of the string
%REPLACE - Replaces the specified number of characters from the specified
position.
%SUBST - gives a sub string from a variable (%SUBST(X:Y:Z)
%ELEM - Gives number of elements or occurrences
%INDEX - Change the index of a table or multiple-occurrence data- structure.
%LEN – Returns the length of value from a field.
%CHAR – Converts a Numeric filed to character.
%EOF – End of File.
%FOUND – If record is Found.
How to print HEADER if
O-specs are used in program ?
Answer: With the help of op-code
EXCEPT.
How to define array in D
spec?
Answer:
D
ARR2
S
5 DIM(5) CTDATA PERRCD(1)
It is a Compile time
array.
D
ARR1
S
1 0 DIM(5)
It is a Run time array
D
ARR1
S
40 DIM(7) FROMFILE(File name) PERRCD(1)
It is Pre Run time
array
What is *PSSR and INFSR?
Answer: It is an exception/error
handling routine which is specified in F-Sepcs for a file. INFSR(*PSSR), INFSR
is an information subroutine to specify the routine name in F-specs.
How to go to *PSSR ?
Answer: Whenever an
exception/error occurs and *PSSR is declared in F-specs, it is automatically
goes to *PSSR
Can we all *PSSR if no
exception occurs? What happen it is called ?
Answer: Yes, Whatever the
statements specified are executed.
What is INFDS?
Answer: INFDS is a File
Information Data Structure.
1 -
8 Character
*FILE
The first 8 characters
of the file
9 -
9 Character
Open indication (1 =
open).
10 - 10
Character
End of file (1 = end of
file)
11 - 15 Zoned
dec *STATUS
Status code.
16 - 21
Character *OPCODE
Operation code The first
five posi
22 - 29
Character *ROUTINE
First 8 characters of
the procedure
30 - 37
Character
RPG IV source listing
line number
How to determine if the
record is in used by another user ?
Answer: We can determine
weather a record is in use bye another user with the help of status code (*STATUS).
If *STATUS = 01218 i.e. record already locked.
How to write *PSSR ?
Answer: It just similar to any
other subroutine.
*PSSR
BEGSR
………………
………………
…………….
ENDSR
What is Procedure ?
Answer: A procedure is the set
of self contained high level language statements that can perform a particular
task and then returns to a caller.
How to define a
procedure ?
Answer: First we have define
Procedure Prototype along with all parameter and PR.
D
PROC1
PR
Then
define Procedure with Begin/End
Procedure
Name
Begin/End
P
PROC1
B
Export
Then
define Procedure Interface along with parameter and PI
D
PROC1
PI
5 0
D PARMA
5 0
D
PARMB
5 0
Define all the parameters
as a variable to the procedure
D PARMA
S
5 0
D
PARMB
S
5 0
In not returnable
procedure, the procedure should end with
C
PROC1
E
In returnable procedure, it should end
with
C
RETURN
PARMA +
PARMB
What is Procedure
Prototype and Procedure Interface.
Answer:
Procedure Prototype In this section we specify the name of the
procedure along with PR.
D
PROC1
PR
Procedure Interface It is section where we define all the parameter
which are receiving or returning some values.
D
PROC1
PI
5 0
D PARMA
5 0
D
PARMB
5 0
How to define Global
Parameter in ILE ?
Answer: Declare a variable with
key word EXPORT and while using this variable in another program declare
with IMPORT keyword.
What is the disadvantage
of using Global variable?
Answer: We can not trace out at
which point the value of variable is changed.
What is Service Program?
Answer: A Service Program is a
collection of runnable procedures and available data items easily accessible
by other ILE programs. In many respects it is similar to a subroutine library
and procedure library.
A service program
differs from a program in two ways:
§ It does not contain a program entry
procedure. This means that you cannot call a service program using
the CALL operation.
§ A service program is bound into a program or
other service programs using binding by reference.
What is *ISO date format?
Answer: YYYY-MM-DD for other
formats refer to IBM manual or ERIS document.
If we tried to move year
part of *ISO date into a field of length 3, what will happen ?
Answer: Program crashes,
as in case of *ISO format it required fields of 4,2,2.
How to avoid using
indicators in ILE ?
Answer: By using the standard
Built In Expressions like %FOUND,%EOF, NOT %EOF, %BOF, NOT %BOF…etc.
RPG/RPGLE 400 INTERVIEW QUESTIONS & ANSWERS
This comment has been removed by the author.
ReplyDeleteSmall point regarding %TRIM - this BIF trims both leading and trailing spaces.
ReplyDelete%TRIMR trims just the trailing spaces.
Small point regarding %TRIM - this BIF trims both leading and trailing spaces.
ReplyDelete%TRIMR trims just the trailing spaces.
Please visit www.as400interviewquestions.com for all as400 interview question
ReplyDelete