November 30


Interview Question and Answer – *RPGLE Integrated Language Environment (ILE) RPG

By NickLitten

November 30, 2013

exam, legacy, QA, RPG

ILE RPG (sometimes called RPG4) was the biggest change to the RPG programming language in recent years.

What are the advantages of ILE in RPG?

  • 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 ILE RPG it is supported.
  • 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.
  • ACTIVATION GROUP logic lets us build boundaries around executable business logic.
  • In ILE EPM (Extended Program Model) is implemented while in RPG OPM (original program model)

What is a sub-file?
Scrolling data displayed on a terminal. 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.

What is subfile control – SFL and SFLCTL ?
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?
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.

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.

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.

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
With the help of READC op-code we can read only changed records from subfile.

What are the Required Display File key-words for subfiles?
SFL, SFLCTL, SFLDSP, SFLSIZ, SFLPAG are the mandatory key words. SFLDSPCTL, SFLCLR, SFLINZ, SFLEND are the optional key words used in subfile.

Difference between PLIST and KLIST
PLIST is a list of parameter and KLIST is the list of KEY fields.

How do we programatically Position to particular record when using native IO?
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.

Difference between LR indicator and RETURN operation?
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?
There are only two operations on indicator those are SETON and SETOFF.

What is the operation / op-code to change in file?
In RPG/RPGLE with the help of UPDAT / UPDATE op-code.

How do I insert a record into a database file?
In RPG / RPGLE with the help of WRITE op-code.
In CL/CLLE we can not insert a record into database file.

Thtee ways of deleting records from file?
Use SQL or in native IO use the DELETE keyword and other with the help of O-Specs ADD/DEL specify DEL.

How to define a subroutine ?
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.
Yes. It will retain all the options entered in the previous page.

How will you take care of multiple options in case sub-file?
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?
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?
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 a 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 ?
%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 ?
With the help of op-code EXCEPT.

How to define array in D spec.
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?
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 ?
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 ?
Yes, Whatever the statements specified are executed.

What is INFDS?
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 ?
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.

What is Procedure ?
A procedure is the set of self contained high level language statements that can perform a particular task and then returns to a caller.

What is Procedure Prototype and Procedure Interface.

Procedure Prototype
In this section we specify the name of the procedure along with 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 PARM 5 0

How to define Global Parameter in ILE ?
Declare a variable with key word EXPORT and while using this variable in anther program declare with IMPORT keyword.

What is the disadvantage of using Global variable?
We can not trace out at which point the value of variable is changed.

What is Service Program?
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?
YYYY-MM-DD for other formats refer to IBM manual or ERIS document.

If we try to move year part of *ISO date into a field of length 3, what will happen ?
Program crashes, as in case of *ISO format it required fields of 4,2,2.

How can we avoid using indicators in ILE ?
By using the standard Built In Expressions like %FOUND,%EOF, NOT %EOF, %BOF, NOT %BOF…etc.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips