Subfiles
1. Explain Subfile.
To access multiple records at a time, we can use subfiles. It makes easy the user task that he can work with group of record. It has two record formats.
1. Subfile Record
2. Subfile Control Record
2. What is a Subfile control record?
The record that controls the display of the record format and text information
3. What is a Subfile record format?
The record that contains the displayable data.
4. What must follow the SFLCTL keyword in the Subfile control record?
The name of the Subfile Record Format.
5. What are the mandatory keywords for declare Subfile.
SFL, SFLCTL, SFLDSP, SFLSIZ and SFLPAG
SFL
It defines the record is Subfile record.
SFLCTL
It defines the record is a control record.
SFLDSP
It is to display the data is the display screen.
SFLSIZ
It identifies the Subfile size. The max size for Load all is 9999.
SFLPAG
It identifies the no. of record to be displayed at a time. For load all it should be less than SFLSIZ
6. What is Relative Record Number [RRN]?
Relative Record Number [RRN] is a unique numeral value used to position records in Subfile.
7. What DDS keywords are required when defining a control record format?
SFLCTL, SFLDSPCTL, SFLPAG, SFLSIZ.
8. What are the 3 types of subfiles?
Single page, expandable and load-all.
9. Which type of Subfile has the better performance?
Single page.
10. What is a Subfile record number?
The internal value associated with the each Subfile record.
11. What does ‘O.S 400 controlling of Subfile’ mean?
In Load All Subfile if we press the Page Up or Page Down key the control will not go to the program and the O.S.400 will take the control and redisplay the preceding or succeeding records.
This simplifies the coding and if the beginning or end of Subfile reached then the O.S 400 will automatically display the message like ‘End Of File Reached’.
12. Why would one take control over rolling of Subfile record?
I t will reduce the time taken to redisplay the records if there is large records. If we define the roll key then the control will return to program while the roll key is pressed. The program then adds new records and display.
13. How will you get a Plus sign in Subfile?
By specifying the SFLEND keyword. If we specify *More with SFLEND then the word MORE will be at lower right corner which indicates more records are there in Subfile than displaying and if end of file reached then it will display ‘BOTTOM’.
14. How does CLRL work? Compare it with OVERLAY.
This keyword is used to Clear and Control specific number of lines from the screen. It also helps to overlap two record formats without the first format is being cleared completely. Only those lines cleared from the first format are deleted, all other lines will remain in the screen.
If we specify CLRL (*NO) for a format then no line will be cleared. So if a record format is overlayed then the lines of the previous format will not be deleted but just overlayed.
It is not in case of OVERLAY. If any line in the first format in the overlaps then the complete format will be deleted before next format display.
15. What do you mean by SFLRCDNBR?
It means Subfile record number. This is used in load all type.
Suppose we are living in third page and if we press Enter key, then the control will go to first page. So if we move the position of 378 to 379 of the File Information Data Structure to a hidden field then the RRN value and Subfile Record Number will be same. So the control will be in the living page.
We cannot use SFLRCDNBR and SFLROLVAL simultaneously.
16. What does the SFLNXTCHG keyword mean?
It means Subfile Next Change. It activates the READC operation and mark records as changed records.
Suppose the READC operation reads fifth or sixth changed record and if modify a second or first record then READC wont read that record. For this we activate the SFLNXTCHG keyword with an indicator. So if we change a record that indicator will seton and READC will read all changed record.
17. Explain all keywords.
SFLENTER - This record level keyword used to assign as a roll-up key. You can define another key for enter purpose.
SFLINZ - This record level keyword is used to initialize the Subfile.
SFLLIN - This record level keyword is used to define how many spaces are to be inserted between Subfile records.
SFLMSG - This record level keyword, which identifies the subfile, is a Message Subfile.
SFLMSGID - This record level keyword is used as like as SFLMSG. Here you just put the message ID instead of hard coding the message text.
SFLMSGKEY - This record level keyword is used to specify the field used as message key.
SFLMSGRCD - This record level keyword is used to specify what line #, where the message has to be displayed.
SFLPGMQ - This keyword specifies the program message queue that confirms the Subfile records for a message Subfile.
SFLNXTCHG - This record level keyword is used to mark the Subfile records as being changed.
SFLPAG - This record level keyword is used to determine how many Subfile records to show per display screen.
SFLROLVAL - This record level keyword identifies the no. records to roll, whenever a roll-up/roll-down key is pressed.
SFLSIZ - This record level keyword is used to set the initial size of Subfile
SFLDROP - This record level keyword. The program first displays the Subfile in truncated mode [display in one line form]. When the user presses the associated key, it will display folded form.
SFLFOLD - This record level keyword. The program first displays the Subfile in folded mode [display in multiple line form]. When the user presses the associated key, it will display truncated form.
SFLMODE - This record level keyword is used to tell whether the Subfile is in drop mode or fold mode. If the mode = 1 means Drop mode and the mode is 0 means Fold mode.
SFLEND - Controls the display of “plus sign”.
SFLRCDNBR - Controls what Subfile page is displayed and where cursor goes.
SFLRNA – Record not active used to make the file inactive.
18. What opcodes can be used to retrieve Subfile record?
READC and CHAIN.
19. Explain 2 ways of handling the roll-up/roll-down keys in an RPG Subfile program.
If SFLSIZ > SFLPAG, OS/400 will handle scrolling.
If SFLSIZ = SFLPAG, the programmer must handle scrolling by checking roll-up or roll-down indicators and filling Subfile appropriately.
20. How do you clear a Subfile?
Set the indicator associated with the SFLCLR keyword to ON and WRITE the Subfile control format.
21. How are roll keys handled by the program and in the system?
a.) Using ROLLUP and ROLLDOWN keyword indicators, or
b.) Automatically, if SFLSIZ > SFLPAG.
22. How do you utilize the Subfile message control?
By using SFLMSG and MSGLOC keywords.
23. How does a Subfile handle displaying multiple lines of Subfile data?
Use the SFLDROP keyword at record level in the control record and assign a command key to the keyword. Ex: SFLDROP(CF11).
24. Differentiate Assume and Overlay?
These two keywords are using in creating display-file, sub-file and window.
Overlay => it shows the screen on the previous screen.
Assume => it shows the screen by erasing previous screen.
25. Explain about sub files in AS/400.
If we want to access multiple records, then we have to go sub-files. There are three types of sub-files.
i. Load all by this method we have to load only 9999 records. Here the page up and page down has been control by system. In this method sub-file size is greater than sub-file page.
ii. Load on demand [SIZ>PAG] by this method we can load only 9999 records. Here the page up control can be controlled by system and user controls the page down. In this method sub-file size is greater than sub-file page.
iii. Load on demand [SIZ=PAG] by the method we can load unlimited records. Here user controls both of the Page-up and Page-down. In this method sub-file size is equal to sub-file page. This type is more advantage.
Points to Sub-files
• Active sub-file is sub-file, which are in main memory is known as active sub-file. Maximum 24 sub-files can be active at a time.
• There are 512 sub-file record formats and 512 sub-file control record formats.
• Sub-file Size [SFLSIZ]: is a property that determines the maximum no of records in the sub-file.
• Sub-file Page [SFLPAG]: is a property that determines the no of records display in a page. The default value is 2. Maximum is 9999. It is less than or equal to sub-file size. If SFLSIZ>SFLPAG then the sub-file size will grow dynamically. If the SFLSIZ=SFLPAG the sub-file size will not grow.
• Relative Record Number [RRN]: it is a unique numeral value. Each record has a RRN value for accessing purpose. We have to specify this in F-Spec keyword.
• Mandatory Keywords: SFL, SFLSIZ, SFLPAG, SFLDSP, SFLCTL
26. What is the difference in defining Subfile and Message Subfile?
A Subfile record I defined by SFL keyword and Message Subfile is defined
SFLMSG keyword.
27. What are the mandatory keywords for message Subfile?
i. SFLMSGRCD – Subfile Message Record specified in Subfile record format. It defines the line on which the record should be displayed.
ii. SFLMSGKEY – Subfile Message Key specified in record format. Here we defining a predefined field, which contains four positions, hidden value, which is used as a message reference key to locate and select messages from Program Message Queue while loading a message, Subfile.
iii. SFLPGMQ – Subfile Message Queue can be specified on record format or on control format. Here we define a ten position hidden field to hold program message queue.
28. What is Window Subfile?
This is for designing Subfile screen. To get this concept WINDOW should be specified in record level keywords.
29. What is the max. no. windows that can be active at a time?
12
Open Query File
1. What is an Open Query File?
Open query file is a dynamic selection of records. It retrieves records thro’ open data path. So it’s processing time is slow.
Functions supplied by OPNQRYF are:
Dynamic keyed sequence access path
Dynamic keyed sequence access path over a join.
Dynamic join
Handling missing records in secondary join files
Unique-key processing
Mapped field definitions
Group processing
2. What does the Open Query file do?
Creates an open data path to physical file data.
3. Notify the wrong steps in the following.
a. OVRDBF b. OPNQRYF c. OVRDBF d . OPNQRYF
OPNQRYF OVRDBF OPNQRYF OVRDBF
CALL PGM CALL PGM CALL PGM CALL PGM
CLOF DLTOVR DLTOVR CLOF
DLTOVR CLOF CLOF DLTOVR
a and b are correct steps.
4. What are the various steps involve creating an Open Query File? (Or) What are the mandatory steps for Open Query File?
OVRDBF
If a physical file having 100 records and if we want to override the PF. So that it contains only the specific number of records we are using OVRDBF
OPNQRYF
If you want to perform a SQL operation, we have to declare in OPNQRYF command only.
OPNQRYF (FILE PF) QRYSLT (‘EMPNO *EQ’ *BCAT &A) will retrieve empno equals &A QRYSLT (‘EMPNAME *EQ % WLDCRD (“S*”)’) will retrieve empname which starting with s QRYSLT (‘EMPNAME *CT “S”’) will retrieve empname contain S
QRYSLT (‘EMPNO *EQ %RANGE (100 200)’) will retrieve empno between 100 to 200.
CALL / PROCESSING/CPYFRMQRYF
To see the records being selected we have to copy from the source file to a temporary file for this action CPYFRMQRYF will be used.
DLTOVR
As we see early the main file is logically overridden and after performing the necessary operation, we have to delete the logical file. So that the main file contain the actual records. For this action DLTOVR will be used
CLOF
Finally we have to close the file, which is opened.
5. What do you mean by Open data path?
It is an imaginary pointer and it will move from one record to another while the file is being read.
6. How to share the ODP?
By using OVRDBF command and make sure of the parameter SHARE (*YES).
7. What is the purpose of OVRDBF SHARE (*YES)?
By sharing the path *YES, the data is passed to the subsequent usage of that file, until the override is deleted.
8. What is the main purpose of overriding any file?
This command is mainly used to override the file’s attribute(s).
9. Override DBF - Explain.
It is used to share the open data path.
It is used to redirect the file name.
It used over the file by its member.
10. How to use all the members in a P.F
Use OVRDBF with member option *all
11. Is it possible to create a new field dynamically?
Yes. By using OPNQRYF command you can create a new field dynamically by defining the new field in MAPFLD parameter.
12. Can we over ride other files apart from DBF?
Yes. We can use OVRPRTF, OVRDSPF, OVRTAPF, and OVRDKTF
13. What is the purpose of OVRPRTF [Over ride Printer file]?
To change the no. of copy dynamically, one can use the OVRPRTF command.
14. What is the CPF9899 error?
It is the CL program message ID for Open query file error.
15. What are the advantages for using Open Query File?
• Dynamic selection of records.
• Can create a join logical file.
• Dynamic join.
• Virtual field can be used.
• Accessing by open data path
• Group processing
[Virtual field does not exist in PF. But it is the combination of PF fields. Let PF01 has empno, salary, allow. and OpnQryF has empno, net=salary+allow. Here net is virtual field]
16. How are the records accessed in Open Query File?
By creating an Open Data Path, it will access the records from the PF/LF.
17. What are the differences between SQLRPG, Open query File and Logical File?
Open query file Logical file SQLRPG
1. Selection is thro’ Open Data Path
2. Dynamic selection
3. Slow process
4. Virtual field can be used
5. Dynamic join
6. We can use more selection criteria 1. Selection is thro’
Access Path.
2. Static selection
3. Fast process
4. Can not be used
5. Static join
6. Can not use more selection criteria 1. Selection thro’ Access path
2. Dynamic selection
3. Slow than OPNQRYF
4. Can not be used.
5. Dynamic join.
6. Can use more selection criteria.
/**************************************************/
RPG (Report Program Generator)
1. What is the current version in RPG?
ILERPG/RPG4. It is used to write coding in AS/400 environment.
2. What is RPG Program cycle?
Refer Q &A Book Page no. 18
3. When is it efficient to make RPG Program cycle?
It will be efficient when the file is arranged in sequence and the output is based on control break.
4. What are the specifications in RPG-3?
H - Control Spec - Gives information about generating and running
Programs.
F - File Definition Spec - To define files
E - Extension Spec - To define record address file, array and tables.
L - Line Counter Spec - To control the line and length of printer file.
I - Input Spec - To define data structure and fields of a Program
described file.
C - Calculation Spec - For calculation purpose.
O - Output Spec - To define the report layout.
5. What is the use of H spec?
We can use it for some functions like Change of Date format etc.,
One spec is allowed in RPG3. And if we didn’t specify then the SEU automatically include it as first statement.
In ILERPG we can include many H spec.
6. In F where will you specify the Input file Full Procedural file and externally described file?
File Type (15) – I, O, U, C
File Designation (16) – F, P
File Format (19) – E, F (Program described)
7. What is the length of variable and opcode in RPG/400?
Opcode - Five
Variable - Six
8. What are the severity levels in RPG?
Severity 0 is no errors.
Severity 10 is information.
Severity 20 is warnings.
Severity 30 is variable not found/declared and general errors.
Severity 40 is object/file/library not found.
Severity 50 is LR indicator not Seton
9. What are the data types in RPG?
Alphabet [A]
Packed Decimal [P]
Zoned Decimal [S]
Date [D]
Time [T
Timestamp [Z]
10. What is the difference between Packed and Zoned decimal?
Zoned decimal occupies 8 bits for a digit and packed decimal occupies 4 bits or a digit. And also, suppose the input data is coming from another environment [like Unix, MQ-Series.], you have to declare in zoned only.
11. How many files [PF/LF/DSPF/PRTF] you can use in a RGP program?
50 – PF in RPG/400 program.
Endless – PF in ILERPG
24 – Subfile/display file in RPG
8 – PRTF in RPG
512 – Subfile in Display file
12 – Active Subfile for a single file
1024 – Record format in Display file
1 – Record format in PF
32 – Record format in LF
1 – File in CL
12. What are the devices in AS/400?
Disk, Workstn, Printer, Special Device, Sequential Device.
13. How many parameters can be defined in RPG?
255
14. What is the max? no. times a Multiple Occurrence D.S can occur in a RPG?
9999
15. What does IPL stand for?
Initial Program Load, which is used for start-up.
16. What is a level checking error?
When a HLL object is not linked with the current DDS object.
17. What does the phrase “subscript out of range” mean?
It means you are trying to access an area outside of the defined table range.
18. What is an indicator and explain its types?
Indicator is a single bit flag and it’s possible status are ‘0’ and ‘1’.
The types are
• Overflow indicator (OA to OF)
• Record identifying indicator (01-99)
• Field indicator
• Control indicator (L1 to L9)
• Resulting indicator (01-99)
(OR)
• Control indicator
• Match field indicator (01-99)
• Halt indicator (H1 to H9)
• General indicator
•
19. What is control indicator?
L1 to L9 are the control indicator used to identify certain fields on control fields and then used to condition, which operations are to be presented at Detail time calculation/output (or) Total time calculation/output.
20. What is Match field indicator?
They are used to identify whether all the matching field of a secondary file record matches the matching field of a primary file record and if matches then it will set on
21. What are record identifying indicators?
While preparation of report in I spec (19 – 20) we use this. For program defined record formats should be assigned this record identifying indicator. When a record is read from a PF it will turn ON for the complete program cycle and when the last output operation is performed it will turn OFF. For each record read from PF it will turn ON and turn OFF.
22. What is Overflow indicator?
These indicators are used to check the page overflow line and if it finds the overflow line, it will set ON.
23. What is resulting indicator?
The Hi, Lo, Eq indicators in C spec are called resulting indicator and they are to check the result of an operation. The types are Arithmetic, Compare, Lookup indicators.
Arithmetic indicators
In any arithmetic operation we can specify these indicators. If Hi is set ON the Factor 1 value is grater than Factor 2, if Lo is set ON the Factor 1 is lesser than Factor 2 and if Eq is set ON the Factor 1 is equal to Factor 2.
The above is same for Compare operation.
24. What are Figurative constants?
It is a type of literal used to initialize fields, field comparison and set the pointer in file.
E.g.: *ZEROS
*BLANKS
*LOVAL
*HIVAL
*ON
*OFF
25. What are the modes of opening a physical file?
I, O, U, C
26. How would you Half adjust a field in RPG?
In C spec at column 53 we can specify H to Half adjust.
27. What is an externally described file?
Any DDS file that has its’ layout automatically defined as part of the RPG program.
28. What is a Primary file?
If we specify ‘P’ for Primary file then the file will automatically be read by the program and we can not use READ operation, can not alter the sequence as well as we can not stop reading the file.
We can use only one file as Primary file.
29. How to create a RPG program?
CRTRPGPGM – In RPG/400
CRTBNDRPG – In RPGILE
30. What are the different ways of exiting from a RPG program?
By SETON LR
SETON H1 to H9 (Halt indicator)
SETON RT
RETURN command we can come out from the program.
33. How does the READP work?
It reads data from a physical file in reverse order.
31. What is the difference between just exiting a program with return and by setting on indicator LR?
Opened files are closed when exiting with LR equal to ON.
Opened files remain open when using RETRN with LR equal to OFF, and the program is still resident (potentially active.)
32. How do you do *LOVAL operation in non-keyed table?
Using Chain with 1, we can do *LOVAL operation.
C 1 CHAIN REC1
We can't do *HIVAL operation for a non-keyed table.
34. What is the difference between READE and CHAIN?
READE and READPE will read a group of record with same key and we need to set the pointer in beginning of file but it is not needed for CHAIN.
READE is a sequential search, CHAIN is a random search.
35. If a PF have so many field and if we need to update only one or two field. Then which is the efficient way?
Thro’ O spec and in that the File Name and Field Name should be specified.
36. What is Lock? How you achieve in AS/400?
To give access permission is known as Lock in AS/400.
There are two types of Lock.
One is Share Lock is used for Multi user. [To perform read operation].
E.g. IN operation without *LOCK
Another one is Exclusive Lock is used for Single User. [To perform Insert / Update / Delete operation]
E.g. IN operation with *LOCK and OUT operation
The Locks are provided by AS/400 system itself.
37. How you will release the lock?
By using RCLRSC [Reclaim Resource] command we can release. UNLCK command also helps to release the lock. We can see the lock by using WRKOBJLCK command. [But in the AS/400 system can manage these types of locks automatically]
38. How you will release a record lock?
i. An UPDATE or DELETE will release the record lock.
ii. A READ or CHAIN will release the record lock when it was locked by previous READ or CHAIN.
iii. A SETLL or SETGT will release the record lock.
iv. The opcode UNLOCK will release the record lock.
v. An EXCEPTopcode will release the record lock.
39. Which statement should precede the UPDATE command in RPG?
A READ or CHAIN opcode should proceed.
40. What opcode checks the existence of a specific record in a keyed file?
SETLL should be used. CHAIN should be used only if data from the file is needed.
41. Explain CHECK, CHECKR, MOVE, MOVEL, SCAN and SUBST.
CHECK : used to check the non-matching character from left side.
CHECKR : used to check the non-matching character from right side
MOVE : assigns the text as right alignment to the variable
MOVEL : assigns the text as left alignment to the variable
SCAN : checks the matching character from left side
SUBST : filters the required string from the main string.
Suppose, A='SANKAR'
C 2 SUBST A: 4 B [Now B is 'KA']
42. How are the following RPG operation codes used?
a.) CAT
To concatenate fields and /or constants.
b.) SCAN
Searches fields/arrays/data structures for the occurrence and start position of a string.
c.) CLEAR
To initialize fields, record arrays, data structures to blanks or zeros.
43. What is the difference between the MOVE and the MOVEL?
MOVE transfer is a right justified move; MOVEL is a left justified move.
44. What is the value of W0TEMP in the following?
DW0TEMP S 2P 0 INZ: Here W0TEMP values is 0
DW0TEMP S 2P 0 INZ (1) : Here W0TEMP values is 1
DW0TEMP S 2A INZ : Here W0TEMP values is *BLANKS
DW0TEMP S 2A INZ ('AA') : Here W0TEMP values is AA
45. What are the arithmetic operators?
ADD, SUB, MULT, DIV, MVR, Z-ADD, Z-SUB, SQRT and EVAL
46. What are string operators?
CAT, MOVE, MOVEL, CHECK, CHECKR, SCAN and SUBST
47. What are the file related operators?
READ (Groups), CHAIN, WRITE, UPDATE, DELETE, OPEN, CLOSE, UNLCK, SETLL and SETGT.
48. What are the Logical and Relational operators?
GT, LT, GE, LE, EQ, NE, (NL-Not Less than, NG-Not Grater than,), AND, OR and NOT
49. What is diff between DOW and DOU and give a scenario for DOU?
DOU : The control will enter at least once.
DOW : While the condition is satisfied the control will enter inside the loop.
So for I didn’t come across a situation to use exclusively DOU.
50. What is the purpose of CASXX?
By this statement, we can conditionally execute a subroutine.
51. What is needed in an RPG program to receive parameters?
An *ENTRY parameter list.
52. What for KLIST is used?
To define a composite key.
53. What for CASxx is used?
To execute subroutines based upon the result of a logical comparison.
54. What is the difference between SELECT and CASExx?
SELECT is used to perform some operation with condition and if we need to execute a subroutine we have to use EXSR command.
The pair is SELECT and ENDSL.
CASExx is to execute a subroutine with condition and we cannot perform other operation.
The pair is CASExx and ENDCS.
55. What is the advantage of using *LIKE DEFN?
It automatically updates attributes of the work field, when attributes of the base field change and the program is recompiled.
56. How are parameters accepted in an RPG program?
*ENTRY PLIST
57. How are parameters passed in RPG?
CALL ‘----‘
PARM xxx
58. How do you define a Subfile in RPG?
IPFC (prompt) ---- RRN KSFILE rcdfmt-name.
59. How can a subroutine be executed?
EXSR
60. How can indenting be utilized to make it easier to read a compiled RPG program?
By overriding the indent parameter in the CRTRPGPGM command with a character.
61. What is the operation SELEC used for?
For CASE structure handling.
62. How would you execute SQL statement in RPG?
In C spec as in the following scenario
C/ EXEC SQL
C+ SELECT *FROM EMPPF
C/ END EXEC
63. What is an Output queue (*OUTQ?)?
An area, which stores all spooled files waiting to be printed.
64. What is a Job queue (*JOBQ?)?
An area that stores all batch jobs waiting to be compiled.
65. What are the testing opcodes available in RPG?
TEST (d) To test date.
TEST (n) To test numeric value in an alphanumeric field.
TEST (z) To test time stamp.
TEST (t) To test Time
66. How can you concatenate two strings in RPG?
By CAT or by MOVE followed by MOVEL.
67. Explain ITER and LEAVE.
ITER - Transfer control from within DO group to the ENDDO statement. It will
execute the next DO loop
LEAVE - Transfer control from within DO group to the next statement of ENDDO.
68. Explain CLEAR and RESET.
CLEAR - It sets Zero or Blank or ‘0’ to a variable depending upon data type (decimal, character, indicator).
RESET - It sets the initial value to a variable.
69. EXCEPT – Explain.
It is to write Record Format in O spec. It is similar to the WRITE opcode used in RLU report.
C* Factor1 Opcode Factor 2
C EXCEPT DETAIL
70. What is the difference between ‘O’ spec and RLU (or) advantages of RLU or Printer file?
No need of hard coding in RPG program thus easy maintenance.
It is easy to design a report in RLU because we can able to see the layout.
If more program uses the same report format then the coding do not have to be repeated in all program.
If we need any modification then it is enough to modify the printer file and no need to modify in all programs.
71. What are the keyword levels used in Printer file?
File level
Record level
Field level
72. What are the three line types in RLU?
Report line, Filler Line and Sample line.
73.What are the commands used in RLU?
DR Define Record
DF Define Fields
DC Define Constants
VF View Fields
CF Centre Field
74. What are the line types available in RLU?
Three types
a. Report Line
b. Filter Line
c. Sample Line
75. What are the different recording spacing keywords available in RLU?
SKIPA
SKIPB
SPACEA
SPACEB
76. What does the POST opcode do?
Put information into INFDS.
77. What are the opcodes used for Subfile operation?
READ, READC, CHAIN, WRITE and UPDATE
78. How will you display a specific page in Subfile?
By moving RRN value to SFLRCDNBR.
79. What are the opcodes related to Journaling?
COMMIT,ROLBK
80. How will you declare a file, which has commitment control?
In F spec K COMIT keyword.
81. How will you use OPEN, CLOSE opcode in RPG, ILE?
RPG in F spec UC keyword.
ILE in F spec USROPN keyword.
82. If you get the error ‘You cannot use CHAIN (or READE) operation’ then which one
you will check first?
In F spec whether the Record Addressing Type ‘K’ is specified.
83. How many PARM Opcodes are used in a PLIST group?
84. What will happen if you specify any C spec opcode after SETON LR opcode?
If the variable used in that C spec is in any File then that command will not be executed if not it will be executed.
85. When will you use *pssr in your Program?
In INFDS F spec.
86. Can we use CALL opcode for other purpose than to call a program?
87. How many Record-addressing files can be used in RPG?
One.
88. What is the max. no. of nested loop that you can have in RPG?
50
89. How do you get the automatic increasing page no. in report?
In O spec the keyword PAGE. Here we should not specify the length and it assign the length of 4 characters.
Array
1. What do you mean by Tables?
List of data stored in main memory is called tables. We can refer tables with 'TAB' as starting letters. [Suppose, Product Master table is TABPROD and City Names is TABCITY]
2. What are the types of tables?
Compile time and Pre-run time tables.
3. What is a compile-time table?
A table whose information is hard coded in the program source.
4. What is a pre-execution table?
A table whose data comes from an external file.
5. What is the max. no. element in an array?
9999
6. How can you define Multiple Dimension Array in RPG?
We cannot define a Multiple Dimension Array in RPG.
7. Is it possible to insert a record in a table, while the table in open in 'P' mode?
Yes. It is possible to insert a record by using 'O' spec.
8. How is data accessed from a table?
By LOKUP operation.
9. Can we use tables in RPG4/ILERPG?
No. Tables are available in RPG3 only.
10. What are the keywords needed in Pre-run time table?
DIM, FROMTABLE and PF name.
The PF should be opened in 'T' mode.
11. What do you mean by array and mention its types of arrays?
Set of similar attribute elements is known as array. There are three types of array are referring here.
Compile time, Run time and Pre-run time array.
12. Explain Multi Dimensional Array.
We are achieving multi dimensional array by using OCCUR clause. It is similar elements of same data types and attribute size are repeating many times can be performed by OCCUR clause.
13. Explain. Compile time array and Run time array.
Compile time array Run time array
Values are stored during the compile time. So the values are constant. Values are stored during the run time. So the values are dynamic.
Three keywords DIM, CTDATA, PERRCD are used to declare Only DIM keyword enough.
14. What are the keywords used in array declarations?
Compile time array - DIM, CTDATA, and PERRCD
Run time array - DIM
Pre-run time array - DIM, FROMFILE and PF should be opened in T mode
15. What are the array related keywords?
SORTA : used to Sort the array in ascending
LOOKUP : used to find an element in the array we can specify indicator and it will
set on if the element is found.
XFOOT : used to sum the elements of a numeric array
MOVEA : used to move set of elements of another array into your array.
16. How can you copy element of one array into another in one statement?
ADD opcode will add all elements of one array into another.
17. Is it possible to write an array element into a PF?
Yes. It is possible to write the pre-run time array elements to a pf. For that the mode of pf opening is 'C' [Combined] and the DIM, FROMFILE and TOFILE keywords have to be used.
If no executable statements after 'C' spec, we can declare the elements after 'C' spec. Otherwise, we can declare the elements after 'O' spec.
18. What is the diff between tables and array?
Table Array
1. Indexing is impossible Indexing method is possible
2. Cross-reference is impossible Cross-reference is possible
19. How many arrays can be declared in RPG?
200
Data Structure
1. Explain - Data structure and its types.
By using the DS, we can split a field into sub fields without using move or movel.
We can make non-contiguous data into contiguous data.
Its types are General DS, Data area DS, Program Status DS, File Information DS.
2.Explain. PSDS, DADS and FIDS.
Program Status Data Structure - is identified by S in position 18 of the data structure statement, provides program exception / error information to the program. The keywords are
*ROUTINE
*STATUS
*PARM
*PROGRAM
File Information Data Structure - is identified by BLANKS in 7-52 position, which provides file exception / error information to that fie.
The keywords are
*FILE
*RECORD
*STATUS
*ROUTINE
*OPCODE
Data Area Data Structure - is identified by U in position 18 IN D spec. By using *NAMVAR DEFN we can rename the D.A.D.S
3. What do you mean by Exception/Error Handling?
In RPG, there are two types available for error handling technique. If the status code is greater than 00099, than only both DS [file information and program status] will be executed.
File information DS. Here 'Duplicate Record Found' error will be monitored. For this, the INFDS [data structure] and INFSR [subroutine] will be added.
FTEST O E DISK INFSR (*pssr)
Here we can pickup the error information [duplicate record found] in the position 379 to 400. For that we have to declare a DS. That DS contains, *FILE, *RECORD, *STATUS, *ROUTINE, *OPCODE
Eg. Undefined record type, Device error.
Program status DS. Here we can trap 'Divide by Zero' error by using the PSDS. This DS
This DS contain *PARMS, *PROGRAM, *STATUS, *ROUTINE.
Eg. Divide by zero error, invalid array index, SQRT of negative number.
CL (Control Language)
1. What are the disadvantages in CL? (Or) What is the difference between RGG and CL?
a. You can’t perform Insert, Update and Delete operation in CL.
b. You can’t use printer files in CL.
c. You can’t use sub files in CL except Message Subfile
d. You can use only one file in CL.
2. How do you read a specific record in a keyed database file in a CL program?
OVRDRF FILE (filename) POSITION (*KEYx a b c) and RCVF
3. What CL command is used to read a file?
RCVF - Receive File
4. How can you read a file in CL?
Thro’ RCVF command we can read a file. To read all the records we should use MONMSG command with MSGID (CPF0864). So if the end of file reached then the message CPF0864 is sent to the program so the variable will not be changed by the RCVF command.
5. How can you read a file in CL?
Thro’ RCVF command we can read a file. To read all the records we should use RCVF followed by MONMSG command with MSGID (CPF0864) and followed by GOTO with command label to branch and prier to RCVF command. So if the end of file reached then the message CPF0864 is sent to the program so the variable will not be changed by the RCVF command otherwise.
6. How can you set lower limit to a file in CL?
By two way we can set.
i. POSDBF with parameter “File Position” set to “*Start”.
ii. OVERDBF which allows to position the file by Key Value, by RRN value, or set to *START
7. What CL command is equivalent to write a display file in RPG?
SNDF - Send File
8. What CL command is equivalent to write/read a display file in RPG?
SNDRCVF - Send/Receive File
9. What CL command is used to determine the logical files associated with a particular physical file?
DSPDBR - Display Database Relations
10. If the field is defined in DDS, how is it referenced in a CL program?
By declaring the field (DCL) and placing an ampersand in front of the variable name.
11. What are the data types available in CL?
*CHAR, *DEC, *LGL
12. What is the main use of MONMSG?
Error trapping.
13. What MONMSG in CL?
This command monitors the messages send to the program message queue for the conditions specified in the command. There are two levels of MONMSG commands.
Program level is specified immediately following the last declares command in your CL program. You can use as many as 100 program level MONMSG commands.
Command level immediately follows a CL command. You can use as many as 100 command level MONMSG commands for a single command.
If you monitor a message by giving message ID as CPF0000 then any error will come to MONMSG routine
14. How can a programmer send a message from a CL program?
Using the SNDPGMMSG command - Send Program Message
15. What are the various messages in CL?
A message is a communication sends from one user or program to another. There are two types of messages available. One is Immediate messages, which are created by the program or system user when they are sent and not permanently stored in the system. Another type is Predefined messages, which is created before they are used. These messages are placed in a message file when they are created, and retrieved from the file when they are used. The CRTMSGF command is used to create a Predefined message. The ADDMSGD, DSPMSGD, RMVMSGD commands are used to add a message description, display message description and remove message description respectively. CHGMSGD or WRKMSGD is used to change the description.
Predefined message in CL SNDUSRMSG, SNDPGMMSG, RTVMSG
Predefined message in display files ERRMSGID, SFLMSGID, MSGCON and MSGID
Immediate message in CL SNDUSRMSG, SNDPGMMSG, SNDMSG, SNDBRKMSG
Immediate message in display files ERRMSG, SFLMSG
16. What is the purpose of the CHGVAR command?
To change the value associated with a CL variable
17. How do you access the local data area in a CL program?
RTVDTAARA DTAARA (*LDA) RTNVAR (&var)
18. What are the various steps involve accessing Data Area in CL?
First we get the data from the data area by using the command RTVDTAARA. If you want edit the data of the data area use CHGDTAARA command else if you want view the data of the data area use DSPDTAARA command
19. What is a command label?
An area of transfer within a CL program from which to continue processing directed by a GOTO command.
20. Explain parameter passing.
To pass variables from a CL or RPG program to another CL or RPG program.
21. How can a programmer exit out of a CL program?
By using a RETURN command.
22. Why would the PGM line contain a PARM?
The CL program is using a value passed from another processing program.
23. How to create user-defined command?
First of all create a CL program with a command and compile it. After create a CMD type program. Then by using CRTCMD command define user-defined command.
E.g.
CLP 01
PGM
DSPLIBL
ENDPGM
CMD01
CMD
CRTCMD
CLP name ---------------------- : CLP01
Library ---------------------- : SKANDASAMS
CMD named ------------------- : CMD01
Library ---------------------- : SKANDASAMS
User-defined command ------ : A
Now if you type A and press enter key, system will display library list.
24. How to retrieve a Date in CL?
By using RTVSYSVAL command we ca retrieve a date in CL. The various date formats are *JOB, *SYSVAL, *MDY, *DMY, *YMD, *JUL etc. [if you want system time, you have to specify *time in the format]
25. What are the different date types?
*ISO – YYYY-MM-DD
*USA – MM/DD/YYYY
*EUR – DD.MM.YYYY
*JUL – YY/DDD
*JOB
*SYSVAL
*MDY
*DMY
*YMD
*JUL
*ISO is the default date type.
Format of system value is MM/DD/YY
26. How can you check the date in CL?
By the command CVTDAT.
27. What is the max length of variable in CL?
11
28. What are the advantages of CL?
Because commands are compiled and stored in a form, they can be run immediately and it is faster than entering the commands in command line.
Some CL commands cannot be executed in command line, so we need CL program for them. Eg. RTVSYSVAL, RTVDTAARA
Cl program can be tested and debugged like other HLL program.
29. How to find the field description of an object?
DSPFFD, DSPOBJD
Data Areas
1.What is a Data Area?
Data area is used to store constant values, which can be retrieved by many users. Is an object of type *DTAARA which is located in auxiliary storage. Data area may be created by CRTDTAARA command and it is viewed by DSPDTAARA command, their values updated by CHGDTAARA command. There are three data types in data area is *DEC maximum 24 digit with maximum 9 digit of decimal places and *CHAR type has maximum 2000 character length and *LGL may contain 1 or 0 including on/off responsibility.
RPG operation for Data Area processing:
IN retrieve data from a data area
OUT write data to a data area
DEFN define a data area
2. Define LDA, GDA and PIP.
LDA Local Data Area is created for each job in the system, including auto start jobs; jobs started on the system by reader and subsystem monitor jobs.
The system creates a local data area, which is initially filled with blanks, with a length of 1024 and type *CHAR. When you submit a job using SBMJOB command, the value of the submitting job’s local area is copied into the submitted job’s local data area. You can refer your job’s local data area by specifying *LDA for the DTAARA keyword on the CHGDTAARA, RTVDTAARA and DSPDTAARA commands or *LDA for the sub string built-in function (%SST)
The local data area can’t be referred to from any other object.
You can’t create, delete or allocate the local data area.
No library is associated with the local data area.
GDA Group Data Area will be created by the system when an interactive job becomes a group job. Only one group data area can exist for a group. The group data area can be deleted when the last job in the group is ended or when the job is no longer part of the group job. The group data area which is initially filled with blanks has a length of 512 and type *char.
You can’t use the group data area as a substitute for a character variable on the sub string built-in function.
A GDA can’t be referred by jobs outside the group.
You can’t create, delete and or allocate a GDA
No library is associated with GDA
PIP (Data Area) Program Initialization Parameter (Data Area) is created for each pre start job when the job is started. The object sub-type is of the PDA is different then regular data area. The PIP can only be referred to by the special name *PDA and the size is 2000.
3. What are the RPG opcodes associated with data areas?
IN, OUT, UNLCK and DEFN.
4. Explain Data areas and its types.
Data area is an area in main memory. The types are General DA, Local DA, Group DA and PIP DA. DAs are used to hold some data.
5. How you are referring the General DA in RPG and CL?
In RPG, *DTAARA, DEFN, *LOCK, *UNLOCK, IN and OUT commands are used.
In CL, CRTDTAARA, CHGDTAARA, RMVDTAARA, DSPDTAARA, RTVDTAARA commands are used.
DDS (Data Description Specifications.)
1. What does DDS stand for?
Data Description Specifications.
2. What are the types of files?
• Data base files
• Device file
• DDM files (Distributed Data Management files)
• Save files
Database files
This is the actual database for AS/400.
It includes PF, LF, and Field Reference Files
Device files
A device file contains the description of how to use the physical devices such as display stations, printer and tape devices. E.g. Display file, printer file.
DDM files
The DDM files are employed when we tries to access a file from a remote system to our current system. The current system is called source system and the remote system is called target system. Just like other database files the DDM files are to be opened before they are used in program. After they are created an access path is created, thro’ which the target system is accessed.
DDM files serve as a medium, connecting the program running on source system and the file on the target system.
They are used to
• Copy a file from one system to another.
• Manage file on a remote system.
• Access data from a remote system.
Save files
They are used to hold the data in a format for back up and recovery purposes.
3. What is Source Physical File?
Source physical file is also a file, which has one or more files included in it. It is just like a directory and it contains many members. The members are like a various programs residing in the directory. CRTSRCPF is used to create source physical file.
4. What is a member?
A member is a subset of data within a file.
All program, files within a source file are called member for that file.
5. What is a Physical File?
It is an object its type is PF, that physically occupies memory space for the purpose of store and retrieve data. It is a single record format. CRTPF command is used to create a physical file. Maximum number of fields included in a PF is 8000. Maximum no of key fields included is 120.
6. What are the four level entries of PF?
There is File level entries, Record level entries, Field level entry, and Key level entry.
File level entry keywords are UNIQUE, LIFO, FIFO, FCFO [First Change First Out], REF.
In record level entry, we can give the Record format name.
In the field level entry, we can define the field names, types and size.
In the Key level entry, we can define the key field.
7. UNIQUE – explain.
It is a file level keyword specified not to allow a duplicate key in a keyed file.
8. Can a physical file contain more than one member, and how is it accessed?
Yes, by using OVRDBF (___) MBR (___)
9. When a PF is compiled and default values used how many members does it have?
One
10. What does the DSPPFM command do?
Displays a list of records on the CRT from the physical file.
11. Explain the use of DSPFFD.
To display a physical files record layout structure.
12. How would you change the attribute of file?
CHGPF command is used. By this we can change the length of field, wait time, field name, etc.
13. DSPDBR – Expalin.
Display Database Relation. It tells the no. of logical file that are built over a specified PF.
14. What is the CPYF command used for?
a.) To print all records in a physical file,
b.) To transfer records from one PF object to another PF object.
15. What is the purpose of the *MAP and *NOCHK in the CPYF command?
a.) To transfer data byte by byte.
b.) To transfer data field by field regardless of field names.
16. How to copy a ten specified records from one file to another file?
By using CPYF command we can copy record from one file to another file. If we want to copy from one position to another position, we have to give the starting position and ending position. If we want to copy based on condition, we have to give the criteria on the sql statement.
17. ADDPFCST – explain
ADDPFCST is a command that is used to define the Constraint on your physical file. The constraint has several types. These are REFCST, UNQCST and PRIKEY. By the by, this command is helps to define Update rules and Delete rules.
18. How you will establish Referential Integrity in AS/400?
Referential integrity is a relation between two files, the parent file and the dependent file. The relationship establishes that every record in the dependent file has to have a matching record in the parent file.
By using ADDPFCST command, we can establish in AS/400.
Let we have two PF namely Master and Invoice the fields in Master are CustNo, CustName…. And Invoice PF has the fields are Custnum, Invno, Invdate…
Now we are going to establish referential constraint to those files.
File :Invoice
Library :xxxxxx
Constraint type :*REFCST
Constraint Key :Custnum
Constraint Name :*GEN
Parent file :Master
Library :xxxxxx
Parent Key :Custno
Delete Rule :*cascade
Update Rule :*restrict
Thus the referential constraint has been created
19. Explain DSPFD and DSPFFD.
Display file description is used to list the total number of records in the files remaining records to be added and other related information about the file.
Display file field description is used to listing details about individual fields
20. What is Normalization?
Removing replication of data by applying integrity rules is known as Normalization. Suppose a table have empno, empname, age, address, dob, monthyear, salary fields and the table has the following data
101 raja 28 dsfsdfsdfsd 10-4-77 0102 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0202 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0302 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0402 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0502 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0602 54354
101 raja 28 dsfsdfsdfsd 10-4-77 0702 54354
Here the name, age, address, DOB are fixed data. By feeding these data again and again the table size will be expand. So we can put these data another table by using integrity rules. So the table can be split by
PF01 => Empno, empname, age, address, DOB where empno is KEY
PF02 => Empno, Month year, salary
Now PF01 can has only one record and PF02 has 7 records.
21. How you list all LF of PF?
DSPDBR is used to display all the files, which are related to the physical file. It display all the logical files that are referring the physical file and also list the child table, if it has a relationship with that file.
22. What is a Logical File? And give its types?
It is used to access the data in a physical file.
It cannot exist with out a physical file. It can have multiple record formats. By using LF we can change the key field and attribute size. We can filter the data with criteria by using select and omit command. CRTLF command is used to create a LF. It accesses the data by the access path.
There are two types of LF
Join Logical files.
Non Join Logical files.
23. What are the two types of logical files and its difference?
There is Join Logical files and Non-Join Logical files.
Join Logical Files Non Join Logical File
Impossible to insert, update and deleting records. Able to insert, update and deleting records.
Up to 32 record format can be specified Only one record format can be specified
Commitment control is possible Commitment control can’t be used
24. What are the 6 level entries of LF?
They are
File level
Record level
Join level
Field level
Key level
Select/omit level entries.
25. Does a logical file contain data?
No, it contains access path information only.
26. Explain Non-Join Logical file.
Logical files, which can be derived data from one or more than physical file. But not joining themselves is known as Non-join logical file. If it retrieves data from one physical file, then it is single record format and if it is retrieve data from multiple physical file it has multiple record formats.
There are five level entries in Non-Join Logical file.
File level entries
Record level entries
Field level entries
Key level entries
Select / Omit field level entries.
27. DYNSLT – explain.
Dynamic select. It is a file level keyword used to select records during execution time and the record will not be selected until the file is opened in program.
28. Explain Join Logical file.
A Join Logical file that combine, in one record format from two or more physical files. A PF can’t be changed through a JLF. We can’t insert, update and delete records. DFU can’t be used to display a JLF. Only one record format can be specify. Commitment control can’t be used.
Let PF01 has EmpNo, Empname fields and PF02 has EmpNo, Salary. If we join these files by EmpNo, the result will be EmpNo, EmpName, and Salary.
29. What are the mandatory keywords for join logical file?
JFILE – Record level
JOIN – Join level
JFLD – Join level
JREF – Join level
30. Explain Self-Join with an example.
Join a file to itself is known as self-join
Let PF01 has the fields of EmpNo, EmpName, Salary, MGRID, Job.and has the following data
101 raja 43545 10001 engr
102 mohan 34544 10002 manager
103 kannan 43546 10002 clerk
10001 mani 54654 10002 MD
10002 ganesh 57656
Suppose the LF has EmpNo, EmpName, and MGRName
101 raja mani
102 mohan ganesh
103 kannan ganesh
10001 mani ganesh
10002 ganesh xxxxxx
31. What is access path and what are the various ways to creating access path?
It is a imaginary path, thro’ which the data of a file is accessed for processing. It tells the order in which the record to be retrieved.
There are two types of access path.
Key Sequenced access path.
In case of key sequenced access path, the records accessed according with the key field.
Entry Sequenced access path
In case of Entry Sequenced access path, the records accessed which the order they entered.
Here the record will be accessed by either FIFO or LIFO or FCFO sequence, which is specified in the PF.
Select Omit criteria access path
32. Name three types of access path maintenance?
There are three ways of building or maintaining the access path.
Immediate
For every operation made on a file, the access path, associated with it, is updated whether or not the path is opened
Rebuild
Access path is maintained when the file is open and various updates are recorded and the access path is rebuilt every time when the access path is closed.
Delay
Access path is maintained when file is opened and updates.
33. Why we need to maintain the access path?
Because more than one access path is associated with one data, changing data in one file might cause changes to be made in other files also.
34. Explain JDUPSEQ and JDFTVAL.
JDUPSEQ is used to specify the order in which records with duplicate join fields are presented when the JLF is read.
JDFTVAL is used the system provides default values for all fields, when a join to a secondary file does not produce any records. If this keyword is not specified a record in the primary file for which there is no corresponding record in secondary file is skipped.
35. Is it possible to insert a record in a JLF?
No. It is impossible to insert / update / delete record in a join logical file.
36. What keyword is used to join several physical files into one logical file?
JFILE - Join File
37. What are the major differences between PF and LF?
Physical file Logical file
It contains the actual data so it occupies memory space. Can not occupy memory space
Single record format Multiple record formats
Can be exist even with out LF Can not exist with out PF
If you delete PF the LF also can be deleted. If you delete a LF, the PF can not be deleted
The object type is PF The object type is LF
CRTPF command is used to create such object CRTLF command is used to create such type object
38. What is the difference between a physical file and a logical file?
Physical files contain the data, a logical file us an access path to the physical data
39. How many record formats in a LF ad a PF can have?
PF – One only record format
LF – 32 record formats
40. Can you copy data from a physical file to a logical file?
No.
41. What keyword is used to reference the same field in another file?
REF – Reference
42. What is a Field Reference File?
It is also a physical file, which doesn’t have any data. It has only field description and other physical files can refer these definitions by using ref or reffld keyword. Its type is *PF.
43. What are two methods of creating a record that consists of fields from two or more files?
Join LF and OPNQRYF.
44. What command can be used to clear a physical file?
CLRPFM - Clear Physical File Member
45. What is the keyword VALUES used for?
To set records from a PF based on field values in storage.
46. What is the keyword COMP used for?
To set records from a PF using a comparison between two field values.
47. What is the keyword RANGE used for?
To set records from a PF based on a min/max value of a field.
48. How many record formats in a PF, LF, DSPF and SFL?
PF => 1
LF => minimum 1, maximum 32
DSPF => 1024
SFL => 512
49. What is a display file?
A displayable screen file.
50. What are the keyword levels used in Display file?
File level
Record level
Field level
51. What is Menu?
Menu is a list of short cut commands. We can create Menu thro, STRSDA tool.
52. Define Menu and what is the command to create menu?
Menu is a set of shortcut-commands, which is used to choosing program or commands to execute. In the menu, the text and list of commands are stored in two different objects. The MNUDDS keeps the text and the MNUCMD keeps the list of commands. We are creating menu by using STRSDA command. The default menu name is MAIN. We can check the menu with help of GO command [Syntax GO
No comments:
Post a Comment