Excellent set of 20 AS400 / RPGLE / CL interview questions 🙌
I’ll answer them one by one, with clarity and examples.
1. How SFLSIZ and SFLPAG differs with all 3 types of Subfiles?
-
SFLSIZ = total subfile size (number of records that can be loaded).
-
SFLPAG = number of records displayed at a time (one page).
-
Types:
-
Load-All: SFLSIZ = large enough for all records; SFLPAG = screen limit (e.g. 10).
-
Expanding: SFLSIZ > SFLPAG; subfile grows as you load records.
-
Rolling: SFLSIZ = SFLPAG; when user pages down, earlier records are removed and new ones added.
-
2. How to identify whether any job is interactive or batch?
-
In CL:
RTVJOBA JOBTYPE(&TYPE)
→ *INTERACT or *BATCH. -
In RPG: Use API
QUSRJOBI
to retrieve job info. -
Normally: WRKACTJOB → Subsystem *QINTER = interactive, *QBATCH = batch.
3. How will I explicitly open a file in RPG program?
-
Specify
USROPN
in F-spec:
FMYFILE IF E K DISK USROPN
/Free
OPEN MYFILE;
CLOSE MYFILE;
/End-Free
4. How do you set pointer to some value or its next or higher value?
-
Use SETLL: sets record pointer to equal or next higher key.
-
Use SETGT: sets record pointer to strictly greater key.
5. How can we execute a job in AS400?
-
Submit to batch:
SBMJOB CMD(CALL PGM(MYPGM)) JOB(MYJOB)
. -
Interactive: call directly:
CALL PGM(MYPGM)
.
6. How can we translate values from lower to upper in RPG and Embedded SQL?
-
In RPG:
%XLATE('abcdefghijklmnopqrstuvwxyz':'ABCDEFGHIJKLMNOPQRSTUVWXYZ':Var)
. -
In Embedded SQL:
UPPER(column_name)
.
7. How can we write and read a value using DSPF in CL program?
-
Use
SNDRCVF RCDFMT(FORMAT1)
to display and receive input. -
Then read variables declared in CL with
DCL
.
8. How to check end of file in CL?
-
Use RCVF command inside loop.
-
Monitor for message
CPF0864
(end of file).
9. Can you update a database file in CL?
-
Direct update not possible in CL.
-
You must use RUNSQL or call RPG/SQL program to update.
10. How do you monitor the message in CL?
-
Use MONMSG after command:
RCVF
MONMSG CPF0864 EXEC(GOTO ENDOF)
11. What is CA and CF and difference between them?
-
CA (Command Attention key): Immediate action keys (e.g., F3=Exit).
-
CF (Command Function key): Function-related keys that send data back to program.
-
Difference: CA = exit/attention, CF = normal function.
12. What can be done from O specs in RPG?
-
O-Specs (Output specs) used for report writing.
-
Formatting, line spacing, printing variables. (Mostly obsolete in RPG IV; replaced by printer files).
13. What is *PSSR?
-
Program Status Subroutine.
-
Error-handling routine in RPG called automatically on program error.
-
Can retrieve error info from DS like
INFDS
.
14. Why we use *INLR = *ON?
-
To indicate program end, close files, release storage.
-
Without it, program remains resident in memory.
15. What we called the program variable used with embedded SQL?
-
Host Variables.
-
Declared in RPG (
DCL-S
) and referenced in SQL with:VAR
.
16. How to find dependents of a file in AS400?
-
Command:
DSPDBR FILE(MYLIB/MYFILE)
→ shows dependent files, programs, etc.
17. What is the length of variable in DCL VAR(&VAR1) TYPE(*CHAR)?
-
By default length = 1 unless LEN specified.
-
Example:
DCL VAR(&VAR1) TYPE(*CHAR) LEN(10)
= 10 chars.
18. What is the length of variable in DCL VAR(&VAR2) TYPE(*DEC)?
-
Default length = 15,5 (15 total digits, 5 decimals).
-
Example:
DCL VAR(&VAR2) TYPE(*DEC) LEN(7 2)
= 7 digits with 2 decimals.
19. What is the disadvantage of a global variable in AS400?
-
Global variables consume memory throughout program execution.
-
Risk of unintended value changes across procedures.
-
Not thread-safe in multi-activation group environment.
20. How can we avoid using indicators in RPG?
-
Use Built-in Functions (BIFs) like
%EOF
,%FOUND
,%ERROR
. -
Example:
If %EOF(MyFile);
// End of file reached
EndIf;
✅ That’s a complete answer set.