Skip to main content

RPG Interview Questions

Q: If in the control-specification we state DEBUG(*NO), no dump is executed. How can we override the DUMP keyword?

By specifying the operation extender A DUMP(A), we can override the DUMP keyword.

This operation extender ensures a dump is performed successfully, regardless of the DEBUG keyword value.

Q: How do you code Renames for File Field?

In an externally described file, the PREFIX keyword is used to partially rename the fields.

Q: What are few ILE advantages over RPG?

ILE stands for Integrated Learning Environment.

·         Better performance

·         Modularity - Smaller code components

·         Easier maintenance

·         Multiple-language integration

·         Reusable components

Q: Suppose in ILE PGMA that has 2 parameters and call PGMB that expects 3 parameters from PGMA? What's the error message that we'll get when we execute?

RNF5406: The call passed fewer parameters than the prototype indicates are required

Q: In ILE, Suppose PGMA that has 2 parameters and calls PGMB that expects 3 parameters from PGMA? How can we handle the problem?

The keyword *NOPASS states that the parameter is an optional parameter, which need not be transferred.

D   Name                  10A   options(*NOPASS)

Q:  What are the different specification types?

·         H-Spec

·         F-Spec

·         D-Spec

·         I-Spec

·         C-Spec

·         O-Spec

Q: For what purpose is the H Specs used?

Write header information, date separator, currency symbol, etc.

Q: What are the different file types in the RPG?

I (Input), O (Output), U (Update) & C (Combine).

Q: What are the different File Designation Types in RPG?

·         P (Primary)

·         F (Fully Procedural)

Q: What's the use of File Designation in RPG?

It refers to accessing or retrieving data from a file

Q: What are the different types of file formats?

F (Fixed Length) & E (Externally Described)

Q: List some of the commonly used debugging commands

STRDBG, STRISDB.

Q: What command is invoked when we give option 14 against RPGLE program?

CRTBNDRPG

Q: What happens if we use the STRISDB command for the RPGLE program?

Error: Program type not valid

Q: What is the STRSRVJOB command used for?

It is used to debug a batch program or to debug an interactive program for another job.

Q: How do you use DEBUG utility?

STRDBG program-name UPDPROD(*YES)

Q: How do I debug a batch job?

Hold the batch job to be debugged using the WRKACTJOB command and give option 3. Set the pointer to be debugged in the batch program using STRDBG and call the STRSRVJOB command and start the service program that enters the debug mode. After entering the debug mode, release the job that has been held before.

Q: How many files can be defined in F specs?

50

Q: How many printer files can be defined in F specs?

8

Q: Provide three main purposes of File specification?

To define a file, to describe a file, to assign a file to a specified device.

Q: In F Specs, when you define a flat file in your program, which format do you specify?

Flat File: - F (Fixed Length)

Other File: - E (Externally Described)

Q: How do you specify a page overflow indicator for your printer files?

Specify an indicator in position 33-34 of F specification.

Q: What's the primary file?

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

Q: Can you access an indexed file in the arrival sequence?

Yes.

Q: What is the file described in the program?

The field name and field length are defined in the RPG program.

Q:  What's an externally described file?

All field information is specified in the DDS and the RPG program can use it in the program.

Q:   Can you specify the display file to be used in the following modes: Input, Output, or Combined modes?

Yes.

Q: We have a database file without any key fields. How to read records from an ascending order file through RPG.

By using RRN.

Q: How do we handle file status codes?

The built-in function, %STATUS may contain any of the status codes within the range 1000 to 9999.

Q: How we can find how many records there are in a file without reading the RPG file.

• INFDS keyword in file description specification with the name of the file information data structure.

• In file information data structure and the subfield (NUM_RCDS) on a  definition specification.

DCL-F MYFILE PRINTER(132) INFDS(OPNFBK);

DCL-DS OPNFBK;

NUM_RCDS      INT(10)    POS(156);    // Num of records

Q: What is the purpose of the CVTRPGSRC Command? Or how we can convert RPG source code to ILE source code?

The command to Convert RPG Source (CVTRPGSRC) converts source code for RPG III or RPG/400 to source code for ILE RPG.

