Here is a solid set of 20 intermediate/advanced IBM i (AS400 / RPGLE / CL) interview questions.
I’ll answer them one by one, clearly and concisely:
1. Which library gets loaded first when we login to IBM i?
-
QSYS library is always the first loaded because it contains essential IBM-supplied objects and system commands.
-
Then comes user profile’s job description library list (like QGPL, QTEMP, and user libraries).
2. How to see all the objects in library and its size?
-
Use:
DSPOBJD LIB(MYLIB) OBJ(*ALL) DETAIL(*ALL)→ shows all objects. -
For library size:
DSPLIB LIB(MYLIB) OUTPUT(*PRINT)orWRKLIB MYLIB(F11 = size).
3. How to check all members of a file?
-
Command:
WRKMBRPDM FILE(MYLIB/MYFILE)or -
DSPFD FILE(MYLIB/MYFILE) TYPE(*MBRLIST).
4. How to see all record formats used in a file?
-
Command:
DSPFD FILE(MYLIB/MYFILE) TYPE(*RCDFMT). -
It shows all record formats defined in PF/LF.
5. How to change the record size of a PF?
-
Use:
CHGPF FILE(MYLIB/MYFILE)withMAXMBRS,LVLCHK,REUSEDLT, etc. -
If DDS change is required: Update DDS →
CHGPForCRTPFwithFILE(MYLIB/MYFILE).
6. Why we use USROPN keyword in RPGLE?
-
USROPN = User Open.
-
File will not be automatically opened at program start; programmer must explicitly
OPENandCLOSE. -
Useful for performance and conditional opening of files.
7. Why we use EXTMBR keyword in RPGLE?
-
EXTMBR('MBRNAME') is used when PF has multiple members.
-
It lets RPGLE program access a specific member instead of default
*FIRST.
8. What is the purpose of using Varying?
D Var1 S 10A Varying
/Free
Var1 = 'HELLO';
/End-Free
-
VARYING means storage allocated only for actual length + 2 bytes (to store length).
-
Saves memory and allows dynamic string manipulation.
9. What is CPF4131?
-
CPF4131 = Record Lock Error.
-
Raised when program tries to update/delete a record locked by another job.
10. Difference between CRTDUPOBJ and CPYF command?
-
CRTDUPOBJ: Duplicates object (programs, files, data areas, etc.) definition; optionally with data.
-
CPYF: Copies records between files; structure must exist.
11. Mandatory keywords for subfile?
-
SFL → Defines subfile format.
-
SFLCTL → Subfile control record format.
-
SFLSIZ (size) and SFLPAG (page size) required.
-
SFLDSP, SFLDSPCTL, SFLCLR, SFLEND commonly used.
12. Difference between PLIST and KLIST?
-
PLIST: Defines parameter list (used in CALL/PARM).
-
KLIST: Defines key list (used in CHAIN/SETLL with multiple fields).
13. Difference between *INLR = *ON and RETURN?
-
*INLR = *ON: Last record indicator, closes files and releases storage. -
RETURN: Exits program but doesn’t necessarily close files. -
Using both ensures program ends cleanly.
14. Effective use and side effects of *INLR? How to overcome?
-
Side effect: Files remain open, causing record locks if
*INLRnot set. -
Solution: Use
CLOSEor activation groups (in ILE). -
Example: In service programs, avoid *INLR; use RETURN and CLOSE explicitly.
15. What operations we can perform on Indicators?
-
Turn ON or OFF.
-
Used for conditions (IF), record operations (CHAIN, READ), controlling display fields, conditioning opcodes.
16. How to check if a record is locked in RPGLE?
-
Use
CHAIN(E)orREAD(E). -
E(Error/Lock) extender sets%ERRORor indicator ON if record is locked. -
%STATUS = 1218indicates lock.
17. How can we execute a CL command from within RPG program without calling a CL program?
-
Use QCMDEXC API:
C CALL 'QCMDEXC'
C PARM CMDstring
C PARM CMDlength
18. Can we use a file with same file and record format name in RPGLE?
-
Yes, but not recommended.
-
To resolve, use
RENAMEkeyword in F-spec:
FMYFILE IF E K DISK RENAME(MYREC:NEWREC).
19. What are those commands which can only be executed in CL program but not in RPG program?
-
Examples:
OVRDBF,DLTF,SBMJOB,RTVJOBA,RTVMBRD, etc. -
These are CL-specific commands (RPG can run them via QCMDEXC, but not natively).
20. How to retrieve RRN value of the file record in RPGLE?
-
Use function
%RRN(fileName)after CHAIN/READ. -
Example:
C READ FILE1
C Eval rrn = %RRN(FILE1)