Twenty years ago these are the kind of things you had to know to work on the old AS400 systems. I found these on an old dusty corner of my homeserver. Enjoy the trip down memory lane or to use old RPG lingo AS400 NERD CABEQ ‘1’ START
What is RPG ?
Report Program Generator.
What are the positive points of RPG Language ?
Contains opcodes which makes it flexible with OS/400 Can access the externally described file.
Explain RPG Program Logic Cycle ?
When is it efficient to make use of RPG Cycle ?
When the file is arranged in sequence and output is based on control break.
Can you call a program in your RPG program, which is coded in some other language?
Yes, Any program object available on AS/400.
What are the different types of specification available in RPG/400 ?
Control Spec.( H )
File Spec.( F )
Extension Spec.( E )
Line counter Spec.( L )
Input Spec.( I )
Calculation Spec.( C )
Output Spec.( O )
Is it necessary to define all formats? Which are mandatory and which are Optional?
No, all are Optional.
What is the use of H spec. in RPG ?
It identifies by H in column 6, Provides information about generating and running programs.
When will DUMP and DEBUG opcodes be ignored ?
If blank is specified in position 15 of H specs.
What are the valid file types ( position 15 ) in F specification ?
O (Output file).
U (Update file).
C (Combined (I/O) file).
Specify different indicators used in RPG ?
Record Identifying Indicators.
Control Level Indicators.
What are Control level indicators ?
L1 to L9 used to identify certain fields on control fields and then used to condition which operations are to be processed at detail or total calculation or output time.
What is the use of E specification in RPG ?
Extension Specs describes all record address files, arrays and tables.
What is the use of L specs in RPG ?
Line counter specification can be used to describe printer file to indicate the length of the form and number of lines per page.
In which specification can a report layout be defined ?
How many files can be defined in F specs ?
A maximum of 50 files.
How many printer files can be defined in F specs ?
A maximum of 8 files.
Give three main purposes of File specification ?
To define files, to describe the files, to assign the files to specified devices.
How do you specify page overflow indicator for printer files in RPG ?
Specify an indicator in positions 33-34 of F specification.
What is a Primary File ?
It is used in RPG Program Cycle to automatically read records in a cycle.
Can an indexed file be accessed in arrival sequence in RPG program ?
What is a program described file in RPG ?
The field name and length of the fields are defined with in the RPG program.
What is an externally described file ?
All information about the fields is specified in DDS and the RPG program can use them with in the program.
Can you specify a display file to be used in the following modes:Input, Output or Combined modes?
What are match fields indicators ?
Matching record indicator is seton when all the matching fields in the record of a secondary file matches with all the matching fields of a record in a primary file.
What is the length of a variable in RPG ?
What are the different arithmetic Opcodes ?
ADD, SUB, MULT, DIV, MVR, SQRT, XFOOT, Z-ADD, Z-SUB.
When is a TAG statement used in RPG ?
It is used as a Label.
What are the different Opcodes available in RPG for Database access ?
READ, CHAIN, WRITE, UPDAT, DELET, SETLL, SETGT, READE, READP, REDPE, OPEN, CLOSE,FORCE, NEXT, UNLCK.
What is READP opcode ?
Read previous record.
What is REDPE opcode ?
Read Prior equal record.
How do you check if a division was whole division ?
Check the EQ indicator be set to ‘1’
What opcode could be used to test an alphanumeric field for all numeric values?
What opcode will be used to test the zone of a character field ?
How do you specify Half Adjust ?
It should be specified in the column 53 of C specs as ‘H’ to indicate half adjust. It will be effective only if the resultant value is having more decimals than the result field.
Explain the difference between READ, CHAIN and SETLL ?
READ operation reads the record currently pointed to, from a full procedural file. CHAIN operation retrieves a record from a full Procedural file, sets a record identifying indicator ON and places the data in the input fields. SETLL operation position a file at the next record that has a key or relative record number that is greater than or equal to the search argument specified. The file must be fully procedural for all three opcodes.
What does LO and EQ indicators signify in READ, WRITE and CHAIN operations ?
LO indicator specifies the error status on the above operations.EQ indicator specifies the EOF, Record not found.
How can database records be read without lock ?
Put ‘N’ in position 53 of C specs.
What is the difference between MOVE and MOVEL ?
MOVE operation will transfer characters from the factor 2 to the result field, the move starts from rightmost character of factor
2.MOVEL operation will transfer characters from factor 2 to the result field, the move starts from leftmost character of factor 2.
How do you concatenate two string variables in RPG ?
Using CAT opcode or with MOVE followed by MOVEL.
What are the string operations possible in RPG/400 ?
CHECK, CHEKR, SUBST, CAT, XLATE, SCAN.
What does SUBST do ?
Extracts a specified character string from a base character string.
What does CHECK opcode do ?
The check operation verifies that each character in the base string (factor 2) is among the character indicated in the comparator string(factor 1).
In conjunction with which statements can ORxx and ANDxx conditions be used ?
DOUxx, DOWxx, IFxx, and WHxx.
What is the difference between DOU and DOW ?
DOU checks after entering into the loop, it is performed at least once.DOW check before entering into the loop.
What is ITER and LEAVE opcodes do ?
ITER transfers control from within a DO group to the ENDDOstatement of the DO group. It causes the next iteration of the loop to be executed immediately LEAVE operation transfers control from within a DO group to thestatement following the ENDDO operation.
Which instructions support structured programming in RPG ?
ANDxx, CASxx, DO group, ELSE, ENDyy, IFxx, ITER, LEAVE, ORxx, OTHER, SELEC, WHxx.
What does ‘SR’ in columns 7-8 of C specs mean ?
Calculation operation is a part of RPG subroutine.
Explain CASxx, and CABxx statements ?
CASxx operation allows you to conditionally select a subroutine for processing. The condition is based on the relationship between factor 1 and factor 2 as specified by xx.If the relationship is true the subroutine specified in the result field is processed.
CABxx operation compares factor 1 with factor 2 , if the condition specified by xx is true, the program branches to the TAG operation associates with the label specified in the result field.
What is CLEAR and RESET ?
CLEAR operation sets the elements in a structure (record format, array/table, data structure) or a variable (field, subfield or indicator) to zero , blank or ‘0’ depending on the field type (numeric, character, indicator)
RESET operation sets the elements in a structure (record format, array/ table,data structure) or a variable (field, subfield or indicator) to its initial value.
What is SCAN and XLATE ?
SCAN operation scans a character string (base string) contained infactor 2 for a 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.
How do you use commitment control in RPG program ?
Using COMIT operation. Makes all changes to the files that have been specified in output operation since the previous COMIT or the beginning of operations under commitment control(if there has been no previous COMIT or ROLBK operation).
How do you use exceptional write in C specs ?
Using EXCPT opcode.
What does the opcode FREE do ?
The FREE operation removes a program from the list of activated programs, frees static storage and ensures program initialization (first cycle processing) the next time program is called. It does not close file or unlock data area.
What does opcode POST do ?
Puts information in IFNDS.
What is the difference between WRITE and EXFMT of a display file ?
WRITE displays a record format on workstation,
EXFMT displays and accepts from the workstation.
What is the difference between PLIST and KLIST ?
PLIST operation defines a unique symbolic name for a parameter list to be specified in a CALL operation. KLIST is a declarative operation that gives a name to a list of key fields
Can you have multiple key lists for a single file ?
What are the different types of arrays available in RPG ?
Pre-execution time array.
Compile time array.
Execution time array.
How do you specify data for a compile time array ?
You can specify in E specs about the no of entries per record, no of elements, length of each element with the corresponding data entered at the end of the RPG program starting with **.
What is the maximum number of elements in an array ?
Can we define Multi-dimensional arrays in RPG ?
What is XFOOT opcode ?
Adds all the elements in a numeric array, and places the sum in the result field.
How can we sort an array ?
By using SORTA opcode.
What is MOVEA opcode do ?
Transfer character to numeric values from factor 2 to result field.
MOVEA can be possible to ARRAY-ARRAY, ARRAY-FIELD, or FIELD-ARRAY.
How to initialize an array ?
CLEAR or MOVEA *blanks to array.
What is LOKUP opcode do ?
LOKUP opcode search for a particular element in an array / table.
Can LOKUP operation be used for unsorted array?
What is the difference between an array and a table ?
An array elements can be referred by array name.Elements in array can be accessed by their position relative to other elements. Table name does not refer to the entire set of table elements.
Elements in a table can not be accessed by their position relative to the other elements.
What is the maximum length of a table name ?
What is the syntax of a table name ?
Table name should start with TAB.
How can the user implicitly open and close the files in RPG program ?
Enter UC in position 71-72 of F specs.Use OPEN and CLOSE opcodes in RPG program to open and close files.
During input operation which indicator position is seton if there is a record lock?
LO indicator position is seton.
What is the significance of DEFN opcode on RPG ?
To define fields based on the attributes of another field. To define a field as a data area.
What are different ways by which you define working storage field ?
Explicitly define or use *Like DEFN.
How many parameters can be defined in a RPG program?
What are the different ways of ending an RPG program without a primary file ?
SETON H1 to H9 (halt indicators).
By allowing an exception / error to end the program if
. No exception / error subroutine is specified
. No return point is specified on an exception or error subroutine
. The user’s response is to cancel the program.
Specify different ways by which RPG program can give error message to user?
By calling the SUBR23R3 program as passing message id. By defining the error message in DSPF.
If you are trying to add a record in a file and an error is displayed,where do you look for error ?
Check whether you have opened the file in Update mode.Check whether you have specified ‘A’ in position 72 of F specs.
What is a File Information Data Structure ?
File Information Data structure (INFDS) can be defined for each file tomake file exception/error information available to the program. A file information data structure contains predefined subfields that identify:
. The name of the file for which the exception/error occurred
. The record being processed when the exception/error occurred or the record that caused the exception/error
. The last operation being processed when the exception/error occurred
. The status code
. The RPG routine in which the exception/error occurred.
What is Program Status Data Structure ?
A program status DS can defined to make program exception/error information available to an RPG program.DS is defined as a program status DS by an S in position 18 of the DS statement.
*STATUS contains status code
*ROUTINE contains name of routine in which the exception/error occurred.
*PARMS contains the number parameters passed to this program from the calling program.
Specify heading information/TITLE.
Specify to begin on a fresh page/EJECT.
To control line spacing/SPACE.
Records to be inserted from other files at the point where it is specified/COPY.
What is the maximum no. of times multiple occurrence DS can occur in a program ?
What is the difference between *LIKE and *NAMVAR ?
*LIKE defines the variables as in database.
*NAMVAR is used to define variables as data area.
How is embedded SQL used in RPG ?
+ SQL statements
What are all the compiler directive statements ?
/TITLE, /EJECT, /SPACE, /COPY.
How can RPG program send message to System Operator ?
Use QCMDEXC as called program in the CALL statements, and use SNDPGMMSG to the operator.
Where DBCS data will be used in RPG ?
In any comment statement
. In comment field of E and C Specs
. In literals and constants
. As data in any character field, subfield, array or table.
Where will control be passed after the execution of the *PSSR subroutine if the factor 2 of the ENDSR is blank ?
Control will return to the next sequential instruction.
How can the CPF error-id be retrieved when a program error occurs ?
CPF error codes are placed in the subfield location *STATUS for the program status DS.
How could indicators 50 to 99 be set to ‘0’ in one instruction ?
Using ‘MOVEA *ZEROS IN,50’ .
What are the figurative constants ?
*BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL, *ALL ‘X..’ are implied literals that can be supplied without a length, because the implied length and decimal positions of a figurative constant are The same as those of the associated field.
What is the maximum error severity for which the compilation of RPG program stops?
50, if LR is not seton.
What are the earlier versions of RPG ?
RPG II & RPG III.
Name the different ways by which RPG source program can be entered ?
Interactively with SEU, In batch by using either OS/400 or Spooling functions.
During input operation which indicator position is seton if the record is locked ?
Position 56 – 57 (LO).
What is the record lock status value ?
Status value is 01218.
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
Interview Question and Answer – *CLP AS400 Control Language
An old AS400 Quiz willed with technical questions and plain old fashioned AS/400 brainteasers
AS400 Technical Interview Question and Answer – AS400 Database
Interview Question and Answer – AS400 Subfiles
Interview Question and Answer – AS400 things you should know
Interview Question and Answer – Operating System OS400
How to Install IBM Access Client Solutions (ACS)
IBM i Data Obfuscation – Making Data Foggy Murky and Squinty
How to rename Fresche (BCD) Presto Library – XL_PRESTO