Q: How do we decide, if another user uses the record?

With the aid of status code, we can decide whether a record is in use by another person. If *STATUS = 01218 i.e. record already locked.

Q: Which are the String Manipulation Opcodes?

TESTN, SCAN, CHECK, CHECKR, SUBST & CAT

Q What opcode can be used to test an alphanumeric field for all numeric values?

TESTN

Q:  What opcode can be used to test the zone of a character field?

TESTZ

Q: How to reposition the file pointer after it has reached EOF.

The file pointer is repositioned with SETLL opcode.

Q: What is the difference between operation codes CLEAR and RESET?

Clear - Clear the value of variable, Data structure, Array etc.

Reset-retains the initialized value for the first time.

Q: What is the operation / opcode to change in file?

UPDATE opcode.

Q: How do I insert a record into a database file?

WRITE opcode.

Q: How to skip the junk records in the flat file?

By using %Check

Q: Ways to delete records from file?

DELETE opcode

Q: What is QCMDEXC?

A program that can be invoked from an RPG program to execute most of the CL commands.

Q: What is as an Array?

Array is collection of elements of same data type.

Q: Different types of arrays?

Compile Time array, the array elements will be loaded before programs are run. The values of the array are going to be static.

The pre-runtime array is placed in a separate file. If we make any changes to the array element, we can change this file containing the array element instead of changing the program.

Run time array means that the value will be loaded during runtime only. The value of an array will be dynamic.

Q: How to define different types of arrays in D spec?

Compile time array.

D ARR1            S              5    DIM(5) CTDATA PERRCD(1)

PreRun time array

D ARR2            S             40    DIM(7) FROMFILE(File name) PERRCD(1)

Run time array

D ARR3            S              1  0 DIM(5)

Q: What is the difference between array and a multiple occurrence data structure?

The values stored in array don’t vary.  In the other hand, we can store the different values in same variables at various stages.

Q: What are the Array Operations?

LOOKUP used to find an element in an array.

MOVEA to Move/transfer the values from factor2 to result field.

SORTA to Sort an Array

XFOOT to Sum the Elements of an Array

Q: One program with the OP-Code Return before the LR Set. Will the program execute the LR statement set or not?

Nope. Brings you back to the call program.

Q: What's a Subfile?

To view a tabular format file, it is a collection of records read from or written from.

Q: Maximum subfile size?

9999

Q: what is SFL and SFLCTL?

SFL is used to define the subfile record format and SFLCTL is used to define the subfile record control format.

Q: What is the process involved in subfile?

Subfile process can be divided mainly into 3 parts:

1.  Clearing the subfile control record format.

2.  Loading the subfile buffer with the relevant data.

3.  Displaying the data from subfile buffer to the display device.

Q: What are the Sub file Types?

Three types of sub file

·         Load All

·         Single Page

·         Expandable

Q: What's the Load All Subfile?

• In which all records are in the Physical File or at max. 9999 records will be loaded to the subfile.

• In this case, PAGEUP & PAGEDOWN is taken care of by the system.

• SFLPAG should be lower than SFLSIZ.

Q: What's a single page subfile?

• In this case, the sub-file size (SFLSIZ) must be equal to the sub-file page (SFLPAG).

• In this case, the handling of PAGEUP and PAGEDOWN is required.

Q: What's an Expandable Subfile?

1. In this case, SFLSIZ should be at least 1 larger than SFLPAG.

2. This PAGEUP handling is not required, as the system itself takes care of it.

3. Only PAGEDOWN handling is needed.

Q: Which type of subfile has the best performance?

Single page.

Q: What are SFLDROP and SFLFOLD?

Whenever we display information on a subfile that cannot fit in one line, we can view it in truncated form by using SFLDROP. SFLFOLD in a folded form.

Q: Which line command will be used if the user wants to center the company name on his report?

CF.

Q: What is the difference between CAnn (Command Attention) and CFnn (Command Function) function keys?

CF- Screen is also passed along with the indicator

CA- Only indicator is Passed

Q: What are the SFLCSRRRN and SFLRCDNBR?

