Here’s the 9th set of 20 AS400/IBM i interview Q&A (CL, RPGLE, message handling, file ops).
1. How we retrieve system date in CL?
-
Use RTVSYSVAL:
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&TODAY)
-
&TODAY
will hold the system date.
2. What is command to convert date format in CL?
-
Use CVTDAT:
CVTDAT DATE(&DATE1) TOVAR(&DATE2) FROMFMT(*MDY) TOFMT(*ISO)
3. What is the command used for retrieving user profile attributes?
-
DSPUSRPRF or RTVUSRPRF.
-
Example:
RTVUSRPRF USRPRF(&USER) SPCAUT(&SPCAUT)
4. What is a Message Queue?
-
An object (
*MSGQ
) that stores messages sent by system, jobs, or programs.
5. What are different Types of message queues?
-
Program message queues → temporary, exist for running programs.
-
User message queues → permanent objects (e.g., QSYSOPR).
6. What is monitor group?
-
A block in CL where errors are monitored using MONMSG.
-
Groups related commands and error handling together.
7. What’s the difference between *LIKE and *NAMVAR?
-
*LIKE → defines a variable with same attributes as another.
-
*NAMVAR → declares a variable name that references a data area or CL variable.
8. MSGID to catch all generic messages in CL?
-
CPF0000
→ catches all CPF (Common Program Facility) messages.
9. What’s an Output Queue (*OUTQ)?
-
Queue where spooled files (reports, job logs) wait until printed.
10. What’s a Job Queue (*JOBQ)?
-
Queue where submitted jobs wait for execution by subsystems.
11. How can programmer exit out of CL program?
-
Use RETURN command.
12. How we get to know check object is failed?
-
Use CHKOBJ → followed by MONMSG CPF9801 (object not found).
13. Can we reposition file pointers in CL after reaching EOF? Explain how it works?
-
❌ No direct repositioning in CL.
-
File access is sequential in CL.
-
To restart, you must close and reopen the file.
14. Does the SETLL & SETGT retrieve the record?
-
❌ No.
-
SETLL → positions at equal or next higher key.
-
SETGT → positions strictly greater.
-
Must use READ/READE after positioning.
15. How we can handle the errors in RPG?
-
Methods:
-
INFSR (File Error Subroutine).
-
*PSSR (Program Status Subroutine).
-
MONITOR / ON-ERROR / ENDMON block (ILE RPG).
-
16. In F Specs, when you define a flat file in your program, which format do you specify?
-
Record Format name = file name (since only one format exists).
17. What is the opcode which we will be using to find a previous matching record?
-
READE(P) with key fields (read equal with previous).
-
Or READP directly.
18. How does the READP work?
-
Reads the previous record in the file (reverse sequential).
-
If keyed, goes backward through the access path.
19. What is the opcode that we’re going to use to find the matching record?
-
CHAIN → retrieves record matching given key.
20. What is the opcode that we’re going to use to find a changed record?
-
READC → reads next changed record in a subfile.
✅ That’s 180 questions total (9 sets).
AS400 interview questions | Answers with explanation for 20 questions | Part9