SFLCSRRRN gives the record RRN in which the cursor is located.

SFLRCDNBR provides the First Record RRN seen on the screen at a given time.

Q: What is the SFLNXCHG?

Whenever the record is changed on display file, the MDT will be set to ON. If the indicator is associated with the SLFNXTCHG keyword and SETON, then READC will read only the changed record.

Q: How do we read only changed records from a subfile?

By using an opcode of READC, we can read changed records from a subfile.

Q: In the case of Load all sub-file, if we type options and then PGDN, PGUP, the options will be in the display / subfile.

Yes.

Q:  How are you going to take care of multiple options in the sub-file?

READC in a loop.

Q: What are all the compiler directive statements?

/TITLE, /SPACE, /EJECT, /COPY

Q: Can more than one subfile record be shown on a single line?

Yes, using the keyword of SFLLIN.

Q: How are you going to achieve POSITION TO Load all subfiles?

Move RRN or Key value while loading a subfile. When a key value is entered in the POSITION TO field, we can have a LOOKUP in the array to get the corresponding RRN. Assign RRN value to SFLRCDNBR and then display the sub-file.

Q: What keyword must be used with PROTECT keyword?

OVERLAY

Q: What is the necessary keyword needed to scroll the sub file records?

SFLSCROLL (Subfile Scroll)

Q: What happens when SFLSIZ = SFLPAG? what are the advantages and disadvantages

The result is a single page sub-file. Loads only one page of records at a time, clears the buffer and reloads another set of records.

Q: Explain SFLCLR, SFLEND, SFLDLT & SFLCSRRRN?

•SFLCLR - to Clear the subfile area before the subfile is created.

•SFLEND - Displays positive sign to the right of the last sub-file record on the current page, which means more records are available to process.

•SFLDLT - Deletes a subfile.

•SFLCSRRRN - RRN of the subfile record where the cursor was positioned, is returned.

Q: What are the mandatory keywords in subfile and explain the subfile process in RPG.

SFL                   To define the record is Subfile record.

SFLCTL            To define the record is a control record.

SFLDSP           To display the data is the display screen.

SFLSIZ             To identifies the Subfile size. The max size for Load all is 9999.

SFLPAG           To identifies the no. of record to be displayed at a time. For load all it should be less than SFLSIZ

Q: How to read iSeries dump after a Decimal data error?

Statement in Error

Q: Figurative constants in RPGLE?

*HIVAL, *LOVAL, *ZERO, *ZEROS, *BLANKS, SETLL, SETGT.


Q: Give an sample code for RPGLE free format Call program.

D NAME                  S             30A   INZ('AS400')    

D AGE                     S             3S 0  INZ(21)         

D PROGRAMB        PR                   EXTPGM('PROGRAMB')

D NAME                                 30A                   

D AGE                                     3S 0                 

 /FREE                                                

    PROGRAMB(NAME:AGE);                             

    EVAL *INLR = *ON;                                 

    RETURN;                                           

 /END-FREE       

Q: How do you set pointers to value 300 or greater value?

SETGT

Q: When chain opcode will be helpful?

•  In order to find a match, The CHAIN opcode does a SETLL and READE .

•  CHAIN is used to locate a unique record from a file.

Q: What's the difference between CHAIN and SETLL? Is there a performance advantage?

There are two significant differences between CHAIN and SETLL.

• The CHAIN operation applies a record lock to files that are opened or updated. The SETLL operation does not apply to the lock.

• The CHAIN operation copies the data of the record to the program input buffer. The operation of SETLL is not.

Q: What is the different between READE and CHAIN opcodes?

READE

CHAIN

The matching records for table

The first matching records only

We are using the looping concept

Looping is not necessary

The indicator setin the EQ

The indicator setin the HI

We are most using in SETGT or SETLL

It is not necessary

 

Q: What is the purpose of the "N" in the following calculation specification?

C    KEY        CHAIN FILE        N        99

If you specify 'N' in 53rd position, the record will not be locked if you try to read the locked record. It's a way to avoid a record lock.

Q: Define the opcode check?

It is used to check the position for non-occurrence of a character in a string.

Q: What's the difference between * LIKE and * NAMVAR?

* LIKE defines program variables in the same way as other predefined variables.

* NAMVAR is used to define variables as the data area.

Q: what is Dump Opcode?

We can take the program dump with the aid of DUMP opcode. That is, information / values related to all fields, all files, indicators, data structures, program arrays.

Q: Define the purpose of the LEAVE operation?

If you specify LEAVE, the control will transfer to the ENDDO statement below.

Q: Define the purpose of the ITER operation?

If you specify the ITER, the groups of statements are allowed to execute repeatedly.

Q: What is the opcode, which is a replacement for WRITE (format name) + READ (format name).

The EXFMT operation is a combination of a WRITE operation followed by a READ to the same record format.

Q: How we define key fields?

KFLD (Define Key fields): It comes into picture when we define a key list. It represents the key fields of a key list.

Q: Want to extract the file based on multiple keys, what is the Opcode to achieve the results from a file?

KLIST (Define a Composite Key) consisting of many key fields that is used as an argument for performing operation on a file.

Q: What is MOVE opcode?

MOVE operation/opcode transfers/moves the value from factor 2 to the result field.

Q: What is the use of the MOVEA operation?

To transfer an array to another storage location.

Q: What is the difference between the MOVE and the MOVEL?

MOVE transfer is a right justified move, MOVEL is a left justified move.

Q: What is monitor group?

MONITOR (Begin a Monitor Group) If there is no error indicator or 'E' extender and the code that generates the exception is in the MONITOR block of the MONITOR group, the control will go to the MONITOR group on-error section.

Q: Read opcode?

READ (N | E) (Read a Record) reads the records of a full procedural file.

Q: Which are the Relational Operators in RPG?

GT, GE, LT, LE & EQ.

Q: Which Operator Extender will be used to prevent files from being locked when we read a file in update mode?

The READ operation applies the record lock to files that are opened in the update mode. We use the operator extender 'N' to avoid lock.

Q: What is the opcode that we're going to use to find a changed record?

READC will read subfile records that have been changed.

Q: What is the opcode that we're going to use to find the matching record?

READE Opcode

Q: What is the opcode that we're going to use to read the previous record? 

 READP opcode

Q: How does the READP work?

It reads data from a physical file in reverse order.

Q: What is the opcode which we will be using to find a previous matching record?

READPE opcode

Q: Return Opcode?

RETURN (H | M | R)    (Return to Caller)

• Return ends the program and gives the control to the calling program.

• Return doesn’t release the files.

• After control returns to the calling nothing will be processed.

Q: What is SCAN and XLATE?

The SCAN operation scans the character string (base string) in factor 2 for the substring (compare string) contained in factor 1.

XLATE operation translates characters in source string (factor 2) to the from and to strings (factor 1) and put into the result field.

Q: Which opcode will be used to set the pointer to a particular value in the RPG.

SETLL opcode sets the file pointer for a key field / RRN value greater than or equal to the value of the search argument factor-1.

Q: What is the opcode which we use to translate the value from lowercase to uppercase?

XLATE opcode

Q: What is operational extender in RPG. Why we can use this extender in RPG.?

Operation extenders provide additional attributes performed on opcode.

Q: What are the different types of operation extenders?

A Used on DUMP operation to indicate that the DUMP is always performed regardless of the DEBUG option set on the control/H specification.

H Half adjust/round result of numeric expression.

N Record is read but not locked Set pointer

P Paded with blanks for result field

D Pass operational descriptors on Date field

T Time field

Z Timestamp field

M Default precision rules

R "Result Decimal Position" precision rules

E Error handling

Q: Difference between PLIST and KLIST?

PLIST is used to list the parameter

KLIST is used to the list the KEY fields.

Q: What is CASxx used for?

To execute subroutines based upon the result of a logical comparison.

Q: What are the built-in functions in RPGLE?

%DATE

%PARM

%ABS

%TRIM

%SUBST

%LEN

%CHAR

%EOF

%FOUND

Q: How %FIELDS Built-In function work

%FIELDS built in function is used to partially update a file. when we may need to update only 1 or 2 fields of a file, we use this function.

Q: How %CHECK Built-In function work

%CHECK function is used to find the non-occurrence of a character in a string.

FORMAT:

%CHECK(comparator : base string {: Start position})

Q: Trying to write a record that already exists, the file being used has unique keys and tried to write duplicate relative record number to the subfile. What are the approaches to this type of issue?

Write( E) write with an operation extender 'E'.

EX:

C          WRITE(E) FILENAME

C          If       %STATUS = 01021

C          CALL      PROGRAMNAME

C          EndIf

Q: How we can handle the errors in RPG?

•  For Files we use INFDS

•  Opcode with E extender

•  Monitor Group

•  *PSSR

•  %Error

•   Program status

Q: How do you define a subroutine?

BEGSR(Begin Subroutine) 

//Write the instructions / statements to perform between these two op-codes.

ENDSR (End Subroutine) . 

Q: Can a Subroutine contain a different/another Subroutine?

No.

Q: Does the SETLL & SETGT retrieve the record?

No, they simply position to the record.

Q: What is the purpose of indicators In RPG?

To indicate the result of an operation or to control the processing of an operation.

Q: Specify different indicators used in RPG?

•         Overflow indicators

•         Record Identifying Indicators

•         Field Indicators

•         Resulting Indicators

•         Control Level Indicators

Q: Difference between LR indicator and RETURN operation?

LR Indicator Closes all open files, frees space, and Releases the Open Data path.

Return won’t close files and does not release the Open Data Path. It passes the control to the calling program.

Q: How would you make sure that the files are closed when the program is finished?

Specifying the LR indicator in the RPG and

Specifying the close file command or using the RCLRSC command

Q: What are the different operations/opcodes on indicators?

SETON and SETOFF.

Q: How to avoid using indicators in ILE?

By using the Built in %FOUND, %EOF, NOT %EOF

Q: Why do we define move *ON to *INLR?

It frees the memory.

Q: What is the maximum size of data area?

9999

Q: What is the data area and how is it used in the RPG program?

The data area is an object used to store data. The data is read by \"IN\ "and the opcode is written by \"OUT\."

Q:  Why do we use data structures?

Data structure is a structure, having different type of data fields.

Data Structure is used to

•         Break fields into sub-fields

•         Group fields

•         Change the format of the field

•         Group non-contiguous data into contiguous format

•         Convert data.

Q: Different Types of data structures in as/400?

Types of data structures in as/400:

•         PROGRAM DESCRIBED DATA STRUCTURE

•         EXTERNALLY DESCRIBED DATASTRUCTURE

•         MULTIPLE OCCURENCE DATASTRUCTURE

•         INDICATOR DATA STRUCTURE

•         DATA AREA DATA STRUCTURE (SPECIFIED IN 'U')

•         PROGRAMME STATUS DATASTRUCTURE (SPECIFIED IN 'S')

•         FILE INFORMATION DATASTRUCTURE

Q: What is *PSSR and INFSR?

You can write a program error subroutine (* PSSR) to manage a program error or an exception. If an error occurs on a program:

The program status data structure is updated.

If an indicator is not specified in positions 73 and 74 for the operation code, the error is handled, and control is transferred to the *PSSR.

You can explicitly transfer control to a program error subroutine after a file error by specifying *PSSR after the keyword INFSR on the File Description specifications.

Q: How to go to *PSSR?

PSSR stands for program error subroutine.

Whenever there an exception/error occurs and *PSSR is declared in F-specs, it will automatically going to *PSSR

Q: How to write *PSSR?

It similar to subroutine.

*PSSR                    BEGSR

// statements fall here

ENDSR

Q: What does the phrase “subscript out of range” mean?

It means you are trying to access an area outside of the defined table range.

Q: What is INFDS?

INFDS is a File Information Data Structure. Contains a predefines Structured format.

Q: What is the purpose of the following

C/COPY    QRPGSRC, ORDERR

During the compilation the source code of ORDERR copy book is copied into the               existing program. Whereas /COPY is compiler directive statement.

 


Comments