Sei sulla pagina 1di 287

What does CCSID-safe conversion method means (RPG MAILS) Can we retrieve data from a file which has

been defined in the O SPEC. What does TRNTBL, REFSHIFT and ALTSEQ keyword is used in case of files? Java already stores data in UCS2 (16 bit) format What do we mean by TAPI interface (RPG MAILS) What would be value in MONMSG when the end of file occurs in a CL program? It would be CPF0864. 7. Can we Use Setll or Chain or any database operations on a Primary File. 8. What does CEODD for Data structures signify. 9. What is the real cost of various types of program calls? 10. How can I force records from an output only file to disk for another program to read? 11. What is Expert Cache, and will it help my system performance? 12. How can I find an AS/400 User's Group 13. What is a User Space? 14. What is the difference between DOW and DOUNTIL? 15. What is the difference between Seton LR and Seton RT? 16. Difference B/w Chain and Read. 17. Difference B/w Read and Iter. 18. How to sum all the elements of an array? 19. How to find out the number of elements in an array 20. Which command should we use to see the attributes of a Physical file and its fields? 21. Which command to be used to find out how many logical files a physical files have on it? 22. What is the Difference when we call Program1 and Program2 in another Program3 and Submit Program1 and program2 in another program4. Is there any real difference b/w them. 23. How to Prompt during run time for any command. 24. I have deleted some records from Physical file and now want that the deleted space should be utilized? which command should we use. 25. What would happen to indicator use in HIGH in case of TESTN is successful 26. How to use MONGMSG to Trap all errors. 27. Where to Use the PR and Where to use the PI. 28. How to retrieve data from Data Area in an RPGILE program 29. What is the difference b/w STRDBG and STRISDB. 30. Command to declare a file in CL Program. 31. Command is used to read a file in CL program. 32. At which specs U can use an SQL command in RPGLE? 33. How to call a Procedure? 34. How to call a Module? 35. Which type of file should be used in a Program a simple logical file or a join Logical File? 36. How many times we can Open a file in a Program. 37. About Journal and Commitment Control 38. How to find out the attributes of a job? 39. Program A calling Program B and Program B transfers Control to Program C, what will happen when the program C will finish, which Program would get control? 40. How many files can be used in a CL. 41. How many files can be used in RPG (3). 42. What is the difference between RPG3 AND RPG4. 43. What is static binding and dynamic binding? 44. How do you check for error in CL? 45. What is the use of Ovrdbf? 46. What is the use of open query (OPNQRY)? 47. How do you use the Open Query file in the RPG? 48. How do you submit a job?

1. 2. 3. 4. 5. 6.

49. What is the difference between Move and Movel? 50. What is the difference between Move and Eval? 51. What does Seton LR do? 52. What is the difference between Seton LR and Seton RT? 53. How do you check for error in RPG? 54. Can we execute a statement after Seton LR? 55. How do we control the opening of the files and Closing of the files in RPG? 56. What are the various kinds of Subfiles? 57. When do we use a load all Subfile? 58. What are the basic keywords required for a subfile? 59. Can we use SFLRCDNBR for a Page = Size Subfile. Will it compile (DDS) 60. Why a LF is required? What are the benefits and Overhead? 61. How many formats can a PF/LF/JLF contain? 62. What is the use of multiple member file? 63. What happens if the RRN is Zero in a Subfile and Display Subfile Indicator is Seton and Exfmted? 64. How do I change the PF without losing the data? 65. What are the implications of the same? 66. How the same can be overcome? 67. I do change the PF with the CHGPF command and use one of its logical in a PGM what happens to the PGM? 68. How many kinds of Arrays are available? 69. How many kinds of Data Areas are available? 70. I have a Select statement and When clause/s there are cases where the When clause satisfies, how many clauses gets executed. 71. What is the difference between DOW and DOUNTIL? 72. What is the data type of the Indicator? 73. How can I retrieve the value of a particular element in an Array? 74. How do you journal a file? 75. What is the use of commitment control? 76. What happens if I have a file under commitment control and I have done a Read on the same and Updated the file, again I am trying to update the same record or Read the record? Will there be any error? IF so why? How to fix the same? 77. What are the uses of procedures? 78. How to invoke the procedure? 79. How do we write a procedure? (Steps) 80. How do we execute a CL command from a RPG? 81. Some keywords that can be used in Printer file/ Display file. 82. How do we monitor for the end of file in CL? 83. How do you handle for end of file in RPG (Built ins for Chain/ Read / Reade) 84. What are the I/O operations that can be done on the Subfile? 85. If we modify a value of Subfile record, how do we retrieve the same? 86. What if the changed value in the Subile is erroneous? How can we check it and ask the user to rectify the same? 87. What is the use of SFLNXTCHG? Explain what is MDT. 88. What is the accpth? 89. Three types of sub files Single page / Load All / Expanding 90. What are the keywords that distinguish between the three types of subfiles Single Page SFLSIZ = SFLPAG Expanding subfile SFLSIZ > SFLPAG Expanding subfile SFLSIZ > SFLPAG

91. What are the op codes that are used to read subfile records. READC, CHAIN 92. How can I read a changed record in the second cycle of read of a subfile Keyword- SFLNXTCHG 93. In a Selec /When/ Endsl sequence if all the WHEns evaluate to true which statements execute. 94. Evaluate this statement MOVE 1 FLD1 FLD1 IFNE 1 FLD2 ORNE 1 Y DSPLY ELSE N DSPLY ENDIF 95. Evaluate this statement Z-ADD 0 FLD1 10,3 MOVE 103.25 FLD1 FLD1 DSPLY FLD1 = 10.325 96. Evaluate this statement KEYVAL SETLLFILE1 XXXX01 *IN01 DSPLY Value = 1 97. Evaluate this statement KEYVAL READE FILE1 XXXX01 *IN01 DSPLY Value = 0 98. Format level identifier and its use. Follow it with Can I change a structure of a file and then not compile the RPG program. 99. Describe exception handling 100. How to read a database file in a CL program 101. How to check for end of file CPF 0864 102. Can I use an override to position in a database file 103. Display a record format in CL program 104. How to submit a program in batch 105. How do you debug an RPG program. 106. Three ways of copying a file. CRTDUPOBJ CPYF INSERT INTO 107. I have a program object I need to identify the location of the source DSPPGM PGM (XXXX) (*SERVICE) 108. How to check an object exists on the system in a CL program. 109. How to display record locks 110. Where do system libraries reside? 111. How to get the length of data in a variable? Not the length of variable. 112. How to use TEST opcode for a alphanumeric variable? 113. Why use LF with key and not PF with key if no maintenance considerations. 114. Whats FIFO? 115. Can u have a PF with fields derived from 2 field reference files? 116. Can u have an LF defined on all the members of a PF at once? If so how? 117. How do u know when a Batch Job has ended? 118. How will u use a pgm to change current library list? 119. How will u use a pgm to change library list for an interactive job after a batch job?

120. What are job 121. Difference between activation group and job ? 122. What are the types of activation group and their significance? 123. What are modules, service programs, can u see the code of service pgms if u browse through them? 124. How is ILE different from other HLLs? 125. What is difference between *SRVPGM and a normal RPGLE pgm both can have modules. Why prefer *SRVPGM? 126. Service programs are mare by pass by reference? 127. What are the types of access path maintenance? Explain each of them. 128. How to copy 1000 record from 10000 records using CPYF, tell the keywords. 129. Whats the difference between CALL, CALLB, CALLP when are they used? 130. What are the different ways of transferring control from one pgm to another? 131. DataQs, what happens to the dataq after the data has been sent? 132. What is an access path? 133. CL variable types, max length, default length 134. Why is SFLNXTCHG used? 135. If I use a field reference file and a COLHDG is defined in that and while using them in a PF I again specify a COLHDG, which takes precedence? 136. Difference between ODP and Access path? 137. What is an ODP does it exist if so where? 138. RPGILE is faster than RPG why? 139. How many overflow indicators can u have in a pgm? 140. What are the different kinds of indicators in RPGLE? 141. What is primary file, secondary file, fully procedural file. 142. How many secondary files/printer files can be there in a pgm? 143. Can I specify a update for a primary/secondary file/fully procedural file? 144. What happens if I specify UC (user controlled) for a primary/secondary/fully procedural file? 145. What is level check (LVLCHK)? 146. What is *Namvar DEFINE? 147. What are the error handling subroutines? 148. What are the different kind of MONMSGs 149. Can u se a subfile in a CL pgm? Message Subfile ? 150. What is the difference between CALL and Transfer Control (TFRCTL) ? 151. Explain Multi Dimensional Array? 152. Explain Commitment Control? 153. How can u send data from a production environment to a development environment? 154. READC why n when used? 155. How do you send a Packed decimal value from a CL program to a RPGILE program as parameter? 156. How does CL pgm end if no ENDPGM, is PGM mandatory? 157. Can data be copied from an LDA into a SBMJOB? 1. Given a full procedural, externally-described input file named ORDER with a record length of 41 bytes, which of the following is a valid format for the File specification for the ORDER file? A. FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords FORDER IF E DISK B. FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords FORDER IPE F 41 DISK C. FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords FORDER IF E 41 DISK D. FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords FORDER IF F DISK Answer : A

2. Given the following RPG IV code excerpt: FFilenameIPEASF.....L.....A.Device+.Keywords FORDERS IF E K DISK USROPN Which of the following options describes the result of using the USROPN keyword? A. This file will be opened immediately when this program is called B. This file must be opened with an explicit OPEN operation prior to accessing this file C. This file must be opened with the CL command OPNDBF prior to the call to this program D. This file will be opened when the program reaches a C specification that issues a READ or CHAIN to this file Answer : B 3. Given the following code excerpt: 0395.00 ************************************************ 0396.00 * 0397.00 C *IN44 WHENEQ *ON 0398.00 C Z-ADD D2RRN SFLRCD 0399.00 C MOVEL(P) 'D3SC' #SDFMT #SDFMT Which of the following will use the overlay function to comment out lines 397 to 399 without changing the remaining code?

A. B. C. D.

Type C3 in sequence number 395 and OO in sequence number 397 Type RPO3 in sequence number 396 and A in sequence number 397 Type O in sequence number 396 and OO in sequence numbers 397 and 399 Type C in sequence number 396 and OO in sequence numbers 397 and 399

Answer : D 4. Which of the following RPG operations retrieves a changed record from a subfile? A. READC B. READE C. CHAINC D. READPE Answer : A 5. What type of object stores spooled files that are waiting to be printed on an output device? A. *SPLQ B. *PRTF C. *PRTQ D. *OUTQ Answer : D

6. Given the following RPG IV statement: .....DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords+++++++++++++++++++++ ++++ 0001 D Arr S 30A Dim(30) PerRcd(1) CTDATA

What kind of array is being declared? A. B. C. D. Run-time Prerun-time Compile-time Alternating table

Answer : C 7. A CL program, EMPCL1, calls the RPG program EMP001 and then calls the RPG program EMP002. RPG programs EMP001 and EMP002 were both written to process the file EMPMAST. In order to test changes in EMP001, a test file called TESTEMP in library TESTLIB needs to be used. EMP002 should process EMPMAST as it normally would. The following code segment was provided for testing: OVRDBF FILE(EMPMAST) TOFILE(TESTLIB/TESTEMP) CALL PGM(EMP001) CALL PGM(EMP002) Which of the following actions will accomplish this task? A. Add the SCOPE(*NEXT) parameter to the existing OVRDBF command B. Add the following CL statement directly before the call to EMP002: DLTOVR FILE(EMPMAST) C. Add the following CL statement directly before the call to EMP002: DLTOVR FILE(TESTLIB/TESTEMP) D. Add the following CL statement directly before the call to EMP002: CHGOVR FILE(EMPMAST) SCOPE(*PRV) Answer : B Section 1 CL Command use 1) Use of mon-message. A piece of code was given with the MONMSG at procedure level and it was asked where will the control go if an error happened in the processing of a command defined somewhere in the procedure. 2) Command to write and read a file in CL. 3) A call to a program is to submitted in batch and a customized library list is to be sent along with it. 4) How to retrieve the job date/job name. Available options had RTVJOBA, RTVJOBD etc. 5) CHGDTAARA command was given with a complex VALUE parameter which contained %SST. Was asked to mark the option, which gives the right value in the Data area. 6) How can the current library list be changed? Was asked to mark 2 correct answers. 7) How to debug a program running in batch. 8) A file with key A is to be accessed randomly on the basis of a field B. Available options Create a new logical, Opnqry with STRSEQ parameter having B, Sorting the file etc.

9) How to see the logical files created over a file by using CL command. Section 2 RPG Command use 1) Where is the *INZSR subroutine coded. 2) A field was defined with the like keyword. Was asked about its length and initial value. 3) A DATFMT was defines at control spec. There were date definitions at D spec. Was asked to recognize incorrect format. 4) How is the format of a date defined at control specification level? 5) %ELEM was used to define an array in the DIM keyword. Was asked how many records the array will have. 6) Complex %subst using %scan with addition and subtraction done in the return value of SCAN. 7) If DIV used with factor 2 zero what will happen. Options available Result indicator will be set on, *PSSR code will be executed, Result factor will have zero etc. 8) A piece of code was given using DIV opcode where factor 2 was zero and *PSSR subroutine was coded. Was asked to detect what will happen. 9) A data area DS was given and IN OUT operations performed. Among five different samples of code was asked to find out in which case the Data area will be locked and unlocked. 10) How to find the Program name and some related information. Options had SDS etc. 11) An expression using op-codes was to be converted using built in functions - %Dec and %DECH. 12) What is the correct syntax for Op-code Test(D) 13) When does a indicator defined in 73-74 position seton while chaining a record. 14) Except keyword. A file defined in F spec as O type and a DS defined in D spec. How can the file be updated using the DS. Section 3 Advanced RPG Programming 1) Complex Logical expression using Indicators and a variable. Analyzing and determine the result of the variable. 2) Setting the indicator value by using logical expressions. *IN50 = (A = B) what will be the indicator value. 3) With the same condition as above a complex piece of code was given and the result was to be determined. 4) A complex logic in words using and either, or, neither to be written in expression. 5) A complex piece of code with a variable using ITER and LEAVE was given and analyzing that code the value of that variable was to be determined. 6) How to include a service program in your program. 7) While creating the program if *OWNER is given to the usrprf parameter what is its significance. 8) A program A compiled with activation grp. *New calls a program B compiled in activation grp. QILE. Program B has the following code: Count = count + 1 Seton RT After the program has been invoked 3 times. What will be the value of count? 9) A Question on the same lines as above but not in different activation group. What will be the value of count? 10) Where is a prototype defined. 11) Select the right prototype definition. Extpgm definition was used? 12) A piece of code for sub procedures was given. What is the length of the value returned? 13) API for ovrdbf.

Section 4 Subfiles 1) There are some 200 records to be loaded. The roll up/down keys should be very fast. Which loading technique to be used. 2) What does the keyword SFLNXTCHG do. 3) What does the keyword SFLRCDNBR do. 4) A piece of code was given using SFLRCDNBR. At what position the cursor will be? 5) There was a piece of code having different keywords along with there indicators. What will be the indicator positions to initialize the sub file. 6) If a record has been deleted and you dont want do display it on the subfile anymore. What is the best possible way to do it? Section 5 RPG Performance and Exception/Error Handling 1) There was some question where some data movement was done and then finally asked what will be the result. Available option Data truncation etc. Section 6 RPG Data Handling 1) A multiple occurrence data structure was defined. How to set the occurrence using the OCCUR opcode. 2) An EDS was defined using prefix but the fields were not renamed using EXTFLD. What will be the name of the fields used in the program. Tick one or more correct choice/s (1 Mark each) 1. Which of the following is not a valid CL datatype? (a) *dec (b) *char (c) *log (d) *lgl 2. Max no. of files that can be declared in a CL program (a) 0 (b) 1 (c) 50 (d) 9999 3. How many files can be updated through CL? (a) 0 (b) 1 (c) 20 (d) 50 4. Predict which programs will be executed in the following code when &Opt = 1: IF COND(&Opt *EQ 1) THEN ( Call Pgm4) ELSE CMD(Call Pgm3) CALL Pgm(Pgm2) CALL Pgm(Pgm1) Pgm4, pgm2, pgm1 5. Which of the following files can be used in the TOFILE parameter of CPYF? a) Logical file b) Join Logical file c) Tape file d) None of the above (c) 6. Which of the following commands cannot be used on the command line?

a) b) c) d)

RTVDTAARA CRTDTAARA CHGDTAARA All the above

(a) 7.

What is the command used to find all logical files based on one physical file? a) DSPDBR b) DSPOBJD c) DSPPFM d) a and b Which is the command used to find the access path of a file? a) DSPFFD b) DSPFD c) DSPOBJD d) All the above Which of the following combination of files can be declared in CLP? a) Printer file, Database file b) Display subfile, Message subfile c) Message subfile, Database file d) Database file, Display subfile What is the function of DSPPGMREF? a) Displays list of all files referred in the program b) Displays the list of all objects used in the program c) Displays all copy books used in the program d) Displays list of all call programs used in the program

(a) 8.

9.

10.

Use Short Answers: (2 Marks each) 1. What is the difference between program level and command level MONMSG? 2. What is the difference between TFRCTL command and CALL command? 3. How can the data be shared across different jobs? 4. Differentiate between data base files and data areas 5. How do you compile RPG program having compile time override? 6. What is wrong in the following program: PGM MONMSG CPF0000 DCLF FILE (INPUT) ENDPGM 7. How do you know the keys used in a physical file without using SEU? 8. How to extract a word hello from the string hello world? 9. Which has the highest priority if you give both program level MONMSG and command level MONMSG? 10. How to use multiple files in CLP? Mention True/False: (1 Mark each) 1. Two objects with same name and type cannot exist in different libraries 2. The built-in menu called MAJOR organizes all the AS/400 commands 3. 4. 5. 6. SNDF writes a record to a display or a data base file. The value of a CL variable can be changed using CHGVAR The current library cannot be a duplicate of any library in the library list The RETURN command in a program removes that program from the program stack

7. 8. 9. 10.

A data area is an object used to hold data for access by any job running on the system. Library list is an object LDA can be used to pass information to a subprogram without the use of a parameter list SNDPGMMSG command allows us to send messages to a work station user or the system operator.

Answer the following questions: (2 marks each) 1. Not all CL commands can be used in a CL program (TRUE/FALSE) 2. Declare commands must precede all other commands except the PGM command. (TRUE/FALSE) 3. ENDPGM command is a mandatory command in a CL program. (TRUE/FALSE) 4. ____________________________ Monitors for escape, status, and notify messages sent to a program's message queue 5. __________________ identifies a command in a CL program and is used for branching purposes

1. In the same library there can be objects of the same name of different object types. This statement is a) True b) False c) None of the above 2. Types of jobs on OS/400 are a) 2 b) 3 c) 4 d) 5 3. Save file is an object and it is used for the backup. This statement is a) True b) False c) None of the above 4. In join logical file you can have multiple files and multiple record formats. This statement is a) True b) False c) None of the above 5. To show the physical file member , its attribute and its logical files commands used is a) DSPDBR b) DSPFFD c) DSPFD d) DSPPFM 6. To look at the job correct set of command used is a) WRKACTJON, WRKSBMJOB, DSPJOB, WRKUSRJOB b) WRKSBMJON, WRKSBSJOB, WRKUSRJOB c) WRKACTJOB, WRKSBSJOB, DSPJOB, WRKUSRJOB 7. DYNSLT keyword is used in a) Physical file b) Logical file c) Both d) None of the above 8. Command function and command attention Key performs the same function and have same concept. This statement is a) True

b) False c) None of the above 9. OPNQRY FILE AND LOGICAL FILE both are used to access the database file only. This statement is a) True b) False c) None of the above 10. Which statement is false a) QUERY400, OPNQRYF, LOGICAL FILE all are objects. b) Logical file is an object c) QUERY400 is a system supplied utility d) OPNQRY is not an object 11. There are 2 physical files. File(a) is having 3 logical file and other File(b) is having 2 logical file. Which can be easily complied with out deleting its dependent logical file a) File(a) b) File(b) c) None of the above 12. In join Logical File Min. files required are a) 1 b) 6 c) 32 d) None of the above 13. In join logical file Max files required are a) 2 b) 4 c) 6 d) 32 14. To find a string CL command used is a) FNDSTRPDM b) ALCOBJ c) DSPFD d) None of the above 15. Please read the following CL statements Program A CALL PGM (B) OPEN FILE X OPEN FILE A Program B OVRDBF FILE (X) FILE (Y) OVRDBF FILE (A) TOFILE (B) OVERSCOPE (*JOB) RETURN The file opened in the program A is a) File A,X b) File B.Y c) File X,B d) File Y,A 16. Please read the following CL statements. Program A OVRDBF FILE(B) TOFILE(C) OVRDBF FILE(A) TOFILE(B) OPEN FILEA. File opened will be

a) A. b) B c) C d) None of the above 16. Read the following statements Program A OVRDBF FILE(A) ToFILE(B) ENDPGM Program B OPEN FILEA File Opened will be a) A. b) B c) None of the above 17. You can send a message in the program through sub file. This statement is a) True b) False c) None of the above 18. QCMDEXC is a system supplied API. This statement is a) True b) False c) None of the above 19. You can display a error message only on 24th Line in a display file. . This statement is a) True b) False c) None of the above 20. You can define (a) Only one file in CL program .(b) & update the database file through CL program .In this statement a) A is true B is false b) B is true A is false c) A & B are true d) A & B are false 21. You can get the user information in the CL program by using command a) RTVJOBA b) RTVUSRPRF c) DSPJOBA d) RTVSYSVAL e) None of the above 22. (A ) call in the CL program will pass control to the next program. (B) while RETURN command remove the procedure from the call stack .In This statement a) A is true B is false b) B is true A is false c) A & B are true d) A & B are false 23. (A) Call in the CL program will pass control to the next program and again back to the calling program.(B) while TFRCTL command removes the calling program from the call stack. In this statement a) A is true B is false b) B is true A is false c) A & B are true d) A & B are false 24. Wait command is used in CL program only. This statement is

a) True b) False c) None of the above

1. Give examples of DCL, DDL, DML SQL commands. A. DATA CONTROL LANGUAGE(DCL)- grant , revoke. DATA DEFINITION LANGUAGE(DDL)- create, alter , drop. DATA MANIPULATION LANGUAGE(DML)- select, insert, update, delete. 2. What are data types? What is meant by null? Give examples of operators. A. Data types are attributes of columns, literals and host variables. They are SMALLINT, INTEGER, FLOAT, DECIMAL, CHAR, VARCHAR, DATE, TIME, TIMESTAMP, GRAPHIC, VARGRAPHIC. NULL is a special value that indicates the absence of data in a column. Operators: - , + , * , / , :: concatenation, date, day, year, days, substr , current date, current time, user. 3. What are the column or aggregate functions available in SQL? A. AVG for average, COUNT for counting the number of rows in the result table, MAX which returns the maximum value in the column , MIN which returns the minimum value, SUM which gives the sum total of the column. 4. Explain the usage of the terms GROUP BY, HAVING, ORDER BY. A. GROUP BY - the column function will calculate its result based on the individual groups created by GROUP BY specification creating one result for each group. HAVING - is used to specify the conditions each row of each returned group must satisfy. ORDER BY - used to sort the output of a query using the column names or position of column in the list of columns named in the select expression. 5. What does the LIKE and IN and BETWEEN search operators allow you to do? A. They search for rows where the column specified satisfies one among a number of values. LIKE - to select rows based on a similarity of partial strings. ( - for a single unknown char and % for 0 to any no. of unknown char) IN - to select rows where the column values are one among a specific list of values. BETWEEN - to select rows having column values within the given limits. 6. What are the DB2 objects that can be created using CREATE statement? What are the DB2 objects you require before creating a Table? A. TABLE, INDEX, VIEW, SYNONYM, ALIAS, STOGROUP, DATABASE, TABLESPACE. Tablespace and Database are required before creating a table. 1. What is a CURSOR and how is it operated for read, update, delete? A. A cursor is a named control structure used to make a selected set of rows available to a program one row at a time for read or update. DECLARE CURSOR, OPEN CURSOR, FETCH CURSOR, CLOSE CURSOR are used to operate the cursor. The results table will be created during the execution of the OPEN CURSOR statement. The values are fetched from the table row into the host variables and the cursor position remains on the row until the next FETCH or CURSOR CLOSE statement. During this time ,the cursor position could be used to update or delete this row from the table using the WHERE CURRENT OF clause. 2. What is the difference between Dynamic SQL and Embedded SQL? A. Dynamic SQL statements are prepared and executed within a program while a program is being executed. The SQL source is contained in the host variables rather than being hard coded into the program and may change from execution to execution. Embedded SQL statements are hard coded within the application program and are prepared during the program preparation process before the program is executed. 3. What is the difference between cascade and restrict with ref. to DELETE statement? What is a primary key and a foreign key?

A. Cascade and Restrict are part of the delete rule when specifying the referential constraints between two tables. Cascade on Delete - deletes all dependent rows from the dependent table while deleting a row in the parent table. The Restrict rule fails the delete request if a dependent row exists. A primary key is the unique identifier of the rows in a table. A foreign key is a column or combination of columns in a table whose values are required to match with those of the primary key in some other table. 4. What is the difference between a base table, view, synonym, alias, index? Base table - table that physically exists and has physical stored records ,can be updated.
View - an alternative representation of data contained in one or more tables including all or some of the columns from the constituent tables , cannot be updated, automatically dropped when source tables are dropped.

Synonym - alternate name for a table or view, accessible only by creator of synonym, cannot be updated unless authorized to update base table. Alias - similar to synonym , but accessible by all users who have access to the source tables represented by the alias, can be defined for local or remote objects before they exist, remains intact after the object it represents has been dropped. Index - set of row identifiers or pointers that are logically ordered by the values of a column that has been specified as being an index, provides faster access to data and can enforce uniqueness on the row in a table. 5. What is the difference between JOIN and UNION? A. JOIN - relational operation that allows retrieval of data from two or more tables based on matching column values, results in addition of columns of the different constituent tables with the same key values. UNION - used to combine the results of two or more Select statements into a single results table, results in the addition of rows of the different tables. 6. What are Subqueries ? What is SQLCA , where is it given in a COBOL pgm. ? A. A Subquery is a query that is written as a part of another querys WHERE clause. SQLCA ( SQL Communication Area ) is made up of a series of variables that are updated after each SQL statement is executed and contains the sqlcode , it is given in the working-storage section using an SQL INCLUDE statement. 1. What are the different types of locks that can be held? What is meant by locking and concurrency ? What does COMMIT accomplish and what does ROLLBACK accomplish? A. Locks- Exclusive, Shared , Update. Locking - used to ensure the integrity of data and prevents concurrent users from accessing inconsistent data. The data is locked until a commit is executed to release the updated data. Concurrency - allows more than one DB2 application process to access the same data at essentially the same time. COMMIT - allows data changes to be made permanent, frees all locks so that other applications can access the data, closes any open cursors being processed. The recoverable processing is that done between two commits. ROLLBACK - allows data changes (updates) made by pgm. since the previous commit to be undone, locks are released, cursors are closed. 2. What is cursor stability and repeatable read? What are the AQUIRE & RELEASE parameters? A. Cursor stability - tells DB2 that database values read by its application are protected only while being used. Changed values are protected until the application reaches a commit point. Repeatable read - rows referenced by the program cannot be changed by other pgms. until the program reaches a

commit point. AQUIRE, RELEASE parameters on the BIND command specify when tablespace-level locks are to be acquired and released. The parameters are: Aquire- USE : locks are required on first use. ALLOCATE: locks are required when the PLAN is allocated. Release- COMMIT: all Tablespace-level locks are released at each synchpoint. DEALLOCATE: locks are held until the PLAN is deallocated. 3. What is a PLAN? What is DBRM? Where are PLANs stored? What does FREE command do? A. PLAN- a DB2 object produced during the bind process that associates one or more DBRMs. DBRM- (data base request module) is a DB2 component created by DB2 precompiler containing the SQL source statements extracted from the application program and is used as input to BIND process. BIND- process that builds access paths to DB2 tables, uses the DBRMs and produces an application plan. It also checks the users authorization level and validates the SQL statements in the DBRMs. PLANs are stored in sysibm.sysplan. FREE - will drop the existing PLAN. 4. When do the following SQL codes occur? A. +000 successful execution. -904 unavailable resource -811 embedded SQL returning more than one rows -100 row not found -925 commit not valid 5. What is meant by attachment facility? What command is used by TSO users to invoke DB2 ? What does DSNDB07 database do? A. The attachment facility is an interface between DB2 and TSO, IMS/VS, CICS, or batch address spaces. It allows application programs to access DB2. DSN RUN command is used. DSNDB07 is where the DB2 does its sorting, it includes DB2s sort work area and external storage. 6. What do the following contain? A. sysibm.sysdatabase - one row for each database. sysibm.sysdbrm - one row for each dbrm. sysibm.sysplan - one row for each plan. sysibm.sysdbauth - shows which authids have privileges on which databases. sysibm.sysplanauth- shows which authids have privileges on which plans. sysibm.sysrels- one row for each referential constraint.
1.) What is needed in an RPG program to receive parameters? An *ENTRY parameter list. 2.) What is KLIST used for? To define a composite key. 3.) What is CASxx used for? To execute subroutines based upon the result of a logical comparison. 4.) 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. 5.) What is the difference between just exiting a program with retrn or by setting on indicator LR, first? Open files are closed when exiting with LR equal to ON.

Open files remain open when using RETRN with LR equal to OFF, and the program is still resident (potentially active.) 6.) What RPG operation codes are associated with data areas? IN, OUT, UNLCK and DEFN. 7.) How are the following RPG operation codes used? a.) CAT To concatenate fields and /or constants. b.) SCAN To search 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. 8.) What operation code should be used to check for 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. 9.) How are parameters accepted in an RPG program? *ENTRY PLIST 10.) How are parameters passed in RPG? CALL ---- PARM xxx 11.) How do you define a subfile in RPG? IPFC(prompt) ---- RRN KSFILE rcdfmt-name. 12.) What is a compile-time table? A table whose information is hard coded in the program source. 13.) What is a pre-execution table? A table whose data comes from an external file. 14.) How is data accessed from a table? A LOKUP operation. 15.) How can a subroutine be executed? EXSR 16.) 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. 17.) What is the use of the MOVEA operation? To transfer data to an array or transfer an array to another storage location. 18.) What is the difference between the MOVE and the MOVEL? MOVE transfer is a right justified move, MOVEL is a left justified move. 19.) How does the READP work? It reads data from a physical file in reverse order. 20.) What is the operation SELEC used for? For CASE structure handling. 21.) What is an externally described file? Any DDS file that has its layout automatically defined as part of the RPG program. 22.) What is a level checking error? When a HLL object isnt linked with the current DDS object. 23.) What does the phrase subscript out of range mean? It means you are trying to access an area outside of the defined table range. 24.) What is an Output queue (such as *OUTQ?) An area, which stores all spooled files waiting to be printed. 25.) What is an Job queue (such as *JOBQ?) An area that stores all jobs waiting to be compiled. 26.) What does IPL stand for? Initial Program Load, which is used for start-up. 27.) What is PWRDWNSYS?

The command to power down the AS/400. 28.) What is the purpose of the EDTOBJAUT command? To permit or exclude user access to specific objects. Subfiles: 29.) What DDS keywords are required when defining a control record format? SFLCTL, SFLDSPCTL, SFLPAG, SFLSIZ. 30.) What operation codes can be used to retrieve subfile record? READC and CHAIN. Ans:- READC 31.) 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. 32.) Explain the following DDS keywords: a.) SFLEND Controls the display of plus sign. b.) SFLNXTCHG Controls modified data tag on subfile records. c.) SFLRCDNBR Controls what subfile page is displayed and where cursor goes. d.) SFLDROP Controls when a subfile fold area is displayed. 33.) How do you clear a subfile? Set the indicator associated with the SFLCLR keyword to ON and WRITE the subfile control format. 34.) What are the 3 types of subfiles? Single page, expandable and load-all. 35.) Which type of subfile has the better performance? Single page. 36.) What is a subfile control record? The record that controls the display of the record format and text information. 37.) What is a subfile record number? The internal value associated with the each subfile record. 38.) 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. 39.) What is a subfile record format? The record that contains the displayable data. 40.) What must follow the SFLCTL keyword in the subfile control record? The name of the Subfile Record Format. 41.) What does the SFLNXTCHG keyword mean? To activate the READC operation and allow all records to be modified as changed records. 42.) How do you utilize the subfile message control? By using SFLMSG and MSGLOC keywords. 43.) 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). 44.) Define the following keywords: SFLPAG and SFLSIZ? a.) Number of records displayed per page. b.) Number of total records displayable in the subfile. CL: 45.) 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. 46.) What is the main use of MONMSG?

Error trapping. 47.) What is the purpose of the DCL statement in a CL program? To define variables. 48.) 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 49.) How do you access the local data area in a CL program? RTVDTAARA DTAARA (*LDA) RTNVAR (&var) 50.) What CL command is used to read a file? RCVF - Receive File 51.) What CL command is equivalent to write a display file in RPG? SNDF - Send File 52.) What CL command is equivalent to write/read a display file in RPG? SNDRCVF - Send/Recieve File 53.) What CL command is used to determine the logical files associated with a particular physical file? DSPDBR - Display Database Relations 54.) Explain the use of DSPFFD. To display a physical files record layout structure. 55.) Why would a programmer use the OVRDBF command? To override default values set for the physical file; i.e., to utilize a specific member in a physical file. 56.) What CL command is used to debug a program on-line? STRISDB - Start Interactive Debugger 57.) 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. 58.) 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. 59.) What is the purpose of the CHGVAR command? To change the value associated with a CL variable. 60.) How does a programmer create a new variable within a CL program? By using the DCL command. 61.) What is a command label? An area of transfer within a CL program from which to continue processing directed by a GOTO command. 62.) Explain parameter passing. To pass variables from a CL or RPG program to another CL or RPG program. 63.) How can a programmer exit out of a CL program? By using a RETURN command. 64.) Why would the PGM line contain a PARM? The CL program is using a value passed from another processing program. 65.) How can a programmer send a message from a CL program? Using the SNDPGMMSG command - Send Program Message. 66.) What does the DSPPFM command do? Displays a list of records on the CRT from the physical file. 67.) What is the purpose of the DSPLIBL command? Displays a list of all libraries whose objects are available to the interactive job. 68.) Explain the STRSEU command. To create a new program or put the last used program in edit mode DDS: 69.) In the DDS keyword WINDOW(___), what belongs inside of the parentheses? Either the coordinates of the window or the name of the record format. 70.) What is the difference between CA and CF command keys?

CA means that screen validity checking is bypassed and no screen data is passed to the program. CF means that screen validity checking is performed and screen data is passed to the program. 71.) What is the DDS keyword UNIQUE used for? To prohibit duplicate keys in a keyed database file. 72.) Does a logical file contain data? No, it contains access path information only. 73.) Name three types of access path maintenance. Immediate delayed and rebuild. 74.) What are two methods of creating a record that consists of fields from two or more files? Join, LF and OPNQRYF. 75.) What keyword is used to reference the same field in another file? REF - Reference 76.) What keyword is used to join several physical files into one logical file? JFILE - Join File 77.) What does DDS stand for? Data Description Specifications. 78.) What command can be used to clear a physical file? CLRPFM - Clear Physical File Member 79.) 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. 80.) Can you copy data from a physical file to a logical file? No. 81.) What is a display file? A displayable screen file. 82.) What is a printer file? A print layout for a report that can be used by any program. 83.) Can a physical file contain more than one member, and how is it accessed? Yes, by using OVRDBF(___) MBR(___) 84.) What does the Open Query file do? Creates an open data path to physical file data. 85.) When a PF is compiled and default values used how many members does it have? 1 86.) What is the keyword VALUES used for? To set records from a PF based on field values in storage. 87.) What is the keyword COMP used for? To set records from a PF using a comparison between two field values. 88.) What is the keyword RANGE used for? To set records from a PF based on a min/max value of a field. 89.) Why would a DSPF program use a DSPSIZ keyword? To select the screen display size used. 90.) What is the INDARA keyword used for? To store all program indicators into a useable array. 91.) What is the purpose of the OVERLAY keyword? To allow multiple screen records to display at one time. 92.) How can a programmer control how data on a screen will display? By using the DSPATR keyword. Miscellaneous: 93.) What is QTEMP? A unique temporary library associated with each job. It is deleted at the end of a job. 94.) What is the purpose of level checking? To ensure that the version of a file used by a program has not changed since the program was compiled. 95.) What two CL commands are usually used to debug a program? STRDBG and ADDBKP - Start Dedub abd Add Breakpoint. 96.) What is QCMDEXC?

A program that can be called from an RPG program to execute most CL commands. 97.) What is the purpose of the CHKOBJ command? To test for the existence of and object and to check for object authorization for the user.

Choose correct answer: 1. What is the maximum number of files which can be declared in CLP? a) 3 b) 2 c) 1 d) No limit 2. Which of the following commands cannot be used on the command line? a) RTVDTAARA b) CRTDTAARA c) CHGDTAARA d) All the above 3. What is the command used to find all logical files based on one physical file? a) DSPDBR b) DSPOBJD c) DSPPFM d) a and b 4. What does the command FNDSTRPDM do? a) Searches for the member in source physical file b) Searches for particular string in a member or file c) Searches for objects in a library d) None 5. Which is the command used to find the access path of a file? a) DSPFFD b) DSPFD c) DSPOBJD d) All the above 6. Which of the following combination of files can be declared in CLP? a) Printer file, Database file b) Display subfile, Message subfile c) Message subfile, Database file d) Database file, Display subfile 7. What is the function of DSPPGMREF? a) Displays list of all files referred in the program b) Displays the list of all objects used in the program c) Displays all copy books used in the program d) Displays list of all call programs used in the program 8. What is the command used to delete program object? a) DLTOBJ b) DLTPGM c) DLTF d) All the above 9. Which is the command to retrieve system date? a) RTVSYSVAL b) RTVJOBA c) RTVJOBD d) a and b 10. Which of the following files can be used in the TOFILE parameter of CPYF?

(a)

(a)

(b)

(b)

(b)

(b)

(a)

Logical file Join Logical file Tape file None of the above 11. Following method is used to load the messages in Message subfile (a) a) Load All b) Expanding c) Single Page(Equal subfile) d) None 12. What is the command used to see the messages in message file? a) CRTMSGF b) DSPMSGF c) WRKMSGF d) None 13. To which queue will you send messages? (a) a) PGMQ b) MSGQ c) External MSGQ d) None 14. Which of the following is not true for CL programming? a) CL programs are flexible b) CL programs can be tested and debugged c) Cannot add or update records in data base files d) All the above 15. What is the command used to change the value of a data area? a) DSPDTAARA b) RTVDTAARA c) CHGDTAARA d) None Answer the following briefly: 1. Name three CL commands which cannot be used on the command line. 2. What is the difference between program level and command level MONMSG? 3. What is the use of TFRCTL command? 4. What is the use of CALL command? 5. What is the difference between TFRCTL and CALL commands? 6. Can you create a Local Data Area? Is Local Data Area (*LDA) specific to a JOB? 7. How can the data be shared across different jobs? 8. Differentiate between data base files and data areas. 9. List out the advantages of data areas. 10. What are the different types of data areas? 11. What are the different Override commands? 12. How do you access all the members on a PF? 13. What is the function of RCLRSC command? 14. What is the CL command to display the record of display file? 15. What is the command used in CLP to read records from the database file? 16. What is DDMF? How do you create, change and display DDMF?(4marks) 17. How do you use a numeric database field in OPNQRYF? 18. How do you compile RPG program having compile time override? 19. Write program to find the number of members in a source file and store the names of members in the source file through a physical file? 20. Write a program to add records in physical file from first member to second member without using CPYF statement and find the record number difference if any.
a) b) c) d)

Can a CL use Subfile?(MSGSFL) How many record formats can you specify for a display file in a CL program? How many number of files can you declare in a CL program? What is wrong in the following program: PGM MONMSG CPF0000 DCLF FILE(INPUT) ENDPGM 25. How to extract a word hello from the string hello world? 26. What is the command used to add members to a physical file? 27. What is the command used to read a record from the database or display file? 28. How do you know the keys used in a physical file without using SEU? 29. How do you know the field attributes used in database file without using SEU? 30. How do you know the logical files based on a particular physical file? 31. What is the function of DSPPGMREF? 32. How to find the number of records in a physical file? 33. How to copy a spool file to a database file? 34. How do you execute system/38 commands? 35. Which has the highest priority if you give both program level MONMSG and command level MONMSG? 36. How to find the system date in CLP? 37. How can you compress objects? Why? 38. How to use multiple files in CLP? 39. How to view overrides present on a file? 40. What is the function of SHARE parameter in OVRDBF command? 41. Describe how to handle error exceptions in a CLP. 42. Explain the function of SNDRCVF. 43. What is the function of ENDRQS command? 44. What is a library list? 45. List the components of a library list. 46. If &var1 = ---hello---- &var2 = world result of the following operations (Interpret - as blank in the above variable) &var1 *cat &var2 &var1 *tcat &var2 &var1 *bcat &var2 47. What is the command to delete a display file and a printer file? 48. Suppose FILEA contains two fields: NUM(numeric) and NAME(character). Write an OPNQRYF command to sort the FILEA on NAME and take the records which have NUM greater than 10. 49. How to create a physical file with records generated in the above OPNQRYF? 50. How to find the member name, source file and library from which an object is created? 51. Explain the difference between ordinary subfile and message subfile. 52. What are the mandatory keywords used for DDS coding of a message subfile? 53. We will give SFLPGMQ value as 10 or 276. Explain in which cases these values will be used. 54. Which Function key is used to do step by step debugging? 55. How you will find particular string/word ? 56. Which function key is used to add break points? 57. Which function key is used to remove break points? 58. How to display the value of a variable? 59. What is the command used to start the debug? 60. How to run the program up to a particular point skipping in between statements? 61. How to change the value of a variable?
21. 22. 23. 24.

How to enter a system command? How do you start source debugger? Which keyword will effect the messages to come at particular line on the screen? To which queue will you send messages? How will you clear the messages from message queue? In DDS coding for Message subfile, will you need SFLCLR keyword? What is the default value for SFLPAG in Message subfile? Is controlling indicators necessary for mandatory keywords(Except for SFLEND Keyword) that will be given in DDS coding. 70. Which API is used to send the messages? 71. Which API is used to clear the messages from program Q? 72. How do you start source debugger? 73. How can we rename an object? 74. What are data queues? 75. What are message queues? 76. What is an Open Data Path (ODP)? 77. Compare and contrast Open Query File and Logical Files. 78. List out the various steps involved in a typical Open Query File. 79. What are the types of joins supported by OPNRYF? 80. What is the function of the POSDBF command? 81. What is the function of CPYFRMQRYF? 82. How can we find the number of records present in a file without using SEU? 83. What is a break point? 84. Change the value of data area MYDAT using a CL program. State whether true or false: 1. Two objects with same name and type cannot exist in different libraries. (F) 2. Not all commands typed on command line are CL commands . (F) 3. A CL command can be an IBM or user defined command. (T) 4. DCLF is used to declare a display or database file in CL. (T) 5. All variables in the file being declared gets implicitly defined in the CL program. (T) 6. CL command is a statement that requests the system to perform a function. (T) 7. The built-in menu called MAJOR organizes all the AS/400 commands. (T) 8. RCVF reads a record from a display or data base file. (T) 9. SNDF writes a record to a display or a data base file. (F) 10. OVRDBF is used to qualify the library where the file is located. (T) 11. The submit job command is used to submit a job to a job queue for interactive processing. (F) 12. A message subfile is a repository of all the predefined messages. (F) 13. A library is an object used to group related objects. (T) 14. The declare commands (DCL & DCLF) must precede all other CL statements. (T) 15. A CL program can contain only CL commands. (T) 16. Program variables are stored in libraries. (F) 17. The value of a CL variable can be changed using CHGVAR. (T) 18. The CHGVAR command can be used to retrieve and to change the LDA. (T) 19. The current library cannot be a duplicate of any library in the library list. (F) 20. We should not create a library with a name that begins with Q. (T) 21. *CHANGE (change authority) allows the user to access the objects in the library. (T) 22. The two types of files that are supported in CL programs are display and data base files. (T) 23. The GOTO command processes a conditional branch. (F) 24. The DO command repeats a group of commands. (F) 25. Embedded IF commands are permitted up to 12 levels, in CL programming. (F) 26. The MONMSG command is used to monitor for escape, notify, or status messages sent to its program queue. (T)
62. 63. 64. 65. 66. 67. 68. 69.

27. CVTDAT command is used to change the format of the date in a CL program. (T) 28. The name of the user who called the program can be retrieved using RTVUSRPRF command.

(T)
29. When the TFRCTL command is used, control returns to the program containing the TFRCTL 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68.

command. (F) The RETURN command in a program removes that program from the program stack. (T) Using CALL command, a maximum of 40 parameters can be passed to the called program. (T) The TFRCTL command cannot be used to pass parameters to the program being called. (F) Data queues are similar to message queues. (T) A data area is an object used to hold data for access by any job running on the system. (T) The Local Data Area cannot be referred to from any other job. (T) The data area cannot be locked for a single user. (F) You can create, delete, or allocate a local data area. (F) Library list is an object. (F) No library is associated with the local data area. (T) LDA can be used to pass information to a subprogram without the use of a parameter list. (T) The system creates a group data area when an interactive job becomes a group job. (T) Only one group data area can exist for a group. (T) A group data area can be referred to by jobs outside the group. (F) The group data area is deleted when the last job in the group is ended. (T) You cannot create, delete, or allocate a group data area. (T) QTEMP is associated with the group data area. (F) A PIP data area is created for each prestart job when the job is started. (T) The CRTDTAARA command uses *SHRUPD (shared for update) lock on the data area during the command processing. (F) The CHGDTAARA does not change the attributes other than its value, for a data area. (T) For a running job, you cannot add entries nor remove entries from the library list. (F) The current library for a job can be changed using CHGCURLIB or CHGLIBL commands. (T) The libraries in a library list may not be existing on the system. (F) If no library is specified while creating an object, it is placed in QGPL. (F) Only display files with a single record format can be used by a CL program. (F) Display files can have a maximum of 99 record formats. (T) Communication on AS/400 system occurs through messages. (T) System messages are stored in the file QCPFMSG in the library QSYS. (T) SNDPGMMSG command allows us to send messages to a workstation user or the system operator. (F) RMVMSGQ command removes a message from a message queue. (F) MONMSG monitors for escape, notify, and status messages that are sent to a programs message queue. (T) The MRGMSGF command can be used to copy message descriptions from one message file to another. (T) User profile message queues are used for communication between users. (T) A break-handling program is called whenever a message of high severity arrives on the message queue. (T) Program message queues are used to send messages between program calls of a job. (T) A program message queue for a program is no longer available for use when the program ends. (T) CHKOBJ checks the object authority. (F) The duplicate object created using CRTDUPOBJ has the same object type as the original object. (T) Any object can be renamed if we have the object management authority for the object and update and read authority for the library containing the object. (T)

69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88.

CHGDTAARA command changes only a part of the value of a specified data area. (F) CPROBJ command compresses selected objects in order to save disk space on the system. (T) Display and print files only can be compressed using CPROBJ. (T) The user part of the library list contains those libraries referred to by the systems users and applications. (T) OPNQRYF acts as a filter between a high-level language program and display files. (F) A high-level language program must share the open data path created by the OPNQRYF. (T) The KEYFLD parameter causes OPNQRYF to create the open data path in an ordered sequence. (T) A maximum of 50 key fields can be specified in KEYFLD parameter of OPNQRYF. (T) The QRYSLT parameter of OPNQRYF is used to restrict the records to which a high-level language program has access. (T) OPNQRYF supports relational, logical, arithmetic and string operators. (T) A FORMAT file is a physical file that contains no data, but exists only for the benefit of OPNQRYF. (T) OVRDBF command can dynamically join files. (F) Random processing is not supported for unique key or group processing using OPNQRYF. (T) The POSDBF command positions the file pointer of an open query file to the beginning or end of a file. (F) The CL command RTVMBRD retrieves the description of a specific object. (F) The DSPPGM command displays the attributes of a program. (T) RTVCLSRC recreates the CL source of a CL program, whose source has been deleted. (T) PARM parameter is used to pass parameters using either CALL or TFRCTL commands. (T) To start debug mode, STRDBG command cannot be used. (F) DSPDBG command is used to display the debugging program. (F) 1. How many Types of jobs there are present on as/400. Ans: - 5 jobs 1. Prestart 2. Interactive 3. Batch 4. Auto start 5. Communication 2. How many sub-files can be declared in an RPG. Ans :- 24 3. How many data-structure can be declared in an RPG. Ans :- 32763 4. At What specs we define the data area, data structures etc in case of RPG. Is it E specs or I specs. Ans:- I 5. What is the function of these keywords in an Sub file Program SFLFOLD & SFLDROP, are they totally opposite. 6. Which OPCODE to use in RPG for showing compilers to go to O specs 7. DOW & DOU (Difference). 8. OVRDBF for what purpose. 9. Return & TFRCTL (main usage). 10. Sub file option for what purpose. 11. How many parameters can be used in a CL program Ans:- 99 parameters in CLP parm command 12. In DCL, Only one DCLF allowed in program DB only for input processing (RCVF for database file) to receive data from a display device 13. By parm only 75 parameters.

14. OPNQRYF 15. ADDPFCST 16. ADDPFTRG 17. SQL if ve will cause an error if + ve > 0 then unsuccessful if 0 then successful,100 no rows found. 18. To get a message 7 char message 132 char 19. SSFLDSPCTL 20. SFLINZ 21. SFLCLR 22. SFCTL 23. SFLSIZ 24. SFLPAG 25. Who can grant authority?
Object Right *OBJOPR *OBJMGT *OBJEXIST *AUTLMGT *OBJALTER *OBJREF Data Right *READ *ADD *UPD *DLT *EXECUT *

26. Can we generate the error message at any other place rather than on 24th line. Ans :- MSGLOC keyword is used to define where we want to show the message line 27. TYPE of Array. Ans: - Three types of Arrays are there
1. 2. 3. Run-time array. Compile time Array. Pre-run time array

28. How to retrieve the user information in case of a RPGLE Program. 29. Which command to be used for backup purpose 30. How to search an element from an array (which OPCODE to use). 31. At which position we should define the indicator In different cases, e.g., what will happen if we define an indicator at LO position in case of a SETLL OPCODE. 32. If we will not use the index with the array variable, what would happen 33. How to define a table in an RPG. 34. How many user classes are there Ans: - There are five user classes *SECOFR *SECADM *PGMR *SYSOPR *USER 35. About group-profile, can we define one group profile in another group profile 36. What would happen if we use two OVRDBF Command in CLP? 37. The usage of indicators with difference OPCODE (VVP). 38. How to declare SQL statement in RPG/400. 39. Where is the statement Used. (PREPARED) I mean to say in which type of Program 40. DYSLT where to used in Logical or in Physical or in Both of these 41. Function of OPNQRY, LF, is they all objects. 42. Are LF and OPNQRY only used for physical files? 43. In how many categories we can break the system securities. Ans:- we can break the system securities in four categories
I) General System Values III) System values that control password II) Others System values related to security. IV) system values that control audit map

44. Difference between DOW & DOU. 45. Difference between Physical file & Source Physical File.

46. I have deleted the source of a CL program. Is it possible for me to retrieve the source of the same. 47. Usage of journal, why is it necessary & incase we dont journal a Phy. File what will happen. 48. How many files could be used in Query 400 at a time. 49. Usage of PGM & ENDPGM. Are they necessary command in CL Program. 50. While compiling a program we get some compilation error and error message, where does their message exits, which message file, is used at the compilation time. 51. Difference between LF & Open Query which one is dynamic & which one static. 52. What do you mean by PEP. 53. Type of Data Structures. 54. Can we retrieve the name of user from RPG 55. How to call a program in batch mode from another program. 56. Multi-member files. 1. How many members can a file have? 2. How to generate a report based on all the member of a file. 3. If we created a logical file how many members can a logical file have? 4. On join operation in logical file (How many files can be joined). Ans:- 1. depending upon the user, if he has mentioned *maxval at the time of compiling then no limit. 57. If we will use two OVRDBF command in CL program what will happen. Ans:- nothing, it will rename the previous file with a new name. 58. Function of MONMSG where we have to use these commands can we use this command anywhere in a program. Ans:- yes. 59. If you change any of your program on my particular date after some date you want to view how many changes & what changes you have made to your source program how can you find it. 60. Different method by which you can pass parameters from a program to another. 61. Question related to sub files & there usages of different key words like SFLDSP, SFLCTL, SFLDLT, SFLCLR SFLENDD SFLNVTCHG 62. At what position on a screen can generate a message line. 63. Type of Message. 64. What do you means by service program. 65. What is the main difference between RPG/400, RPG IV & RPGILE 66. Type of Sub file & define each one of them. Ans:- 3 types of subfiles are there.
In Brief: Single-Page Subfile - Large set of data - Highly random selection - Forward and backward roll - Programmer provides roll logic Multi-Page Subfile, Single-Page Load - Random access to large file - Forward roll from selected point - System-provided roll logic Multi-Page Subfile, Multi-Page Load - Maximum rolling through small file - Complete system-provided roll logic - Performance drag at program initialization Descriptive Multi-Page Subfile with Multi-Page Load

The multi-page subfile with multi-page load method is most suitable to an application that almost never displays a data set greater than five pages. With this method, the user can have all of the data available at one time and will be able to roll forward and backward. This might be appropriate, for example, to review a small transaction file. Multi-Page Subfile with Single-Page Load The multi-page subfile with single-page load method is recommended for inquiry into a larger file, such as a master file. Some type of file positioning will be provided, and the data you are searching for will usually be found within the first five pages displayed. After several pages have been added, it will be possible to roll backward and forward. If, however, the data you need occurred before the first display page, you will have to enter a new search value. Single Page Subfile The single-page subfile method is most suitable for displaying a large set of data where you need both random access and the capacity to roll forward and backward from the selected beginning point. Remember that your program must provide all rolling function. Use single-page subfiles for highly random selection of data or where field-level selection of subfile fields is a requirement.

67. Can we use multi-dimensional array if yes then how. 68. Can we change the sign on screen for any one subsystem, if yes how? 69. What is the usage of QTEMP library can we store any of our Physical file on QTEMP library. 70. Type of System values 71. How many files can be declared in one CL Program. Ans:- 1 file only 72. How Many files can be declared in one RPG/400 program. Ans:- 50 files only, no limit in RPGILE 73. How many libraries can be added in a job? Ans:- In V5R2 it is 251.
74. What RPG operation codes are associated with data areas? 75. What operation code should be used to check for the existence of a specific record in a keyed file? 76. What is a compile-time table? 77. What is a pre-execution table? 78. How is data accessed from a table? 79. How can indenting be utilized to make it easier to read a compiled RPG program? Ans :- By overriding the indent parameter in the CRTRPGPGM command with a character. 80. What is a level checking error? Ans :- When a HLL object isnt linked with the current DDS object. 81. Explain the severity 10, 20 , 30 and 40 errors. 82. Why is %Switch is used in CL 83. What is MONMSG in CL. What is CPF9000 for? 84. DLCOBJ can be used to remove record lock or not? 85. Using UNLOCK opcode, record lock is removed or not? 86. Four ways of defining help on AS/400 87. Benefits of using Externally described files in RPGLE programs 88. Message subfile gets all the records from Message file. True or False? 89. Explain Activation group 90. What is ODP? 91. Explain access paths in database file. 92. What is the difference between Production Library and Test Library 93. How wiil you declare a variable having the same tpye and length of a file field in RPGLE. 94. Explain the difference between packed and zoned data types 95. HOw do you pass variables to a called program and in which way we'll receive them in the program 96. Different types of string manipulation function provided in CL 97. Why is %Switch is used in CL 98. How will you convert a Text in Lower case to upper case 99. How will you find a 'AB' in 'ERWETWETABQEQE' in RPGLE? 100. Describe all data and object authorities

101. 102. 103. 104. 105. 106. 107. 108. 109.

What is the difference between the spool file and physical file?

Difference B/w Chain and Read. Difference B/w Read and Iter. How to sum all the elements of an array? How to find out the number of elements in an array Which command should we use to see the attributes of a Physical file and its fields? Which command to be used to find out how many logical files a physical files have on it? How to Prompt during run time for any command. I have deleted some records from Physical file and now want that the deleted space should be utilized ? which command should we use 110. What would happen to indicator use in HIGH in case of TESTN is successful 111. How to use MONGMSG to Trap all errors. 112. Where to Use the PR and Where to use the PI 113. How to retrieve data from Data Area in an RPGILE program 114. What is the difference b/w STRDBG and STRISDB. 115. Command is used to read a file in CL program. 116. How to call a Procedure? 117. How to call a Module? 118. Which type of file should be used in a Program a simple logical file or a join Logical File? 119. How many times we can Open a file in a Program. 120. About Journal and Commitment Control 121. How to find out the attributes of a job? 122. A file with key A is to be accessed randomly on the basis of a field B. Available options Create a new logical, Opnqry with STRSEQ parameter having B, Sorting the file etc. 123. Where is the *INZSR subroutine coded. 124. When does a indicator defined in 73-74 position seton while chaining a record. 125. Except keyword. A file defined in F spec as O type and a DS defined in D spec. How can the file be updated using the DS. 126. How to include a service program in your program. 127. While creating the program if *OWNER is given to the usrprf parameter what is its significance. 128. Where is a prototype defined. 129. API for ovrdbf. 130. Difference b/w seton LR and Seton RT. 131. What is a Job ? What are the attributes Of a job ? Ans :- A job is the basic unit of work on AS/400 The attributes are : Job Number : Unique system generated sequential number Job Name : Any user defined name (Max. 10 char) User Name : Who initiated the job 132. What is the difference b/w CPF 0000 and CPF9999.
ppp0000:- Monitors for every message with a generic message identifier that begins with a specific licensed program (ppp). For example, CPF0000 indicates that all notify, status, and escape messages beginning with CPF are monitored. Note: Do not use MONMSG CPF0000 when doing system function, such as install or saving or restoring your entire system, since you may lose important information. v CPF9999 Monitors for function check messages for all generic message identifiers. If an error message is not monitored, it becomes a CPF9999 (function check).

1. How will you check whether a command as given error or not? By using the command MONMSG with suitable message identifier. 2. How many ways you can copy records? CPYF
3. CRTDUPOBJ In CL how to read a file?

RCVF 4. In CL which command is equivalent to EXFMT? SNDRCVF 5. Difference between Interactive call and Batch call (SBMJOB). If case of Interactive call it is a sequential execution. Where as in case of SBMJOB if there are three programs called Eg: PGMA, PGMB and PGMC. Whether or not PGMA is ended PGMB and PGMC is called. 6. What is the difference between MOVE and EVAL Using MOVE we can move values from variable of one Data type to another. In case of EVAL both the variable types should be of same type.MOVE just moves value from one variable to another. But EVAL first initializes the variable and then it moves the values. 7 By what all ways we can insert values in a file? CPYF STRDFU In STRSQL by using INSERT statement 8. By what all ways we can view records in a file? STRDFU RUNQRY command DSPPFM DSPF In STRSQL by using SELECT statement 9. How to find fields associated for a particular file? Using DSPFFD (Display File Field Description) 10. What is the CL Command to find all the logical files associated for a particular physical file? DSPDBR 11. What is the use of DSPPGMREF? The Display Program References (DSPPGMREF) command provides a list of the system objects referred to by the specified programs. 12. What is use of SETLL, SETGT, READ, READE, READP, REDPE, CHAIN? SETLL: It will Position the pointer in a file equal to or greater than the value specified in FACTOR1 field. SETGT: It will Position the pointer in a file greater than the value specified in FACTOR1 field. READ: It will read the records sequentially in a file. Mainly used in sequential file. READE: It will read the equal records, based on the value specified in FACTOR1 field. READP: It will read the prior records, sequentially in a file. REDPE: It will read prior equal records, based on the value specified in the FACTOR1 field. CHAIN: It is used in Indexed file. Its Equivalent to STELL & READE. First it will Position the record in the file and then it will read the specific record.

13. What is difference between DOW and DOU? DOU will execute at least one time, control will enter into the loop and only after that it will check for the condition. But in case of DOW it will first check the condition, only when the condition is true it will enter the DO loop. 14. What is the difference between LEAVE and ITER? LEAVE: Quits the loop and the control will be transfered to the statement following the ENDDO statement. ITER: It quits that particular iteration and control goes back to the DO statement 15. How will you eliminate leading and trailing blanks for a string. Using %trim 16. How will you Debug when an application is running in a production environment. a. If the job is already running, using WRKACTJOB first we need to hold the job. (or) If the job is not running then while submitting include this parameter SBMJOB CALL (PGMA) HLD (*YES) b. Note the Job Number, Job Name & User. c. Issue STRSRVJOB with the Job Number, Job Name & User. d. STRDBG e. Release the job. f. Start Debugging. g. ENDDBG h. ENDSRVJOB 17. When will you go for a multiple occurrence data structure If we want multiple Dimensional Array 18. While declaring what is the following meant for S - Standalone field DS - Data Structure PR Prototype PI Procedure interface C Constant Blanks - specification does not define a data structure, a constant, a standalone field, an array, or a table. 19. How to view all the PF in a Library? Using WRKF command. Specify the file attribute as PF and give the required Library. If only PF-DTA Then wrkobjpdm command 20. Why do you use EXCEPT Keyword in RPG? The EXCPT has two major functions v.i.z It allows records to be written during calculations time. It allows a variable number of records to be written in a program i.e at either detail calculation or total calculation time. 21. Usage of DSPOBJD. The Display Object Description (DSPOBJD) command displays the names and attributes of specified objects in the specified library or in the libraries of the job's library list. The command can also display the names and attributes of libraries themselves, if specified. 22. Usage of WRKJOBD The Work with Job Descriptions (WRKJOBD) command shows a list of job descriptions and allows you to change, copy, delete, and display specified job descriptions. 23. How do you create a series of PF say starting with "AB1",AB2,and so on ? 24. Which opcode writes record and reads ? EXFMT. 24. When would you not use *INLR?

When the entire file operations are handled by the RPG CYCLE. 25. Difference between *INLR and RETURN. *INLR closes all files used and removes the call stack entry. RETURN passes control to the called program. Call stack entry is not removed. 26. Steps that has to be followed for writing Sub files. 27. Steps that has to be followed for implementing Commitment control. - See end of docs. Usage of CHGPF. If you have pf which contains data, you want add one more filed that time you can use this command. 28. Select Opcode Syntax : The SELEC operation appears on a line to identify the start of a case construct. The SELEC is followed by one or more WHXX lines, each of which specifies a condition to be tested ; each WHXX is followed by one or more calculations to be performed when that condition is met. ENDSL signaled for end of operation. SELEC - X WHXX 1 Z add X - Y WH yy 2 Z add y ENDSL 30. Usage of *INZSR and *PSSR. It is first executable routine in a RPG Pgm. Essentially all variables & Data structures, Array definitions get initialized in this routine. PSSR is the default Exception/Error handler for RPG Programs. We can also define our own *PSSR routines in the PGM. 29. How do u display records from a particular page in Subfiles? SFLRCDNBR 30. Usage of *LIKE with DEFINE. This coding techniques eliminates the need to constantly change the programming code when database fields are changed .When the program is recompiled, the new field definitions will automatically be applied to the program work fields . C * LIKE DEFN DTAFLD WRKFLD

SYNON 1. Types of File relations? Defined as Owned by Refers to Extended by Includes 2. Types of file to field relation? Known by Qualified by Has 3. How many types of file are available in synon/2e? Reference file (Master file) Capture file (Transaction file) Structure file (Field reference file) 4. Types of Accesspath Physical, Update, Retrieval, Resequence, Query, Span. 5. Built in Functions available in Synon *ADD, *COMMIT, *COMPUTE, *MOVE, *MULT, *QUIT, *DIV, *CONCAT, *SUBSTRING etc.,

5. Types of Objects in Synon CRT, CHG, DLT, SLTRCD, EDTRCD 6. Virtual Field It is logically present in many files but physically present only in one file. 7. If you want to avoid system performance Degradation due to Virutalization. What will you do? Transaction file might contain many Virtual fields. So while opening the transaction file it might take sometime, as all the records in the virtual field as to be dumped into the transaction file. So we need to minimize the use of Virtual field. 8. In Data Modeling what is the effect when we give *None or *All for Sharing. When we give *All for Sharing - If same fields exists in both the files. Declaring the fields and its attributes in one file is enough. When we give *None for Sharing - If same fields exists in both the files. Declaring the fields in one file is enough. But attributes as to be defined separately 9. What will happen when you hide, drop a field? Drop Field is not used. Hide Field is not visible to the user. We can access at any point of time. 10. Type of EDTRCD Edit record (1 screen) Edit record (2 screen) Edit record (3 screen) 11. What is Assimilation? Process of retrieving existing externally described OS/400 file definitions into SYNON/2E design model. The Command is YRTVPFMDL 12. What is differentiation? The process in data-modeling of creating new entities by splitting a current entity into two separate entities. 13. What are the functions created by default for a REF file CHGOBJ, CRTOBJ, DLTOBJ, EDTFIL & SELRCD 14. Difference between EXCEXTFUN and EXCINTFUN Execute external functions allows to specify a high level program using an action diagram. Implemented as separate program and has its own action diagram. Parameter of VRY is allowed. Execute internal functions allows to specify a portion of an action diagram for repeated use in other functions. 15. Does a RTVOBJ have to be coded before a DLTOBJ No 16. Does an EDTFIL automatically read the database file it is built over? Yes 17. Does a PMTRCD automatically read the database file it is built over? No 18. Difference between EDTTRN and EDTFIL EDTTRN Loads an entire subfile. EDTFIL - Only loads one page of a subfile at a time. 19. Name the Access paths which are created automatically for every REF or CPT file Physical Access path Update Access path Retrieval Access path 20. What are two ways to define a Select/Omit access path? Explain. Dynamic Selection is not build into AS/400 path,is applied at run time.Dynamic selection is less ifficient than statis selection .,but may help to reduce the number of OS/400 access path s that are required. Static(S) Selection is build into access path .

21. What does ICF do on an action diagram line? Insert a case statement and prompt. 22. What are the roles a parameter can take RST, POS, MAP, VRY 23. What are different types of context DB Context: DB1 & DB2 Device contexts: CTL, RCD, DTL, 2ND, 3RD, CUR, NXT, KEY System contexts: JOB, PGM Program contexts: PAR, WRK Literal contexts: CON, CND 24. What is RTVMSG? The RTVMSG function returns a message to the calling program. Using the message text we can perform any number of process such as moving a character string from a database file into a field. 25. What is EXCMSG? This function specifies that a request message is to be executed. The request may be any CL, OS/2 or Unix command. 26. Various data types available in Synon/2E CDE, NBR, PCT, REF, STS, TXT, VAL, VNM, DTE, NAR, QTY, TME, IGC, SGT, PRC 27. Object types in Synon File, Relation, Condition, Function & Access path 28. How will you Submit a Batch job in Synon Using EXCMSG 29. Various message functions available EXCMSG, RTVMSG, SNDCMPMSG, SNDERRMSG, SNDINFMSG, SNDSTSMSG 30. 6 Forms of an Output variable. ADD,MULT,DIV,SUB 31. How do u submit batch jobs in Synon apart from EXCMSG? 32. How to display a status field next to a status field?- By using RTVCND Declare function field next to status field / declare out put function field retrive command ot get the description value. 33. How do you delete access path? We can not delete a access path which is referred by some other function/accesspath. If you want to delete, you have to remove the (REF) relations then delete. 38. How do you handle level check error ? - Again compile pf with *level check-No or compile program. 39. Explain use of EXSR ,EXCPT,ROLBK 40. EVAL HNO = % trim(% subst (address :1:4)) 41. List Various access path maintaince Immediate- Update changes immediately Delay- changes are logged and the access path updates when the file is opened .No rebuild is done. Rebuild- Access path is rebuild when the file is opened again. 42.Why would you want to define a parameter as *Neither ? - 1.For use as work variable within function. - 2.In a chgobj, field passed as neither are not updated in the database - 3.In screen functions ,Neither Map parameters can be used to create O/P fields on the device design (Thus avoiding the need to create function fields) 43. How can you pass more than 9 parameter to a function ? - By using Array. 44. what is Diff between a PRTFIL & PRTOGJ ?

-PRTFIL is an external function which specifies a complete report. -PRTOBJ is an internal function type which specifies a segment of report for inclusion within another report function . 45. Which access path needed for PRTFIL and PRTOBJ -QRY access path. 46. What are constructs ? Constructs are the basic building blocks of an action diagram .By combining different types of constructs we define the procedural logic of an action diagram.The combination constructs are : sequence, Conditional and interactive. 47.How is Commitment control implemented in synon? - It can be implemented by specifying one of the following three options in function options. - MASTER : By choosing this option the program will run under commitment control .This program will contain appropriate - commit points,which will be defined in the synon supplied program Y2BGCTL . - SLAVE : The program will run under commitment control .No automatic start or commit points are included.Commit points can be added using commit build in function. - * NONE : The program does not run under commitment control.Hence ther are no commit points .(Physical files running under Commitment control must be journalized) Metamor Global Solutions Academy Hyderabad Test on Introduction to AS/400 concepts Topics : 1. Architecture 2. Source Entry Utility 3. Physical Files 4. Logical Files 5. Display Files Fill in the Blanks : Type of AS/400 Architecture is ____________. (Layered) Any thing which occupies space in the memory is ___________. (Object) Single-level storage means _____________. The Library which contains all libraries is _____________. ____________ library contains OS/400 and all other libraries. The Library which is created for each job is _____________. (QTEMP) _______________ is not one library , but many. (QTEMP) What are system security levels _______________. (10,20,30,40,50) QGPL stands for ______________. (General Purpose library) Product Libraries contains _________. The library list can have a maximum of ___names and is always scanned from ______ to _____ 1.12 The Library list consists of 4 parts: ____ ____ _____ and ____ 2.1 _____________ line command is used to copy a block of records to the targets and retain this command. 2.2 _____________ line command is used to copy a record n times immediately below this record. 2.3 TABS is a ____________command .
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11

Line command to shift the data in a block of records to left by n positions is _____________ 2.5 Line command to shift the data in a block of records to right by n positions is _____________ 2.6 HIDE is a ____________command. 2.7 Command line command to exit the edit session without saving the changes is _____________. 2.8 Command line command to save the changes and exit the edit session is ________________. 2.9 Command line command to save the changes and remain in the edit session is _______________. 2.10 Command line command to shift data over when replacing a string during change operations ___. 2.11 Command line command to tailor the session defaults is ________________. 2.12 Line command to move 5 lines to the left by 10 positions __________________ 3.1 Physical file contain ___________ no. of record formats. 3.2 Field reference file is used for _____________________ 3.3 Keywords used for validity checking are _________________ 3.4 ____________________ keyword is used for mandatory fill of the field. 3.5 ____________ keyword is used to provide a default value for the field. 3.6 _______ is the default usage mode in a Physical File if a blank is specified in usage column. 4.1 Logical file may contain ____________ no. of record formats. 4.2 ____________ key word is mandatory for creation of Logical file. 4.3 Select/Omit key words may be defined in __________________ files. 4.4 ______________ is a record level key word to identify physical files containing the data to be accessed through the join logical file. 4.5 Neither (usage) field can be defined in _________________ files. 5.1 The default usage of fields in display file is ______________ 5.2 __________________ , ________________ are sizes of display screens. 5.3 _________ Function key is used for selecting database fields in SDA. 5.4 _____________,_______________ characters are used for copying a field from one place to another place in SDA. 5.5 A numeric output field of length (5+2) is defined in SDA by specifying ____________ 5.6 In SDA immediately preceding space of the field is called ________________ 5.7 Shifting of fields is done by ____________ or __________________ in SDA. 5.8 To delete a block in SDA ______________ is to be given in attribute position . 5.9 To center a field in SDA _______________ is to be given in attribute position. 5.10 Cursor location can be specified by using the Keyword _____________ 5.11 __________________ Edit code is used to remove the leading zeros. True/False : 1.1 OS/400 has got built-in database. 1.2 A Library cannot contain other Libraries with exception to QSYS. 1.3 All IBM-supplied libraries have names beginning with the letter Q. 1.4 All libraries with names beginning with the letter Q are IBM-supplied libraries. 2.1 SEU can syntax-check HLL and CL source statements 2.2 SEU provides predefined prompts and format lines for HLL and CL. 3.1 A Physical File cannot be deleted if Logical Files are defined on it. 3.2 Data in a Physical File can be updated through a Logical File. 3.3 RANGE (5 10) allows only to have values from 5 to 10 excluding the both. 4.1 Join logical file may contain more than one record format. 4.2 Logical file contains Data. 4.3 CONCAT and SUBST keywords are valid for Logical Files only.
2.4

Key fields are required if UNIQUE key word is specified. Logical file should have all the fields that are there in parent Physical File. Physical Files cannot be updated through Join Logical File defined on them. 4.7 In Multiple Format Logical File separate PFILE keywords are required for each record. 5.1 C is used for Combined use of input and output of field in Display Files. 5.2 ERRMSG keyword in Display Files is used to display the system messages. 5.3 If COLOR keyword is given at record level it applies to the entire record. 5.4 DSPATR(MDT) will become *ON if Data moves from field 5.5 OVERLAY keyword is used to display the record format over the previous display. Multiple-choice : 1.1 No. of layers in AS/400 architecture a. 1 b. 3 c. 5 d. None of the above 2.1 Command Line command to exclude the records in a member a. X b. HIDE c. EXCL d. None of the above 3.1 The keyword used to ignore the sign of the field is a. ALTSEQ b. ABSVAL c. NOSIGN d. None of the above 3.2 REF Keyword is not used with a. Physical File b. Logical File c. Display File d. None of the above 4.1 Mandatory Keyword for creation of Join logical file. a. PFILE b. JFILE c. JLFILE d. None of the above 4.2 RENAME is a ______ level keyword and used with ________ files. a. File , Logical b. Record , Logical c. Field , PF d. Field , LF 5.1 Maximum no. of record formats in a Display File a. 100 b. 2024 c. 1024 d. 1000 5.2 To protect a field from input keying the keyword used is a. DSPATR(PC) b. DSPATR(PR) c. DSPPTR d. None of the above 5.3 The keywords that are used to specify the system name, date, time and user name are a. SYSTEMNAME, DATE, TIME, USERNAME b. SYSTEM, DATE, TIME, USER c. SYSNAME, DATE, TIME, USER d. SYSTEMNAM, DAT, TIME, USER 5.4 To change the attributes of a field ______ must be entered at attribute position. a. * b. ? c. d. None of the above. 5.5 To define a field as a Password field the keyword used is a. DSPATR(PW) b. DSPATR(ND) c. DSPATR(PD) d. None of the above Subjective : 1.1 How many layers are there in AS/400 Architecture. What are they. 3.1 Consider the following PF & LF PF1: A R RMT0 A FLD1 5P 0 A FLD2 5P 0 LF1: A R RMT3 PFILE(PF1) A FLD1 A FLD2 A K *NONE A S FLD1 COMP(EQ 2) A FLD2 COMP(EQ 3) What is the output of the above LF. 3.1.1 Consider PF described in Question 3.1
4.4 4.5 4.6

LF2: A R RMT4 PFILE(PF1) A FLD1 A FLD2 A K *NONE A S FLD1 COMP(EQ 2) A S FLD2 COMP(EQ 3) What is the output of the above LF. 3.1.2 Consider PF in Question 3.1. LF3: A R RMT5 PFILE(PF1) A FLD1 A K *NONE A S FLD1 VALUES(2) A O ALL What is the output of the LF. 3.2. Is the LF given below is correct. If not, What is wrong in it. R REC1 PFILE(PF1) NAME EMPNO DESG SAL S SAL COMP(GT 5000) K EMPNO 3.3 Consider the following PF and LF PF : PFEMP Data in PF R RECPF NAME DESG SAL JAIN SE 12000 RAO SSE 15000 JAIN FACULTY 10000 VIKAS SE 16000 RAMARAO SE 9000 SHARMA OB 5000 Write the output of LF PFILE( PFEMP)

20A 10A 7S 2

LF : LFEMP R RECLF NAME DESG SAL K *NONE S NAME COMP(EQ JAIN) O SAL COMP(LE 12000) S DESG COMP(EQ SE) 3.4 What is the difference between EDTCDE and EDTWRD. 3.5 Write down the various file level access path key words. 3.6 In how many ways a record format in a Physical File can be specified. Explain. 4.1 Write the situations where defining DYNSLT is a must. 4.2 Define the mandatory keywords for a join logical file. 4.3 Explain about different types of Logical Files. 4.4 What are the various Keywords used to define a Join Logical File. Explain. 5.1 What is the difference between CAnn key and CFnn key. Metamor Global Solutions Academy

Hyderabad Test on RPG Topics : 1. RPG Fundamentals 2. RPG Programming 3. Subfiles 4. Printer Files State True or False. Control specification follows File description specification. (F) Calculation specification is written after all specifications. (F) Only one H spec is allowed in a program. (T) Spooling is system function that puts data into a storage area to wait for processing. (T) A maximum of 50 files are allowed per program. (T) Maximum 8 printer files are allowed per program. (T) . File Type (position 15) U is valid for Work station files. (F) *12ABC is a valid symbolic name. (F) Any opcode can be used as symbolic name. (F) SET ON LR is the last statement of any program. (F) 2.2 In Compile time array data must be given after SET ON LR statement. (F) 2.3 Pre-run time array is loaded before compilation. (F) loaded bfore calc op 2.4 AND operation is given higher precedence than the OR operation. (T) 2.5 CABxx opcode compares and branches to a subroutine. (F) branched to a label 2.6 CALL opcode is used to invoke a subroutine. (F) 4 a program 2.7 Parameters must be passed when CALL opcode is used. (F) 2.8 CHAIN opcode retrieves the record randomly and reads it. (T) 2.9 CHAIN opcode is used only with Full procedural files. (T) 2.10 DELET opcode deletes a file. (F) [only record Is deleted.] 2.11 EXFMT operation is a combination of a WRITE followed by READ to the same record. (T) [for display files] 2.12 GOTO and TAG opcodes are associated to each other. (T) 2.13 MOVE opcode copies contents of Fact2 field to Result field. (T) 2.14 PARM opcode can be used only with PLIST opcode. (F) [parm can also be used with call] 2.15 Equal indicator is set on if the READ operation is successful. (F) [for chain u use hi, for read u always go 4 equal] set on is used for not found 2.16 SELEC and WHxx opcodes are related to each other. (T) 2.17 WRITE opcode writes a new record to a file. (T) 3.1 SFLDSP keyword must be activated only if there are records in the subfile. (T) 3.2 SFLRCDNBR is a mandatory keyword for Expand subfiles (T) 3.3 Subfiles are used just for displaying the records. (F) 3.4 Subfiles can also be used to input or update data. (T) 3.5 Subfiles enables the user to display more than one record at a time. (T) 3.6 The function of keywords SFLCLR and SFLINZ is same. (F) Fill-in the blanks. 1.1 There are ________ kinds of specifications in RPG/400. (7) 1.2 Date format for the program is given in _____________ spec. (H) [debug also] 1.3 Array files are described in _____ spec. (E) [tables also] 1.4 __________ spec is used for defining data structures. (I) 1.5 For _________________files record description is given in the program. (Programdescribed) 1.6 To rename a record-format name, use _______ option on ______ spec continuation line. (RENAME,F)
1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.1

1.7 Record description for Program-described files is given in _________ spec. (I) 1.8 __________ file allows a program to communicate interactively with the work-station user. (WORKSTN) [display files] 1.9 The system process arithmetic calculations more efficiently if the data is in ______________ format. (Packed-decimal). 1.10 Various options in File Type (position 15) of F-spec are ___________. (I, O, U, C) 1.11 Various options in File Designation (position 16) of F-spec are ________________. (Blank, P, S, R, T, F)[primary, sec, record add, tables, fully procedural] 1.12 ____ and ____ are options in File Format (position 19). (F, E) [programe described n externally described] 1.13 Input is controlled by calculation operations in _____________ file. (Full procedural) [from where the i/p is to be taken] 1.14 Various options in Device (positions 40-46) of F-spec are ______________________. (Printer, Disk, Workstn, Special, Seq) 1.15 C-specs indicate the ___________ to be done on the data in a program. (Operations) 2.1 ____________ command is used to compile an RPG program. (CRTRPGPGM) [or option 14] 2.2 ____________ is an area in storage which is defined into subfields. (Data structure) 2.3 ____________ subroutine is automatically invoked in the program before 1P output. (*INZSR) 2.4 __________ function provides a way to include source specifications from a source-file member in a program. (/COPY) 2.5 _________ array is loaded before any operations are processed (Pre-run time) 2.6 ________ opcode does Addition operation. (ADD) 2.7 ________ opcode identifies the beginning of a subroutine. (BEGSR) 2.8 ________ opcode conditionally invokes the Subroutine. (CASxx) 2.9 _______ opcode retrieves a record from a full procedural file Based on Key value. (CHAIN) 2.10 The High indicator of CHAIN opcode is set on when the record is found/not found. (Not found) 2.11 The Low indicator of COMP opcode is set on if Fact1 ________than Fact2. (Less than) 2.12 ________ opcode is used to define a field based on the attributes of another field. (DEFN) 2.13 To display the contents of a field ______ opcode is used. (DSPLY) 2.14 _________ opcode defines the end of a subroutine. (ENDSR) 2.15 _________ opcode invokes a subroutine. (EXSR) 2.16 To form a composite key _______ and ________ opcodes are used. (KFLD, KLIST) 2.17 MVR operation must immediately follow the ________ operation. (DIV) 2.18 ________ opcode is used to read the previous record. (READP) 2.19 ________ opcode is used to read the previous equal record. (REDPE) 2.20 To sort an array ________ opcode is used. (SORTA). 2.21 Use of SUBST opcode is _____________. (Return a substring) 2.22 ________ opcode adds the elements of an array. (XFOOT) 2.23 ENTRY is used in ______________(called/calling) program. (Called) [*entry to pass some parameters ] 2.24 What is the maximum length of the op-code. (5) 3.1 Subfiles are essentially a two step process- __________ and ____________. (Load,Display) 3.2 In _________ method of Subfiles roll keys are handled by Subfile itself. (Load-all) 3.3 A Subfile is made up of two formats- ___________ and ____________. (Subfile,Subfile control) 3.4 In _________ method of Subfiles SFLSIZ=SFLPAG. (Single-page) 3.5 Keyword to specify subfile control format _________ (SFLCTL) 4.1 _________ is the file-level keyword to remove option indicators from buffer and to place them in a 99-byte separate indicator area. (INDARA)

4.2 _________ is the field-level keyword to specify the location of an unnamed, 4-digit, zoned decimal field to contain the page number. (PAGNBR) 4.3 _________ is the keyword to specify the printer to skip to a specific line number after it prints one or more lines. (SKIPA) 4.4 _________ is the keyword to specify the printer to space some no of lines after it prints one or more lines. (SPACEA) 4.5 RLU stands for __________________ (Report Layout Utility) 4.6 The significance of Overflow indicator in printer files is ____________ (Page break) Multiple choice questions. 1.1 Information about files is given in which spec. (b) a. H-spec b. F-spec c. C-spec d. E-spec 1.2 Named constants are defined in ____ spec. (c) a. F-spec b. C-spec c. I-spec d. E-spec 1.3 Currency symbol is specified in which spec. (a) a. H-spec b. F-spec c. C-spec d. I-spec 1.4 ________ file is processed by Cycle. (a) a. Primary b. Full procedural c. Array d. Output 1.5 Opcodes are given in which spec. (b) a. F-spec b. C-spec c. I-spec d. Control 2.1 For which array, data is given in the program. (a) a. Compile-time b. Pre-run time c. Run time d. Compile-run 2.2 A maximum of _____ arrays are allowed in a program. (d) a. 100 b. 50 c. 1024 d. 200 2.3 Which Opcode is used to pass control to the specified program. (a) a. CALL b. EXSR c. EXEC d. None 2.4 Which Opcode is used to Concatenate Two Character Strings (a) a. CAT b. CONCAT (in LF) c. CATCON d. None 2.5 _____Opcode verifies that each character in the given string is from the given set of characters. (a) a. CHECK b. VERFY c. CHRCH d. None 2.6 Which opcode is used for division operation. (a) a. DIV b. DIVDE c. DIVD d. None 2.7 Opcode to remove a program from the list of activated programs is (a) a. FREE b. CALL c. FRECAL d. None 2.8 To search for a particular element in an array or table _______ opcode is used (d) a. LOOKP b. LUKUP c. LKUP d. LOKUP 2.9 To find the product of 2 fields _________ opcode is used (c) a. MULTI b. MUPLY c. MULT d. None 2.10 OCUR opcode is associated with (b) a. Arrays b. Data structures c. Tables d. None 2.11 Which of the below mentioned opcodes is associated with Subfiles (c) a. READE b. READP c. READC d. None 2.12 Which opcode is used to find the Square root (a) a. SQRT b. SQR c. SQTR d. None 2.13 To find the difference between the values of two fields ______ opcode is used (b) a. SUBT b. SUB c. SUBTR d. None 2.14 UPDAT opcode can be used only when the file type (position 15 of F-spec) contains (c) a.I b. O c. U d. C 4.1 In which subfiles SFLSIZ = SFLPAG. (d) I. Load-all II. Expand III. Single-page a. I b. II c. III d. I & II 4.2 The maximum number of record formats in a printer file is (a)

a. 1024 b. 1000 c. 2410 d. 2024 _________ is the keyword to specify that the printer device is to skip to a specific line number before it prints one or more lines. (c) a. SKIP b. SPACEB c. SKIPB d. None 4.4 Maximum page with in RLU is (a) a. 378 b. 132 c. 80 d. 738 Subjective questions. 1.1 How many kinds of specifications are there in RPG/400. What are they. 1.2 What is the purpose of various specifications of RPG/400. 1.3 Differentiate between Externally described files and Program-described files. 2.1 What are special data structures. 2.2 How many types of arrays are there. What are they. Differentiate. 2.3 What is the difference between the CLEAR and RESET opcodes. 2.4 What is the difference between the DO, DOUxx and DOWxx opcodes 2.5 What is the difference between ITER and LEAVE opcodes 2.6 What is the difference between MOVE, MOVEL and MOVEA. Explain with examples. 2.7 How many types of READ operations are there. Explain about READ, READP, READE. 2.8 Explain about READC, READP, REDPE 2.9 What is the difference between CHECK and SCAN opcodes 2.10 Differentiate SETGT and SETLL opcodes. 2.11 What is the difference between Z-ADD and Z-SUB. Expain with examples. 2.12 Which reserved words allow us to access the System date and portions of it, in the program. 2.13 List 6 figurative constants. Explain the purpose of these. 2.14 What is the difference between CLOSE & FEOD opcode. 2.15 What is the use of exception records in O spec. 2.16 How can we open a program without using User Control. 2.17 How will you read the last record in a PF. 2.18 a. A |A| B |C | B |P |Q |R |S | op-code fact2 result After executing MOVE A B B contains | p | a | b | c | b. A |1 |2 |3 | B |1 |0| op-code fact2 result After executing DIV A B B contains | ` | | 2.19 If an indicator, say 99 is to be set on, in how many ways you can do it. (write C-specs) 2.20 What is the out put of KEY1, KEY2 and KEY3 in the following program ? 0000.01 C MOVE 'CBMEDCLT KEY1 7 0000.02 C KEY1 DSPLY 0000.03 C MOVEL'CBMEDCL' KEY2 8 0000.04 C KEY2 DSPLY 0001.00 C MOVEL'CBMEDC' KEY3 8 P 0002.00 C KEY3 DSPLY 0003.0 0 C SETON LR 2.21 What is the output of A,B, C and D in the following program? 0001.00 C Z-ADD1000 A 40 0002.00 C Z-ADD2000 B 40 0003.00 C MOVE '3000' C 4 0004.00 C MOVE '4000' D 4 0006.00 C MOVE A C 0008.00 C MOVE D B 0009.00 C A DSPLY 0010.00 C B DSPLY 0011.00 C C DSPLY
4.3

0013.0 C SETON LR 2.22 What is the output of $TMP1 and $TMP2 in the following program? 0002.00 C MOVEL*BLANKS $TMP1 8 0003.00 C $TMP1 DSPLY 0004.00 C MOVEL*BLANKS $TMP2 5 0005.00 C MOVEL'I' $TMP2 0007.00 C 'RMTP' CAT $TMP2 $TMP2 0008.00 C $TMP2 DSPLY 0009.00 C SETON LR 2.23 What is the output of $PAY, $PAYC, $PAYD and $ARR,I in the following program? 0001.01 E $ARR 3 8 0003.00 I DS 0004.00 I 1 10 $PAY 0005.00 I 1 8 $PAYD 0006.00 I 9 10 $PAYC 0006.01 C Z-ADD*ZEROS $VAL 80 0006.02 C MOVE 'ARRAY' $RSN 5 0007.00 C Z-ADD 0217199 $TEMP 82 0009.00 C MOVE $TEMP $PAY 0010.00 C $PAY DSPLY 0010.01 C $PAYD DSPLY 0010.02 C $PAYC DSPLY 0011.00 C MOVE *BLANKS $ARR 0012.01 C Z-ADD1 I 20 0012.02 C MOVE $RSN $ARR,I 0012.03 C $ARR,I DSPLY 0013.0 3 C SETON LR 2.24 What is the output of SUM in the following program? 0001.0 C Z-ADD5 A 30 0001.1 C Z-ADD0 SUM 50 0001.2 C I DOWLE 100 0001.3 C ADD I SUM 0001.4 C ADD 15 I 0001.5 C ENDDO 0001.6 C SUM DSPLY 3.1 How many types of Subfiles are there. What are they. Differentiate. 3.2 Explain about the keywords SFLCTL, SFLDSPCTL, SFLDSP. 3.3 What is the difference between the keywords SFLPAG and SFLSIZ. 3.4 What is the difference between the keywords SFLCLR and SFLINZ. 3.5 What is the advantage of SFLRCDNBR and SFLNXTCHG keywords.

AS/400 SYSTEM
QS30001 What is the Configuration of the AS/400 system on which you have worked? AS30001 System E35(Model 9406), 24MB main memory, 3.2GB of HD and supports 49 terminals(7 Port). QO20002 How many terminals can be connected to a port ? AO20002 7 terminals QS20003 What do the terms CUA and SAA stand for? AS20003 Common User Access Systems Application Architecture QL40004 What are the communication protocols supported by AS/400 ?

AL40004

APPC (Advanced Program to Program Communication) BSCEL(Binary Synchronous Link) ASYNCH(Asynchronous Communication) RETAIL TCP IP FINANCE SNUF SNA Upline facility INTRA Intrasystem communication. QS30005 What are the different ways of connecting a terminal to a system ? AS30005 Twinnax, Workstation, ASCII and OS/2 Workstation. QL30006 Why is AS/400 called an Object Oriented Machine ? AL30006 Everything on the AS/400 system that can be stored or retrieved is contained in an Object. Object exist to make users independent of the implementation techniques used in the machine. QS30007 What is SAA ? AS30007 Systems Application Architecture (SAA) is a collection of selected software Interfaces, Conventions and Protocols that will provide a consistent framework across the System/370, AS/400 and PS/2. QS30008 What are the different AS/400 rack models supplied by IBM ? AS30008 9402, 9404 and 9406. QL10009 What are the different high-level languages available on AS/400 ? AL10009 RPG/400, CL/400, BASIC, PL/1, C/400, PASCAL, FORTRAN/400 and RM/COBOL-85, COBOL/400 etc.. Q1S2001 What are all the IBM Mid range machines prior to AS/400? A1S2001 S/38, S/36, S/34, S/32 &S/3. Q1O2002 What is the Operating System on AS/400? A1O2002 OS/400. Q1S2003 What are office tasks available on AS/400? A1S2003 Office Vision/400 & PC Support/400. Q1S2004 What are the graphic utilities available on AS/400? A1S2004 BGU & GDDM.

OS/400
QO20010 What is the version of OS/400 that you have used? AO20010 Ver 2.2 QS40011 What is DDM ? AS40011 Distributed Data Management is a function of the OS/400 that allows an application program or user on one system to use database files stored on remote system. QS30012 What are the facilities available on AS/400 for self-learning ? AS30012 on-line education, Q&A Database and Help. QS20013 What is an Object ? AS20013 An object is any thing that exist in and occupies space in storage and on which operation can be performed. QS20014 What are the different types of Objects available in the AS/400 ? AS20014 Libraries, Folders, Files, Programs, Combined definitions, Queues, User Profiles. QL50015 How are the objects stored in AS/400 ? AL50015 All objects are stored on AS/400 in a single level storage. In this method all objects are referenced by one virtual address which is translated into a physical address whether it is a auxiliary storage or main memory. QS30016 What is a library in AS/400 ?

AS30016 A library in AS/400 is an object that serves as a repository for other objects. QS20017 Name few IBM supplied libraries ? AS20017 QGPL, QTEMP, QUSRTOOL, QSYS, QRPG & QCBL. QS10018 What is a library list ? AS10018 A list that indicates libraries used for the process and the order in which it has to be searched. System identifies it in *LIBL. QO30019 How many libraries can be there in a library list ? AO30019 Total 40 (15 system and 25 application). QO30020 Where is the system part of the library list stored ? AO30020 In SYSVAL QS40021 What is a Folder ? AS40021 A Folder is a named object that is used as a directory for documents and other folders. Folders can be filed with in another folder. QS20022 What are the different Application Development Tools available on AS/400 ? AS20022 SEU, RLU, PDM, SDA, QUERY QO30023 What are the levels of security on AS/400 ? AO30023 10,20,30,40,50 QS30024 What is error severity ? AS30024 Error severity determines the level of severity that is required to terminate the job. QL50025 What is a User Profile ? What are the various classes ? AL50025 User profile is an object which identifies a user to the system. It contains user name, Password, Owned objects, Authorized objects, Scheduling priority, Special authority, Initial program, Job description. Security officer, Programmer, Workstation, System operator, Programmer services Rep & Customer engineer. QS40026 What is Group Profile ? AS40026 It is similar to User Profile, but the attributes specified is applicable to entire group. QS20027 What are the different types of queues in AS/400 ? AS20027 Job queue, Message queue, Output queue, Data queue. QL20028 What are JobQ and PrintQ ? AL20028 JobQ : An object that contains a list of batch jobs waiting to be processed by the system. PrintQ : An object that contains a list of spool files to be written to a printer device. QL20029 What is a Spool file ? Why is it required ? AL20029 A file that holds output data to be processed, such as information waiting to be printed. QL30030 What is a Job ? What are the attributes Of a job ? AL30030 A job is the basic unit of work on AS/400 The attributes are : Job Number : Unique system generated sequential number Job Name : Any user defined name (Max. 10 char) User Name : Who initiated the job QS20031 What is job description ? AS20031 A job description defines the environment in which a batch/interactive job is to be executed. QL20032 What is the difference between Interactive & Batch job ? AL20032 Interactive Job : Job started for a person who signon to a workstation.

an

Batch Job : A predefined group of processing actions submitted to the system to be performed. QL30033 What is a Group Job ? AL30033 A Group Job is attached to one workstation and a user. There should be an initial group job and it can be branched to many other group jobs. The group jobs can have different library lists and different output, message queues. Group Job is useful in enhancing the programmers productivity. It is as though logging into the same userid many times. QO20034 What are the two main attributes which govern the execution of a job ? AO20034 Run time priority and Time slice. QL20035 What is a sub-system ? AL20035 Sub-Systems are specific user defined partitions of the CPU where various jobs may be executed. One subsystem can have more than one active job at a time. QL20036 What is a device file ? AL20036 A device file contains the description of how data is to be presented to a program from a device or Vice versa. Device file can be Printer, Disk, Tape or Remote system. QS30037 What is an ICF file ? AS30037 A device file that allows a program on the system to communicate with program in other system. QS30038 What is a message file ? AS30038 It is a file which contains the messages of an application. For example all RPG/400 messages are stored in a file, all COBOL/400 messages are stored in a file. QL30039 What is a job log ? AL30039 A record of request submitted to system be a job. The message related to the requests, and the action performed by the system on the log. It is maintained by the system program QL20040 What is the purpose of OPNQRYF (Open Query File) ? AL20040 OPNQRYF is used to select certain records of the database file based on the QRYSLT (Query select) condition. QS10041 How do you create files dynamically without DDS ? AS10041 Through OPNQRY. QO10042 What command must be executed before executing OPNQRYF command ? AO10042 OVRDBF. QL30043 What is a data area ? AL30043 A data area is an object used to hold data for access by any job running on the system. A data area can be locked to a single user, thus preventing other users from processing at the same time. QS20044 What are the types of data areas ? AS20044 User defined Data Area, Local Data Area (LDA), Group Data Area (GDA), Program Initialization Parameter (PIP) Data Area. QS20045 What is LDA ? AS20045 An LDA is created by the system for each job in the system, including autostart jobs, jobs started on the system by a reader, and subsystem monitor jobs. QS10046 What is the type and length of an LDA ? AS10046 *CHAR, 1024 bytes. QS20047 What is GDA ? AS20047 The system creates a GDA when an interactive job becomes group

jobs. Only one GDA can exists for a group. How can you create a user defined data area ? Using CRTDTAARA command. What are the different ways to input data into a data area ? CHGDTAARA (using CL) Using OUT opcode in RPG QS10050 How do you retrieve data from data area ? AS10050 Using RTVDTAARA command in CL Using IN opcode in RPG. QS10051 What are the valid user defined data area types ? AS10051 CHAR, NUMARIC and LOGICAL. QS20052 How can a data area be locked after being updated ? AS20052 Using OUT *LOCK. QS20053 What is the use of data queues ? AS20053 Data queue is a type of system object that you can create. Data queues are used in program to program communication. QO10054 How do you create data queues ? AO10054 Using CRTDTAQ command. QS10055 What are the valid data types for a data queue ? AS10055 Char, Numeric, and Logical. QS20056 What are the two types of read performed on data queues ? AS20056 Read with lock, and read without lock. QS20057 How do you use DEBUG utility ? AS20057 STRDBG program-name UPDPROD(*YES) QS30058 What is an authorization list ? AS30058 A list of two or more user Ids & their authorities for system resources. The system identifies it as an object type *AUTL. QO10059 How do you grant authority for an object? AO10059 Using GRTOBJAUT command. QL30060 What are the types of object authorities ? AL30060 *USE, *CHANGE, *ALL, *EXCLUDE, *AUTL, *OBJEXIST, *OBJMGT, *OBJOPR, *ADD, *DLT, *READ, *UPD. QO20061 How do you execute jobs in batch mode ? AO20061 SBMJOB QL40062 What is the use of OVRDBF ? AL40062 You can use the Override with Database file (OVRDBF) command to replace the database file named in a CL program or to change certain parameters of the existing database file. QL30063 What is the use of OVRPRTF ? AL30063 Override with Printer file (OVRPRTF) command is used to override certain parameters of the printer files used in the program or to replace printer file. QO30064 How do you change file attributes such as size, file wait time, record wait time etc., permanently ? AO30064 Using CHGPF command. QO10065 What is the purpose of CRTCMD ? AO10065 To create user defined command. QS30066 What is class of service ? AS30066 A set of link and node characteristics associated with a session. QO10067 How to see active jobs of the system ? AO10067 Using WRKACTJOB command. QS30068 How do you detect unused spool storage ? QS10048 AS10048 QS10049 AS10049

the

AS30068 Using Reclaim Spool Storage. QS50069 What are the functions of Remote Job Entry (RJE) ? AS50069 Allows user of AS/400 system to submit jobs and receive jobs from a host system. QL50070 What is the function of RJE Conversion Utility ? AL50070 It converts compressed data written to an AS/400 database file to decompressed data written to another AS/400 database, diskette, or device file. QS40071 What is the function of the SBMRJEJOB command ? AS40071 Sends RJE input stream to host system. QL40072 What is journalling and commitment control ? AL40072 Journalling is a function which records the changes in a file in a journal.These record images are used to recover the changes in the file should the system ends abnormally. Commitment control is a function that allows you to define and process a no. of changes to database files as a single unit(transaction). QS30073 What is the purpose of STRCMTCTL command ? AS30073 Starts commitment control for files that are being journalled. QS40074 What are the system objects required for journalling ? AS40074 Journal receiver, journal and PFs to be journalled. Q2S4001 What is CPF ? A2S4001 Control Program Facility (CPF) is an operating system on S/38. Q2S4002 What is invocation stack ? A2S4002 List of programs maintained by the system as one program calls another in a series of calls within a single task or job. Q2S3003 What is time slice ? A2S3003 A finite amount of time in which a job is granted system resources while other jobs are queued. Q2S4004 What is IPL ? A2S4004 Initial Program Loading (IPL) is run by OS/400 when the system is started. Q2S3005 What does V2R2M0 mean ? A2S3005 Ver. 2, Release 2 & Modification level 0. This refers to the version of OS/400. Q2S3006 Name the commands used to duplicate a file ? A2S3006 CPYF - Copy File & CRTDUPOBJ - Create Duplicate Object. Q2AS3007 Name the command for changing the attributes of a spool file ? A2S3007 CHGSPLFA - Change Spool file Attributes. Q2S3008 Name the command which gives the attributes of a job ? A2S3008 RTVJOBA - Retrieve Job Attributes. Q2S2009 What is the function of PDM ? A2S2009 Productivity tool for copying, deleting, scanning, changing & creating source files. Q2S2010 What is the function of SEU ? A2S2010 A utility for editing programming language source code.

DATABASE FILES
QL30075 What are the different definition levels in Data Description specifications ? AL30075 File level, Record level, Field level, Join level, Keyfield level, Select/Omit level. QL30076 What is difference between Source Physical File and Physical File ? AL30076 A Source Physical File contains the source for the various objects created. This file has a specific structure. A Physical File contains data, and the record format can be different for different physical files. QS20077 What is the difference between Physical and Logical files ?

AS20077

Physical file contains data, where as Logical file serves as a access Path to database. QS20078 What is an access path ? AS20078 The order in which the database fields are organized for processing in the program. QS30079 What are all the different types of access paths ? AS30079 Arrival sequence access path, Keyed sequence access path. QS30080 How many record formats can you have in a Physical file and in a Logical file ? AS30080 Physical file can contain only one record format, Logical file can contain more than one record format. QS20081 What is a field reference file ? AS20081 A field reference file is a physical file which contains no data, contains field description. this is used as a reference file by other physical files. QO20082 What is the default value for the number of increments for the physical file ? AO20082 Three. QS10083 When is the DFT keyword in PF used for? AS10083 To specify the default value it a field. QS20084 What is Multi-format logical file ? AS20084 Logical which uses fields from two or more physical files. QL30085 What is dynamic select ? AL30085 Selection and omission of LF records performed during processing, instead of access path is maintained. This can be used when key access path does not exist. QL20086 What is the Select and Omit criteria in logical file ? AL20086 This is used to specify rules for the Selection/Omission of records from a Physical File. QS20087 Can fields be concatenated at the logical file level ? AS20087 Yes, by using CONCAT keyword. QS30088 When would the ALL keyword be used ? AS30088 Use with Select or Omit, to select/omit records. QS30089 What is a Join Logical File, Can it be used for Update ? AS30089 Logical file that combines more than one physical file. Update is not possible through JLF. QL30090 How many files can be joined at a time, What is the max. no. of files ? AL30090 At a time you can join two files. The max. no. of files is 32. Only one primary file and the remaining are secondary files, The primary file and atleast one secondary file must be physical files. QO20091 Is it possible to join the same file to itself ? AO20091 Yes. QS10092 What is FCFO, FIFO, LIFO in Database environment ? AS10092 These are file level keywords which are used to access the records in the order FCFO: First Changed First Out FIFO: First In First Out LIFO: Last In Fist Out QL40093 If a file layout is changed, how do you generate new PF and retain data? AL40093 Copy the file and change the structure of Physical file, later copy old file with drop option. QS50094 What is the overhead on logical file ? How can it be improved ?

AS50094 Maintaining access path and storage space. We can improve the performance by using *DELAYED, *REBUILD keywords to enhance QS40095 How can the sign of a numeric be ignored when sequencing a logical file ? AS40095 By specifying the record level keyword UNSIGNED. QS40096 If a field references a field that has an EDTCDE or an EDTWRD keyword specified, can the EDTCDE or EDTWRD from the Referenced field ignored ? AS40096 Yes, by using DLTEDT keyword. Q3S2001 What does the keyword UNIQUE mean ? A3S2001 Records with duplicate key values are not allowed. Q3S4002 State three different methods of maintaining access paths ? A3S4002 Immediate, Rebuild & Delay.

the speed.

DISPLAY FILES
QS20097 What are the different types of keywords in display files ? AS20097 File level, Record format level, Field level. QO30098 What is the maximum number of records you can specify in a display file ? AO30098 1024. QS40099 How can a screen field that has changed since the last output operation be detected ? AS40099 Attach the MDT attribute to the field, to detect whether field has been changed as a result of user input. QS50100 What would be the effect on the field where reverse image, underline and highlight display attributes are active ? AS50100 The result is same as if you had specified ND. QL40101 What is the use of DSPATR(MDT) keyword ? AL40101 Sets on the modified Data Tag of the field. This Data Tag detects whether the field has been changed as a result of user input. QO30102 If DSPATR(PC) and CSRLOC were specified for a format, which keyword would have priority ? A030102 CSRLOC gains priority. QS40103 Can error messages as a result of a COMP, RANGE or VALUES keyword be overridden ? AS40103 Yes, through CHKMSGID keyword. QL40104 What is the purpose of OVRDTA and OVRATA keywords ? AL40104 OVRDTA keyword (field or record level) can be used to override the existing data contents of a field or record already on the display. OVRATA keyword (field or record level) can be used to override the existing display attributes of a field or record already on the display. QS30105 How can a message from a message file appear as a constant on the screen ? AS30105 By using MSGCON (message constant) keyword. QS30106 In conjunction with what other keyword must OVRDTA and OVRATA be used ? AS30106 PUTOVR keyword must be used. QS50107 How can a field that is larger than what could fit onto one line be truncated from the last blank rather than from the last character position? AS50107 Using BLKFOLD keyword. QS40108 What is the purpose of the INDARA keyword ? AS40108 This File-level keyword is used to remove option and response indicators from the buffer and places them in 99-byte separate indicator area. QL40109 Explain the purpose of KEEP and ASSUME keywords ?

AL40109 KEEP : Keep the display from being deleted when the display file is closed. ASSUME : It is used to specify that the OS/400 program is to assume that this record is already shown on the display when this file is opened. QS30110 Explain the use of DFRWRT display keyword ? AS30110 No records will be displayed until there is an I/O operation. QS30111 What is the purpose of FRCDTA keyword ? AS30111 Immediately display a record format without waiting for the next I/O operation. QS10112 What keyword must be used with PROTECT keyword ? AS10112 OVERLAY QS30113 Where is the variable for the SLNO(*VAR) keyword be defined ? AS30113 At run time before displaying the record format. QS50114 Under what conditions would a field where the ERRMSG keyword was active would not be displayed in reverse image ? AS50114 If it is an output-only field or input capable field with display attributes UL, HI are active. QS50115 When will the message for field that has the ERRMSG keyword active not be displayed ? AS50115 If more than one ERRMSG keywords are active then the first will be active, because only one error message will be displayed at a time. QL50116 What is CHGINPDFT keyword, and what will be the effect if you define this keyword at file with out any parameter values ? AL50116 This file, record or field level keyword is used to change one or more input defaults for input capable fields. If you define this keyword at file level without any parameter then the underline will be suppressed. QS30117 In what case control will be passed back to the program when the last character of the field is keyed ? AS30117 CHECK(ER) ER - End of Record.

SUBFILES :
QL10118 What is a subfile ? AL10118 Subfile is a group of records of same record format and can be read from or write to the display in a single operation. QL30119 What are the contents of subfile ? AL30119 Subfile Record Format, Subfile Control Record Format, Relative Record Number, Subfile Record Number, Associated Subfile Keywords. QS20120 What are the two record formats that a subfile contains ? AS20120 Subfile record format(SFL), and subfile control record format(SFLCTL). QL30121 What is SFLPAG and SFLSIZ ? AL30121 SFLPAG : it is an attribute which specifies the number of records that can be displayed in a screen. SFLSIZ : it is an attribute which specifies the number of records can be stored in the subfile. QO30122 What is the maximum number of subfiles that can specified in a display file ? AO30122 512 QO30123 The maximum number of subfiles that can defined in a RPG program for one display file is ___ . AO30123 24 QO30124 The maximum number of subfiles that can be active for a single file is ____ .

AO30124 12 QL20125 What are the different opcodes used for file operation on a subfile in a RPG Program ? AL20125 READ, READC, CHAIN, UPDAT and WRITE QS30126 Can more than one subfile record be displayed on one line ? AS30126 Yes, by using SFLLIN keyword. QS30127 How do you specify the number of records to roll in a subfile ? AS30127 Use SFLROLVAL keyword in DDS along with the number, which specifies the number of records to scroll at a time. QL30128 How will you display a particular page in subfile ? AL30128 Move a valid relative record number(RRN) in the field specified using SFLRCDNBR keyword in DDS. QS30129 How to pick up the changed records every time in a subfile after the first change made ? AS30129 Seton SFLNXTCHG keyword indicator and update the subfile record. QS30130 What is the use of the SFLEND keyword ? AS30130 By specifying this keyword, the Bottom/More message could be displayed at end of screen. QS30131 How do you toggle between single line and multi-line display of a particular record in a subfile ? AS30131 Using SFLDROP keyword. QL40132 Explain the difference between defining Subfile and Message-subfile ? AL40132 A subfile record is defined by SFL keyword, whereas a message Subfile is defined by SFLMSG keyword. QO30133 Can a single screen format occupy a screen area above and below a subfile format ? AO30133 Not possible. QS50134 How can a program be prevented from failing over when READC is performed on an empty subfile ? AS50134 Check indicator placed in position LO, which will be seton if EOF reached.

CONTROL LANGUAGE (CL/400)


QO10135 AO10135 QO20136 AO20136 QO30137 AO30137 QS10138 AS10138 QO10139 AO10139 QO10140 AO10140 QO20141 AO20141 QL50142 AL50142 How to start a CL program ? PGM. How many files can be declared in CL ? One. Which precedes, the file declaration or variable declaration ? Variable declaration and then File declaration. What are the different types of variables available in CL ? DEC, CHAR, LGL In CL Program '&' precedes ____ . Variables. How do you pass parameters in CL ? Using PARM keyword. Can libraries be added to the library list through CL ? Yes, using ADDLIBL. What is the difference between CAT, TCAT and BCAT ? CAT : Concatenate two variables or constants into one continuous BCAT : Truncates all trailing blanks in the first character string ; one blank is inserted , then the two character strings are concatenated. TCAT : Truncates all trailing blanks in the first character string, the two character strings are concatenated.

string.

QO10143 AO10143 QS30144 AS30144 QS30145 AS30145 QO30146 AO30146 QL50147 AL50147

How do you end a CL program ? ENDPGM What are the different types of messages in CL ? Immediate message, Break message, Program message, User message. How can errors be trapped in a CL program? By using Monitor Message Command ( MONMSG ) What is the maximum length of a variable name in CL ? Maximum 11 characters (including '&') What are the limitations of CL (compare to RPG) ? You cannot use CL program to : ADD or UPDATE records in database files Use Printer or ICF files Use Program described files Use the concept of subfile (to display more than one record), but a single output message subfile is a special type of subfile that is supported well in CL Use subroutines. You cannot declare more than one object (file) in a CL programme.

RPG/400
QS10148 AS10148 QL30149 AL30149 QL50150 AL50150 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 ?
START

Perform detail calculation

Perform header, detail output Read a record Set ON LR if EOF If change in control field, set ON control level indicators.

Move data from selected record into processing area

Perform total calculations Perform total output If LR is ON then END program

QS30151 When is it efficient to make use of RPG Cycle ? AS30151 When the file is arranged in sequence and output is based on control break. QS20152 Can you call a program in your RPG program, which is coded in some other language ? AS20152 Yes, Any program object available on AS/400. QL20153 What are the different types of specification available in RPG/400 ? AL20153 Control Spec.( H ) File Spec.( F ) Extension Spec.( E )

Line counter Spec.( L ) Input Spec.( I ) Calculation Spec.( C ) Output Spec.( O ) QO40154 Is it necessary to define all formats ? Which are mandatory and which are Optional ? AO40154 No, all are Optional. QS20155 What is the use of H spec. in RPG ? AS20155 It identifies by H in column 6, Provides information about generating and running programs. QS50156 When will DUMP and DEBUG opcodes be ignored ? AS50156 If blank is specified in position 15 of H specs. QS20157 What are the valid file types ( position 15 ) in F specification ? AS20157 I (Input file). O (Output file). U (Update file). C (Combined (I/O) file). QL40158 Specify different indicators used in RPG ? AL40158 Overflow indicators. Record Identifying Indicators. Field Indicators. Resulting Indicators. Control Level Indicators. QL40159 What are Control level indicators ? AL40159 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. QS20160 What is the use of E specification in RPG ? AS20160 Extension Specs describes all record address files, arrays and tables. QS30161 What is the use of L specs in RPG ? AS30161 Line counter specification can be used to describe printer file to indicate the length of the form and number of lines per page. QS10162 In which specification can a report layout be defined ? AS10162 O Specification. QO30163 How many files can be defined in F specs ? AO30163 A maximum of 50 files. QO30164 How many printer files can be defined in F specs ? AO30164 A maximum of 8 files. QS20165 Give three main purposes of File specification ? AS20165 To define files, to describe the files, to assign the files to specified devices. QS20166 How do you specify page overflow indicator for printer files in RPG ? AS20166 Specify an indicator in positions 33-34 of F specification. QS20167 What is a Primary File ? AS20167 It is used in RPG Program Cycle to automatically read records in a cycle. QO30168 Can an indexed file be accessed in arrival sequence in RPG program ? AO30168 Yes. QS20169 What is a program described file in RPG ? AS20169 The field name and length of the fields are defined with in the RPG program. QS20170 What is an externally described file ?

AS20170 All information about the fields is specified in DDS and the RPG program can use them with in the program. QO30171 Can you specify a display file to be used in the following modes: Input, Output or Combined modes? AO30171 Yes. QL40172 What are match fields indicators? AL40172 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. QO20173 What is the length of a variable in RPG ? AO20173 6 Characters. QS10174 What are the different arithmetic Opcodes ? AS10174 ADD, SUB, MULT, DIV, MVR, SQRT, XFOOT, Z-ADD, Z-SUB. QS10175 When is a TAG statement used in RPG ? AS10175 It is used as a Label. QL30176 What are the different Opcodes available in RPG for Database access ? AL30176 READ, CHAIN, WRITE, UPDAT, DELET, SETLL, SETGT, READE, READP, REDPE, OPEN, CLOSE, FORCE, NEXT, UNLCK. QS10177 What is READP opcode ? AS10177 Read previous record. QS10178 What is REDPE opcode ? AS10178 Read Prior equal record. QO30179 How do you check if a division was whole division ? AO30179 Check the EQ indicator be set to '1' QO30180 What opcode could be used to test an alphanumeric field for all numeric values? AO30180 TESTN. QO30181 What opcode will be used to test the zone of a character field ? AO30181 TESTZ. QS40182 How do you specify Half Adjust ? AS40182 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. QL30183 Explain the difference between READ, CHAIN and SETLL ? AL30183 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. QL30184 What does LO and EQ indicators signify in READ, WRITE and CHAIN operations ? AL30184 LO indicator specifies the error status on the above operations. EQ indicator specifies the EOF, Record not found. QS30185 How can database records be read without lock ? AS30185 Put 'N' in position 53 of C specs. QL20186 What is the difference between MOVE and MOVEL ? AL20186 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). QS10191 In conjunction with which statements can ORxx and ANDxx conditions be used ? AS10191 DOUxx, DOWxx, IFxx, and WHxx. QS10192 What is the difference between DOU and DOW ? AS10192 DOU checks after entering into the loop, it is performed atleast once. DOW check before entering into the loop. QL20193 What is ITER and LEAVE opcodes do ? AL20193 ITER transfers control from within a DO group to the ENDDO statement 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 the statement following the ENDDO operation. QL20194 Which instructions support structured programming in RPG ? AL20194 ANDxx, CASxx, DO group, ELSE, ENDyy, IFxx, ITER, LEAVE, ORxx, OTHER, SELEC, WHxx. QS10195 What does 'SR' in columns 7-8 of C specs mean ? AS10195 Calculation operation is a part of RPG subroutine. QL20196 Explain CASxx, and CABxx statements ? AL20196 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. QL30197 What is CLEAR and RESET ? AL30197 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. QL40198 What is SCAN and XLATE ? AL40198 SCAN operation scans a character string (base string) contained in factor 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. QL40199 How do you use commitment control in RPG program ? AL40199 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). QS30200 How do you use exceptional write in C specs ? AS30200 Using EXCPT opcode. QL30201 What does the opcode FREE do ?

QS20187 AS20187 QL30188 AL30188 QS10189 AS10189 QS20190 AS20190

AL30201 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. QS30202 What does opcode POST do? AS30202 Puts information in INFDS. QS20203 What is the difference between WRITE and EXFMT of a display file ? AS20203 WRITE displays a record format on workstation, EXFMT displays and accepts from the workstation. QS20204 What is the difference between PLIST and KLIST ? AS20204 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. QO30205 Can you have multiple key lists for a single file ? AO30205 Yes. QS40206 What are the different types of arrays available in RPG ? AS40206 Pre-run time array. Compile time array. Run time array. QL40207 How do you specify data for a compile time array ? AL40207 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 **. QO30208 What is the maximum number of elements in an array ? AO30208 9999. QO30209 Can we define Multi-dimensional arrays in RPG ? AO30209 No. QS20210 What is XFOOT opcode ? AS20210 Adds all the elements in a numeric array, and places the sum in the result field. QS20211 How can we sort an array ? AS20211 By using SORTA opcode. QS20212 What is MOVEA opcode do ? AS20212 Transfer character to numeric values from factor 2 to result field. MOVEA can be possible to ARRAY-ARRAY, ARRAY-FIELD, or FIELD-ARRAY. QS20213 How to initialize an array ? AS20213 CLEAR or MOVEA *blanks to array. QS20214 What is LOKUP opcode do ? AS20214 LOKUP opcode search for a particular element in an array / table. QS20215 Can LOKUP operation be used for unsorted array ? AS20215 Yes. QL20216 What is the difference between an array and a table ? AL20216 An array elements can be refered 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. QO30217 What is the maximum length of a table name ? AO30217 6 characters. QO20218 What is the syntax of a table name ? AO20218 Table name should start with TAB. QS30219 How can the user implicitly open and close the files in RPG program ?

AS30219

Enter UC in position 71-72 of F specs. Use OPEN and CLOSE opcodes in RPG program to open and close

files. QO20220 During input operation which indicator position is seton if there is a record lock? AO20220 LO indicator position is seton. QS20221 AS20221 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? Max. 255.

QS20222 AS20222 QO30223 AO30223

QL40224 What are the different ways of ending an RPG program without a primary file ? AL40224 SETON LR. SETON H1 to H9 (halt indicators). SETON RT. RETRN. 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. QL40225 user? AL40225 Specify different ways by which RPG program can give error message By calling the SUBR23R3 program as passing message id. By defining the error message in DSPF. to

QL50226 If you are trying to add a record in a file and an error is displayed, where do you look for error ? AL50226 Check whether you have opened the file in Update mode. Check whether you have specified 'A' in position 72 of F specs. QL50227 What is a File Information Data Structure ? AL50227 File Information Data structure (INFDS) can be defined for each file to make 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. QL50228 What is Program Status Data Structure ?

AL50228 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. QO30229 program ? AO30229 QL30230 AL30230 What is the maximum no. of times multiple occurrence DS can occur in 9999. What is the difference between *LIKE and *NAMVAR ? *LIKE defines the variables as in database. *NAMVAR is used to define variables as data area. a

QL30231 AL30231

How is embedded SQL used in RPG ? /EXEC SQL + SQL statements + -------------------+ -------------------/END EXEC What are all the compiler directive statements ? /TITLE, /EJECT, /SPACE, /COPY.

QS30232 AS30232

QS40233 How can RPG program send message to System Operator ? AS40233 Use QCMDEXC as called program in the CALL statements, and use SNDPGMMSG to the operator. QL50234 AL50234 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. QS40235 Where will control be passed after the execution of the *PSSR subroutine if the factor 2 of the ENDSR is blank ? AS40235 Control will return to the next sequential instruction.

QS40236 How can the CPF error-id be retrieved when a program error occurs ? AS40236 CPF error codes are placed in the subfield location *STATUS for the program status DS. QS30237 AS30237 How could indicators 50 to 99 be set to '0' in one instruction ? Using 'MOVEA *ZEROS IN,50' .

QL30238 What are the figurative constants ? AL30238 *BLANK/*BLANKS, *ZERO/*ZEROS, *HIVAL, *LOVAL, *ALL 'X..' are implied literals that can be supplied without a length, because implied length and decimal positions of a figurative constant are The same as those of the associated field. QO30239 What is the maximum error severity for which the compilation of RPG program stops ? AO30239 50, if LR is not seton. Q6S2001 A6AS2001 Q6L4002 A6L4002 Q6O3003 A6O3003 Q6O5004 A6O5004 What are the earlier versions of RPG ? RPG II & RPG III.

the

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.

MISCELLANEOUS
QO30240 AO30240 QO30241 AO30241 QO20242 AO20242 QO40243 AO40243 QS40244 AS40244 QS30245 AS30245 QO20246 AO20246 How do you combine two record formats in RLU ? Using CLC. How do you split record formats in RLU ? Using CLR. What is the use of SDA ? Screen Design Aid is used to create display files interactively. How do you define overlapping fields in SDA ? They can be defined through condition indicators. Mention different ways of specifying user help. Through SDA and Panel Group. To which member type does help text for panel belong ? PNLGRP Can Printer files be externally described or program described ? Yes.

QS20247 AS20247

What are the valid file operation codes for a PRINTER file ? WRITE, OPEN, CLOSE, FEDO.

QS50248 If you use INDARA keyword for a program-described PRINTER file, what will be the result ? AS50248 You will get run-time error. QL50249 What is PRTCTL, and where will you define it ? AL50249 The PRTCTL (Printer Control) option allows you to change forms control information and to access the current line value within the program for a program-described PRINTER file. PRTCTL option will be specified on a F specifications continuation line for the PRINTER file. Q8S2001 A8S2001 Q8S2002 A8S2002 Q8S2003 A8S2003 Q8O1004 A8O1004 Q8L4005 A8L4005 What is the function of RLU ? To design & prototype a report. What are the three types of keywords associated with printer file ? File level, Record level & Field level. What are the three line types in RLU ? Report line, Filler line & Sample line. Which option number is used to invoke RLU ? Option 19. What are the different commands used in RLU ? DR - Define Record, CLC - Change Line for Continuation, CLR - Change Line for Record, SD - Create Sample Data, VF - View Fields, NP - New Page, DC - Define Constants, DF - Define Fields, CF - Centre Fields & SP - Space Fields evenly. What is the command used to invoke RLU ? STRRLU. What are different record spacing keywords in RLU ? SKIPA, SKIPB, SPACEA & SPACEB. What is job description ? A job is an unit of work on the AS/400. Jobs run in a subsystem using system resources viz. memory, disk, etc. A job can be either interactive or batch. For interactive jobs JOD in User profile is used and for batch jobs JOBD along with SBMJOB is submitted with an object type of job description is *JOBD. Job description is a set of characteristics that define how the system handles a job. It contains: Job queue (only for batch), job priority, printer to be used, OUTQ & its priority, time slice & run priority. If none of the above is specified the system used the default job description. Define a sub system? Sub system is an operating environment, defined by a sub system description. All user jobs are processed in the sub system. Eg.QBASE, QBATCH, QCTL, QINTER, etc. Sub system description defines the characteristics of a sub system. ROUTING

Q8O1006 A8O1006 Q8S1007 A8S1007 Q8L4008 A8L4008

Q8L4009 A8L4009

ENTRY: Specifies the program to be called to control a routing step. WORK ENTRY: Source from which jobs can be accepted. WORK STATION ENTRY: Display stations from which users can log into the sub system. Q8L4010 A8L4010 Open query file [OPNQRYF]? Open query file (OPNQRYF) selection can be on: * Dynamic record selection * Dynamic keyed sequence * Dynamic join * Unique key processing * Group processing * Final total processing * Improve performance Query access path will be implemented through the following objects * CL program containing an OPNQRYF to open access path at runtime * OS/400 physical file used to compile programs [dummy PF] used at runtime * OS/400 logical file defines the key to OPNQRYF command Q8L4011 A8L4011 Override database [OVRDBF] ? Override database [OVRDBF] lets to override the filenames or attributes of file selected when we compile/run program. Overrides can be used to change most of the attributes. To cancel the override database command we shall have to give delete override databases DLTOVR. How do you pass numeric parameters for submitjob ? Convert numeric parameters to character and pass, or.pass in hexadecimal format ( x0nf if n contains odd number of digits xnf if n contains even nunber of digits)

Q8L4011 A8L4011

APPENDIX - A
The coding methodology to be followed to code questions & answers that are to be added to this question bank is described below. CODE STRUCTURE : ABCDnnn.

A - A indicates whether the code is a question or an answer. The possible values are : Q - Question. A - Answer.

B - B indicates the topic under which the question/answer falls. The possible values are :

1 - AS/400 SYSTEM. 2 - OS/400 3 - DATABASE FILES 4 - DISPLAY FILES 5 - CL/400 6 - RPG/400 7 - COBOL/400 8 - MISCELLANEOUS

C - C indicates the question/answer type. The possible values are : O - Objective type. S - Short answers. L - Long answers.

D - D indicates the complexity level of the question/answer. The possible values are : Complexity levels 1/2/3/4/5 ( Where complexity level increases from 1 - 5 ) nnn - These represent the numeric sequence.

WRKOBJPDM If we want to list all the source physical file or files of a particular type the Wrkobjpdm with file type as pfsrc for source physical file ior *file for listing all the files etc can be given

DSPOBJD If we know library name and object name and we want to know the source physical file where it is residing then dspobjd with option as services instead of basic will give the source physical file name WRKACTJOB To display the active jobs running in as/400 systems RTVMSG If you want to retrieve the text message from message files and move it to a temporary variable we can make use of this command PGM DCL VAR(&MSGVAL) TYPE(*CHAR) LEN(100) DCL VAR(&MSGFI) TYPE(*CHAR) LEN(10) VALUE(SHYAMFILE) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) VALUE(MSG0002) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(3) CHGVAR VAR(&MSGDTA) VALUE(5) RTVMSG MSGID(&MSGID) MSGF(&MSGFI) MSGDTA(&MS MSG(&MSGVAL) SNDMSG MSG(&MSGVAL) TOUSR(SHYAMR) ENDPGM

This will retrieve the message whose message id is msg0002 and message file is shyam file and msgdta is the value passed and here it is 5 CPYSRCF If we want to copy all the members in a source physical file to another source physical file we can use this command CPYTODKT If we want to copy from source physical file to a diskette file CPYTOTAP If we want to copy a source physical file to a tape then we can use this command STRDBG If we want to debug a ILE program then we can use this command. We have to create a ile program by compiling with 15 which is CRTRPGMOD command and give debugging values as *source .This will create a module. Then we have the create the program by giving program name and module name as the same and if we are calling any other modules also in that include that in the crtpgm command EX: CRTPGM PGM(SHYAMRLIB/ZP1263) MODULE(SHYAMRLIB/ZP1263 SHYAMRLIB/ZR3002) Now the program as well as the module is created .Then we have to start the debug by using the command STRDBG PGM(SHYAMRLIB/ZP1263) UPDPROD(*YES) It will show the source code of the program and we have to press F10 key and call the program Call pgm(zp1263) And it will move to debug mode and we can watch the flow of the program. When we start the debug and when the source is not available then there is some problem in the creation of the program ENDDBG After the debugging is over we have to end it by using this command DSPDBR This is used to list all the files which are related to a physical file. It displays all the logical files that are referring the physical files and also list the child table if it is having a relation through ADDPFCST CopyBook in ile It will copy a subroutine or any group of codes physically into the program which is copying it.
C DSPLY A C EXSR ADD C SETON C/COPY TESTSHYAM,SUBRTN C C C C ADD A BEGSR ADD 3 DSPLY ENDSR 50 LR

In the above program we are copying a subroutine called SUBRTN residing in the source physical file TESTSHYAM.The subroutine SUBRTN called can be of any type even text and no need to compile this program. In the above example the object will be created with code present in both the

programs. Normally a copy book will be presented after seton lr statement if you are using it as a subroutine but if you are just including a piece of code or initializing some statements then it can be used in between the programs either in d spec or c spec or even fspec depends on the application. In other words we can create 3 programs having F SPEC,D SPEC and C SPEC and just use 3 copy books like below F/COPY TESTSHYAM,FILEDEF D/COPY TESTSHYAM,DDEF C/COPY TESTSHYAM/CDEF TEST Test is the most powerful opcode which will check a date is a valid or not. The low level indicator is set on if the date is not valid or set off if the date is a valid one. Test will be given with extended factor like test(d),test(t), Test(z) for date, time and time stamp and if test without extended factor defaults to date(z). Factor 1 will be date format or time format. If it is blank it will take the value from H-spec and no H-spec then default format is *iso . Factor 2 is blanks and result contains the data to be tested datfmt(*dmy) movel '13/03/1999' a 8 test(d) a 30 *in30 dsply seton lr In the above example the date format is *dmy and 30 will set to off (valid date) .If in the H-Spec if we give *mdy then it is an error. DUMP Dump is a opcode in RPG which is used to force to produce a dump if any error occurs. It is used in program status data structure or file information data structure and it is used for a user to see if any error occurs in the system. We have to specify debug(*yes) in h-spec to make a dump
HDEBUG(*YES) dpssr DSTATUS DROUTINE DPARMS dRES C C C C 'NOTCOM' C A C 'COMING' C C *PSSR C STATUS C ROUTINE C PARMS C C C sds *STATUS *ROUTINE *PARMS S Z-ADD Z-ADD EVAL DSPLY TAG DSPLY SETON BEGSR DSPLY DSPLY DSPLY DUMP GOTO ENDSR

2S 0 1 NUM1 0 NUM2 RES=NUM1/NUM2

2 0 2 0

LR

In the above example divide by zero exception is caused and the control will be transferred to *pssr routine where it is making the dump and move the control to tag a. This program also illustrate the usage of parms status, routine keywords in program status data structures

Pre runtime array: In case of compile time array the elements of the array will be loaded before the execution of the programs. The value will be static in this case. In case of runtime array the value will be loaded during the runtime only and this is dynamic Pre runtime array is in between these 2 conditions where the values are static and the value will be retrieved from the disk and loaded into the array. As a result there is no need to retrieve the value every time from the disk and usage of pre runtime array makes it fast. Example of pre runtime array FPF02 IT F 80 DISK Here T will represents that this is a pre runtime array and F for representing it as a program described file and 80 is the size of the file. DARR1 S 15 0 DIM(100) Here the from file size is 80 and since perrcd file will have elements like this element1element2element3element4+20 free space Like this there are 100 elements are stored in We can specify to file location if you want to and this is optional FPF02 IT Fwsdatapf o DARR1 d DI C 1 C ARR1(I) C C C F F S S DO DSPLY ADD ENDDO SETON 10 1 I LR 80 80 DISK DISK 15a FROMFILE(PF02) PERRCD(4) is 4 and length is 15 the from

the array. copy the content of the from file

DIM(100) FROMFILE(PF02) PERRCD(1) tofile(wsdatapf) 2S 0 INZ(1)

This will load first 100 records into the file and display only the first 10 records Build in functions in ILE %SUBST(String name:starting position:length) %abs(-32.32)= Absolute value by omitting the sign %editc(string:X) In a application if we want to concatenate a string with a numeric then we can use this editc da s 5a INZ('SHYAM') db s 5s 0 INZ(20) dc s 5a INZ('SUNDA') dd s 5s 0 INZ(12) de s 5a INZ('RAMBA') dout s 25a c eval out=a+ %editc(b:'X') +c+%editc(d:'X')+e c out dsply %REPLACE: %replace(replacing string,actual string,starting position,offset) Here we are replacing shyamsundar from position 1to 5 by sam. The output will be sam sundar. DC S 12A INZ('SHYAMSUNDAR') C EVAL C=%REPLACE('SAM ':C:1:5) If we are not giving starting position then the result will be samamsundar. If we are giving starting position as 3 then the output will be shsamsundar. If we are giving EVAL C=%REPLACE('SAM ':C:1:1) then result is samhyamsundar. Keyword Overlay ddds1 ddate1

ds 10a inz('2001-01-01')

dyyyy 4s 0 overlay(date1:1) inz(1999) dmm 2s 0 overlay(date1:6) inz(12) ddd 2s 0 overlay(date1:9) inz(12) c date1 dsply c eval *inlr=*on Here the value of date1 is 1999-01-01 instead of 2001-01-01.Here the first four character are overlaid by the next statement Note1: We can create a module in CLP by making the type as CLLE

Question1: How can you copy only 100 records in a file which contains millions of records? (Ans) By using CPYF command we can give the record copying position starting and ending of the records. If we want to copy the records between 1000 and 1100 in the million records we can give 1000 in the start position and 1100 in the end position. In the another way by using CHGPF commands we can restrict the number of records to be there in a file by giving number of records as 100 and increments as 0. In this case we can copy only the first 100 records and not possible to copy from one position to another. Question2: How to convert a field from Uppercase to lowercase? (Ans) By using XLATE command we can convert a field from upper to loew case or vice versa. FDSPF001 CF E WORKSTN Dlower S 26A inz('abcdefghijklmnopqrstuvwxyz') Dupper1 S 26A inz('ABCDEFGHIJKLMNOPQRSTUVWXYZ') C *in03 doweq *off C exfmt casecon C 03 leave C if *in09=*on C upper1:lower XLATE lowcase upper C endif C enddo C seton lr Here lowcase and upper are the two fields in the screen and the user is entering characters in lowcase in upper case and convert that to upper case and move it to field upper when user press f9 key. Question 3: How to copy a file from as/400 system to a local pc. (Ans) Do the following to copy ftp as/400 machine ip address In wipro case ftp 10.200.9.80 It will ask for user name and password. Enter your as/400 user id and password. It will then say the user has logged in successfully. If you want to copy a rpgle program called load2 residing in shyamrlib library and source physical file name is shyamrile then we have to change the current library into shyamrlib .Just type cd shyamrlib and it will change the library. And then get shyamrile.load2 will copy the file into c:\ in local pc. If you want to copy from a PC to as/400 library then do the following To do: Copy from c:\shyam\load2 to shyamrile\load2 in shyamrlib Steps: cd shyamrlib put c:\shyam\load2 shyamrile.load2 will copy the file in shyam in c directory into shyamrile in shyamrlib. Question 4: How will your read a 100th record in a group of records in a file? (Ans)

Declare the file without K in record address type in file definition. z-add the position you want to retrieve. Suppose you want to retrieve 125th records then z-add 125 to rrn Do chain based on rrn. fworkfile1 if e disk c z-add 2174 rrn1 4 0 c rrn1 chain workfile1 40 c seton lr Here we are reading the 2174th record. Question 5: Explain the usage of procedure in a life project (Ans) Here is a procedure which will accept the character in lower case and return the value in upper case. In java the user may enter either in lower or upper cases and we have to convert into uppercase else the chain will fail. So we create a procedure in our program which do this and call the procedure in our program. Ex: This is the program which is calling the procedure. DPROC1 PR DX 10A DA S 10A C EVAL A='shyamsunda' C CALLP PROC1( C A) c A dsply c seton lr The procedure HNOMAIN DPROC1 PR D PPROC1 B DPROC1 PI DX Dlower S Dupper1 S C lower:upper1 XLATE C RETURN PPROC1 E

10A 10A EXPORT 10A 10A 26A 26A X X

inz('abcdefghijklmnopqrstuvwxyz) inz('ABCDEFGHIJKLMNOPQRSTUVWXYZ) X

Question 6: How to query a record for getting the rrn value? (Ans) Select rrn(zphamsp) from zphamsp where code=AE Here zphamsp is the program name. Question 7: Is it possible to send arrays,data structures as a parameter to another program? (Ans) Yes it is possible and we have to call in the same way a parameter is passed in the program. Ex: darr1 s 2p 0 dim(10) darr2 s 2p 0 INZ(1) c callB 'ARR2PGM' C PARM ARR1 C 1 DO 10 C ARR1(ARR2) DSPLY C ADD 1 ARR2 C ENDDO c SETON LR called program

DARR1 S DI S C *ENTRY PLIST C PARM C 1 DO C EVAL C ADD C ENDDO C SETON Here the array is passed as a

2P 0 DIM(10) 2P 0 INZ(1) ARR1 10 ARR1(I)=I 1

LR parameter and the values after callb is 1 to 10

Question 8: What is the difference in between CALL,CALLB,CALLP (Ans) Call is a dynamic call where the control will be transferred when the program Is executed where as Callb and Callp are static calls. A module is a non executable program and it contains one or more procedures. If you have modules without procedure then it means that it is having only one default procedure and in case we can use CALLB. But if a module is having more than one procedure then we can give explicitly the procedure name to be called in case of CALLP Out of these three Callp is the most efficient one. Question 9: What is the new name for as/400? (Ans) Iseries 400 is the new name given to as/400 by IBM now. Question 10: How to see the source of copy books included in a program while compiling or debugging? (Ans) While Compiling the program give *list instead of *source which will expand all the copy books. Question 11: How to retrieve the value from data area and how to change the value of a data area? (Ans) ds s 10a dg s 10a inz('i hate u') c *dtaara define data1 s c *lock in s c eval s=g c out s c s dsply c seton lr I created a data area by using the command crtdtaara and give the length as 10a and value as I love you Statement *dtaara define data1 s *lock in s will copy the content into a temporary variable s and now we are changing the value of s as I hate you and now by using out command the value of the data structure will be changed Question 12: How you will avoid multiple users updating the same record? (Ans) While displaying the records in the screen we will be getting the timestamp Along with the actual data. Store this in output data structure and while updating check weather the previous time stamp is the same timestamp before updating. If the record is updated by another user then the time stamp will be changed and if it does not matches then throw the error message Record is already updated by another user else update the records with current time stamp

Program1 Store the time stamp and this time stamp will come as a input to the second program Program 2 Here wstmst1 contains the input time stamp and check this matches with the database.If matches Update else send error message C K1CDFL CHAIN ZPCDFLR 80 C MOVEL WSTMST1 WSTMST C IF CDMOTS=WSTMST C TIME CDMOTS C UPDATE ZPCDFLR C ELSE C EVAL ERROR=1 c LEAVE C ENDIF C ENDDO Question 13: What will %size and %elem keywords will do? (Ans) %size will display the size of the variable where as %elem will display the array dimension. darr1 s 3s 0 dim(1000) c eval c=%size(arr1) c eval d=%elem(arr1) c c dsply c d dsply c seton lr In the above program c will be 3 and d will be 1000 Question 14: What will you format a number by using as/400? (Ans) By using Editw Keyword For example if you want to print 1234567890.12 as $1,234,567,890 dollars and 12 cents then the edit word must contains $ , , , &dollars&and& &cents. Here & will be used to add a space and a blank space represents the variable. So for printing and 12 cents we will give as &and& 12&cents. Where & represents blanks space in edit word and actual blank space is the variable 12. dsalary dedit damount c c amount c s c s eval dsply seton 12p 2 inz(1234567890.12) '$ , , , &dollars&and& 40a amount=%editw(salary:edit) lr
Deleted: 14:

&cents

Question 15 How you can schedule a job to run periodically? (Ans) We have to create a job scheduler for running a job periodically. Here we can make a job to run once or periodically at a given date and time. . We can create a job scheduler by using addjobscde command. We can list all the job scheduler running by using the command wrkjobscde and we can delete a job scheduler by using rmvjobscde or we can reschedule the job by using chgjobscde. Question 16: How you can bind a C module with a RPG Program? (Ans) Create a C module of type c void logit (char *t) { printf("'%s'\n",t); }

Deleted: 15

And bind this program by calling it as a module in RPG program D txt S 40A INZ('Hello, world !') D logit PR EXTPROC('logit') dtxt * value OPTIONS(*STRING)

c CALLP logit(%TRIMR(txt)) c return Create program for this rpg by binding with the c module and call this program. Question 17 How to debug a batch job? (Ans) Hold the batch job to be debuged by using wrkactjob command and having option 3. Set the pointer in the batch program to be debuged by using strdbg and then call the strsrvjob command and start the service program which will enter into the debug mode. After entering into debug mode release the job that is hold before. Question 18 Explain briefly about Non join Logical File. (Ans) Logical files can be derived from 1 to 32 physical files and so a logical file can have a maximum of 32 Record formats. If a logical file is derived from single physical file without joining then it is single record format logical file. Single record format logical file: Refaccpth is applicable for Non join logical file only and meaning is refer the access path from the physical or the logical file in the file level entry. PFILE is applicable only for non join logical file in record level entry. R RECPF2 PFILE(PF02) K EMPNAME Here the employee files key will be changed from empno to empname. Output of this query is No 1 2 3 NAME SHYAM RAMBABU SASI ADDRESS1 ADDRESS2 CITY STATE ZIPCODE 29,ARUNA NAGAR PUTHUR TRICHY TN 17 29,ARUNA NAGAR PUTHUR TRICHY TN 17 53,KULALAR STREET CUMBUM TN
Deleted: 16:

Deleted: 17:

54 ******** End of report ******** Here runqry will select all the records in pf02. R RECPF2 PFILE(PF02) EMPNAME 15A CITY 10A K EMPNAME Here the attribute size of city is changed from 30 to 10 and also the key value is changed. The output of this query is EMPNAME CITY SHYAM TRICHY RAMBABU TRICHY SASI CUMBUM R RECPF2 EMPNAME CITY EMPNO K EMPNAME O EMPNO The output of this is EMPNAME CITY SHYAM TRICHY RAMBABU TRICHY PFILE(PF02) 15A 10A 5S 0 CMP(GT 2) empno 1 2

Here the employee number 3 is omited since it is greater than 2. Multiple record non join logical file will select records from 2 or more physical files by referring to only one logical file 1) Each record format is always associated with one or more physical file. 2) The same PF can be used in more than one record format. Question 19: Explain Inner join or natural join and left outer join. (Ans) Natural join In case of natural join only the matching records in between the joining file will be selected. If the pf of 2 files is like this PF01 PF02 R JP1REC R JP2REC EMPNO 5S 0 EMPNO 5S 0 EMPNAME 20A EMPSAL 15P 0 K EMPNO K EMPNO The records in the 2 files are as follows Empno Empname Empno Empsal 1 shyam 1 1000000 2 sundar 2 2000000 3 rambabu 4 1000000 Then in case of natural or inner join the records selected are Empno 1 2 Empname shyam sundar Empsal 1000000 2000000

where as in Left outer join all the records from primary file and the matching records from the secondary file will be selected. The output is Empno Empname Empsal 1 shyam 1000000 2 sundar 2000000 3 rambabu 0 Note that the salary will be defaulted to default values and the employee number 4 is not selected since this is the secondary file. R JL1REC J JFILE(JP01 JP02) JOIN(1 2) JFLD(EMPNO EMPNO) JREF(JP01)

EMPNO EMPNAME EMPSAL K EMPNO Where as in inner join we have to specify jdftval in file level entry JDFTVAL R JL2REC JFILE(JP02 JP01) J JOIN(1 2) JFLD(EMPNO EMPNO) EMPNO JREF(JP02) EMPNAME

EMPSAL K EMPNO JFILE: It is similar to indicate that this is a Join logical file and it must have more than 2 physical files Join : It indicates what are the files to be joined in this case. We can represent the position of the files. There must be one primary file and can have more than 1 secondary files. JFLD which fields we are going to join JREF represent the primary file reference field. JDFTVAL represents that it as a left outer join. If we are joining more than one Physical files then we can represent it as follows. If the first two files are the same JP01 and JP02 and the third file to be joined is JP05 Which is having these fields R JP1REC Empno address Empno 5s 0 1 Trichy Address 20a 2 Cumbum K empno Then the result is 1 shyam 1000000 2 sundar 2000000 which fetches the matching record in all the three files. JDFTVAL R JL5REC JFILE(JP01 JP02 JP05) J JOIN(JP01 JP02) JFLD(EMPNO EMPNO) J JOIN(JP02 JP05) JFLD(EMPNO EMPNO) EMPNO JREF(JP01) EMPNAME 20A EMPSAL 15P 0 ADDRESS K EMPNO trichy cumbum

Question 20 What will FOR opcode will do? (Ans) dn s di s * for(i=0;i<n;i++) c for c i dsply c endfor * for(i=n;i<1;i--) c for c i dsply c endfor * for(i=5;i<40;i=i+10) c for c i dsply c endfor c c for c i dsply c endfor c * for(i=5;i<40;i=i+10) c seton Question 21

5s 0 inz(10) 5s 0 i=1 to n

i=n downto 1

i=5 by n to 40

i=5

to 40 by n

lr

What are the various stages for a job after it is submitted? (Ans) Jobqueue, Active job and OUTQ are the three stages after the job has been submitted. Question 22 What are the difference between non join logical files and join logical files (Ans) Non Join Logical Files We can able to insert or delete or update records using non join logical files. DFU can be used to display Non join logical files 1-32 record format can be specified Commitment control is used Question 23 Explain Self join in detail (Ans) In a employee physical file there are 3 fields named empno,empname and mgrid. Manager is also an employee and he has an employee id in the same table with some other as manager. We want to query the records with the fields empno,empname and manager name. So based on the manager id we have to select the corresponding employee id and select the employee name and move that as the manager name. DDS of Physical File SEU==> PFTEST FMT PF .....A..........T.Name++++++RLen++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 A R EMP 0002.00 A EMPID 5 0 0003.00 A EMPNAME 20 0004.00 A MGRID 5 0 ****************** End of data **************************************** Data in 000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 ****** Physical File EMPID EMPNAME 10,001 Sebi Joseph C. 10,002 Purushottam 10,003 Sameer Dighe 10,004 Sharada Menon 10,005 Saju Paul C. 50,001 Shivaram Pasuvan 50,002 Praveen K. Gaurav 50,003 Lionel King 50,004 Sam Mathew Varghese 50,005 Anil Jandyam ******** End of report ******** Join Logical Files Insertion, updating or deletion of records is not possible in join logical files DFU is not available Only one record format can be specified Commitment control is possible

MGRID 50,001 50,002 50,003 50,004 50,005 90,001 90,002 90,003 90,004 90,005

FMT LF .....A..........T.Name++++++.Len++TDpB......Functions++++++++++++++++++ *************** Beginning of data ************************************* 0001.00 A R EMP JFILE(PFTEST PFTEST) JOIN(1 2) 0002.00 A J 0003.00 A JFLD(MGRID EMPID) 0004.00 A EMPID JREF(1) 0005.00 A EMPNAME JREF(1)

0006.00 A MANAGER RENAME(EMPNAME) JREF(2) 0007.00 COLHDG('MANAGER') ****************** End of data **************************************** Output of Join Logical File

Line 000001 000002 000003 000004 000005 ******

....+....1....+....2....+....3....+....4....+....5. EMPID EMPNAME MANAGER 10,001 Sebi Joseph C. Shivaram Pasuvan 10,002 Purushottam Praveen K. Gaurav 10,003 Sameer Dighe Lionel King 10,004 Sharada Menon Sam Mathew Varghese 10,005 Saju Paul C. Anil Jandyam ******** End of report ********

Question 24: What is a field reference file? (Ans) This is a physical file which does not have any data and contains only the field descriptions and these fields are referred in other pf by using ref and reffld. This is the third type of file along with PF and LF. Question 25 What will runsqlstm will do? (Ans) If we want to execute set of sql statements (only insert, update and delete and no select is allowed) then we can write all the sql statement to be included with the source type as sql. Then use strsqlstm to execute the program RUNSQLSTM SRCFILE(SHYAMRLIB/TESTSHYAM) SRCMBR(SQL1) COMMIT(*NONE)

Question 26 What is the advantage of Opnqryf over SQLRPG? (Ans) opnqryf sqlrpg Opnqryf will come along with os/400 We need to have sqlrpg installed in system and no need to have any as/400 system which involves additional package needed to additional cost to the programmers execute it. Opnqryf is faster as compared to It is slower sqlrpg Opnqryf Is nothing but a dynamic SQLRPG is imbedding sql statements logical files which will be created directly within SQL Statement and the records are queried and finally the logical files are deleted and OPNQRYF provides that facility

Question 27 What is the equivalent command to setll *loval in CL (Ans) POSDBF with file position as *start will set the file to the beginning or using ovrdbf and specify the keyfield value by rrn value or by giving *start.

Question 28 What is the difference between OPM, EPM and RPGILE? (Ans) OPM EPM

RPGLE

Open Program Model is the old RPG/400 system, which will not allow a program type to call another program type.

Extended program model will support PASCAL, FORTRAN and other programming concepts.

Version is V1R2

It supports mixed program support in which you can combine any program with another type of program Version is V2R3

Question 29 What is the difference between Bind by value and Bind by reference? (Ans) Bind by value Bind by Reference Here all the modules to be bounded In this case we are binding the are physically copied into the main programs by using service programs program object. which contains a reference to the modules that has been called and the modules are not physically copied into the program objects The program will be executed even The program will not executed when when you delete all the modules the bind modules are deleted. that have been called. Bind by value is faster than bind It is not as faster as bind by by reference value Question 30 How to create a service program and what are the steps involved in this? (Ans) While creating service program we can create a binder program where we can refer the modules or procedures or even data types to be used by the program, which is using service program. If we are having 100 procedures in a module and if you want to specify only some procedures to be bind in the service program we can create the binder program. STRPGMEXP SIGNATURE('BND') EXPORT SYMBOL('PGM1') ENDPGMEXP Here there are 2 programs PGM1 and pgm PGM1 PGM DA S 2P 0 INZ(8) CALLB PGM1 DB S 2P 0 INZ(8) SETON LR DC S 2P 0 C EVAL C=A+B C SETON LR Then we create the binder program, which will give authority to only one module named PGM1 Then create the service program with binding program incorporated. If no binder program is incorporated then all the modules will be taken as default CRTSRVPGM SRVPGM(QTEMP/SRVPGM) MODULE(QTEMP/XXXX) SRCFILE(IDCPGRRSP/SHYAMR ILE) SRCMBR(BND) DSPSRVPGM Will helps us to display the details about the service program that has been created. We can also create a bind directory for a service program where we can bind all the modules together and if we do like this then there is no need to bind all the programs and we can compile the program straightly by using crtbndrpg even it has more than 1 module. CRTBNDDIR BNDDIR(QTEMP/BNDDIR) 2) ADDBNDDIRE BNDDIR(QTEMP/BNDDIR) OBJ((*LIBL/SRVPGM *SRVPGM))

The type of service program that is created is *srvpgm. Question 31 What is an activation group? (Ans) Activation group is the boundary set for similar programs. Activation group is also a storage space in memory. Consider for example the following scenario 2) CLP has a ovrdbf command and calls a rpg program 3) RPG program performs a read operation and the pointer is now in the second program and now call the program 3 4) RPG program that also do a read operation which will read the second record since the pointer is in the second position and then return to 2nd program In the above situation when the control transfers from 3rd program to the 2nd program then it will read the 3rd record since the 2nd record is already read in program 3. But we need to read the 2nd record according to the logic but this is not possible in any OPM programs. But in ILE there is a solution for this problem by giving a common activation group for 1st and 2nd program and have a separate activation group for the 3rd program while creating the program itself and this will avoid all the problem we faced before. In some situation we want to share between 2 programs then we can give the activation group in *job level in which the changes in one program will be affected in another program. Types of activation group levels: *new : In this case every time you call the program an new activation group will be created which this case will not be used mostly. *caller: If we dont know the type of the program that is calling then we can specify *caller where the activation group will be the same of the program that is calling. Named activation group: We can give our own named for different activation group Question 32 What are the statements that are affected by activation group? (Ans) 1) OVRDBF 2) OPNQRYF 3) STRCMTCTL 4) DLTOVR 5) OPNDBF Question 33 What are the statements, which is not used in CLLE that is used in CLP? (Ans) 2) RCLRSC which is replaced by RCLACTGRP 3) TFRCTL Question 34 Write a brief note on procedures used in RPGLE (Ans) 1) Defining the Prototype: Prototype will specify the following things 2) Parameter type 3) Sequence of the parameter 4) Return variable and its type 5) It tells the name of the procedure and also the type of the call. It will avoid all the run time problems like parameter mismatch by specifying the prototype like this 2) Prototype interface: It is like the *entry parameter where we will specify the parameters that are received in this program.

3) IMPORT and EXPORT If you want to specify the procedures to be used by the external programs then we can specify EXPORT in your procedure. If you dont want then leave it blank. It is similar like giving private or public in JAVA. 4) Global and local variables If you declare a variable in main procedure then it will be accessible in all its sub procedure and this is global declaration and if you specify the declaration in the sub procedures then it will not be accessed in other procedures or in the main procedure. 5) RETURN If we specify return in the sub procedure then it means that we are returning something to the calling program. We can return a maximum of only one variable to the calling program. 6) Recursion A procedure calling to it self is known as recursion 7) Pass by value/Pass by reference In case of pass by reference we are passing the address of the parameters and not the actual value and so the changes in the called procedure will affect the value in the calling programs. In OPM programs we are using only call by reference and in RPGLE we have the option to pass the parameter by value by giving the keyword VALUE 8) CALLP/Expression We can call the procedure by using CALLP command if it is not having any return type and by an expression if it returns any value Example EVAL C=PROC1(A:B) Example program doing recursion using procedure. Called procedure: H NOMAIN DRECUR PR 3S 0 DA 2S 0 * DB S 3S 0 INZ(1) PRECUR B EXPORT D RECUR PI 3S 0 D A 2S 0 C IF A<>1 C EVAL B = B*A C EVAL A = A-1 C CALLP RECUR(A) C ENDIF C RETURN B PRECUR E * Calling program DVAL DFACT DRECUR DA C C C FACT C

S S PR

2S 3S 3S 2S

0 INZ(5) 0 INZ(1) 0 0

EVAL DSPLY SETON

FACT = RECUR(VAL) LR

Question 35 What is program entry procedure (PEP) and User entry procedure (UEP)

(Ans) If we are binding many modules together to form a program then we have to specify which module has to take control first when it has been called and that module is called as PEP for that program. User entry procedure is the first statement that takes the control when a program has been called. For example in C programs main( ) will be executed first when it has been called and like wise in RPG the statement coded in C spec will take the control first.

Question 36 Explain about FMTDTA in detail. (Ans) Here there is a pf of the following attributes R REC1 EMPNO 5S 0 EMPNAME 20A ADDRESS 25A DOB 8S 0 And this physical file is having the following records Empno name address dob 1 shyam trichy 11,021,999 2 tom pune 11,122,002 3 ccc jjhhj 11,021,999 We want to sort the file based on address in ascending order then we have to code the format data in the following way. IPRH and IPRF are used to add the attributes of format data. HFILE 025A X pf02 FNC00260050 address FDC00010058 Here we want to sort the physical file based on the address and the length of the field to be sorted is 25. If we want to sort based on more than 1 field (address,dob) then give the length as 33(25+8) HFILE 025A X pf02 The address position starts from 26th position to 50 and we have more fields declare all the fields by taking IPRF Spec FNC00260050 address After coding all the fields to be sorted give the total length of all the fields in the file. Here the file pf02 has a length of 58 and we declare it as follows FDC00010058 The type of this program is anything even a text file. After coding the sorting manner we have to make use of format data command to create a file that contains the sorted record. FMTDTA INFILE((IDCPGRRSP/PF02)) OUTFILE(QTEMP/PF02) SRCFILE(IDCPGRRSP/SHYA MRILE) SRCMBR(FMT) This will copy the records into PF02/qtemp and the records will be sorted on address. Output after sorting: EMPNO EMPNAME ADDRESS DOB 3 ccc jjhhj 11,021,999 2 tom pune 11,122,002 1 shyam trichy 11,021,999 Question 37 What is the difference between FMTDTA and OPNQRYF (Ans) FMTDTA It will sort the records sequentially based on the position of the record. If any changes in the attribute size of a pf then we have to change OPNQRYF It will sort the records based on the field values. If there is any change in the attribute size it will not affect

the program specification also FMTDTA is bit faster in process than opnqryf.

the program specification also. OPNQRYF is slower as compare to FMTDTA if we are processing millions of records.

Question 38 How you can import and export a data type between 2 programs (Ans) If you are using an export statement when declaring a variable then the data type can be imported in any modules that is bind either by value or by reference. So in this case we can pass values in between modules instead of using plist and *entry. Program 1 DDD C C DD C Program 2 ddd c c

S CALLB DSPLY SETON

2S 0 EXPORT INZ(1) 'EXP01' LR

s eval seton

2s 0 import dd=6 lr

In the above example the value of the variable DD will be passed to the next program and it value is changed in the second program without using *entry and plist Question 39 How you can use pointers in RPGLE (Ans) Pointer is concept of referring the variable in the basis of address. We can make many variables or data structures that refer the same address space by using this pointer. dbase_address s * ddsname1 ds based(base_address) dfirname 10a dlasname 10a ddsname2 ds 30 c eval base_address=%addr(dsname2) c eval dsname2='shyam sundar' c firname dsply c lasname dsply c seton lr Here in the above example we declare the pointer base_address and we make the datastructure dsname1 assigning to that pointer. We declare another data structure and till now the memory is not allocated to the pointer. Then by using the command c eval base_address=%addr(dsname2) we are allocating the address space to the pointer and since the data structure dsname1 is also referring this any change to dsname2 will affect dsname1. So assign some values to dsname2 and we can see the values in dsname1 also. Here the firname and lasname will print as shyam and sundar respectively. Question 40 Discuss about option keyword in detail (Ans) options(*varsize) : It is similar to declaring the variable as varchar instead of char. So if we declare a variable with size 100 and if you initialize with shyam then it will allocate only 5 spaces. Options(*nopass): This means that this parameter can be passed or even omitted Options(*omit): We can give both *nopass and *omit for a single variable.

Options(*string): If we are passing string to the called program and if it is expecting the pointer then in such case we can give this option. Please refer the question 16 for further clarification Question 41 Explain EXTPGM in detail (Ans) If we want to call a procedure dynamically then we can make use of this command d prot1 pr extpgm('qcmdexc') d cmdstr 1000 options(*varsize) D CONST d cmdlen 15s 5 D CONST d const1 3 options(*nopass) D CONST D Cmds C 'DSPWSUSR' c callp prot1(cmds:%len(cmds)) c seton lr In the above program example we are passing 3 variables to qcmdexc command for listing cl command. Question 42 Explain O Spec and use of EXCEPT Opcode in detail (Ans) O-Spec is used for printing records and except opcode is equal to writing the record format name in case of RLU. We are printing all the records in the physical file pf02 whose has empno,name and address as the fields by using O-spec and except opcode. fpf02 if e disk fqsysprt o f 132 printer dss s 20a inz('--------------------') c* *loval setll rec1 c read rec1 80 c except header c *in80 doweq *off c except detail C read rec1 80 c enddo c seton lr * oqsysprt e header o ss 20 o ss 40 oqsysprt e detail o empno 5 o empname 25 o address 45 ****************** End of data ************************* The output of the spooled file is ---------------------------------------00001shyam trichy 00002tom pune 00003ccc jjhhj Question 43 Describe the architecture of MQ Series. (Ans)

What all the E specification describes? Extension specifications describe all record address files, table files, and array files used in the program. The information includes: _ _ _ _ Name of the file, table, or array Number of entries in a table or array input record Number of entries in a table or array Length of the table or array entry.

What all the L specification describes? Line counter specifications describe the page or form on which output is printed. The information includes: _ Number of lines per page _ Line of the page where overflow occurs. What all the I specification describes? Input specifications describe the records, fields, data structures and named constants used by the program. The information in the input specifications includes: _ Name of the file _ Sequence of record types _ Whether record-identifying indicators, control-level indicators, field-record-relation indicators, or field indicators are used _ Whether data structures, lookahead fields, record identification codes, or match fields are used _ Type of each field (alphanumeric or numeric; packed-decimal, zoned-decimal, or binary format) _ Location of each field in the record _ Name of each field in the record _ Named constants. What all the C specification describes? Calculation specifications describe the calculations to be done on the data and the order of the calculations. Calculation specifications can also be used to control certain input and output operations. The information includes: _ _ _ _ Control-level and conditioning indicators for the operation specified Fields or constants to be used in the operation The operation to be processed Whether resulting indicators are set after the operation is processed.

What all the O specification describes? Output specifications describe the records and fields in the output files and the conditions under which output operations are processed. The information includes:

_ _ _ _ _ _ _ _ _

Name of the file Type of record to be written Spacing and skipping instructions for PRINTER files Output indicators that condition when the record is to be written Name of each field in the output record Location of each field in the output record Edit codes and edit words Constants to be written Format name for a WORKSTN file.

What are all the OS/400 allowes to control? The operating system that controls all of your interactions with the AS/400 system is called the Operating System/400 (OS/400) system. From your work station, the OS/400 system allows you to: _ _ _ _ _ _ _ Sign on and sign off Interact with the displays Use the online help information Enter control commands and procedures Respond to messages Manage files Run utilities and programs.

Tell us some commonly used CL commands, and the reasons for them ? The following table lists some of the most commonly used CL commands, their function, and the reasons you might want to use them.
?????????????????????????????????????????????????????????????????????????? ? Table 1. RPG/400 Functions and Associated CL Commands ? ?????????????????????????????????????????????????????????????????????????? ? RPG/400 Function ? Associated Control Language Commands and their ? ? ? Uses ? ?????????????????????????????????????????????????????????????????????????? ? Calling ? CALL program-name Run an RPG/400 program ? ? ? CALL QCL Access the System/38 ? ? ? environment ? ?????????????????????????????????????????????????????????????????????????? ? Commitment Control ? CRTJRN Prepare to use commitment ? ? ? control. ? ? ? CRTJRNRCV Prepare to use commitment ? ? ? control. ? ? ? ENDCMTCTL Notify the system you want ? ? ? to end commitment control. ? ? ? JRNPF Prepare to use commitment ? ? ? control. ? ? ? STRCMTCTL Notify the system you want ? ? ? to begin commitment control. ? ?????????????????????????????????????????????????????????????????????????? ? Communications ? CRTICFDEVE Create ICF Device ? ? ? OVRICFDEVE Override ICF Device ? ?????????????????????????????????????????????????????????????????????????? ? Compiling ? CRTRPGPGM Create RPG Program ? ? ? CRTRPTPGM Create Auto Report Program ? ?????????????????????????????????????????????????????????????????????????? ? Consecutive ? OVRDBF Override with Database file ? ? Processing ? ?

?????????????????????????????????????????????????????????????????????????? ? Control Specification ? CRTDTAARA Create Data Area ? ? Data Area ? DSPDTAARA Display Data Area ? ?????????????????????????????????????????????????????????????????????????? ? Debugging ? ADDBKP Add Breakpoint ? ? ? ADDTRC Add Trace ? ? ? DSPBKP Display Breakpoint ? ? ? STRDBG Start Debug ? ?????????????????????????????????????????????????????????????????????????? ? Edit Codes ? CRTEDTD Create Edit Description (For ? ? ? User Defined Edit Code) ? ? ? DSPDTAARA Display Data Area ? ?????????????????????????????????????????????????????????????????????????? ? Printer Files ? CRTPRTF Create Print File ? ? ? OVRPRTF Override Print File ? ?????????????????????????????????????????????????????????????????????????? ? System Editor ? STRSEU Start Source Entry Utility ? ??????????????????????????????????????????????????????????????????????????

The Control Language and all of its commands are described in detail in the CL Reference manual.

What are the Structured programming operation codes ? The structured programming operation codes are: _ _ _ _ _ _ _ _ _ _ _ _ IFxx (If/Then) ELSE (Else Do) ENDyy (End) DO (Do) DOWxx (Do While) DOUxx (Do Until) ANDxx (And) ORxx (Or) CASxx (Conditional Invoke Subroutine) SELEC (Select a module) WHxx (When) OTHER (Otherwise).

where xx can be: GT LT EQ NE GE LE Blanks Factor 1 is greater than factor 2. Factor 1 is less than factor 2. Factor 1 is equal to factor 2. Factor 1 is not equal to factor 2. Factor 1 is greater than or equal to factor 2. Factor 1 is less than or equal to factor 2. Factor 1 is not compared to factor 2 (unconditional processing). This is valid for CASxx operation only.

and where yy can be: CS End a CAS group. DO End a DO, DO UNTIL, or DO WHILE group. IF End an IF group. SL End a SELEC group.

What a message contain and what is message Severity ? Messages you receive during compilation and run-time. These messages are displayed on your screen or printed on your compiler listing. This product has no message manuals. Each message contains a minimum of three parts as illustrated in the following sample message:
???????????????????????????????????????????????????????????????????????????????????????????????????? ???? ? ? ? ? ? ? ? ? ? A 10 ? ? ? ? B Message: Syntax of Program-Identification entry is not valid. Defaults to RPGOBJ. ? ? ? ? C Cause: The Program-Identification entry (positions 75-80) of a control ? ? specification has a not valid syntax: the first character is not ? ? alphabetic or it is not left-justified, or it contains embedded blanks ? ? or special characters. Defaults to RPGOBJ. ? ? ? ? Recovery: Specify RPGOBJ or a valid entry (positions 75-80) for the ? ? Program-Identification option. Recompile. ? ? ? ? ? ? ? ???????????????????????????????????????????????????????????????????????????????????????????????????? ????

A A number indicating the severity of the error. The severity-level value of the RPG/400 compile-time messages does not exceed 50. Severity Meaning 00 An informational message displayed during entering, compiling, and running. No error has been detected and no corrective action is necessary. 10 A warning message displayed during entering, compiling, and running. This level indicates that an error is detected but is not serious enough to interfere with the running of the program.The results of the operation are assumed to be successful. 20 An error message displayed during compiling. This level indicates an error, but the compiler is attempting a recovery that might yield the desired code. The program may not work as the author intends.

30 A severe error message displayed during compiling. This level indicates that an error too severe for automatic recovery is detected. Compilation is complete, but the program does not run. 40 An abnormal end-of-program or function message displayed during compiling or running. This level indicates an error that forces cancelation of processing. The operation ended either because it could not handle valid data, or because the user canceled it. 50 An abnormal end-of-job message displayed during compiling or running. This level indicates an error that forces cancelation of job. The job ended either because a function failed to perform as required, or because the user canceled it. 99 A user action to be taken during running. This level indicates that some manual action is required of the operator, such as entering a reply, changing diskettes, or changing printer forms. B The text you see online or on a listing. This text is a brief, generally one-sentence, description of the problem. C This text is printed on your listing if you specify *SECLVL in your compile-time options. It contains an expanded description of the message and a section detailing the correct user response. The IBM-supplied default for this option is *NOSECLVL. At run time, you can enter D to obtain an RPG/400 formatted dump, S to obtain system dump, C to cancel, G to continue processing at *GETIN, or F to obtain a RPG/400 full-formatted dump.

Give me one example of Breakpoints ? Example of Using Breakpoints Figure 1 shows a source listing of a sample RPG/400 program, DBGPGM, and the CL commands that add breakpoints at statements 1200 and 1500. The value of variable *IN is displayed when the breakpoint at statement 1200 is reached, and the value of variables FLD1 and PART are displayed when the breakpoint at statement 1500 is reached. CL Commands STRDBG PGM(EXAMPLES/DBGPGM) ADDBKP STMT(1200) PGMVAR((*IN)) ADDBKP STMT(1500) PGMVAR((FLD1) (PART)) OUTFMT(*HEX)
5763RG1 V3R0M5 940125 IBM RPG/400 QGPL/DBGPGM 01/25/94 13:42:19 Page 2 SEQUENCE IND PAGE PROGRAM NUMBER *...1....+....2....+....3....+....4....+....5....+....6....+....7...* USE UPDATE LINE ID S o u r c e L i s t i n g H ***** 100 FTESTX IF F 5 DISK 01/01/02 200 FTESTA UF F 10 DISK 01/01/02 300 ITESTX NS 01 01/01/02 400 I 1 5 PART 01/01/02

DO NUM

LAST

500 01/01/02 600 01/01/02 700 01/01/02 800 01/01/02 900 01/01/02 1000 01/01/02 1100 01/01/02 1200 01/01/02 1300 01/01/02 1400 01/01/02 1500 01/01/02 1600 01/01/02 1700 01/01/02 1800 01/01/02 1900 01/01/02 2000 01/01/02

ITESTA I

NS

02 1 5 FLD1

***************************************************** * MAINLINE

***************************************************** C C C C C C C C C OTESTA O * * * * * E N D E N67 N67 N66 ENDPGM 66 LOOP TAG READ TESTX GOTO ENDPGM READ TESTA MOVE PART EXCPTMAST GOTO LOOP TAG SETON MAST FLD1 O F 5 * * * * * LR 1 FLD1 67 3 66 3

S O U R C E

Figure 1. Sample RPG/400 Program DBGPGM

The first breakpoint shows you where you are in the program. Figure 2 shows the two displays as a result of reaching the first breakpoint.
???????????????????????????????????????????????????????????????????????????????????? ? ? ? Display Breakpoint ? ? ? ? Statement/Instruction . . . . . . . . . : 1200 /004A ? ? Program . . . . . . . . . . . . . . . . : DBGPGM ? ? Recursion level . . . . . . . . . . . . : 1 ? ? Start position . . . . . . . . . . . . : 1 ? ? Format . . . . . . . . . . . . . . . . : *CHAR ? ? Length . . . . . . . . . . . . . . . . : *DCL ? ? ? ? ? ? Variable . . . . . . . . . . . . . . . : *IN ? ? Lower/upper bounds . . . . . . . . . : (1:99) ? ? Type . . . . . . . . . . . . . . . . : CHARACTER ? ? Length . . . . . . . . . . . . . . . : 1 ? ? Element --------------------- Values ------------------- . ? ? 1 '1' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 11 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 21 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 31 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? ? ? Press Enter to continue. ? ? More... ? ? F3=Exit program F10=Command entry ? ? ? ? ? ????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????????????????? ? ? ? Display Breakpoint ? ? ?

? Statement/Instruction . . . . . . . . . : 1200 /004A ? ? Program . . . . . . . . . . . . . . . . : DBGPGM ? ? Recursion level . . . . . . . . . . . . : 1 ? ? Start position . . . . . . . . . . . . : 1 ? ? Format . . . . . . . . . . . . . . . . : *CHAR ? ? Length . . . . . . . . . . . . . . . . : *DCL ? ? ? ? ? ? ? ? 41 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 51 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 61 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 71 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 81 '0' '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? 91 '0' '0' '0' '0' '0' '0' '0' '0' '0' ? ? ? ? ? ? ? ? Press Enter to continue. ? ? ? ? F3=Exit program F10=Command entry ? ? ? ? ? ????????????????????????????????????????????????????????????????????????????????????

Figure 2. First Breakpoint Display for DBGPGM

Figure 3 shows the two displays as a result of reaching the second breakpoint.
???????????????????????????????????????????????????????????????????????????????????? ? ? ? Display Breakpoint ? ? ? ? Statement/Instruction . . . . . . . . . : 1500 /0060 ? ? Program . . . . . . . . . . . . . . . . : DBGPGM ? ? Recursion level . . . . . . . . . . . . : 1 ? ? Start position . . . . . . . . . . . . : 1 ? ? Format . . . . . . . . . . . . . . . . : *HEX ? ? Length . . . . . . . . . . . . . . . . : *DCL ? ? ? ? ? ? Variable . . . . . . . . . . . . . . . : FLD1 ? ? Type . . . . . . . . . . . . . . . . : CHARACTER ? ? Length . . . . . . . . . . . . . . . : 5 ? ? * . . . +. . . . 1 . . . . + . . *...+....1....+. ? ? 404000063F ' ' ? ? ? ? Variable . . . . . . . . . . . . . . . : PART ? ? Type . . . . . . . . . . . . . . . . : CHARACTER ? ? Length . . . . . . . . . . . . . . . : 5 ? ? ? ? Press Enter to continue. ? ? More... ? ? F3=Exit program F10=Command entry ? ? ? ? ? ????????????????????????????????????????????????????????????????????????????????????

???????????????????????????????????????????????????????????????????????????????????? ? ? ? Display Breakpoint ? ? ? ? Statement/Instruction . . . . . . . . . : 1500 /0060 ? ? Program . . . . . . . . . . . . . . . . : DBGPGM ? ? Recursion level . . . . . . . . . . . . : 1 ? ? Start position . . . . . . . . . . . . : 1 ? ? Format . . . . . . . . . . . . . . . . : *HEX ? ? Length . . . . . . . . . . . . . . . . : *DCL ? ? ? ? * . . . +. . . . 1 . . . . + . . *...+....1....+. ? ? 404000063F ' ' ?

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Press Enter to continue. ? ? ? ? F3=Exit program F10=Command entry ? ? ? ? ? ????????????????????????????????????????????????????????????????????????????????????

Figure 3. Second Breakpoint Display for DBGPGM At this point, you can change the value of one of these variables to alter how your program runs. After getting to the Command Entry Screen by pressing F10, you can use the CL command CHGPGMVAR (Change Program Variable) to change the value of a variable.

What are the considerations using Break points ? You should know the following characteristics of breakpoints before usingthem: _ If a breakpoint is part of a conditional statement, that breakpoint request is processed even if the condition is not met. _ If a breakpoint is bypassed by a GOTO operation, that breakpoint request is not processed. _ Some statements that are not processed do not represent a definite position in the logic flow of your program. Avoid putting breakpoints on PLIST, PARM, KLIST, KFLD, and DEFN operations. _ When a breakpoint is requested for a statement, the breakpoint occurs before that statement is run. _ When a breakpoint is requested for a statement that is not processed, such as a TAG operation, the breakpoint is set on the next statement. _ Breakpoint functions are specified using CL commands. You can use CL commands to add breakpoints to programs, display breakpoint information, remove breakpoints from programs and start a program after a breakpoint has been displayed. Refer to the CL Reference for descriptions of these commands and for a further description of breakpoints. _ Input fields not used in your program cannot be specified in the PGMVAR parameter of the debug commands. You can display the entire input or output buffer for a record by using the variable name ZZnnBIN (input buffer) or ZZnnBOUT (output buffer). The nn value is the sequence number corresponding to the order in which the files are defined in your specifications. This number also appears in the cross

reference section of the compiler listing. Thus you can display the input buffer for the second file in your program by specifying PGMVAR (ZZ02BIN).

How do you handle Exception / Erros in the RPG Program ? The RPG/400 compiler handles two types of exception or errors: program exception or errors and file exception or errors. Some examples of program exception or errors are division by zero, not valid array index, or SQRT of a negative number. Some examples of file exception or errors are undefined record type or a device error. Figure 1 shows an example of a file information data structure (INFDS) and a file exception/error subroutine. For further information on exception/error handling by the RPG/400 compiler, see the RPG/400 Reference manual.
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* F* F* Three files are defined on the file description specifications. F* You want to control the program logic if an exception or error F* occurs on the TRNFIL file or on the MSTFIL file. Therefore, a F* unique INFDS and a INFSR are defined for each file. They are F* not defined for the AUDITFIL file. F* FFilenameIPEAF....RlenLK1AIOvKlocEDevice+......KExit++Entry+A....U1.* FTRNFIL OF E K DISK KINFDS FILDS1 F KINFSR ERRRTN FMSTFIL UF E K DISK KINFDS FILDS2 F KINFSR MSTERR FAUDITFILOF E K DISK *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* I* I* The location of the subfields in the file information data I* structures is defined by special keywords in positions 44 I* through 51. To access these predefined subfields, you must I* assign a name to each subfield in positions 53 through 58. I* If an exception or error occurs, you can test the information I* in the data structure to determine, for example, what exception I* or error occurred (*STATUS) and on which operation it occurred I* (*OPCODE). You can then use that information within the file I* exception/error subroutine to determine the action to take. I* IFilenameSqNORiPos1NCCPos2NCCPos3NCC................................* IFILDS1 DS I....................................PFromTo++DField+L1M1FrPlMnZr...* I *FILE FIL1 I *RECORD REC1 I *OPCODE OP1 I *STATUS STS1 I *ROUTINE RTN1 IFILDS2 DS I *FILE FIL2 I *RECORD REC2 I *OPCODE OP2 I *STATUS STS2 I *ROUTINE RTN2 *.. C* C* C* C* C* 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* On the WRITE operation to the TRNREC record in the TRNFIL file, an exception/error indicator is specified in positions 56 and 57. This indicator is set on if an exception or error occurs on this operation. The ERRRTN subroutine (the file exception or error

C* subroutine for the TRNFIL file) is explicitly called by the EXSR C* operation when indicator 71 is on. Because factor 2 of the ENDSR C* operation for the ERRRTN is blank, control returns to the next C* sequential instruction following the EXSR operation after the C* subroutine has run. C* CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++* C WRITETRNREC 71 C 71 EXSR ERRRTN ?????????????????? C " ? Calculations ? C* ?????????????????? C* C* No exception/error indicator is specified in positions 56 and 57 C* of the WRITE operation to the AUDITREC record in the AUDITFIL C* file. No exception/error subroutine was defined for this file C* on the file description specifications. Therefore, any exception/ C* errors that occur on this operation to the AUDITFIL file are C* handled by the default RPG default error handler. C* C WRITEAUDITREC ?????????????????? C " ? Calculations ? C* ?????????????????? *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* C* C* No exception/error indicator is specified in positions 56 and 57 C* of the CHAIN operation to the MSTREC record in the MSTFIL file. C* However, a file exception/error subroutine (MSTERR) is defined C* for the file on the file description specifications. Therefore, C* when an exception or error other than no record found occurs on C* the CHAIN operation, RPG passes control to the MSTERR subroutine. C* On the ENDSR operation for this subroutine, factor 2 contains a C* field name. This allows the programmer to alter the return point C* from the subroutine within the subroutine based on the exception C* or error that occurred. The field must contain one of the values C* described under File Exception/Error Subroutine earlier in C* this chapter. C* CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++* C MSTKEY CHAINMSTREC 61 C 61 GOTO NOTFND C " C " C MSTERR BEGSR ?????????????????? C " ? Calculations ? C " ?????????????????? C ENDSRRTRPNT C " C " C ERRRTN BEGSR ?????????????????? C " ? Calculations ? C " ?????????????????? C ENDSR

Figure 1. Example of File Exception/Error Handling Figure 2 shows an example of a program exception/error subroutine.

*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* IDsname....NODsExt-file++.............OccrLen+......................* I SDS I *ROUTINE LOC I *STATUS ERR I *PARMS PARMS I *PROGRAM NAME *.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ..* CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++* C *PSSR BEGSR

C C C C C

ERR 20 20 N20

COMP 102 ADD 1 MOVE '*DETC' MOVE '*CANCL' ENDSRRETURN

20 DIV BY ZERO? DIVSR RETURN RETURN 6

Figure 2 Example of *PSSR Subroutine The program-status data structure is defined on the input specifications. The predefined subfields *STATUS, *ROUTINE, *PARMS, and *PROGRAM are specified, and names are assigned to the subfields. The *PSSR subroutine is coded on the calculation specifications. If a program exception/error occurs, the RPG/400 compiler passes control to the *PSSR subroutine. The subroutine checks to determine if the exception or error was caused by a divide operation in which the divisor is zero. If it was, indicator 20 is set on, 1 is added to the divisor (DIVSR), and the literal '*DETC'. is moved to the field RETURN. Moving the literal into the RETURN field, which is specified in factor 2 of the ENDSR operation, allows you to control the return point within the subroutine. In this example, control returns to the beginning of the detail calculations routine, unless the exception or error was not a divide by zero. In that case, the literal '*CANCL' is moved into the RETURN field, and the program is ended.

What is Level Check ? Because RPG/400 programs are dependent on receiving an externally described file whose format agrees with what was copied into the program at compilation time, the system provides a levelcheck function that ensures that the format is the same. The RPG/400 program always provides the information required by level checking when an externally described DISK, WORKSTN, or PRINTER file is used. The level-check function can be requested on the create, change, and override file commands. The default on the create file command is to request level checking. Level checking occurs on a record-format basis when the file is opened unless you specify LVLCHK(*NO) when you issue an override command or create a file. If the level-check values do not match, the program is notified of the error. The RPG/400 program then handles the OPEN error as described in "Exception/Error Handling" The RPG/400 program does not provide level checking for program-described files or for files using the devices SEQ or SPECIAL.

How does the file locking done by RPG ? The OS/400 system allows a lock state (exclusive, exclusive allow read, shared for update, shared no update, or shared for read) to be placed on a file used during a job. Programs within a job are not affected by file lock states. A file lock state applies only when a program in another job tries to use the file concurrently. The file lock state can be allocated with the CL command ALCOBJ (Allocate Object). The OS/400 system places the following lock states on database files when it opens the files:

??????????????????????????????????????????????????????????? ? File Type ? Lock State ? ??????????????????????????????????????????????????????????? ? Input ? Shared for read ? ??????????????????????????????????????????????????????????? ? Update ? Shared for update ? ??????????????????????????????????????????????????????????? ? Add ? Shared for update ? ??????????????????????????????????????????????????????????? ? Output ? Shared for update ? ???????????????????????????????????????????????????????????

The shared-for-read lock state allows another user to open the file with a lock state of shared for read, shared for update, shared no update, or exclusive allow read, but the user cannot specify the exclusive use of the file. The shared-for-update lock state allows another user to open the file with shared-for-read or shared-for-update lock state. The RPG/400 program places an exclusive-allow-read lock state on device files. Another user can open the file with a shared-for-read lock state. The lock state placed on the file by the RPG/400 program can be changed if you use the Allocate Object command.

How does record locking mechanism works with RPG ? When a record is read by a program, it is read in one of two modes: input or update. If a program reads a record for update, a lock is placed on that record. Another program cannot read the same record for update until the first program releases that lock. If a program reads a record for input, no lock is placed on the record. A record that is locked by one program can be read for input by another program. In RPG/400 programs, you use an update file to read records for update. A record read from a file with a type other than update can be read for inquiry only. By default, any record is read from an update file will be read for update. For update files, you can specify that a record be read for input by using one of the input operations CHAIN, READ, READE, READP, or REDPE and specifying an N in column 53 of the calculation specification. When a record is locked by an RPG/400 program, that lock remains until one of the following occurs: _ the record is updated. _ the record is deleted. _ another record is read from the file (either for inquiry or update). _ a SETLL or SETGT operation is performed against the file _ an UNLCK operation is performed against the file. _ an output operation defined by an output specification with no field names included is performed against the file. Note: An output operation that adds a record to a file does not result in a record lock being released.

If your program reads a record for update and that record is locked through another program in your job or through another job, your read operation will wait until the record is unlocked. If the wait time exceeds that specified on the WAITRCD parameter of the file, an exception occurs. If the default error handler is given control when a record lock timeout occurs, an RPG1218 error message will be issued. One of the options listed for this message is to retry the operation on which the timeout occurred. For programs compiled for version 2 (or higher) this will cause the operation on which the timeout occurred to be re-issued, allowing the program to continue essentially as if the record lock timeout had not occurred. Note that if the file has an INFSR specified in which an I/O operation is performed on the file before the default error handler is given control, unexpected results can occur if the input operation that is retried is a sequential operation, since the file cursor may have been modified. With programs compiled using version 1 of the RPG/400 compiler, the retry option is still displayed, but it is not valid. If a retry is requested for a version 1 program, an additional error message (RPG1918) is issued indicating that a retry is not valid for programs compiled using version 1. In all cases, if control is returned to the program by specifying a return to *GETIN, the RPG STATUS value is set to 1218. If a retry is specified and the subsequent read operation is successful, the STATUS returns as if the record lock and subsequent retry did not occur. If no changes are required to a locked record, you can release it from its locked state using the UNLCK operation or by processing output operations defined by output specifications with no field names included. These output operations can be processed by EXCPT output, detail output, or total output.

How do you block output records and unclock input records ? Unblocking Input Records and Blocking Output Records The RPG/400 compiler unblocks input records and blocks output records to improve run-time performance in SEQ or DISK files if: _ The file is an output-only file (O is specified in position 15 of the file description specifications) and contains only one record format if the file is externally described. _ The file is a combined table file. (C is specified in position 15, and T in position 16 of the file description specifications.) _ The file is an input-only file. (I is specified in position 15 of the file description specifications.) It contains only one record format if the file is externally described, and uses only the OPEN, CLOSE, FEOD, and READ operation codes. The RPG/400 compiler generates object program code to block and unblock records for all SEQ or DISK files that satisfy these conditions. Certain OS/400 system restrictions may prevent blocking and unblocking. In those cases, performance is not improved and the input/output feedback area is updated for each input/output operation. The contents of positions 60 through 65 of the RECNO option in the file description specifications continuation line may not be valid when the RPG/400 compiler blocks and unblocks records.

The input/output and device-dependent sections of the file information data structure are not updated after each read or write for files in which the records are blocked and unblocked by the RPG/400 compiler. The feedback area is updated each time a block of records is transferred.

What happens when Sharing an Open Data Path ? An open data path is the path through which all input and output operations for a file are defined. Usually a separate open data path is defined each time a file is opened. If you specify SHARE(*YES) for the file creation or on an override, the first program's open data path for the file is shared by subsequent programs that open the file concurrently. The position of the current record is kept in the open data path for all programs using the file. If you read a record in one program and then read a record in a called program, the record retrieved by the second read depends on whether the open data path is shared. If the open data path is shared, the position of the current record in the called program is determined by the current position in the calling program. If the open data path is not shared, each program has an independent position for the current record. If your program holds a record lock in a shared file and then calls a second program that reads the shared file for update, you can release the first program's lock by performing a READ operation on the update file by the second program, or by using the UNLCK or the read-no-lock operations. Sharing an open data path improves performance because the OS/400 system does not have to create a new open data path. However, sharing an open data path can cause problems. For example, an error is signaled in the following cases: _ If a program sharing an open data path attempts file operations other than those specified by the first open (for example, attempting input operations although the first open specified only output operations) _ If a program sharing an open data path for an externally described file tries to use a record format that the first program ignored _ If a program sharing an open data path for a program described file specifies a record length that exceeds the length established by the first open. When several files in one RPG/400 program are overridden to one shared file at run time, the file opening order is important. In order to control the file opening order, you should use a programmer-controlled open or use a CL program to open the files before calling the RPG/400 program. If a program shares the open data path for a primary or secondary file, the program must process the detail calculations for the record being processed before calling another program that shares that open data path. Otherwise, if lookahead is used or if the call is at total time, sharing the open data path for a primary or secondary file may cause the called program to read data from the wrong record in the file.

You must make sure that when the shared file is opened for the first time in a job, all of the open options that are required for subsequent opens of the file are specified. If the open options specified for subsequent opens of a shared file are not included in those specified for the first open of a shared file, an error message is sent to the program. Table 1 details the system open options allowed for each of the open options you can specify.
?????????????????????????????????????????????????????????????????????????? ? Table 1. System Open Options Allowed with User Open Options ? ?????????????????????????????????????????????????????????????????????????? ? RPG User ? System ? ? Open Options ? Open Options ? ?????????????????????????????????????????????????????????????????????????? ? INPUT ? INPUT ? ?????????????????????????????????????????????????????????????????????????? ? OUTPUT ? OUTPUT (program created file) ? ?????????????????????????????????????????????????????????????????????????? ? UPDATE ? INPUT, UPDATE ? ?????????????????????????????????????????????????????????????????????????? ? DELETE ? DELETE ? ?????????????????????????????????????????????????????????????????????????? ? ADD ? OUTPUT (existing file) ? ??????????????????????????????????????????????????????????????????????????

1. Why Subprocedures are Used ? Ans. A Subprocedures can define their own local variables. B Subprocedures can accept parameters. C Subprocedures provide parameter checking D Subprocedures can be used as a user defined function. E You can call the subprocedure from outside the module, if it is exported. F Subprocedures provides multiple entry points within the same RPG module. 2. Can you use a subprocedure in an subprocedure ? Ans. Yes 3. What are the specifications used in a subprocedure ? Ans. P D C only. 4. How many ways a subprocedure can pass parameters ? Ans. By reference (default) By value (keyword VALUE on the parameter definition) By read-only reference (keyword CONST on the parameter definition) 5. What is a Module ? Ans:- Modules are objects of *MODULE type that are created by the compiler when the Create RPG Module (CRTRPGMOD) command is performed. A module can be composed of a main procedure (also referred to as main program) and/or one or more subprocedures. The term procedure often designates a subprocedure or a main procedure. A module is sometimes called compilation unit as it comes from compilation of one source member. Modules are not executable, they only serve as building blocks for program creation. The process of program creation is called binding. Bound programs are executable objects of *PGM type. To bind modules into a program, the Create Program (CRTPGM) command is used. If an RPG IV program does not call subprocedures, or external modules, the Create Bound RPG Program (CRTBNDRPG) command will do for both compilation and binding. This is the case, for example, of an RPG IV program resulting from converting an RPG III program by the CVTRPGSRC command. 6. What is a Service Program ? Ans:- If you have procedures that are called by more than one program, you could bind them individually to each of the programs. In such a case, they would occupy space in each program and would be difficult to maintain. If you group the procedures in a service program instead, the procedures occur only once and can be easily maintained. Service programs are objects of *SRVPGM type which are created by the Create Service Program (CRTSRVPGM) command. A service program is simply a collection of modules especially those containing subprocedures. Service programs cannot be directly called, however, the procedures contained in it may be called by ILE programs. Service programs are built by binding, much like programs, but they need to be further bound to a program before they are used. This is done by the CRTPGM command. Service programs can also be bound to other service programs. The top service program in such a group is eventually bound to a program using the CRTPGM command. 7. What is a binding Directory ? Ans:- Binding directories are objects of *BNDDIR type. Binding directories can be used as an additional source of exports. A binding directory contains a list of modules and service

programs that are candidates for automatic binding. Not all items of the list in the binding directory are necessarily bound. Only those required by imports that cannot otherwise be resolved are bound. Modules and service programs listed in a binding directory often contain standard procedures, for example mathematical functions or other system procedures. We can create their own binding directories using special CL command CRTBNDDIR. 8. Why Import and Export ? Ans:- A service program makes its own modules and procedures available to external users through a mechanism called export. The external users are modules and subprocedures in external programs and other service programs that use (call) the modules and subprocedures of the service program to call them. The external users are also called public or clients. Main procedures of modules comprising the service program are exported automatically (implicitly), the programmer do not need to use any special specifications to make a main procedure available to external users. A service program exports its own subprocedures by specifying the EXPORT keyword in the subprocedure definition. However, in order to bring this specification in effect, the binding command (CRTSRVPGM) specifies which of the exported procedures are actually made available to external users. Besides modules and subprocedures, variables may be exported (by specifying the EXPORT keyword). Exported modules, subprocedures and variables are collectively called exports. Exports are used in other procedures where they are referred to. The references are also called imports as opposed to the exports that are sometimes called definitions. 9. What is an Activation Group ? Ans:- Activation groups are temporary storage structures placed inside jobs (which themselves are also temporary structures). There are three types of activation groups: default named new Default activation groups exist automatically and are never deleted. There are two default activation groups. Many system programs run in the default activation group 1. RPG IV programs created with the parameter DFTACTGRP(*YES) of the CRTBNDRPG command run in the default activation group. The other types of activation groups are specified by the parameter ACTGRP in program and service program creation commands - CRTPGM and CRTSRVPGM. Thus, the type of an activation group is determined by the program or service program at creation time. An activation group is created when the program is started. An activation group may include: Static and automatic variables The variables of programs running in the activation group. Static variables are those defined in a main procedure. They come from external sources such as DDS or SQL specifications, or they are defined as RPG variables (fields, indicators). One more place you will find static variables is as local variables in subprocedures declared with the STATIC keyword. Automatic variables are local variables defined in subprocedures. Open data paths (ODP) Temporary objects representing open files to programs. Data buffer and pointer to a record are part of the ODP.

Dynamically allocated storage Temporary object created by the ALLOC operation in the RPG IV program. Error handling routines System or user programs (modules) handling error messages. Programmers can write their own modules to handle error messages coming from any procedure in the call stack, no matter in which programming language the procedure is written. Notice that the program stack has been renamed to call stack. 10. Name Some ILE APIs ? And Tell something about them ? Ans The List Module Information (QBNLMODI) API lists information about modules. The information is placed in a user space specified by you. This API is similar to the Display Module (DSPMOD) command. You can use the QBNLMODI API to: List the symbols defined that can be exported to other modules List the symbols that are defined external to the module List procedure names and their type List objects that are referenced when the module is bound into an ILE program or service program List copyright information 2. The List Service Program Information (QBNLSPGM) API gives information about service programs, similar to the Display Service Program (DSPSRVPGM) command. The information is placed in a user space specified by you. You can use the QBNLSPGM API to: List modules bound into a service program List service programs bound to a service program List data items exported to the activation group List data item imports that are resolved by weak exports that were exported to the activation group List copyrights of a service program List procedure export information of a service program List data export information of a service program List signatures of a service program 3. The List ILE Program Information (QBNLPGMI) API gives information about ILE programs, similar to the Display Program (DSPPGM) command. The information is placed in a user space specified by you. You can use the QBNLPGMI API to: List modules bound into an ILE program List service programs bound to an ILE program List data items exported to the activation group List data item imports that are resolved by weak exports that were exported to the activation group List copyrights of an ILE program You can, for example, list signatures of service programs bound in a program using the QBNLSPGM API to get the "old" signatures. You can also list all "new" signatures of these service programs using the QBNLPGMI API and compare the two lists if they match. If there is some mismatch, you can trigger a new binding of the program (by performing the CRTPGM command). Be prepared to inspect lists of lists in some cases because the information retrieved by these APIs is organized hierarchically. 11. What do we mean by externalizing? Ans. By externalizing we mean that all READ, CHAIN, and other database operations are located in separate routines and programs that require I/O make requests to these routines to perform the operation on their behalf.

12. Why externalize? Ans. Why would you want to do this? Perhaps we can best answer that question by posing one of our own. Suppose that during discussions with your users, it becomes apparent to you that the business needs have changed. After having studied the new requirements for a while, you realize that you need to redesign the database to accommodate these changes. Would you: Modify your database and then locate all relevant I/O operations and modify them as required. Decide that doing the right thing is just too much work, and just "hack" the database one more time. Externalizing the I/O operations of databases provides one way of helping to ensure that your applications can adapt quickly and (relatively) painlessly to changing business needs. Instead of coding a READ, CHAIN, or whatever at each point in the program where database access is required, you invoke a routine to perform the I/O for you. 13. Tell me the differences between DB2 CLI (call Level Interface ) and embedded SQL ? Ans. An application that uses an embedded SQL interface requires a precompiler to convert the SQL statements into code, which is then compiled, bound to the database, and executed. In contrast, a DB2 CLI application does not require precompilation or binding, but instead uses a standard set of functions to execute SQL statements and related services at runtime. This difference is important because, traditionally, precompilers have been specific to a database product, which effectively ties your applications to that product. DB2 CLI enables you to write portable applications that are independent of any particular database product. This independence means a DB2 CLI application does not have to be recompiled or rebound to access different database products, but rather selects the appropriate one at runtime. DB2 CLI can execute any SQL statement that can be prepared dynamically in embedded SQL. This is guaranteed because DB2 CLI doesn't actually execute the SQL statement itself, but passes it to the DBMS for dynamic execution. 14. How do you invoking a stored procedure ? Ans. To invoke a stored procedure we use the SQL CALL statement. This statement contains the name of the stored procedure and any arguments passed to it. Arguments may be constants, special registers, or host variables. Here is an example how to call stored procedure and pass two arguments: /Exec Sql
CALL mylib/procname (:PARTNUM, :PARTDES)

/End-Exec Easiest way to return a completion status to the SQL program issuing the CALL statement is to code an extra INOUT type parameter and set it prior to returning from the procedure. Another, more complicated method of returning a completion status is to send an escape message to the calling program (operating system program QSQCALL) which invokes the procedure. 15. Is there any cycle code generated for the sub procedure ? Ans . No . Not generated.

16. Explain me about the ILE RPG Cycle steps ? Ans. 1. RPG processes all heading and detail lines (H or D in position 17 of the output specifications). 2. RPG reads the next record and sets on the record identifying and control level indicators. 3. RPG processes total calculations (conditioned by control level indicators L1 through L9, an LR indicator, or an L0 entry). 4. RPG processes all total output lines (identified by a T in position 17 of the output specifications). 5. RPG determines if the LR indicator is on. If it is on, the program ends. 6. The fields of the selected input records move from the record to a proc-essing area. RPG sets on field indicators. 7. RPG processes all detail calculations (not conditioned by control level indicators in positions 7 and 8 of the calculation specifications). It uses the data from the record at the beginning of the cycle. The first cycle The first and last time through the program cycle differ somewhat from other cycles. Before reading the first record the first time through the cycle, the program does three things: handles input parameters, opens files, initializes program data writes the records conditioned by the 1P (first page) indicator processes all heading and detail output operations. For example, heading lines printed before reading the first record might consist of constant or page heading information, or special fields such as PAGE and *DATE. The program also bypasses total calculations and total output steps on the first cycle. The last cycle The last time a program goes through the cycle, when no more records are avail-able, the program sets the LR (last record) indicator and the L1 through L9 (control level) indicators to on. The program processes the total calculations and total output, then all files are closed, and then the program ends.

17. What are the Important frequently used commands in ILERPG environment ? Ans.

Commonly Used CL Commands


Action
Using System Menus GO MAIN GO INFO GO CMDRPG GO CMDCRT GO CMDxxx CALL CRTxxxMOD CRTBNDxxx CRTPGM CRTSRVPGM UPDPGM STRDBG ENDDBG CRTPRTF CRTPF CRTSRCPF CRTLF

CL command

Result

Calling Compiling Binding modules Debugging Creating Files

Display main menu Display help menu List commands for RPG List commands for creating List commands for 'xxx' program-name Runs a program Creates xxx Module Creates Bound xxx Program Creates a program from ILE Creates a service program Updates a bound program object Starts ILE source debugger Ends ILE source debugger Creates Print File Creates Physical File Creates Source Physical File Creates Logical File

18. What is CODE/400 / Visual Age ?? Ans. ADTS CS (for Windows) is a workstation product that includes two server access programs: * CoOperative Development Environment/400 (CODE/400) * VisualAge for RPG CODE/400 contains features to help edit, compile, and debug: RPG, ILE RPG, COBOL, ILE COBOL, Control Language (CL), ILE C, and ILE CL host source programs; design display, printer, and database host files; and manage the components that make up your application. This enhances program development and moves the program development workload off the host. The application, when built, runs on an AS/400. For RPG and ILE RPG application development and maintenance, CODE/400 provides: * Language sensitive editing includes token highlighting, format lines, a full suite of prompts, and online help. * Incremental syntax checking provides immediate error feedback as each line of source is entered * Program verification performs, at the workstation, the full range of syntax and semantic checking that the compiler does, without generating object code * Program conversion performs, at the workstation, an OPM to ILE RPG conversion * A windowed environment for submitting host compiles and binds * Source-level debugging * A DDS design utilityallows you to easily change screens, reports, and database files * Access to Application Dictionary Services. Visual Age for RPG offers a visual development environment on the workstation platform for RPG application developers to develop, maintain, and document client/server applications. Applications can be edited, compiled, and debugged on your workstation. The applications, when built, are started on a workstation and can access AS/400 host data and other AS/400 objects. Its integrated components allow application developers to preserve their current skills and easily develop AS/400 RPG applications with graphical user interfaces. 19. What is a Main Procedure and a sub procedure ?

Ans. An ILE RPG module consists of a main procedure and zero or more subprocedures. ( If there are subprocedures, the main procedure is optional.) A main procedure is a procedure that can be specified as the program entry procedure (and so receive control when an ILE program is first called). The main procedure is defined in the main source section, which is the set of H, F, D, I, C, and O specifications that begin a module. In V3R1, all ILE RPG modules had a main procedure and no other procedures. A subprocedure is a procedure that is specified after the main source section. A subprocedure differs from a main procedure primarily in that: * Names that are defined within subprocedure are not accessible outside the subprocedure. * No cycle code is generated for the subprocedure. * The call interface must be prototyped. * Calls to subprocedures must be bound procedure calls. * Only P, D, and C specifications can be used. Subprocedures can provide independence from other procedures because the data items are local. Local data items are normally stored in automatic storage, which means that the value of a local variable is not preserved between calls to the procedure. Subprocedures offer another feature. You can pass parameters to a subprocedure by value, and you can call a subprocedure in an expression to return a value. 20. What are the ILE RPG coding programming considerations ? Ans. Coding Considerations This section presents some considerations that you should be aware of before you begin designing applications with multiple-procedure modules. The items are grouped into the following categories: * General * Program Creation * Main Procedures * Subprocedures 1. General Considerations * When coding a module with multiple procedures, you will want to make use of /COPY files, primarily to contain any prototypes that your application may require. If you are creating a service program, you will need to provide both the service program and the prototypes, if any. * Maintenance of the application means ensuring that each component is at the most current level and that any changes do not affect the different pieces. You may want to consider using a tool such as Application Development Manager to maintain your applications. For example, suppose that another programmer makes a change to the /COPY file that contains the prototypes. When you request a rebuild of your application, any module or program that makes use of the /COPY file will be recompiled automatically. You will find out quickly if the changes to the /COPY file affect the calls or procedure interfaces in your application. If there are compilation errors, you can then decide whether to accept the change to prototypes to avoid these errors, or whether to change the call interface. 2. Program Creation

* If you specify that a module does not have a main procedure then you cannot use the CRTBNDRPG command to create the program. (A module does not have a main procedure if the NOMAIN keyword is specified on a control specification.) This is because the CRTBNDRPG command requires that the module contain a program entry procedure and only a main procedure can be a program entry procedure. * Similarly, when using CRTPGM to create the program, keep in mind that a NOMAIN module cannot be an entry module since it does not have a program entry procedure. * A program that is created to run in the default OPM activation group (by specifying DFTACTGRP(*YES) on the CRTBNDRPG command) cannot contain bound procedure calls. 3. Main Procedure Considerations * Because the main procedure is the only procedure with a complete set of specifications available (except the P specification), it should be used to set up the environment of all procedures in the module. * A main procedure is always exported, which means that other procedures in the program can call the main procedure by using bound calls. * The call interface of a main procedure can be defined in one of two ways: 1. Using a prototype and procedure interface 2. Using an *ENTRY PLIST without a prototype * The functionality of an *ENTRY PLIST is similar to a prototyped call interface. However, a prototyped call interface is much more robust since it provides parameter checking at compile time. If you prototype the main procedure, then you specify how it is to be called by specifying either the EXTPROC or EXTPGM keyword on the prototype definition. If EXTPGM is specified, then an external program call is used; if EXTPROC is specified or if neither keyword is specified, it will be called by using a procedure call. * You cannot define return values for a main procedure, nor can you specify that its parameters be passed by value. 4. Subprocedure Considerations * Any of the calculation operations may be coded in a subprocedure. However, all files must be defined globally, so all input and output specifications must be defined in the main source section. Similarly, all data areas must be defined in the main procedure, although they can be used in a subprocedure. * The control specification can only be coded in the main source section since it controls the entire module. * A subprocedure can be called recursively. Each recursive call causes a new invocation of the procedure to be placed on the call stack. The new invocation has new storage for all data items in automatic storage, and that storage is unavailable to other invocations because it is local. (A data item that is defined in a subprocedure uses automatic storage unless the STATIC keyword is specified for the definition.) 21. Tell me the difference between the CALL, CALLB and CALLP ? 22. What is a Program Temporary Fix (PTF)? 23. What way ILERPG differs with RPG/400 ?

24. What opcodes are added in ILE ? Ans. ADDDUR , SUBDUR , EVAL 25. How many modules can become a *SRVPGM max and minimum ? 26. How many subprocedures can be a Module (*MODULE) max and minimum? 27. How many Modules can become a RPGPGM (*PGM) max and minimum? 28. Have you used any change management tool in ILE environment ? If so What is it? 29. Tell me something about call stack ? 30. Behavioral difference b/w OPM RPG/400 and ILE ? Ans. Compared to OPM, ILE provides RPG users with improvements or enhancements in the following areas of application development: * Program creation * Program management * Program call * Source debugging * Bindable application program interfaces (APIs) Each of the above areas is explained briefly in the following paragraphs and dis-cussed further in the following chapters. 31. How do you do debug for ILE programs and Handle Exceptions ? Ans. Create the program EMPRPT so that you can debug it using the source debugger. The DBGVIEW parameter on either CRTBNDRPG or CRTRPGMOD determines what type of debug data is created during compilation. The parameter provides six options which allow you to select which view(s) you want: * *STMT allows you to display variables and set breakpoints at statement locations using a compiler listing. No source is displayed with this view. * *SOURCE creates a view identical to your input source. * *COPY creates a source view and a view containing the source of any /COPY members. * *LIST creates a view similar to the compiler listing. * *ALL creates all of the above views. * *NONE no debug data is created. The source for EMPRPT is shown in Figure 28 on page 54. 1. To create the object type:
CRTBNDRPG PGM(MYLIB/EMPRPT) DBGVIEW(*SOURCE) DFTACTGRP(*NO)

The program will be created in the library MYLIB with the same name as the source member on which it is based, namely, EMPRPT. Note that by default, it will run in the default named activation group, QILE. This program object can be debugged using a source view. 2. To debug the program type:
STRDBG EMPRPT

AS/400 QUESTION BANK 1.Define library? A Library is a collection of objects. Type *LIB that is used to group related object and to find objects by name. A library is a directory to a group of objects. The number of objects contained in a library and the number of libraries on the system are limited only by the amount of storage available. All libraries are placed in the system library QSYS. Libraries provide a method for organizing objects. A library is an open-ended directory. A library can never become FULL as it has no finite size. Libraries themselves are objects. A library contain the object name, type, and the address Library list System library- 15 (QSYSLIB) QSYS QHLPSYS QUSRSYS Product library 2 Current library 1 User library - 25 (QUSRLIB) QGPL QTEMP MYLIB When you logon the first library to be load is QSYS. The system library is loaded at the first time. 2.Define object? Every thing that can be stored or retrieved on the system is known as an OBJECT. Objects exit to make users independent of the implementation used in the machine. The create object instruction establish the objects name and its type. All objects are structured with a common object header, and a type dependent functional portion. A user is not concerned with the space his object occupies. The system allocate space automatically WRKOBJPDM is used to display all object in such a library The library the object name and its type is Unique. 3.Define 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.Define physical file? It is a file, which physically occupies the portion of memory. A physical file contains one record format and one or more members. Its type PF. By using CRTPF command to create PF. Maximum number of fields included in a PF is 8000. Maximum no of key fields included is 120.

5.Define logical file?


Logical file does not occupies any memory space and logical file be derived from physical file. One or more logical file can be derived from a single physical file. A logical file can contain up to 32 record formats. It selects records dynamically. It cannot exist with out a physical file. 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 creating access path.

A logical file does not contain any data but provides the VIEWS of the data to satisfy endusers needs. There are two types Non join logical file Join logical file 6.Difference between physical file and logical file? Physical file Logical file

1. Occupies the portion of memory. Its Does not occupy any memory space. Does containing data. not contain any data. 2. A physical file contains one record A logical file can contain up to 32 record format formats.
3.Can be exist even with out LF 4. If you delete a LF, the PF can not be deleted 5.CRTPF command is used to create such object 6.The object type is PF Can not exist with out PF If you delete a LF, the PF can not be deleted CRTLF command is used to create such type object The object type is LF

7. What are the four levels of entries in physical file? (i). File level entries (optional): File level entries give the system information of the entire file. (UNIQUE, LIFO, FIFO, FCFO, REF) UNIQUE: A record cannot be entered or copied into a file if its key value is same as the key value of a record already existing in the file. LIFO: Last in first out FIFO: First in first out FCFO: First change first out. REF: This keyword is used to specify the name of the file from which the field descriptions are retrieved. Ex: you can specify whether the key is unique. (ii). Record format level entries: Record format level entries give the system information about specific record format in the file. For a PF the record format name is specified along with an optional text description. (FORMAT, TEXT) (i) FORMAT: This record-level keyword specifies that the record format being define is to share the field specifications of a previously defined record format. The name of the record format being defined must be the name of the previously defined record format. The format of this keyword is: FORMAT (LIB-NAME / FILE-NAME) (ii) TEXT: This record level keyword is used to supply a text description of the record format and it is used for documentation purposes only. The format of this keyword is: TEXT (description) (iii) Field level entries: The field names and field lengths are specified along with and optional text description for each field. (ALIAS, ALWNULL, CCSID, CHECK,

(iv)

CHKMSGID, CMP, COLHDG, COMP, DATFMT, DATSEP, DFT, EDTCDE, EDTWRD, REFFLD, REFSHIFT, TEXT, TIMEFMT, TIMESEP, VALUES, VARLEN) Key field level entries: The field names used as key fields are specified. (DESCEND, SIGNED, ABSVAL, UNSIGNED, ZONE, NOALTSEQ, DIGIT)

8. What are the six levels of entries in logical file? (i) File level entries (optional): File level entries give the system information of the entire file. You can specify whether the key is same as physical file. (ii) Record format level entries: Record format level entries give the system information about specific record format in the file. for examples ,for a logical file when a record format is described we can specify the physical file it is based on. (iii) JOIN Level entries: Join level entries give the system information about PF used in a JOIN LOGICAL FILE. (It is not applicable to NON JOIN LOGICAL FILES). (iv) Field level entries (optional): The field level entries give the system information about individual fields in the record format. (v) Key field level entries: The key field level entries give the system information about the key fields of a file. The field names used as key fields are specified. (vi) Select / Omit level entries: These entire give the system information about which records are to be returned to the program when processing the file. These specifications apply to logical file only. 9. Explain JDUPSEQ and JDFTVAL. JDUPSEQ: This join level keyword is used to specify the order in which records with duplicate join fields are presented when the JLF is read. The format for this keyword is: JDUPSEQ (Sequencing field-name [*DESCEND]) This keyword has no effect on the ordering of records with unique keys. If *DESCEND is not specified then the default is sequencing in ascending order. JDFTVAL: When this file-level keyword is used the system provides default values for all for 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 the secondary file is skipped. 10. What are the different between non-join logical files and join logical files. Non join logical file We can able to insert or delete or update records using non-logical file. DFU can be used to display non-join logical file. 1-32 record format is specified Commitment control is used Join logical file Insertion, updating or deletion of records is not possible in join logical files. DFU is not available Only one record format can be specified Commitment control cannot be used.

11. How many record formats can have physical & logical file. The physical file only one record format can be specified. The logical file 1-32 record format is specified

12. What is the advantage open query file? Dynamic selection of records It will sort the records based on the field values. We can retrieve records based on Virtual fields. Can create join logical files 13. Explain non-join logical file? Non-join logical files can either be a simple logical file, which contains only one record format or a multiple record format logical file, which contains more than one record format. Logical files can be derived from 1 to 32 physical files and so a logical file can have a maximum of 32 record formats. Single record format logical file: If a logical file is derived from single physical file it is called simple logical fie. Multiple record format logical file: Multiple record non-join logical files will select records from 2 or more physical files by referring to only one logical file. Each record format is always associated with one or more physical file. The same PF can be used in more than one record format. Specify the entries in single or multiple format logical files: 1.File-level entries (optional): (REFACCPTH, DYNSLT) REFACCPTH: The access path information for this logical file is to be copied from another PF or LF. Format of the keyword is: REFACCPTH (LIB name / DATABASE name) DYNSLT: This keyword is selection and omission tests in the file. This keyword specifies dynamic select/omit. 2.Record level entries:(PFILE) PFILE: The physical files containing the data to be accessed through the record formats being defined. Format of the keyword is: PFILE (LIB name / PF name) 3.Field-level entries (optional) 4. Key field level entries (optional) 5.Select and Omit field level entries (optional) REFACCPTHIt is applicable for non-join logical file only and meaning is referring the access path from the PF or LF in the file level entries. PFILE--- it is applicable only for non-join logical file in record level entries. 14. Explain join logical file? A join-logical file is a logical file that combines two or more PF. In the record format not all the fields need to exist in all the PF. A PF cannot be changed through a JLF. DFU cannot be used to display a JLF. Only one record format can be specified in a JLF. Commitment control cannot be used with a JLF. Key fields must be fields defined in the join record format and must be fields from the PRIMARY FILE. Specify the entries in join logical file: 1.File-level entries (optional): (JDFTVAL)

2.Record-level entries: (JFILE) 3.join-level entries :(JOIN, JFLD, JDUPSEQ) 4.field level entries (optional): (JREF, ALL, CONCAT, DYNSLT, RENAME, SST, TRNTBL) 5.Key field level entries (optional) 6.Select and Omit field level entries. (Optional) JFILE----It is similar to indicate that this is a join logical field and it must have more than 2 physical files. JOIN: It is similar that this file level entries to be represent the position of the files .There must one primary file and can have more than I secondary files.. JFLD: Which feels we are going to join. JREF: represents the primary file reference field JDFTVAL: represents that it as a left outer join.
SELECT OMIT Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMIT FMT PF. *************** Beginning of data ******************* 0001.00 R RECSEL 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ****************** End of data ************************ EMPNO EMPNAME 000001 10,001 SHYAM 000002 10,002 SANKA 000003 10,003 SHYAM 000004 10,004 SENTH 000005 10,005 SANKA 000006 10,006 SHYAM 000007 10,007 SANKA 000008 10,008 SENTH 000009 10,009 SHYAM 000010 10,010 SENTH ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF FMT LF... *************** Beginning of data ********************* 0001.00 R RECSEL PFILE (SELOMIT) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 10003) 0004.00 O EMPNAME CMP (EQ 'SHYAM') ****************** End of data ************************** Display Report EMPNO 000001 000002 000003 000004 000005 000006 000007 000008 ****** Columns SEU==> FMT LF 0001.00 0002.00 EMPNAME 10,002 SANKA 10,004 SENTH 10,005 SANKA 10,006 SHYAM 10,007 SANKA 10,008 SENTH 10,009 SHYAM 10,010 SENTH ******** End of report ******** . . . 1 71 Edit SELOMILF

KRAMANAVS/EXAMPLE

*************** Beginning of data ************************ R RECSEL PFILE (SELOMIT) K EMPNO

0003.00 0004.00

O EMPNAME CMP (EQ 'SHYAM') S EMPNO CMP (GT 10001) ****************** End of data ************************

EMPNO 000001 000002 000003 000004 000005 000006 ******

EMPNAME 10,002 SANKA 10,004 SENTH 10,005 SANKA 10,007 SANKA 10,008 SENTH 10,010 SENTH ******** End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMIT FMT PF. *************** Beginning of data ******************* 0001.00 R RECSEL 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ****************** End of data ************************

EMPNO EMPNAME 000001 20 SHYAM 000002 30 RAM 000003 40 TOM 000004 50 RAMESH 000005 60 SHYAM 000006 70 SHYAM 000007 80 TOM 000008 90 TOM 000009 100 VASU ****** ******** End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data ************************ 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 S EMPNAME VALUES ('SHYAM') ****************** End of data **************************

EMPNO

EMPNAME 000001 20 000002 60 000003 70 000004 80 000005 90 000006 100 ****** ********

SHYAM SHYAM SHYAM TOM TOM VASU End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF. *************** Beginning of data ************************ 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 O EMPNO RANGE (20 40) ****************** End of data ***************************

EMPNO EMPNAME 000001 50 RAMESH 000002 60 SHYAM 000003 70 SHYAM 000004 80 TOM 000005 90 TOM 000006 100 VASU ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data **************** 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 S EMPNAME VALUES ('SHYAM') 0005.00 O EMPNO RANGE (70 90) ****************** End of data ******************** EMPNO EMPNAME 000001 20 SHYAM 000002 30 RAM 000003 40 TOM 000004 50 RAMESH 000005 60 SHYAM 000006 70 SHYAM 000007 80 TOM 000008 90 TOM 000009 100 VASU ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data ***************** 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0005.00 O EMPNO RANGE (70 90) ****************** End of data ************************

EMPNO

EMPNAME SHYAM RAM TOM RAMESH SHYAM SHYAM TOM TOM VASU End of report

000001 20 000002 30 000003 40 000004 50 000005 60 000006 70 000007 80 000008 90 000009 100 ****** ********

********

15. Explain self join?


Joining a file to it self is known as self-join.

(Or) A physical file can be joined to itself to read records that are formed by combining two or more records from the PF itself.
Columns . . . 1 71 SEU==> SEJOIN FMT PF Edit KRAMANAVS/EXAMPLE

0001.00 0002.00 0003.00 0004.00 0005.00

*************** Beginning of data ******************** R EMP EMPID 5P 0 EMPNAME 20A MGRID 5P 0 K EMPID ****************** End of data *************************** EMPID EMPNAME MGRID 10,001 SEBI JOSEPH C. 50,001 10,002 PURUSHOTTAM 50,002 10,003 SAMEER DIGHE 50,003 10,004 SHARATA 50,004 10,005 PAUL 50,005 50,001 SHIVARAM 90,001 50,002 GAURAV 90,002 50,003 KING 90,003 50,004 SAM 90,004 50,005 ANIL 90,005 ******** End of report ******** . . . 1 71 Edit KRAMANAVS/EXAMPLE SELJOIN *************** Beginning of data ************************** R EMP JFILE (SEJOIN SEJOIN) J JOIN (1 2) JFLD (MGRID EMPID) EMPID JREF (1) EMPNAME JREF (1) MANAGER RENAME (EMPNAME) JREF (2) COLHDG ('MANAGER') ****************** End of data ***************************** EMPID 10,001 10,002 10,003 10,004 10,005 ******** EMPNAME MANAGER SEBI JOSEPH C. SHIVARAM PURUSHOTTAM GAURAV SAMEER DIGHE KING SHARATA SAM PAUL End of report ********

000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 ****** Columns SEU==> FMT LF 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00

000001 000002 000003 000004 000005 ******

ANIL

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELJOIN1 FMT LF *************** Beginning of data************************ 0001.00 R EMP JFILE (SEJOIN SEJOIN) 0002.00 J JOIN (1 2) 0003.00 JFLD (MGRID EMPID) 0004.00 EMPID JREF (1) 0005.00 EMPNAME RENAME (EMPNAME) 0006.00 JREF (1) 0007.00 MGRID JREF (2) ****************** End of data *************************

EMPID EMPNAME MGRID 000001 10,001 SEBI JOSEPH C. 90,001 000002 10,002 PURUSHOTTAM 90,002 000003 10,003 SAMEER DIGHE 90,003 000004 10,004 SHARATA 90,004 000005 10,005 PAUL 90,005 ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELJOIN1 FMT LF *************** Beginning of data************************ 0001.00 R EMP JFILE (SEJOIN SEJOIN) 0002.00 J JOIN (1 2) 0003.00 JFLD (MGRID EMPID) 0004.00 EMPID JREF (1)

0005.00 MANAGER RENAME (EMPNAME) 0006.00 JREF (2) COLHDG ('MANAGER') 0007.00 MGRID JREF (2) ****************** End of data **************************** EMPID MANAGER MGRID 000001 10,001 SHIVARAM 90,001 000002 10,002 GAURAV 90,002 000003 10,003 KING 90,003 000004 10,004 SAM 90,004 000005 10,005 ANIL 90,005 ****** ******** End of report ********

16. Explain normalization?


It is the process of segregating and decomposing information held within a system into logically grouped, related. Uniquely identifiable entities

17. How to create user define command?


By using the CRTCMD command process the command definition statements to create the command definition object. The CRTCMD command may be run interactively or in a batch job.

Steps for creating CRTCMD commands 1.Enter the command definition statements into the source file Command type CMD
VRAMANA/CLP CMD1 *************** Beginning of data **************************** 0001.00 CMD ****************** End of data *******************************

2. Enter source program in any language


VRAMANA/CLP DLIB TYPE :CLP *************** Beginning of data ****************************** 0001.00 PGM 0002.00 DSPLIBL 0003.00 ENDPGM ****************** End of data *********************************

3. Create the command by using CRTCMD take f4


Command . . . . . . . . . . . . > KS Name Library . . . . . . . . . . . > VRAMANA Name, *CURLIB Program to process command . . . > DLIB Name, *REXX Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Source file . . . . . . . . . . > CLP Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Source member . . . . . . . . . > CMD1 Name, *CMD Threadsafe . . . . . . . . . . . *NO *YES, *NO, *COND Multithreaded job action . . . . *SYSVAL *SYSVAL, *RUN, *MSG, *NORUN Text 'description' . . . . . . . *SRCMBRTXT

18. How do copy a record in existing object to another object? By using CPYF command if you want data one position to another position. We can give the records coping position starting and ending of the records. We want particular records means. We can give the command in sq position. CPYF take F4
File name (source file) : PF01 Lib-name :VRAMANA New file name :PF02 Lib-name :VRAMANA :*FIRST Replace :*ADD :*NO

:*CHAR Start position End position Sql command :1000 :2000 : FILED EMPNO CONDITION *GT VALUE 40 :*MAP(add field) +DROP (delete field)

Record format mapping

19. Explain the command ADDPFCST?


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.

20.How will be establishing REFERENTIAL INTEGTITY in as/400 system? By using ADDPFCST command establish in as/400 system. Referential integrity concepts Referential constraint Parent and dependent files Unique key and primary keys Parent and foreign keys Delete rule Propagate delete from parent file to dependent file Restrict delete on parent file Update rule Restrict inconsistent updates Insert operations on dependent file are checked Referential constraint A referential constraint is a relation between two files, the parent file and the dependent file. This relationship establishes that every record in the dependent file has to have a matching record in the parent file. The key value of any record in the dependent file must match a key value in the parent file. We call parent key the key of the parent file and foreign key the key in the dependent file. The parent key has to be unique and cannot contain null values. The foreign key value has to match one (any only one) value of the parent key. Otherwise the foreign key can contain a null value. A record in the parent file may be related to multiple records in the dependent files; each record in the dependent file has to have just one parent or have a null foreign key. Primary key we means a unique and ascending key, which is the primary, access path for a PF and cannot contain null values. Primary access path for a database file on the AS/400 in the access path used to access the file by using OPNDBF command. Delete rule We can delete a record from parent file or dependent file first check for delete rule. CASCADE: If we want to delete a record from the parent file and its parent key is matching records in a dependent file, the DBMS will delete all the matching records of the dependent file.

SETNULL: If we delete a record from the parent file and parent key is matching some records in a dependent file, the DBMS will set to null the matching keys in the dependent file. SETDEFAULT: This is like previous case, but matching occurrences in the foreign key are set to their default values. The default value for the foreign key has to match a record in the parent file. RESTRICT: The DBMS will prevent any attempt to delete records in the parent file if its key is matching some records in the dependent file. NO ACTION: This has the same meaning as restrict, but different timing. When we use *NOACTION and an invalid delete operation is about to take place, DB2 /400 will delay any error message until the end of the operation itself, allowing for instance the activation of a before trigger attached to the PF. If *restrict is in use, the exception message is sent immediately. Deleting records in a dependent file is always permitted. Update rule RESTRICT: We cannot change the value in a parent key if the old values are matching some records in the dependent file. The remaining portion of the record can always be updated. We cannot update a foreign key in a dependent file if the new value for the key is not null and does not match any value of the parent key. NO ACTION: This is same as * restrict but with different timing considerations. Refer above; where we describe no action delete operations. Inserts There is no insert rule to be chosen, but referential integrity prevents any insert in the dependent file if the new record has no match in the parent file and its foreign key is not null. 21. How to create a trigger in AS/400? The trigger is an event to be performing before or after any change to a database. When a trigger is added to a physical file, three attributes need to be defined. The first is the event that will cause the trigger to fire. A trigger event can be an insert, an update, or a delete a record from the file. The second attribute to define is when to fire the trigger-before or after the event. The third attribute to define is the identification of the trigger program to by run. We can infer that up to six triggers can be defined for each PF. For each update, insert, and delete Two triggers can be defined One that runs before the event One that runs after the event These trigger are added using the ADDPFTRG Can be removed with the remove PF trigger command (RMVPFTRG) The command ADDPFTRG takes F4
PF LIB TRIGGER TIME TRIGGER EVEVT *UPDATE PROGRAM LIB REPLACE TRIGGER ALLOW REPEATED PF001 VRAMANA *AFTER *UPDATE PGM001 VRAMANA *NO *NO *NO *NO

*BEFORE *AFTER *INSERT *DELETE NAME *YES *YES

22.What is the data area? A data area is an object used to store data for access by any job running on the system. it is permanent storage . A data area can be used whenever you need to store information of limited size, independent of the existence of the programs or files. Typical uses of data areas are: To provide an area to pass information within job. To provide a field that is easily and frequently changed to control references within a job such as supplying the next check number. To provide a constant field for use in several jobs, such as tax rate To provide limited access to a large process that requires the data area. A data area can be locked to a single user, thus preventing other users from processing at the same time. To create a general data area use the command (CRTDTAARA) To retrieve values from data area use (RTVDTAARA) To change this value, use (CHGDTAARA) To display the current value, use (DSPDTAARA) To delete a data area use (DLTDTAARA) Type of data area created by the system Local data area Group data area Program initialization parameter (PIP) data area
VRAMANA/RPGILE DAREA *************** Beginning of data ****************************** 0001.00 DS S 10A 0002.00 DG S 10A INZ ('I LIKE YOU') 0003.00 C *DTAARA DEFINE DATA1 S 0004.00 C *LOCK IN S 0005.00 C EVAL S=G 0006.00 C OUT S 0007.00 C S DSPLY 0008.00 C SETON ****************** End of data *********************************** OUTPUT DSPLY I LIKE YOU AUTO NUMBER GENERATION VRAMANA/TEST TESTEX19 *************** Beginning of data ******************************* 0001.00 DA S 4S 0 0002.00 C *DTAARA DEFINE DATA2 A 0003.00 C *LOCK IN A 0004.00 C EVAL A=A+1 0005.00 C OUT A 0006.00 C A DSPLY 0007.00 C SETON 0008.00 C 0009.00 C 0010.00 C ****************** End of data *********************************** OUTPUT DSPLY 5 DSPLY 6

LR

LR

23.Define LDA, GDA, and PIP? LOCAL DATA AREA (LDA) A local data area is created for each job in the system automatically, when you submit a job. Only one LDA can be created by submitting a job.

The system create 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 jobs local data area is copied into the submitted jobs local data area. You can refer to your jobs local data area by specifying *LDA for the DTAARA keyword on the CHGDTAARA, RTVDTAARA, and DSPDTAARA commands or *LDA for the substring built-in function (%SST) The following is true of a local data area: The local data area cannot be refered to from any other job. You cannot create, delete or allocate a local data area. We can to change the contents of LDA by the by using CHGDTAARA command. No library is associated with the local data area. ACCESSING LDA: CHGVAR VAR (%SST (*LDA 3 5)) VALUE(123) OR CHGDTAARA DTAARA (*LDA (3 5)) VALUE(123) CHGVAR VAR(&ROLNO) VALUE( %SST (*LDA 3 5)) OR RTVDTAARA DTAARA (*LDA (3 5)) RTNVAR (&ROLNO) GROUP DATA AREA (GDA) The system creates a group data area when an interactive job becomes a group job. Only one group data area can exist for a group. The group data area is deleted when the last job in the group is ended, or when the job is no longer part of the group job. A group data area, which is initially filled with blanks, has a length of 512 and type *CHAR. The following is true for a group data area You cannot use the group data area as a substitute for a character variable on the substring built-in function. A group data area cannot be refered by jobs outside the group. You cannot create, delete, or allocate a group data area No library is associated with a group data area. Example CHGDTAARA DTAARA (*GDA) VALUE (DECEMBER 1996) RTVDTAARA DTAARA (*GDA) RTNVAR (&GRPARA) PROGRAM INITIALIZATION PARAMETER (PIP) DATA AREA A PIP data area is created for each pre-started job when the job is started. The object sub-type of the PDA is different then a regular data area. The PIP can only be refered to by the special value name *PDA. The size of the PDA is 2000 bytes but the number of parameter contained in it is not restricted.

24. What are various steps accessing data area in CL? The first create a general data area use the command (CRTDTAARA) To retrieve values from data area use (RTVDTAARA)

To change this value, use (CHGDTAARA) To display the current value, use (DSPDTAARA) To delete a data area use (DLTDTAARA) 25. Various types of message available in CL? Message is the interface between operating system and the programs or user and program. We can classify the message into two types namely Immediate message Predefined message Immediate message Which does the program or system user create when they are sent and are not permanently stored in the system? Control language SNDUSRMSG SNDPGMMSG SNDMSG SNDBRKMSG Display files ERRMSG SFLMSG INQUIRY and INFORMATIONAL message: Using SNDUSRMSG command to send type of message Predefined message Which are created before they are used. These messages are placed in a message file (queue) when they are created, and retrieved from the file when they are used. Control language SNDUSRMSG SNDPGMMSG RTVMSG Display files ERRMSGID SFLMSGID MSGCON MSGID COMPLETION and DIAGNOSTIC message Using SNDPGMMSG command these of message can be sent to any message queue. DIAGNOSTIC message tell the calling program about errors detected by the program. Completion message tell the result of work done by the program. STATUS messages Using SNDPGMMSG command status message can be sent to its callers program message queue or to the external message queue for the job. These message tell the receiving program the status of the work performed by the sending program. ESCAPE message

Using SNDPGMMSG command escape message from a CL program can be sent to its calling program. An escape message tells the calling program ended abnormally and why. NOTTFY message Notify message from a CL program can be sent to the message queue of calling program or to the external message queue. A notify message tells the calling program about a condition under which processing can continue. Predefined message are stored in message file To create a message file CRTMSGF MSGF (MFILE) SIZE () AUT() TEXT () Create and maintain messages ADDMSGD CHGMSGD OR WRKMSGD DSPMSGD RMVMSGD Message file QCPFMSG in library QSYS contain the system message 26. What will MONMSG command in do? The monitor message (MONMSG) command monitors the message send to the program message queue for the conditions specified in the command. If condition exists, the CL command specified on the MONMSG command is run. Types of monitor message Escape Message Status or Notify Message Escape Message Escape message are send to tell your program of am error condition that forced the sender to end. By monitoring for escape message, you can take corrective actions or clean up and end your program. Status or Notify Message Status and notify message are send to tell your program of an abnormal condition that is not serious enough for sender to end. By monitoring for status or notify message, your program can detect this condition and not allow the function to continue. Two levels of MONMSG command Program level Specific command level

Program level The MONMSG is specified immediately following the last declare command in your CL program. You can use as many as 100 program-level MONMSG commands in a program. Specific command level Here the MONMSG command immediately follows a CL command. You can use as many as 100 commands-level MONMSG commands for a single command.

Monitor message command syntax MONMSG MSGID () MSGID-Required Ex: MSGID (MCH1211)

CMPDTA ()

EXEC ()

CMPDTA (Optional) Ex: MONMSG MSGID (MCH1211) CMPDTA (LIB) EXEC - -(Optional) CL command 27 What are the disadvantages of using CL over RPG? We can able to read only records but we cannot able to write or update or delete records. We can have only one file to be used in a CL program We cannot able to use printer files in CL We cannot able to use subfile in a CL program 28 How you can read and write single command in CL? By using SNDRCVF command. Example Type: CLP
VRAMANA/CLP ADD *************** Beginning of data ******************************** 0000.01 /*ADDING TWO NUMBERS */ 0001.00 PGM 0002.00 DCLF FILE(VRAMANA/CLPSCR) RCDFMT(SECLP) 0003.00 SNDRCVF RCDFMT(SECLP) 0004.00 CHGVAR VAR(&RES) VALUE(&NUM1 + &NUM2) 0005.00 SNDRCVF RCDFMT(SECLP) 0006.00 ENDPGM ****************** End of data ********************************** OUTPUT FIRST NUMBER: 12 SECOND NUMBER: 12 ---------RESULT= 0000024 ----------

29 How to retrieve a date in CL? By using RTVSYSVAL command we can get the system dates. For getting date QDATE. The various format of date are *DMY, *MDY, *YMD, *YYMD, *JOL, *JOB 30 How to send the message to the screen SNDPGMMSG? BY passing unique message ID message data and message file. SNDPGMMSG syntax SNDPGM MSG MSGID (MSG0001) MSGF (MSGSUB)

31 What is the open query file? It is a dynamic record selection. The OPNQRYF command acts as a filter between the processing program and the database records. The database file can be a PF or LF. It will create open data pathway to access (retrieve) data file. The OPNQRYF command creates only a temporary file for processing the data; it does not create a permanent file. If you want to specify any SQL operation within a CL we have to use OPNQRYF Functions supplied by OPNQRYF are: Dynamic record selection. 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 Final total-only processing Improving performance Open query identifier (ID) 32. What is the different between OPNQRYF and SQLRPG? OPNQRYF SQLRPG

OPNQRYF will come along with OS/400 We need to have SQLRPG installed in system and no need to have any as/400 system which involves additional cost to the programmers additional package needed to execute it OPNQRYF is faster as compared to It is slower SQLRPG OPNQRYF is nothing but a dynamic SQLRPG is imbedding SQL statements logical files will be created and the directly within SQL statement records

33. What are the various steps in creating OPNQRYF? Totally five steps involve in creating OPNQRYF OVRDBF FILE (file PF) TOFILE (LIB/ PF) SHARE (*Yes) If a PF is having 100 records and if we want to override the PF so that it continues only the specific number of records we are using OVRDBF OPNQRYF FILE (LIB / PF) QRYSLT (EMPNO *EQ *BCAT &A) If you want to perform any SQL operation we have to declare in OPNQRYF command only. In case of OPNQRYF we can perform expression only based on characters but not on numeric. *BCAT

If you want to perform any charter expression are using *BCAT expression which will provide a blanks in between the 2 variables. %WLDCRD It is similar to %LIKE in SQL QRYSLT (EMPNAME *EQ %WLDCRD (S* )) It will fetch all the records whose empname starts from S. *CT It will fetch all the records, which conditions the particular charter. QRYSLT (EMPNAME *CT S ) %RANGE It will fetch the records within the specific range QRYSLT (EMPNO *Eq %RANGE (100 110)) CALL PGM (LIB/NAME) PARM () DLTOVR As we see early the main file logically overridden and after performing the necessary operation, we have to delete the logical file so that the main file contains the actual records for this DLTOVR will be used. DLTOVR FILE (OPNPF) CLOF We have to close the file, which has been opened CLOF OPNID (OPNPF) You will copy overridden file records using CPYFRMQRYF CPTFRMQRYF Since OVRDBF is logical we cannot able to list the variables, which satisfy the query condition. To see the records being selected we have to copy from the source file to a temporary file for this CPYFRMQRYF will be used CPYFRMQRYF FROMOPNID (OPNPF) TOFILE (LIB/NAME) MBR (*REPLACE) CRTFILE (*YES) FMTOPT (*NOCHK) RUNQRY We have copied the contents satisfy the query into a temporary file using CPYFRMQRYF. If we run the destination file we got the actual records, which satisfy the query. RUNQRY QRYFILE (LIN/NAME) Example: Database PF
VRAMANA/CLP OPENF *************** Beginning of data **************************** C UNIQUE C R OPNQFILE C OEMPNO 5S 0 C OEMPNAME 20A C OADDRESS 20A C ODOB 8S 0 C K OEMPNO ****************** End of data ******************************** Data file 0000.01 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00

Display Report
OEMPNO OEMPNAME OADDRESS ODOB

000001 1,001 RAMANAV 000002 1,002 KUMAR 000003 1,003 SHYAM 000004 1,004 RAMESH 000005 1,005 BALU 000006 1,007 KUMAR ****** ******** End of report CL program

SALEM1 TRICHY SALEM SALEM SALEM JJ ********

1,232,002 12,123,000 12,345,000 1,010,100 222 32,938

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0006.01 0006.02 0006.03 0006.04 0009.00 0010.00 0010.01 0011.00

VRAMANA/CLP OPNQFILE5 *************** Beginning of data ********************************* PGM DCL VAR(&A) TYPE(*CHAR) LEN(5) DCLF FILE(VRAMANA/OPNQFILE3) RCDFMT(OPNF3) SNDRCVF RCDFMT(OPNF3) CHGVAR VAR(&A) VALUE(&OEMPNO) OVRDBF FILE(OPENF) SHARE(*YES) OPNQRYF FILE((VRAMANA/OPENF)) QRYSLT('OEMPNO *EQ' + *BCAT &A) CPYFRMQRYF FROMOPNID(OPENF) TOFILE(VRAMANA/TEMP) + MBROPT(*REPLACE) CRTFILE(*YES) DLTOVR FILE(OPENF) CLOF OPNID(OPENF) RUNQRY QRYFILE((VRAMANA/TEMP)) ENDPGM ****************** End of data*********************************

OUTPUT EMPLOYEE NUMBER: 1001 OEMPNO OEMPNAME OADDRESS SALEM1 ******** ODOB 1,232,002

000001 1,001 RAMANAV ****** ******** End of report

34. How the records are accessed for using OPNQRYF? By creating open data pathway to access (retrieve) data file. 35. What is the journal? Any changes in PF will be recorded. A journal is an object of type *JRN which detects and records that cause a PF to change. The information recorded by the journal is stored in an object *JRNRCV called journal receiver. 36. What are the various steps creating journal? The steps to start journaling Create a journal receiver - CRTJRNRCV Create a journal - CRTJRN Start journaling of a PF -STRJRNPF Backup the PF -SAVOBJ The steps to end journaling End journaling a PF -ENDJRNPF Delete a journal -DLTJRN Delete the last journal receiver -DLTJRNRCV Save journal receivers -SAVOBJ The commands used for house keeping purposes Change journal -CHGJRN

Save object -SAVOBJ Delete a journal receiver -DLTJRNRCV The commands used in case of a failure are Display journal entries -DSPJRN Apply journal changes -APYJRNCHG Remove journal changes -RMVJRNCHG Restore a saved object -RSTOBJ 37. How you can list all the LF of a PF? By using DSPDBR command it is to list all the files, which are related to a PF. It displays all the LF that is referring the PF and also lists the child table if it is having a relation through ADDPFCST. 38. What is use of DSPFFD and DSPFD? DSPFD (display file description) It is used to display the details about the file when it is created. DSPFFD (display file field description) It is used for listing details about individual fields. 39. What is the data queue? It is a temporary storage. We can able to store and retrieve the data, but once data is retrieved the data is lost. First create the data queue by using CRTDTAARA command Sending a message to a data queue (QSNDDTAQ, QRCVDTAQ, And CLRDTAQ) Data query is nothing but a queue in which are program can send a data and other program or the same program can receive the program. QSNDDTAQ is stored in QSYS.

40. Explain QSNDDTAQ and QRCVDTAQ? QSNDDTAQ By using this command sent data same / another program. QSNDDTAQ PARM (QUEUE NAME LIB &LEN &DAT) QRCVDTAQ By using this command receive data same /another program QRCVDTAQ PARM (QUEUE NAME LIB &LEN &DAT &WAIT)
41. What are the mandatory parameters for declaring a Data queue? QUEUE NAME LIB NAME LENGTH DATA WAIT 42. What will RUNSQLSTM will do? If we want to execute set of SQL statement then we can write all the SQL statement to be including with the source. Type as SQL Only insert, update and delete and no select is allowed. Then use STRSQLSTM to execute the program RUNSQLSTM SRCFILE (LIB/TEST) SRCMBR (SQL01) COMMIT (*NONE)

43. What is a field reference file? This is PF, which does not have any data and contains only the field descriptions and these fields are referred in other PF by using REF and REFFLD

44. What is the difference between OPM, EPM and RPGLE? OPM Original program model is the old RPG/400 system, which will not allow a program type to call another program type. Like CL, RPG, COBOL, PL/I, BASIC only supported. EPM Extended program model will support C, PASCAL, FORTRAN and another programming concepts. RPGLE It supports mixed program support in which you can combine any program with another type of program. it supports modularity, copy book, better call performance. Version is V2R3

Version is V1R2

45. Explain WRKOBJPDM and DSPOBJD? WRKOBJPDM If we want to list all the source PF or files of particular type the WRKOBJPDM with file type as PFSRC for source PF IOR *file for listing all the files extra can be given DSPOBJD If we know library name and object name and we want to know the source PF where it is residing then DSPOBJD with option as *services instead of basic will give the source PF name 46. How to create RPG, RPGLE, CL, CLLE, PF, LF, PRN, and display file? RPG -by using CRTRPGPGM command RPGLE -by using CRTBNDRPG Command (or) 14 RPGLE -by using CRTRPGMOD (or) 15 /CRTPGM command CL -by using CRTCLPGM command CLLE -by using CRTBNDCL CLLE -by using CRTCLMOD/CRTPGM command PF -by using CRTPF command LF -by using CRTLF command PRN - by using CRTPRTF command DSPF -by using CRTDSPF command 47. It is possible to insert record to JOIN LF? NO, insertion, updating or deleting of records is not possible in JOIN LF. 48. What are the advantages of using AS/400 system? AS/400 is designed and build as a total system. This means that facilities such as relational database and networking capability (and much more) are fully integrated into the operating system and machine. The user communication with all these functions through a single control language Layered machine architecture Object orientation Single-level storage Hierarchy of microprocessors Security levels Layered machine architecture This insulates users from hardware characteristics. It enables them to move to new hardware technology at any time, without disrupting their application programs. We can able to change any layer without affecting the other layer. If any problem occurs in OS, then we can work with application program independently and this is the major advantage of AS/400 system. Object orientation Every that can be stored or retrieved on the system is known as an objects. Objects exist to make users independent of the internal structure of the machine. Single- level storage

It provides contiguous memory between main storage and disk storage. It provides authority to add any disk space so that use. Can access it without any problem. There is no need for the user to think where to store the application program. Hierarchy of microprocessors Various types of microprocessors are used in AS/400. Each and every microprocessor is allocated for specific purpose. If one chip is for input operation and other for output then we can do both input and output operation since both the microprocessor can perform independently. Security levels It will list the various security provided by the system. No security Password security Resource security OS security Certifiable security 49. What are the various types of Security in AS/400? AS/400 is designed for business that requires levels of security ranging from nothing at all to full government certifiable security. By setting a system value, we can configure five increasing level of security. No security Password security Resource security OS security Certifiable security When as AS/400 is configured, three system values dealing with security need to be specified. These values are QAUDJRL, QMAXSIGN & QSECURITY.

QSECURITY: This system value determines the level of security enforcement. S/38 and the original AS/400 only had three of system security. At VIR3 of OS/400 the fourth level of security was added, and the fifth level of security was added at V2R3. The valid values for QSECURITY are 10,20,30,40,50. QMAXSIGN: This system value determines the maximum number of signon attempts allowed. If the number of unsuccessful attempts to signon to the system exceeds this number, the terminal or device that attempted the signon is varied off. QAUDJRL: AS/400 supports an optional security auditing function. If this function is specified, certain security events are journal. The specific events that are logged in the security audit journal are determined by the value specified in the QAUDJRL system value and the level of system security specified. Level 10: No security System is shipped with minimum-security level and doesnt require any password to signon. If user profile doesnt exists with the same name as the Userid the system creates the user profile with that name. Level 20:Password security Minimum security is active and password is required to signon. The user profile must already exist for the user before we can signon the system Level 30:Resource security Password security is active and user must specify given authority to resources. This level is recommended because the system doesnt give the user authority to access the entire object on the system after the user signon.

Level 40:Operating system security

Password security, resource security and OS integrity are active. User must be especially given authority to resources this level providing more security than level 30. All attempts to access object using interfaces that are not supported fail. Programs that contains restricted instructions will not compile Users submitting jobs using the job description containing the user profile name, must have *USE authority to user profile. Level 50: C2 level security All the level 40 security attributes are included at level 50,and in addition some of the interfaces are modified to meet the C2 standards. 50. Explain user profile and group profile? User profiles are used to identify users to the systems and verify authorities on the system (DSPUSRPRF, CHGUSRPRF, EDTOBJAUT) User profiles tell the system who can signon and what functions the user can perform on the system on the system resources after signing on. The secutrity officer or security administrator can create it. The user profile defines the following capabilities for a particular user User class Object owned and authorized Authorization of objects Privileged instructions Password Current library Initial program and menu Delimited-capability user Limit device session Maximum storage allowed Priority limit Special environment User class When identifying a user on the system you can specify the user class in the user profile. AS/400 has five user classes that determine the level of systems access a user is permitted. The five user classes, starting the highest level of access, are Security officer (*SECOFR) Security administrator (*SECADM) Programmer (*PGMR) System operator (*SYSOPR) User (*USER) Authorization of objects Object authority, or the right to user to use or control an object comes in two categories. Object rights Data rights Object rights Object rights are concerned with the object itself. Object rights assign a user the following authority Operational rights (*OPER) Object management rights (*OBJMGT) Object existence rights (*OBJEXT) Operational right (*OPER) The authority to use an object, looks at its description, and restores it. A user must have operational rights to a program to execute it. Object management rights (*OBJMGT) The authority to grant and revoke and user rights move and rename object, and members to database file. Object existence rights (*OBJEXT) The authority to delete, free storage, save restore or transfer ownership of an object. Data rights Data rights apply to the data contained within the object.

Types of data rights Read (*READ) The authority to retrieve the contents of an object entry. Add (*ADD) The authority to add entries to an object. For example adding records to a database file requires ADD rights for the library. Update (*UPD) The authority to change the entries in an object requires UPD rights for the file. Delete (*DLT) The authority to remove object in an object. For example deleting a program from a library requires DLT rights for the library. Deleting records for a database the requires DLT rights the database file. 51. What are the various ways creating access path? Access path means the records are to be retrieved from a file. The records can be retrieved from a PF or a LF either ARRIVAL SEQUENCE or by KETED SEQUENCE. For LF you can also select records using select or omit keywords Arrival sequence access path Sequentially, where each record is taken from the next sequential physical position in the file. Directly by relative records number, where the record number is identified by its position from the start of the file.

Keyed sequence access path It is based on the contents of the key fields as defined in DDS. This type of access path is updated in the contents of a CALL TFRCTL key field is changed. 1.Call will transfer the control according with the CALL STACK 2. The CALL is used to different types of programs. Ex: RPGILE/400,CL/400,C/400,COBOL/400. Transfer Control (TFRCTL) will remove the CALL STACK and transfer the control to the calling program. TFRCTL is only used in CL programs. There are three ways of bounding the access path I m m e d

iate Rebuild Delayed Immediate Access path is always maintained for every opening in a file. Rebuild Access path is maintained when the file is open and various updates are recorded and the access path is rebuild every time when the access path is closed. Delayed Access path is maintained when the file is opened and updates recorded. When the file is closed all the updates to the records are closed together but it is not rebuild. When the recorded update percentage exceeds 25% then rebuild of records take place. 52.How many record formats PF, LF, DSPF and SFL? PF- 1 LF- 32 DSPF-1024 SFL-512 53.What is the command to create menu? CRTMNU CRTMNU MENU(*CURLIB/MVRMENU) TYPE(*DSPF / *PGM / UIM) After selection TYPE it changes the attributes. 54. What is the difference between CALL and Transfer Control (TFRCTL)?

55. Explain ADDDUR, SUBDUR, EXTRCT and TEST? ADDDUR: It is a powerful opcode, which is used to add any date related function to a particular date, time or timestamp. Example:
VRAMANA/DATE ADDDUR *************** Beginning of data ******************************** d*date function using the adddur DTIMESTE S Z DTIME5 S Z DDATE1 S D DDATE2 S D DDATE3 S D DDATE4 S D DTIME1 S T DTIME2 S T DTIME3 S T DTIME4 S T C MOVEL *DATE DATE1 C DATE1 ADDDUR 02:*Y DATE2 C DATE1 ADDDUR 05:*M DATE3 C DATE1 ADDDUR 01:*D DATE4 C TIME TIME1 C TIME TIMESTE C TIME1 ADDDUR 10:*H TIME2 C* TIME1 ADDDUR 10:*ML TIME3 C TIME1 ADDDUR 10:*S TIME4 C TIMESTE ADDDUR 10:*MS TIME5 C DATE2 DSPLY C DATE3 DSPLY C DATE4 DSPLY C TIME1 DSPLY C TIME2 DSPLY C TIME3 DSPLY C TIME4 DSPLY C TIME5 DSPLY C SETON LR ****************** End of data ********************************* 2004-06-27 2002-11-27 2002-06-28 12.18.36 22.18.36

0000.01 0001.00 0001.01 0002.00 0002.01 0002.02 0002.03 0003.00 0003.01 0003.02 0003.03 0004.00 0005.00 0006.00 0007.00 0007.01 0007.02 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0014.01 0014.02 0014.03 0014.04 0014.05 0015.00 OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY

DSPLY 00.00.00 DSPLY 12.18.46 DSPLY 2002-06-27-12.18.36.953010

SUBDUR: It is used to find the difference between two date (or) time (or) time stamp Example
VRAMANA/DATE SUBDUR *************** Beginning of data ******************************** d*date function using the SUBDUR DTIMESTE S Z DTIME5 S Z DDATE1 S D INZ (D'1977-06-20') DDATE2 S D DDATE3 S D DDATE4 S D DTIME2 S T INZ (T'12. 50.10) DTIME1 S T DTIME3 S T DTIME4 S T C DATE1 SUBDUR 02:*D DATE2 C DATE1 SUBDUR 05:*M DATE3 C DATE1 SUBDUR 01:*Y DATE4 C TIME TIME1 C TIME2 SUBDUR 10:*H TIME1 C TIME2 SUBDUR 10:*S TIME4 C DATE2 DSPLY C DATE3 DSPLY C DATE4 DSPLY C TIME1 DSPLY C TIME2 DSPLY C TIME3 DSPLY C TIME4 DSPLY C SETON LR ****************** End of data ***********************************

0000.01 0001.00 0001.01 0002.00 0002.01 0002.02 0002.03 0003.00 0003.01 0003.02 0003.03 0005.00 0006.00 0007.00 0007.01 0008.00 0010.00 0012.00 0013.00 0014.00 0014.01 0014.02 0014.03 0014.04 0015.00

OUT PUT DSPLY 1977-06-18 DSPLY 1977-01-20 DSPLY 1976-06-20 DSPLY 02.50.10 DSPLY 12.50.10 DSPLY 00.00.00 DSPLY 12.50.00

EXTRCT:

It is used to extract year, month, day, hours, minutes, seconds, and microseconds of a time stamp or date field. Example:
VRAMANA/DATE EXRCT *************** Beginning of data ******************************** d*FINT THE EXRCT DAY MONTH YEAR DTIMESTE S Z DDATE1 S D INZ (D'1977-06-20') DDATE3 S D DDATE2 S 5P 0 DDATE4 S 5P 0 DDATE5 S 5P 0 DDATE6 S 5P 0 DDATE7 S 5P 0 DDATE8 S 5P 0 DTIME0 S T INZ (T'12. 50.10) DTIME1 S T DTIME2 S 5P 0 DTIME4 S 5P 0 DTIME5 S 5P 0 DTIME6 S 5P 0 DTIME3 S 26P 0

0000.01 0001.00 0002.00 0002.01 0002.02 0002.04 0002.05 0002.06 0002.07 0002.08 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0003.06

0004.00 0004.01 0004.02 0005.00 0006.00 0007.00 0007.01 0007.02 0007.03 0007.04 0007.05 0007.06 0007.07 0011.00 0012.00 0013.00 0013.01 0013.02 0013.03 0014.00 0014.01 0014.02 0014.03 0014.04 0014.05 0015.00 OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY

C C C C C C C C C C C C C C C C C C C C C C C C C C

DATE2 DATE8 DATE4 DATE5 DATE6 DATE7 TIME2 TIME4 TIME5 TIME6 TIME3

MOVEL TIME TIME EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY SETON

*DATE

DATE1:*M DATE3:*M DATE1:*D DATE3:*D DATE1:*Y DATE3:*Y TIME1:*H TIME1:*H TIME0:*H TIME0:*S TIMESTE:*MS

DATE3 TIME1 TIMESTE DATE2 DATE4 DATE5 DATE6 DATE7 DATE8 TIME2 TIME4 TIME5 TIME6 TIME3

LR

6 2002 6 20 27 1977 12 12 12 10 441000

TEST: Test is the most powerful opcode, which will check a date is a valid, or not .The low level indicator is set on if the date is not valid or set off if the date is a valid one. Test will be given with extended factor like test (d), test (t), test (z) for date, time and time stamp and if test without extended factor default to date (z).
Example
VRAMANA/DATE TEST *************** Beginning of data ********************************* C*TEST FOR VALID DATE THE DATE VALID SETOFF OR SETON (NOTVALID) C MOVEL '13/03/1999 A 10 C TEST (D) A 30 C *IN30 DSPLY C IF *IN30=*ON C 'NOTVAILD' DSPLY C ELSE C 'VALID' DSPLY C ENDIF C SETON LR ****************** End of data ***********************************

0000.01 0001.00 0002.00 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0004.00

OUTPUT DSPLY 1 DSPLY NOTVAILD

56. Explain Multi Dimensional Array? The multi dimension data structure array will be implemented in occurs class.

The similar elements of same data type and same attributes size repeating many times this time using OCCUR opcode. Which can only be used with a multiple occurrence data structure, allow you to specify which occurrence of data structure is used for subsequent operation within the programs. 57.Explain about RTNCSRLOC? Type Y (Yes) in the Select parameters prompt to define parameters for the RTNCSRLOC keyword on the Define Return Cursor Location display. 58.Explain Assume and Overlay? Assume Type Y (Yes) to select the ASSUME keyword. It causes the AS/400 system to assume that this record appears on the display when the file is opened. Use this keyword to receive data that a previous program has left on the display. Overlay Type Y (Yes) to allow the overlaying of fields on this record without erasing the entire display. Note: If you type anything other than Y or blank, your entry will be ignored. You must specify the OVERLAY keyword to select the other keywords on this display, with the exception of PUTOVR. 59.Explain Compile time array, lookup, sorta, xfoot, and Run time array? Compile time array The compile time array means the elements of the array will be loaded before the execution of the programs. The value will be static. We must declare in keyword command DIM (), CTDTAT (), and PERRCD (). We are giving the value in after the SETON LR. Example
VRAMANA/ARRAY COMILE *************** Beginning of data ******************************** c*compile time array darr1 s 4 dim(3) ctdata perrcd(1) di s 2p 0 inz(1) c i do 3 c arr1(i) dsply c add 1 i c enddo c seton ** 1001 20 1000 ****************** End of data ********************************

0000.01 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00

OUTPUT DSPLY 1001 DSPLY 20 DSPLY 1000

Run time array The run time array means the value will be loaded during the runtime only. The value will be dynamic.
VRAMANA/ARRAY RUNTIME *************** Beginning of data ***************************** c*runtime array darr1 s 10 dim(12) di s 2p 0 inz(1) da s 3p 0

0000.01 0001.00 0002.00 0002.01

0002.02 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0004.00 0005.01 0006.00 0007.00

dj s 2p 0 inz(1) c i do 12 c dsply arr1(i) c* eval arr1(i)=a c add 1 i c enddo c j do 12 c arr1(j) dsply c add 1 j c enddo c seton lr ****************** End of data ********************************* lookup, sorta, xfoot : VRAMANA/ARRAY SORTARRAY *************** Beginning of data ********************************* c*lookup,xfoot&sorta examples darr1 s 4 0 dim(3) ctdata perrcd(1) di s 2p 0 inz(1) dj s 2p 0 inz(1) dd s 4p 0 c i do 3 c arr1(i) dsply c add 1 i c enddo c sorta arr1 c xfoot arr1 d c 1000 lookup arr1 40 c if *in40=*on c 'found' dsply c else c 'notfou' dsply c endif c d dsply c j do 3 c arr1(j) dsply c add 1 j c enddo c seton lr ** 1001 2000 1000 ****************** End of data *********************************** 1001 2000 1000 found 4001 1000 1001 2000

0000.01 0001.00 0002.00 0002.01 0002.02 0003.00 0004.00 0005.00 0006.00 0006.01 0006.02 0006.03 0006.04 0006.05 0006.06 0006.07 0006.08 0006.09 0006.10 0006.11 0006.12 0006.13 0007.00 0008.00 0009.00 0010.00 0011.00 DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY

Pre runtime array Pre runtime array is in between these 2 conditions where the value are static and the value will be retrieved from disk and loaded into the array. As a result there is no need to retrieve the value every time from the disk and usage of pre runtime array makes it fast. We must declare in keyword command DIM (), FROMFILE (),and PERRCD ().
60.Define data structure and types of data structure? The different types fields and sub field stored with in single area. This area in storage is called data structure. Data structure means program allows you to define an area in storage and the layout of the fields, called sub fields, with the area. This area in storage is called a data structure. Data structure can be used for Group non-contiguous data into contiguous internal storage locations Define the same internal area multiple times using different data formats. Operate on a field and change its contents

Divide a field into sub fields without using the MOVE or MOVEL Define a data structure and its sub fields in the same way a record is defined. Define multiple occurrences of a set of data There are four different types of data structure commonly used. General data structure Data area data structure File information data structure Program status data structure External Data Structure Data structure can be specified in D spec Type IPDS Data structure name I Globally initialized data structure S--Program status data structure U--Data area data structure BlanksGeneral (or) File status data structure Data area data structure A data area data structure, identified by a U in position 18 of the data structure statement, indicates to the RPGLE program that if should read in and lock the data area of the same name at program at program initialization and should write out and unlock the same data area at end of the program. The data area and data area structure must have the same name unless you rename the data within the program by using the *NAMVAR DEFINE statement. File information data structure A file information data structure provides you with status information on file exception /error occurs. This data structure name must be unique for each file. It consists of pre defined sub fields that provide information on the file exception/error that occurred. Program status data structure This data structure is identified by as S in position 18 of the data structure statement, provides program exception/error information to the program. The *ROUTINE, *STATUS, *PARM keywords mostly preferred to determine the PS DS. Example
VRAMANA/DATASTR DUMP *************** Beginning of data ************************* 0001.00 HDEBUG(*YES) 0002.00 DPSSR SDS 0004.00 DSTATUS *status 0005.00 DROUTINE *routine 0005.01 DPARMS *parms 0005.02 DRES S 2S 0 0007.00 C Z-ADD 1 NUM1 2 0 0007.01 C Z-ADD 0 NUM2 2 0 0010.00 C EVAL RES=NUM1/NUM2 0011.00 C 'NOTCOM' DSPLY 0012.00 C A TAG 0013.00 C 'COMING' DSPLY 0014.00 C SETON LR 0015.00 C *PSSR BEGSR 0016.00 C STATUS DSPLY 0017.00 C ROUTINE DSPLY 0018.00 C PARMS DSPLY 0019.00 C DUMP 0020.00 C GOTO A 0021.00 C ENDSR ****************** End of data ****************************** Output DSPLY 102 DSPLY *DETC DSPLY 0 DSPLY COMING

61. What is Lock? How you achieve in AS/400? To give the access permission for database file. The Locks are provided by AS/400 system itself. Type of lock Share lock

The share lock only reading operation (PF file). Exclusive lock The exclusive lock to perform insert, update, and delete operations. 62. How you will release the lock? By using RCLRSC [Reclaim Resource] command we can release the resources only. UNLOCK or CHAIN (N) command also helps to release the lock. By using WRKOBJLCK command and take F4. 63. How you execute CL command in RPGLE? By using QCMDEXC command we can execute CL command in RPGLE. Two parameters will be called use in the CL command to be executed and second is the length of the command. 64. Explain Commitment Control? The AS/400 system has an integrated transaction recovery function called commitment control. Commitment control is an extension of the journal function on the system. The records used during a complex transaction are locked from other user and at the end of the transaction; the program issues the commit operation, updating the records. If the system fails before the commit operation is performed, all database changes are rolled back to the previous commit operation and all the affected records are unlocked. COMMIT-The transactions are updated in the data file. Commit occurs on COMMIT command ROLLBACK- The transactions are NOT updated in the data file. Rollback occurs if there are uncommitted transactions and on ROLLBACK command 65. Explain about sub files in AS/400? A subfile is a group of records READ from or WRITTEN to a display device file in one single operation. It is a display file facility It is a group of records that can be stored in the main memory. The program can store a group of records in the subfile one by one in a sequence. LODING SUBFILES: Load all (Size >Page) Load on demand (Size >Page) Load on demand (Size =Page) Load all (Size >Page) All the records from the database file will be loaded in to the subfile in one shot. The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file. PAGEUP and PAGEDOWN are taken care of by the system. The total subfile size 9999 records. Load on demand (Size > Page) The number of records as mentioned in SFLPAG will be loaded initially. Then the remaining records can be loaded by pressing PAGEDOWN, which is taken care of by the programmer. Same time PAGEUP is taken care of by the system. The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file. All the records loaded will exist in the subfile. The total subfile size 9999 recorde. Load on demand (Size = Page) The number of records that will be loaded into the subfile must always be equal to the value mentioned in for SFLSIZ and SFLPAG. Every time the subfile should be cleared before paging up or paging down. PAGEUP and PAGEDOWN are taken care of the programmer. The number of records that can be in the subfile at any instance will be equal to SFLSIZ and SFLPAG values. Subfile points: Record formats: One display -1024 records formats One display file 512 subfile Record formats are 1.subfile record format (SFL)

2.subfile control record format (SFLCTL) subfile record format(SFL) This record format will have the multiple record definitions -Defining fields. -Defining database fields. Subfile Control record format (SFLCTL) This record format will control the subfile record format. -Defining texts -Defining control fields. Subfile Size (SFLSIZ) This keyword can be used to specify the maximum number of records that can be in the subfile (buffer) Default ->2 Maximum ->9999 Subfile Page (SFLPAG) This keyword can be used to specify the maximum number of records than can be in one subfile page. That is the maximum number of records that the system will display in the screen at a time. -Default ->1 -Maximum-> depends upon the display record size. If the subfile size is at least one greater than the subfile page then the subfile size will grow dynamically up to 9999.

General keywords
SFLDSP -> subfile display SFLDSPCTL -> subfile display control SFLCLR -> subfile clear SFLEND -> subfile end

Define General Keywords


Subfile control record . . . . . Type choices, press Enter. Related subfile record . . . . Subfile cursor relative record Subfile mode . . . . . . . . . Display subfile records . Display control record . . Initialize subfile fields Delete subfile area . . . Clear subfile records . . Indicate more records . . SFLEND parameter . . . SFLEND parameter . . . Record not active . . . . F3=Exit F12=Cancel . . . . . . . . . . . . . . . . . . . . . . : SENWLT1 Keyword . . . SFLCTL SENWND1 . . . SFLCSRRRN . . . SFLMODE Y=Yes . . . SFLDSP Y . . . SFLDSPCTL Y . . . SFLINZ . . . SFLDLT . . . SFLCLR . . . SFLEND . . . *MORE Y . . . *SCRBAR . . . SFLRNA Name Name Name Indicators/+ 25 26

28 30 *MORE ... More...

Subfile Display (SFLDSP) This keyword is used to insert the system that the subfile records format has to be displayed. The subfile record format without any record in it cannot be displayed. Subfile Display control (SFLDSPCTL) This keyword is used to instruct the system that the subfile control record format has to be displayed.

0009.00 C N30

SETON

2526

Subfile Clear (SFLCLR) This keyword is used to clear the records in the subfile records format. An indicator can control this keyword.

0005.00 C 0006.00 C 0007.00 C

SETON WRITE SENWLT1 SETOFF

28 28

Subfile End (SFLEND) This keyword is used to get the display of + sign or a text more or bottom in the bottom of the subfile.

+ or more indicates the existence of more records in the subfile which can be displayed by pressing PAGEDOWN key . Bottom indicates the end of the subfile. Instead of Enter Key - Help Type a CF or CA key number to specify that the operator is to use the Enter key as a Roll Up key. The specified CF or CA key acts as the Enter key. Mandatory keywords for subfile SFL SFLCTL SFLSIZ SFLPAG SFLDSP RRN (Relative record number) RRN is the numeric value (1 to 9999) associated with each subfile record for accessing Each record should have a unique RRN value This value has to be giving by the program. This has to be associated with the subfile record format in the F spec continuation line. This has to be declared in the program as numeric variable of maximum length 4 and decimal position 0. F spec format in continuation line with SFILE option

0002.00 FSENDESFILECF E WORKSTN 0003.00 F SFILE (SFL01:RRN1 ) Where RRN1 -> RRN variable name SFL01-> subfile record format name.
RPGLE Opcodes EXFMT If SFLDSP and SFLDSPCTL indicators are on, this opcode will send the two subfile record formats to the display device and waits for the users response. WRITE (SFL) This opcode is used to add a record to the subfile record format RRN value should be set with a non-existing value before adding the record in the subfile record format. WRITE (SFLCTL) This keyword is used for clearing & display the subfile SFLDROP (subfile drop) This record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in truncated form; subfile records are truncated to fit on one display line. When the user presses the specified key, the program displays the records in the folded form. Or Subfile Initially Truncated - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is first displayed in truncated form. The operator presses thespecified CF or CA key to switch from truncated form to folded form, or from folded form to truncated form. SFLFOLD (subfile fold) This record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in folded form. When the user presses the specified key, the program displays the records again in the truncated form. Or

Subfile Initially Folded - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is firstdisplayed in folded form. The operator presses thespecified CF or CA key to switch from folded form totruncated form, or from truncated form to folded form.
SFLINZ (subfile initialize)

This record level keyword is used to specify that the programis to initialize all records in the subfile on the output operation (read & updates) to the subfile control record format. The fields in each subfile record are initialized to CHAR->BLANKS NUME->ZEROS FLOAT->NULLS SFLNXTCHG (subfile next change) This record level keyword is used on the subfile control record format to force the user to correct program-detected keying error in the subfile records that have been read by the program. It does this by causing the record to be changed so that a get-next-changed operation must read the record. Or Return Record - Help Type Y (Yes) to instruct the system to return this subfile record to your program on a subsequent Get-Next-Changed input operation to the subfile. This record is returned whether or not the operator changes it. Note: You must type Y. If you do not, the entry will not be used.You can specify condition indicators for the SFLNXTCHG keyword. SFLROLVAL (subfile roll value) This field-level keyword is used to specify that the user can key a value into this field to tell the program how many records to PAGEUP or PAGEDOWN when the appropriate paging key is pressed. SFLRCDNBR (subfile record number) This field level keyword on the subfile control record format is used to specify that the page of the subfile to be displayed is the page containing the record whose relative record is in this field. If you do not specify this keyword, the program displays the first page of the subfile by default Example for load all
VRAMANA/SUBFILE NEWEMP *************** Beginning of data ******************* 0001.00 UNIQUE 0002.00 R EMPNEW 0003.00 EMPNOM 6P 0 TEXT('EMPLOYEE NUMBER') 0004.00 EMPNA 15A TEXT('EMPLOYEE NAME') 0005.00 SEX3 1A TEXT('EMPLOYEE SEX') 0006.00 AGE3 3P 0 TEXT('EMPLOYEE AGE') 0007.00 ADDRESS5 15A TEXT('ADDRESS') 0008.00 CITY5 10A TEXT('CITY') 0009.00 K EMPNOM ****************** End of data ********************************* DATA FILE Display Report EMPNOM EMPNA SEX3 AGE3 ADDRESS5 000001 101 K.RAMANAVKUMAR M 25 ATTUR 000002 102 R.SHYAMSUNDAR M 27 TRICHY 000003 103 B.MOHAN M 27 TCODE 000004 104 K.KUMAR M 25 SALEM 000005 105 A.ARUL M 25 SALEM 000006 106 BALU M 25 SALEM 000007 107 RAMANAV M 35 SALEM 000008 108 RAJ M 22 TCODWE 000009 109 HEMA M 33 SALEM 000010 110 VEL M 67 SALEM 000011 111 RAMESH M 56 ATTUR 000012 122 SUDHA M 28 SALEM 000013 123 KANDASAMY M 34 SALEM ****** ******** End of report ******** VRAMANA/SUBFILE CITY5 SALEM TRICHY SALEM SALEM NAMAKKAL SALEM TRICHY SALEM CHENNAI SALEM SALEM ATTUR ATTUR

SUB04 *************** Beginning of data **************************** 0002.00 FSENDESFILECF E WORKSTN 0015.00 C *IN03 DOWEQ *OFF 0016.00 C EXFMT MAIN1 0016.01 C IF *IN04=*ON AND EMPCUR='EMPNOM' 0016.02 C CALL 'SELOADALL3' 0016.03 C ENDIF 0017.00 C 03 LEAVE 0018.00 C ENDDO

0019.00 C SETON LR ****************** End of data ******************************* VRAMANA/SUBFILE SELOADALL3 *************** Beginning of data ***************************** FNEWEMP IF E DISK FSENDESFILECF E WORKSTN F SFILE(SENWND1:RRN1) C Z-ADD 1 RRN1 4 0 C SETON 28 C WRITE SENWLT1 C SETOFF 28 C READ EMPNEW 30 C N30 SETON 2526 C DOW *IN30=*OFF C WRITE SENWND1 C ADD 1 RRN1 C READ EMPNEW 30 C 30 LEAVE C ENDDO C DOW *IN03=*OFF C 03 LEAVE C* WRITE HEATER C* WRITE FOOTER1 C EXFMT SENWLT1 C ENDDO C SETON LR ****************** End of data *****************************

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00 0016.00 0016.01 0016.02 0016.03 0016.04 0020.00 0021.00

window main1 take 8


Select Record Keywords
Record . . . : MAIN1 Type choices, press Enter. General keywords . . . . . . . . Indicator keywords . . . . . . . Application help . . . . . . . . Y=Yes Y Y

Select General Keywords


Record . . . : MAIN1 Type choices, press Enter. If this record is not on display, write it to the display before issuing read . . . . Keep record on display . . . . . . . . . . . Assume record is on display . . . . . . . . Allow rolling of lines . . . . . . . . . . . Retain CLEAR HELP HOME and ROLL keys . . . . Retain command function (CFnn and CAnn) keys Change input defaults . . . . . . . . . . . Select parameters . . . . . . . . . . . . Menu-Bar display . . . . . . . . . . . . . . Select parameters . . . . . . . . . . . . Entry field attribute . . . . . . . . . . . Select parameters . . . . . . . . . . . . Return cursor location . . . . . . . . . . . Select parameters . . . . . . . . . . . . Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INZRCD KEEP ASSUME ALWROL RETKEY RETCMDKEY CHGINPDFT MNUBARDSP ENTFLDATR RTNCSRLOC Y Y=Yes

Define Return Cursor Location


Record . . . : MAIN1 Keyword number 1 of 1 Type parameters, press Enter. Return cursor location . . . . . . . . . . Type indicator *RECNAME . . . . . . . . Cursor record . . . . . . . . . . . . . Keyword RTNCSRLOC Y Y RECSD Y=Yes Y=Yes Name Roll Y +/F4 for list

Cursor field . . . . . . . . . . . . . . Cursor position . . . . . . . . . . . . CF03 03 CF04 04

EMPCUR

Name Name

TAKE 12 AND F4 Work with Fields


Record . . . : MAIN1 Type information, press Enter. Number of fields to roll . . . . . . . . . . . . . . . . . . 6 Type options, change values, press Enter. 1=Select keywords 4=Delete field Option Order Field Type Use Length Row/Col Ref Condition 70 AGE C 21 15 014 80 RECSD A H 10 90 EMPCUR A H 10 100 ---------C 76 21 003 110 F3->EXIT C 37 22 005 120 EMPNOM S B 6,0 09 036 Y Add Add Add H M P Hidden Message Program-to-system

Overlap

More...

TEKE 12

SENWLT1 Select Window Keywords


Window record . . . . . . . . . . . . . : SENWLT1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Select record keywords . . . . . Y General SFLCTL keywords . . . . . Y Subfile display layout . . . . . Y Subfile messages . . . . . . . . Y Select General Keywords Window record . . . . . . . . . . . . . : SENWLT1 Type choices, press Enter. Keyword Window parameters . . . . . . . . . . . . WINDOW Select parameters . . . . . . . . . . . Window borders . . . . . . . . . . . . . . WDWBORDER Select parameters . . . . . . . . . . . Remove windows . . . . . . . . . . . . . . RMVWDW User Restore Display . . . . . . . . . . . USRRSTDSP

Y=Yes Y Y

Indicators/+

Define Window Parameters


Record . . . : SENWLT1 Keyword . . : WINDOW Referenced window . . . . . . . . . . . . -ORWindow definition Default start positioning . . . . . . . -ORStart line Program-to-system field . . . . . . . Actual line . . . . . . . . . . . . . 2 Start position Program-to-system field . . . . . . . Actual position . . . . . . . . . . . 2 Window lines . . . . . . . . . . . . . . 20 Window position . . . . . . . . . . . . 40 Message line . . . . . . . . . . . . . . Y Restrict cursor to window . . . . . . . Y Select Record Keywords Record . . . : SENWLT1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Name

Y=Yes

Name 1-25 Name 1-128 1-25 1-128 Y=Yes Y=Yes

Indicator keywords Application help . Help keywords . . . Output keywords . . CF12 CF03

. . . .

. . . . 12 03

. . . .

. . . .

. . . .

. . . .

. . . .

Define General Keywords Subfile control record . . . . . . . . . : SENWLT1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL SENWND1 Subfile cursor relative record . . . SFLCSRRRN Subfile mode . . . . . . . . . . . . SFLMODE Y=Yes Display subfile records . . . . . . SFLDSP Y Display control record . . . . . . . SFLDSPCTL Y Initialize subfile fields . . . . . SFLINZ Delete subfile area . . . . . . . . SFLDLT Clear subfile records . . . . . . . SFLCLR Indicate more records . . . . . . . SFLEND SFLEND parameter . . . . . . . . *MORE Y SFLEND parameter . . . . . . . . *SCRBAR Record not active . . . . . . . . . SFLRNA F3=Exit F12=Cancel

Name Name Name Indicators/+ 25 26

28 30 *MORE ... More...

Define Display Layout Subfile control record . . . . . . . . . : SENWLT1 Type values, press Enter. Keyword Number Records in subfile . . . . . . . . . . SFLSIZ 6 Program-to-system field . . . . . . Records per display . . . . . . . . . SFLPAG 5 Spaces between records . . . . . . . . SFLLIN OUTPUT EMPLOYEE DETAILS 1.SELECT OPT EMPNUMBER NAME 000101 K.RAMANAVKUMAR 000102 R.SHYAMSUNDAR 000103 B.MOHAN 000104 K.KUMAR 000105 A.ARUL More... EMPLOYEE DETAILS: 1.SELECT OPT EMPNUMBER 000106 000107 000108 000109 000110 NAME BALU RAMANAV RAJ HEMA VEL More... EMPLOYEE DETAILS 1.SELECT OPT EMPNUMBER NAME 000111 RAMESH 000122 SUDHA 000123 KANDASAMY

66. ILE advantages over RPG? Better call performance Modularity Multiple-language integration Enhancements to the ILE compilers Reusable components Control over application run-time environment Code optimization

Tool availability Foundation for the future 67. What is a Module? A module is a non-executable program and it contains one or more procedures. If you have modules without procedure then it means that it is having only one default procedure and in case we can use CALLB. We are creating a RPGLE module by CRTRPGMOD and a CL module by CRTCLMOD commands. 68.How to the create module? A module is created as a separate object type (*MODULE). Using the CRTRPGMOD command creates an RPGLE module. A module object cannot be run directly. You must use the CRTPGM command to bind module object into a program object. First option 15 or CRTRPGMOD command to create a module. The CRTPGM command is used to cerate a program from one or more module.
*************** Beginning C CALLB C CALLB C CALLB C SETON ****************** End of VRAMANA/RPGILE MAIN of data ******************************* 'ADD' 'SUB' 'MUL' LR data ********************************** VRAMANA/RPGILE ADD of data ******************************* 4 A 4 0 5 B 4 0 B C 4 0

0001.00 0002.00 0003.00 0004.00

*************** Beginning C Z-ADD C Z-ADD C A ADD C C DSPLY C SETON LR ****************** End of data ********************************* VRAMANA/RPGILE SUB *************** Beginning of data ******************************* 002.00 C Z-ADD 10 A 4 0 002.01 C Z-ADD 5 B 4 0 004.00 C A SUB B C 4 0 005.00 C C DSPLY 006.00 C SETON LR ****************** End of data ********************************* VRAMANA/RPGILE MUL *************** Beginning of data ****************************** 0002.00 C Z-ADD 10 A 4 0 0002.01 C Z-ADD 5 B 4 0 0004.00 C A MULT B C 4 0 0005.00 C C DSPLY 0006.00 C SETON LR ****************** End of data ********************************* CRTPGM Take F4 Program . . . . . . . . . . . . > MAIN Name Library . . . . . . . . . . . > VRAMANA Name, *CURLIB Module . . . . . . . . . . . . . > MAIN Name, generic*, *PGM, *ALL (PEP) Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB... > ADD > VRAMANA > SUB > VRAMANA + for more values > MUL > VRAMANA Text 'description' . . . . . . . *ENTMODTXT 0002.00 0002.01 0004.00 0005.00 0006.00 OUTPUT DSPLY DSPLY DSPLY

9 5 50

69. What is the difference in between CALL, CALLB, and CALLP?

CALL is a dynamic call where the control will be transferred when the program is executed. (Control will be transfer the another program (run time) so it is dynamic call). Where as CALLB and CALLP are static calls. A module is a non-executable program and it contains one or more procedures. If you have modules without procedure then it means that it is having only one default procedure and in case we can use CALLB. A module is having more than one procedure then we can give explicitly the procedure name to be called in case of CALLP out of these three CALLP is the most efficient one. (Using the CALLB, CALLP a program or module is bind in the program so it is static.) 70. What is the difference between Bind by value and Bind by reference? Bind by value Bind by Reference Here the entire modules to be bounded are In this case we are binding the programs physically copied into the main program by using service programs, which contain a reference to the module that has been object. called, and the modules are not physically copied into the program object. The program will be executed even when The program will not executed when the you delete the entire module that has been bind modules are deleted. called. Bind by value is faster than bind by It is not as faster as bind by value. (All reference. (All the modules to be bind in the modules cant bind the main program it is refer the pointer) the main program, so it is fast) 71. Define pass by value and pass by reference? Pass by reference: Pass by reference we are passing the address of the parameters and not the actual value and so the changes in the called procedure will affect the value in the calling programs. In OPM programs we are using only call by reference. Pass by value: Pass by value we are passing the value of the parameter, changes made to the formal arguments in the called function have no effect on the values of the actual arguments in the calling function it is used in c program. In RPGLE we have the option to pass the parameter by value by giving the keyword VALUE. 72. What are Program Entry Procedure (PEP) and User Entry Procedure (UEP)? If we are binding many modules together to form a program then we have to specify which module has to take control first when it has been called and that module is called as PEP for that program. User entry procedure (UEP) is the first statement that takes the control when a program has been called. For example in C programs main () will be executed first when it has been called and like wise in RPG the statement coded in C Spe will take the control first. 73. Define Copybook in RPGLE? It will copy a Subroutine (or) any group of codes physically into the program, which is copying it.
VRAMANA/RPGILE COP *************** Beginning of data ****************************** 0002.00 C DSPLY A 5 0 0002.01 C EXSR ADD 0004.00 C SETON LR

0005.00 C/COPY RPGILE, COPY ****************** End of data ******************************** VRAMANA/RPGILE COPY *************** Beginning of data ****************************** 0000.01 0001.00 C ADD BEGSR 0002.00 C ADD 5 A 0003.00 C A DSPLY 0004.00 C ENDSR ****************** End of data ******************************* OUTPUT 13 DSPLY 18 74.What will FOR opcode will do? VRAMANA/DOLOOP FOR *************** Beginning of data ***************************** di s 5p 0 inz(1) dn s 5p 0 inz(10) c for i=1 to n c i dsply c endfor c for i=n downto 1 c i dsply c endfor * for(I=5;I<40;i=i+10) c for i=5 by n to 40 c i dsply c endfor c for i=5 to 40 by n c i dsply c endfor c seton ****************** End of data ***************************** DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY 10 9 8 7 6 5 4 3 2 1 5 15 25 35

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0008.01 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00

lr

OUTPUT DSPLY 1 DSPLY 2 DSPLY 3 DSPLY 4 DSPLY 5 DSPLY 6 DSPLY 7 DSPLY 8 DSPLY 9 DSPLY 10 DSPLY 5 DSPLY 15 DSPLY 25 DSPLY 35

75. What are the various stages for a job after it is submitted? Job queue, Active job, ant OUTQ is the three stages after the job has been submitted. 76. What is the equivalent command to setll *loval in CL? POSDBF with file position as *start will set the file to the beginning (or) using OVRDBF and specify the key field value by RRN value (or) by giving *start. 77. How to create a service program and what are the steps involved in this? The service program means most commonly used modules are grouped (binding) together to form it is called service program. A service program is not bound to its caller until activation time While creating service program we can create a binder program where we can refer the modules (or) procedures (or) even data types to be used by the program. Which is using service program.

Advantages of service programs

They do not take up auxiliary storage space. There is only one copy for all users. There is only a single copy of the read-only code in main storage for all users in this service programs is the same as a program that you call dynamically. Each user of the service program has an independent work area. You can pass parameters to a service programs by using the traditional parameter list (or) by importing and exporting variables. Service programs can be maintained independently of the programs that use the functions. In most cases, changing a service programs does not cause a program using the function to be changed or re-created.
Disadvantages of service programs

Service programs are less desirable for a function you may or may not need. The reason is that it is slower to call a main program that refer to a service program 78. What is an activation group? Activation group is the boundary set for similar programs. Activation group is also a storage space in memory. CLP has a OVRDBF command and calls a RPGLE program RPGLE program performs a read operation and the pointer is now in the second program and now call the program 3 RPGLE program that also do a read operation which will read the second record Since the pointer is in the second position and then return to 2nd program in the above situation when the control transfer from 3rd record since the 2 rd record is already read in program 3. But we need to need the 2nd record according to the logic but this is not possible in any OPM programs. But in RPGLE there is a solution for this problem by giving a common activation group for 1st and 2nd program and have a separate activation group for the 3rd program while creating the program itself and this will avoid all the problem we faced before. In some situation we want to share between 2 program then we can give the activation group in *job level in which the changes in one program will be affected in another program. Types of activation group levels: *New: In this case every time you call the program an new activation group will be created which this case will not be used mostly. *caller: If we dont know the type of the program that is calling then we can specify *caller where the activation group will be the same of the program that is calling. Named activation group: We can give our own named for different activation group. 79.What are the statements that are affected by activation group? OVRDBF OPNDBF OPNQRYF STRCMTCTL DLTOVR 80. What are the statements, which is not used in CLLE that is used in CLP? RCLRSC which is replaced by RCLACTGRP TFRCTL 81. What is the difference between FMTDTA and OPNARYF?

82.What is the new name for AS/400?


I series 400 is the new name given to AS/400 by IBM now.

83.How to see source of copybooks include in a program while compiling or debugging? While compiling the program give *list instead of *source which will expand all the copybooks. 84. Explain inner join or natural join and left outer join? Inner join Inner join means the matching records in between the joining file will be selected.
Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JPF01 FMT PF *************** Beginning of data ****************************

FMTDTA

OPNQRY

It will sort the records sequentially based It will sort the records based o the field on the position of the record values. If any change in the attribute size of a PF If there is any change in the attribute size it then we have to change the program will not affect the program specification also. specification also FMTDTA is bit faster in process than OPNQRYF is slower as compare to OPNQRYF. FMTDTA if we are processing millions of records.
***************************** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JPF02 FMT PF. *************** Beginning of data *************************** 0001.00 R JP2REC 0002.00 EMPNO 5S 0 0003.00 EMPSAL 10P 2 0004.00 K EMPNO ****************** End of data ******************************** Display Report

0001.00 R JP1REC 0002.00 EMPNO 5S 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ******* ******* **** End of data

EMPNAME 1,001 SHYAMBABU 1,002 RAMANAVKUMAR 1,003 RAMESH ******** End of report ******** EMPNO EMPSAL 000001 1,001 100.00 000002 1,002 20.00 000003 1,004 300.00 ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JOFILE FMT LF. *************** Beginning of data ************************ 0001.00 R JREC1 JFILE (JPF01 JPF02) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNO EMPNO) 0004.00 EMPNO JREF (JPF01) 0005.00 EMPNAME 0006.00 EMPSAL

EMPNO 000001 000002 000003 ******

0007.00

K EMPNO ****************** End of data*********************

EMPNO EMPNAME 000001 1,001 SHYAMBABU 000002 1,002 RAMANAVKUMAR ****** ******** End of report

EMPSAL 100.00 20.00 ********

Left outer join Left outer join all the records from primary file and matching records from the secondary file will be selected.
Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JOOUT FMT LF. *************** Beginning of data********************* 0001.00 JDFTVAL 0002.00 R JREC1 JFILE (JPF01 JPF02) 0003.00 J JOIN (1 2) 0004.00 JFLD (EMPNO EMPNO) 0005.00 EMPNO JREF (JPF01) 0006.00 EMPNAME 0007.00 EMPSAL 0008.00 K EMPNO ****************** End of data********************

EMPNO 000001 1,001 000002 1,002 000003 1,003

EMPNAME EMPSAL SHYAMBABU 100.00 RAMANAVKUMAR 20.00 RAMESH .00 ****** ******** End of report ********

SEQUENCING DUPLICATE RECORDS Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SEQ1 FMT PF. *************** Beginning of data *********************** 0001.00 R SEQREC1 0002.00 EMPNO 5P 0 0003.00 EMPNAME1 20A 0004.00 ADDRESS 20A 0005.00 K EMPNO ****************** End of data ************************** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SEQ2 FMT PF *************** Beginning of data**************** 0001.00 R SEQREC2 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 TEL 10P 0 ****************** End of data ****************** EMPNO 10,001 10,002 10,003 ******** EMPNAME1 BOB DANNY PRINC End of report ADDRESS 23,OLD MADIWALA 50,LONG ISLAND 90,ATTUR ******** TEL 825,777 825,999 825,888 4,222,600 ********

000001 000002 000003 ******

EMPNO EMPNAME 000001 10,001 BOB 000002 10,001 BOB 000003 10,001 BOB 000004 10,002 DANNY ****** ******** End of report

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JDFTSEQ FMT LF *************** Beginning of data ****************** 0001.00 R RECSEQ JFILE (SEQ1 SEQ2) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNAME1 EMPNAME) 0004.00 JDUPSEQ (TEL) 0005.00 EMPNO JREF (2) 0006.00 EMPNAME1 0007.00 ADDRESS 0008.00 TEL ****************** End of data************************ EMPNO EMPNAME1 ADDRESS TEL 000001 10,001 BOB 23,OLD MADIWALA 825,777 000002 10,001 BOB 23,OLD MADIWALA 825,888 000003 10,001 BOB 23,OLD MADIWALA 825,999 000004 10,002 DANNY 50,LONG ISLAND 4,222,600 ****** ******** End of report ********

JOIN DESCEND Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JDFTSEQ FMT LF *************** Beginning of data *********************** 0001.00 R RECSEQ JFILE (SEQ1 SEQ2) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNAME1 EMPNAME) 0004.00 JDUPSEQ (TEL *DESCEND) 0005.00 EMPNO JREF (2) 0006.00 EMPNAME1 0007.00 ADDRESS 0008.00 TEL ****************** End of data ************************* EMPNO EMPNAME1 ADDRESS TEL 000001 10,001 BOB 23,OLD MADIWALA 825,999 000002 10,001 BOB 23,OLD MADIWALA 825,888 000003 10,001 BOB 23,OLD MADIWALA 825,777 000004 10,002 DANNY 50,LONG ISLAND 4,222,600 ****** ******** End of report ********

85. Explain Build in function in ILE? %SUBST (String name: String position: length) %ABS (Absolute value by omitting sign) %EDITC (string: X) In a application if we want to concatenate a string with a numeric then we can use this %EDITC Example:
VRAMANA/BULID EDITC *************** Beginning of data ******************************* 0001.00 da s 10a inz('shyam') 0002.00 db s 10p 0 inz(20) 0003.00 dc s 10a inz('sundar') 0004.00 dd s 10s 0 inz(12) 0005.00 de s 10a inz('rambabu') 0006.00 dout s 50a 0007.00 c eval out=a+%editc(b:'X')+c+%editc(d:'X')+e 0009.00 c out dsply 0010.00 c seton lr

0011.00 ****************** End of data *********************************** OUTPUT DSPLY shyam 0000000020sundar 0000000012rambabu

%REPLACE (Replacing string, actual string, starting position, offset) Here we are replacing RAMANAVkumar from position 4 to 3 by kum. The output will be Ramkumvkumar.
VRAMANA/BULID REPLACE *************** Beginning of data **************************** d*replace the string using keyword %replace dc s 16a inz('RAMANAVRaman') db s 20a c eval b=%replace('Ram':c:4:3) c b dsply c seton lr ****************** End of data *****************************

0000.01 0001.00 0002.00 0003.00 0004.00 0005.00

OUTPUT DSPLY RamRamvRaman

%TRIM (%TRIML, %TRIMR) The use of the TRIM functions is very limited, in that they support only the use of character variables and data structures. Numeric fields, and zero-fill values are not supported. They do, however, provide some useful function for string handling. For example, in RPG IV, one line of code is all that's needed to left-adjust a value within a field. For example:
CCRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C ExFmtCustMaint CustName=%TrimL(CustName) C Eval

Typically, the %TRIM function is the only one of the three that get used. The other two, however, do have their place. %TRIM removes trailing and leading blanks from a field, and returns the remaining value, in place, within the expression. The returned value is treated similar to a constant value with leading or trailing blanks. %TRIML removes leading blanks (trim-left) from a field, and returns the value in place, within the expression. %TRIMR removes trailing blanks (trim-right) from a field, and returns the value in place, within the expression. %FOUND, %EOF, %EQUAL,%OPEN OS/400 Version 4, Release 2 RPG IV supports the elimination of the Resulting Indicators. In their place, several new built-in functions have been introduced. Most of these new built-in function provide information about the result of File operations similar to the Result indicators. But instead of coding Resulting indicator 3, for example, to check for the end-of-file condition, you simply check the value of the %EOF built-in function. The built-in functions that replace the Resulting Indicators include:

%FOUND, %EOF, %EQUAL. In addition, there are %OPEN, %STATUS, and %ERROR. Mysteriously missing is %LOCK to check for a record lock condition. %FOUND returns an *ON or *OFF condition if the previous File operation returns a record-found condition. This is particularly useful on the CHAIN operation. Realize, however, that when CHAIN sets on Resulting indicator 1, a not-found condition is signaled. Whereas, without coding Resulting Indicator 1, the %FOUND built-in function returns the found condition. %EOF can be used to check for end-of file, beginning of file, or subfile full conditions. A READ and READE return %EOF=*ON if the end of file is reached. READP and READPE return %EOF=*ON if the beginning of file is reached. The WRITE operation returns %EOF=*ON if the WRITE operation to a subfile detail record returned a subfile-full condition. %EQUAL is used by the SETLL operation to indicate that it detected a record in the file with a key equal to that of the value specified in Factor 1. Since SETLL does not read the record, does not lock the record, and does not copy the data into the input buffer, SETLL is much faster and less of an impact on the performance of the application than other operations, such as CHAIN. Use CHAIN when you need to retrieve the record, use SETLL and %EQUAL when you need to only check for the existence of a record. %OPEN is used to check to see if a file has already been opened. The built-in function returns *ON if the file is opened, otherwise it returns *OFF. %ELEM %ELEM will display the array dimension
0001.00 0002.00 0003.00 0004.00 0005.00 ELEM *************** Beginning of data ****************************** darr1 s 3s 0 dim(100) dc s 3s 0 c eval c=%elem(arr1) c c dsply c seton lr ****************** End of data **********************************

OUTPUT DSPLY 100

%SIZE %SIZE will display the size of the variable


VRAMANA/BULID SIZE *************** Beginning of data ***************************** 0000.01 D*BY USING THIS COMMAND FIND SIZE OF DATA VALUE 0001.00 darr1 s 10p 0 dim(10) 0002.00 dds1 s 10p 0 dim(20) 0003.00 dnum s 20p 0 0004.00 c z-add 2 a 20 0 0005.00 c movel 'RAMANAV' b 10 0006.00 c eval num=%size(a) 0007.00 c 0008.00 c num dsply 0009.00 c eval num=%size(b) 0010.00 c num dsply 0011.00 c eval num=%size(arr1) 0012.00 c num dsply 0013.00 c eval num=%size(arr1:*all) 0014.00 c num dsply 0015.00 c eval num=%size(ds1) 0016.00 c num dsply 0017.00 c eval num=%size(ds1:*all) 0018.00 c num dsply 0019.00 c seton lr

****************** End of data ********************************** OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY 6 11 10 6 60 6 120

%EDITW 86.Explain keyword in ILE? Overlay Rename Prefix Options Const 87.How you can schedule a job to run periodically? We have to create a job scheduler for running a job periodically. Here we can make a job to run once or periodically at a given date and time. We can create a job scheduler by using ADDJOBSCDE command. We can list all the job scheduler running by using the command WRKJOBSCDE command and we can delete a job scheduler by using RMVJOBSCDE or we can reschedule the job by using CHGJOBSCDE. 88.How to debug a batch job? Hold the batch job to be debugged by using WRKACTJOB command and having option 3. Set the pointer in the batch program to be debugged by using STRDBG and call the STRSRVJOB command and start the service program, which will enter into the debug mode. After entering into debug mode release the job that is hold before. 89.Define KLIST? KLIST operation is a declarative operation that gives a name to list of KFLD. This KLIST can be used as a search argument to retrieve records from files that have a composite key. 90.Define PLIST? The declarative PLIST operation defines symbolic name for a parameter list to be specified in a CALL operation. 91.Define composite key? It is a key for a file, which is composed of more than one field. 92.Explain procedure used in RPGLE? A procedure is a non-executable program. If a module is having more than one procedure then we can give explicitly the procedure name to be called in case of CALLP.

Defining the prototype: Prototype will specify the following things Parameter type Sequence of the parameter Return variable and its type It tells the name of the procedure and also the type of the call. It will avoid all the run time problems like parameter mismatch by specifying the prototype. Prototype interface It is like *entry parameter where we will specify the parameters that are received in this program. Import and export If you want to specify the procedures to be the external programs then we can specify EXPORT in your procedure.

Global and local variables If you declare a variable in main procedure then it will be accessible in all sub procedure and this is global declaration and if you specify the declaration in the sub procedures then it will not be accessed in other procedures or in the main procedure. Return If we specify return in the sub procedure then it means that we are returning something to the calling program. We can return a maximum of only one variable to the calling program. Recursion A procedure calling to it self is known as recursion. Pass by value/pass by reference In case of pass by reference we are passing the address of the parameters and not the actual value and so the changes in the called procedure will affect the value in the calling program. In OPM program we are using only call by reference and in RPGLE we have the option to pass the parameter by giving the keyword VALUE. CALLP/Expression We can call the procedure by using CALLP command if it is not having any return type and by an expression if it returns any value. 93.How you can import and export a data type between 2 programs? If you are using an export statement when declaring a variable then the data type can be imported in any modules that is bind either by value or by reference. So in this case we can pass values in between modules instead of using PLIST and *ENTRY. 94. Message subfile record format keywords? SFLMSGRCD (subfile message record) This keyword is used to give the line number to get the first message in the display.

SFLMSGKEY (subfile message key) This keyword is used to specify that the program message queue is built one at a time. SFLPGMQ (subfile program queue) It is a message queue created for every program active in the call stack. This keyword is used to specify the field that can have the name of the program message queue. 95. How to create Message subfile? Create message subfile CRTMSGF MKSFILE/LIB WRKMSGF FILE/ANME
OPTION 12
Add Message Description (ADDMSGD) Type choices, press Enter. Message identifier . . . . . . . MKS0001 Name Message file . . . . . . . . . . > MKSFILE Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB First-level message text . . . . EMPLOYEE NUMBER &1 CANNOT BE ZEROS PAGE DOWN Message data fields formats: Data type . . . . . . . . . . *CHAR *NONE, *QTDCHAR, *CHAR... Length . . . . . . . . . . . . 10 Number, *VARY WRKMSGF MKS0001 MKS0002 MKS0003 MKS0004 MKS0005 MKS0006 MKS0007 MKS0008 MKS0009 MKS0010 10

0 0 0 0 0 0 0 0 0 0

EMPLOYEE NUMBER CANNOT BE ZEROS EMPLOYEE &1 NUMBER AIREADY EXIST EMPLOYEE NAME CANNOT BE BLANKS ADDRESS(1) CANNOT BE BLANKS CITY CANNOT BE BLANKS MARITAL STATUS WILL BE WITH (M/S) EMPLOYEE NUMBER &1 ADDED SUCCESFULLY EMPLOYEE NUMBER DOES NOT EXISTS EMPLOYEE UPDATED SUCCESSFULLY EMPLOYEE NUMBERDELETE SUCCESFULLY SFLMSG SFLCTL 06/27/02 06/27/02

Create message subfile


MSGREC1 20 MSGCTL1 USING 8 SELETION MSGREC1

Select Subfile Keywords Subfile record . . . . . . . : MSGREC1 Type choices, press Enter Y=Yes General keywords . . . . . . . . Y Indicator keywords . . . . . . . Y Message record . . . . . . . . . Y TEXT keyword . . . . . . . . . . Define Message Record Subfile record . . . . . . . : MSGREC1 Type choices, press Enter. Keyword Line number for first message . . . . SFLMSGRCD Message ID field . . . . . . . . . . SFLMSGKEY (if program message queue is built one message at a time) Program message queue field . . . . . SFLPGMQ Generate a 276 byte field . . . . . MESSAGE SUBFILE (SFTCTL) Subfile control record . . . . . . . . . : MSGCTL1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Subfile display layout . . . . . Y Subfile messages . . . . . . . . Y Select record keywords . . . . . Y

24 DUMMY

1-27 Name

QUEUE

Name Y=Yes

. . . . . . . . . . Define General Keywords Subfile control record . . . . . . . . . : MSGCTL1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL MSGREC1 Subfile cursor relative record . . . SFLCSRRRN Subfile mode . . . . . . . . . . . . SFLMODE Program message queue field . . . . SFLPGMQ QUEUE Generate a 276 byte field . . . . Y=Yes Display subfile records . . . . . . SFLDSP Y Display control record . . . . . . . SFLDSPCTL Y Initialize subfile fields . . . . . SFLINZ Y Delete subfile area . . . . . . . . SFLDLT Clear subfile records . . . . . . . SFLCLR Indicate more records . . . . . . . SFLEND SFLEND parameter . . . . . . . . *MORE SFLEND parameter . . . . . . . . *SCRBAR Record not active . . . . . . . . . SFLRNA F3=Exit F12=Cancel Select Record Keywords Record . . . : MSGCTL1 Type choices, press Enter. General keywords . . . . . . . . Indicator keywords . . . . . . . Overlay keywords . . . . . . . . Y Y=Yes Y Y

TEXT keyword

Name Name Name Name Y=Yes Indicators/+

*MORE ... More...

Select Overlay Keywords Record . . . : MSGCTL1 Type choices, press Enter. Overlay without erasing . . . . . . Create CL program for SNDPGMMSG Keyword OVERLAY Y=Yes Y Indicators/+ Roll

VRAMANA/EMPCUSTOR MSG *************** Beginning of data ***************************** 0001.00 PGM PARM(&MSGID &MSGFI &MSGDTA) 0002.00 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) 0003.00 DCL VAR(&MSGFI) TYPE(*CHAR) LEN(7) 0004.00 DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(10) 0005.00 SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFI) MSGDTA(&MSGDTA) 0006.00 ENDPGM ****************** End of data****************************** Create CL program for RMVMSG VRAMANA/EMPCUSTOR RMO *************** Beginning of data ***************************** 0001.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL) ****************** End of data ******************************* Design the screen Generate RPG program 0000.01 FMESSTAB IF A E K DISK 0001.00 FMKSSCR CF E WORKSTN 0001.01 C MOVEL MSTATUS S 1 0002.02 C MOVEL '*' QUEUE 0003.00 C MOVEL 'MKSFILE' MSGFI 0004.00 C PL01 PLIST 0005.00 C PARM MSGID 7 0006.00 C PARM MSGFI 10 0007.00 C PARM MSGDTA 10 0008.00 C DOW *IN03=*OFF 0008.01 C MOVEL 0 ERROR 1 0 0008.02 C MOVEL 0 ERROREMP 1 0 0012.00 C WRITE MSGCTL1 0013.00 C EXFMT MKSSEN 0013.01 C CALL 'RMO' 0014.00 C IF EMPNUMB=*ZEROS 0014.01 C MOVEL 1 ERROR 0014.02 C MOVEL 1 ERROREMP

0015.00 0016.00 0017.00 0017.01

C C C C

MOVEL MOVEL CALL ENDIF

'MKS0001' *ZEROS 'MSG'

MSGID MSGDTA PL01

96.What is active subfile? Subfile, which are in the main memory, are called as active subfiles. A maximum of 24 subfile can be active at a time. 97. Navigation between two screens?
VRAMANA/TABLES EX21 *************** Beginning of data ***************************** FEXDSPF CF E WORKSTN C Z-ADD 1 SCR1 2 0 C *IN03 DOWEQ *OFF C SCR1 DOWEQ 1 C EXFMT DSPF1 C 03 LEAVE C IF *IN08=*ON C Z-ADD 2 SCR1 C LEAVE C ENDIF C ENDDO C SCR1 DOWEQ 2 C EXFMT DSPF2 C 03 LEAVE C IF *IN07=*ON C Z-ADD 1 SCR1 C LEAVE C ENDIF C ENDDO C 03 LEAVE C ENDDO C SETON LR ****************** End of data *******************************

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00 0016.00 0017.00 0018.00 0019.00 0020.00 0021.00 0022.00

98. What is the different between READE and CHAIN opcodes? READE 1.The matching records for table 2. We are using the looping concept 3.The indicator setin the EQ 4. We are most using in SETGT or SERLL CHAIN The first matching records only Looping is not necessary The indicator setin the HI It is not necessary

99. Define indicator & MOVEA? It is a 1-bit flag where value will be either 0 or 1 AS/400 provider 99 indicator for the business user. 1-24 ->assigned functions keys 25-99 ->our own purpose 100. Define ITER / LEAVE? ITER-> Transfer the control before do loop. LEAVE-> Transfer the control after do loop. 101.CL commands? 1. WRKMBRPDM
2. CRTSRCPF

By using this command to create source physical file. Default PF size is 92. 3.DSPFD It is used to display the details about the file when it is created. 4. DSPFFD

It is used for listing details about Individual Fields 5.STRDFU It is used to add Data into the records 6.STRSDA It is used to go into screen Designing or Menu Designing 7.CRTMSGF For creating the Message file 8.WRKMSGF If you want to create or change or delete any message we can use this command. 9.CRTDTAARA For creating The Data Area 10.DSPDTAARA For listing the content of Data area. 11.CHGDATARA For changing the content of Data area. 12.DSPLIBL For listing the contents of library 13.ADDLIBLE For Adding a library into the current library. 14.RMVLIBLE For Removing a library into the current library. 15.CHGCURLIB For changing the Current Library to a new library 16.EDTLIBL It is used to the edit of the library file. (Change library file it is temporary delete the library file) For Adding or Removing library lists. 17.SNDBRKMSG Used for sending message to all user.

18.CRTPF It is used to create a PF. Using this command we can set the maximum number of records, whether delete or update operation is allowed or not, maximum storage allocation, waiting time etc can be determined 19.CRTLF To create the logical files. 20.STRRLU To go into the RLU we are using this command. Default length of RLU is 132 if you give it and creating it very first time else it set the page width value of last edited RLU. We can give the page width value from 1 to 378 in page width option. 21.DSPSBS It is used to list the various subsystems running under AS/400 environment. Various subsystems running are QINTER, QACTIVE, and QBATCH etc. 22.CRTRPGPGM It is used to create an RPG program. We can determine what sort of source file is generated. For example when we need the entire source compile as it is since source is default. If we give *NOSOURCE only syntax errors is generated NOSECLVL will not allows secondary message where as other setting is allowed it and so on 23.CRTCLPGM To create CL program

24.EDTOBJAUT It is used to give authority to a particular source PF. For giving authority to other user we must give authority to library, user profile and the source PF. 25.DSPOBJD If we know library name and object name and we want to know the source PF where it is residing then DSPOBJD with option as services instant of basic will give the source PF name. It describes various object descriptions like created Date, Created by, Source Physical file, which it is being created, and so on. 26.STRSQL To start into SQL. 27.WRKSPLF To work with Spool file 28.DLTSPLF To delete the spool file 29.CRTDUPOBJ By using this command to create duplicate object. If you want to compile a PF having 1000 of records and when we compile it all the data will be lost else if you want to add or delete a attribute data for other fields will have to copied. For that we a duplicate object. 30.CPYF Records are being copied from PF to temporary file and after compiling it we have to again copy back from temporary file to the original file. If we Add a attribute we have to give *map and if we want to delete a attribute we have to give *drop in the map entry field.

31.DLTF After copying into the original file we have to delete the temporary file or if you want to delete any file we are using this command. DLTF will only remove the object 32.RMVM It is used to delete the member as well as the object. 33.RUNQRY To display all the records in a PF. 34.CRTCMD It is the powerful command used to create user define commands. 35.CMPPFM It is used to compare two programs or files. It can be coded by taking option 54 in Subfile screen. 36.MRGSRC It is used to merge a file with another file. We have to mention three files one is the root file, which is just a root and does not contain any code even. The second file is target file where we can have the ready-made we can copy the target source. 37.RTVCLSRC If you delete a CL Source then we can retain the source if you are having the object by using this command. 38.SBMJOB If you want to submit the job in certain interval i.e. on a specified date and time we can use this command 39.DSPJOB It will display all the jobs. 40.DSPUSRPRF It will display all the entries regarding the particular user profile. It displays information like what is the user. Profile name; date previously, user class, printing and all.

41.CPYSRCF If we want to copy all the members in a source PF to another source PF. 42.WRKACTJOB To display the active jobs running in AS/400 systems. 43.DSPJOBLOG By using this command display the output console. 44.SNDMSG This command is to send the message to an user. 45.DSPMSG This command is display all the message. 46.CHGCURLIB Change the current library file. 47.ADDLIBLE It is used to add the library. It is fully administrator authority. 48.RMVLIBLE This command is to remove a library from the list. 49.CRTUSRPRF It is used to display the rights given to a user. The system administrator can change authority he can give the authority as a system administrator. 50.DSPDBR (data base relation) This is used to list all the files, which are related to a PF. It displays all the LF that is referring the PF and also lists the child table if it is having a relation through ADDPFCST. 51.DSPJOB It will display all the jobs submitted within the specific interval and display the entire user who worked on the system at that time 52.WRKMSGQ It will list all the messages of different user in the job queue.

53.CPYSRCF If we want to copy all the members in a source PF to another source PF we can use this command. 54.CPYTODKT If we want to copy from source PF to a diskette file 55.CPYTOTAP If we want to copy source PF to a tape then we can use this command. 56.STRDBG If we want to debug a ILE program then we can use this command .We have to create a ILE program by compiling with 15 which is CRTRPGMOD command and take F10 give debugging values as *Source. This will create a module. Then we have the create the program by giving program name and module name as the same and if we are calling any other modules also in that include that in the CRTPGM command Ex: CRTPGM PGM (LIB/PNAME) MODULE (LIB/PNAME) (LIB/SPNAME) Now the program as well as the module is created. Then we have to start the debug by using the command. STRDBG PGM (LIB/PNAME) UPDPROD (*YES) It will shoe the source code of the program and we have to press F6 set the break point and press F10 key and call the program

CALL PNAME F11-> display the variable Shift + F11 -> go to module 102. Data types in CL?

103. String operation in CL? *CAT ->Concatenate without editing. *BCAT->Trailing blanks in the first character string are truncated. One blanks is inserted, then the two character strings are concatenated. Any leading blanks of the second operand are not truncated *TCAT->All trailing blanks in the first character string are truncated, and then the two character strings are concatenated. Any leading blanks of the second operand are not truncated.
VRAMANA/CLP STRING *************** Beginning of data ******************************** 0000.01 /*STRING *CAT *BCAT *TCAT FUNCTION */ 0001.00 PGM PARM(&STR &STR1 &STR2 &STR3 &STR4)

LEN ()

VALUE () Default (0) Default (b) Default (0)

TYPE ()
*DEC *CHAR *LGL
Default (15 5)

Max (15 9) Default (32) 1

0001.02 DCL VAR(&STR) TYPE(*CHAR) LEN(15) 0001.03 DCL VAR(&STR1) TYPE(*CHAR) LEN(15) 0001.04 DCL VAR(&STR2) TYPE(*CHAR) LEN(15) 0001.05 DCL VAR(&STR3) TYPE(*CHAR) LEN(15) 0001.06 DCL VAR(&STR4) TYPE(*CHAR) LEN(40) 0001.07 CHGVAR VAR(&STR2) VALUE(&STR *CAT &STR1) 0001.08 CHGVAR VAR(&STR3) VALUE(&STR *BCAT &STR1) 0001.09 CHGVAR VAR(&STR4) VALUE(&STR *TCAT &STR1) 0001.10 SNDMSG MSG(&STR3) TOUSR(SKANDASAMY) 0001.11 SNDMSG MSG(&STR4) TOUSR(SKANDASAMY) 0001.12 SNDMSG MSG(&STR2) TOUSR(SKANDASAMY) 0006.00 ENDPGM ****************** End of data ********************************** run call program name (string) f4 Program . . . . . . . . . . . . > STRING Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Parameters . . . . . . . . . . . > VENKATA > RAMANA > '' > '' + for more values > '' DSPMSG

104. How to set the cursor position in particular field in particular position? Using the curpos 105. How will retrieve the data in data area? In retrieve a data area Out-write a data area 106.Built in function in CL? %SUBSTRING or %SST

The sub string built-in function produces a character string that is a subset of an existing character string and can only be used with a CL program. %SUBSTRING (Character-variable-name Starting-position length) Or %SST (Character-variable-name Starting-position length) %SWITCH 106. Define indicator in CL? We can set on or setoff the indicator by the command. CHGVAR (&IN30) VALUE (0) ->setoff CHGVAR (&IN30) VALUE (1)->seton 107. Message subfile in CL? Subfile cannot be used in CL but we can use message subfiles in CL. 108. CL processing commands & program control commands? PROCESSING -> CHGVAR, SNDPGMMSG, OVRDBF, AND DLTF. PROGRAM CONTROL ->CALL, RETURN, TFRCTL 109. How to CL code has to change to use a call procedure? By using CALLPRC command. This is the bound call in CL that calls a procedure within a module. 110. Figurative constants in RPGLE? *HIVAL, *LOVAL, *ZERO, *ZEROS, *BLANKS, SETLL, SETGT. 111. Rename of fields and prefix? 112. How you will avoid multiple users updating the same records? The displaying the records in the screen we will be getting the timestamp along with the actual data. Store this in output data structure and while updating check weather the previous time stamp is the same timestamp before updating. If the record is updated by another user than the time stamp will be changed and if it does not matches then throw the error message Record is already updated by another user else update the records with current time stamp.

Program 1
Store the time stamp and this time stamp will come as a input to the second program

Program2
Here wstmst1 contains the input time stamp and check this matches with the database. If matches Update else send error message. 113.Define binder program? The binder program means binding the procedure it is called binder program. 114.question details? DEFAULT CL MSGID? CPF0000 Dspf windows type? WINDOW How many key define in logical file? All the PF fields are create in key. What is the level check error?

The level check error means RPGLE program is compiled and PF or LF are compile suppose the PF or LF compile after the compiling the RPGLE program this type of error is called level check error. If you want to copy a PF without making any modification to it then FORMAT keyword is used. Default access path maintenance is *IMMED Maximum no of printer files included in a RPGLE program is 8 Maximum no of files declared in RPGLE is 50 and CL is l Maximum no of key fields included is 120 Maximum no of fields included in a PF is 8000 Maximum no of arrays included is a RPG is 200 Maximum no of parameter passed in a RPG is 255 and CL 40 Total no of system library is 15 and user library is 25 While logging on the first library to be included is QSYS QGPH and QTEMP are user library Printer file default length is 132. Default size of a member is CRTSRCPF command for ordinary files is 92.

115. What's the difference between CHAIN and SETLL? Is there a performance advantage?
There are two important differences between CHAIN and SETLL. 1. The CHAIN operation applies a record lock to files that are open or update. The SETLL operation does not apply the lock. 2. The CHAIN operation copies the record's data to the input buffer for the program. The SETLL operation does not.

More Details
The CHAIN operation performs a random GET operation to the database file. If the operation is successful, the data in the record is copied to the input buffer. If the CHAIN operation fails, a record-not-found condition is signaled, typically via Resulting Indicator 1. If the database file has been opened for UPDATE, the CHAIN operation places a record lock on the retrieved record. No other application can access this record for update while this lock is applied. Furthermore, if another program has issued a lock to the recording being accessed, the CHAIN operation will wait for the database time-out period. If the record is released during that period, the CHAIN operation continues. If the other program does not release the record, the CHAIN operation fails with an exception. CHAIN with NO LOCK The CHAIN operation supports the NO LOCK operation extender (the old "half-adjust" column). In RPG III you specify an N in the operation extender column, in RPG IV, you specify CHAIN (n) for the operation code. Using NO LOCK allows you to access a record without a record lock being applied, regardless of the way in which the file is open. The record's data, however, is still copied to the input buffer when NO LOCK is specified. The SETLL operation performs a quasi READ LESS THAN OR EQUAL operation. If the operation is successful, a READ PRIOR is performed. The database record's data, however, is not

copied to the input buffer, nor is there a record lock applied to the accessed record. Hence, SETLL is probably the operation code to use for testing the existence of a record. However, if the record needs to be retrieved, CHAIN more effective.

Performance
If your requirement is to check for the existence of a record, traditionally the CHAIN operation is used. However, since CHAIN copies the record's data to your program's input buffer, there is additional overhead required for the CHAIN operation. The SETLL can be used to effectively accomplish the same task as the CHAIN test. Use SETLL with resulting indicator 3 (equal). If this indicator is set on, a record exists whose key matches they value specified in Factor 1. If your requirement is that the record eventually be updated, subsequent to the existents test, you should consider using of CHAIN.

116. How do I debug a remote (i.e. "batch") job from an interactive job?
The ability to debug another job has been a long-standing requirement for AS/400, now iSeries programmers. It isn't as difficult as it may seem. Whether you need to debug a batch job, another interactive job, or an HTTP server job (browser/CGI program), the following steps can get you started.

Starting Debug for a Remote Job


1. Determine the job name of number for the job you need to debug. Use WRKACTJOB and note the Job name, number and user profile ID. If debugging a CGI program, look in the job log of the job for CPF message HTP2001. 2. Run the Start Service Job (STRSRVJOB) command specifying the job to be debugged E.g., STRSRVJOB JOB (012345/usrid/jobname) 3. Run Start Debug (STRDBG) on the program to be debugged E.g., STRDBG PGM (libnam/pgmname) UPDPROD(*YES | *NO) 4. At this point the program in the remote job is under debug control from your job You can now set break points (if you're debugging an RPG IV program, the source will have already been displayed). Press F12 from within the debugger to return to CMD entry after setting your break points. 5. Evoke the program in the remote job. If you you're doing a web browser session, hit the SUBMIT button. 6. You interactive job will "break" at the debug break points and you can debug application normally.

Ending Debug for a Remote Job


Ending the debug session should be done in the following sequence. 1. From your debugging session, run the End Debug (ENDDBG) command 2. Then run the (End Service Job) ENDSRVJOB command Your session is no longer controlling the remote job. The remote job continues normally.

Special Considerations when Debugging a Web Browser/CGI Program


To debug a CGI program that is evoked from a Web Browser session running from the standard IBM HTTP Web Server, you need to do the following in addition to the above.

Before Starting Debug for a Web Browser/CGI Session/Program


End the HTTP Server using the following CL command: ENDTCPSVR *HTTP WARNING!!! -- You MUST include *HTTP as the parameter for ENDTCPSVR otherwise all TCP/IP server jobs (including telnet, ftp, smtp, etc.) will be ended. And this is a bad thing. IBM sucks for making *ALL the default for ENDTCPSVR. Restart the HTTP Server using the following CL command: STRTCPSVR *HTTP HTTPSVR(DEFAULT '-minat 1 -maxat 1') This restarts the HTTP server with once instance of each job type (one for CGI, one for Java, etc.) Using WRKACTJOB in the QHTTPSVR subsystem location the jobs running. The job whose joblog contains the CPF message HTP2001 is the one to be debugged. After Finishing the Debug Session End the HTTP server using the following CL command: ENDTCPSVR *HTTP Restart the HTTP server using the following CL command, unless your shop has another process for starting the HTTP server: STRTCPSVR *HTTP Your system should be back to normal.

117. What is the new E operation extender used for? The new (E) operation extender is used to cause the %ERROR and %STATUS built-in functions to be initialized after an operation is performed. That

is, these built-in functions and the E operation extender are used in place of Resulting Indicator 2 on all operation codes that currently support Resulting Indicator 2 as an error condition.
For example, to check to see if a record is locked, you would code the following:
.....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C CustNO Chain(E) CustMast %ERROR = *ON C if C Select C When %STATUS = 1221 C exsr UpdateNoRead %STATUS = 1218 C When C exsr RecdLocked C endSL C ELSE C if %FOUND( CustMast ) C exsr whatever... C endif C endif

The concept is to first check %ERROR for a generalized error condition, and then check %STATUS for the specific error. Note that no resulting indicators are used in the previous example. The normal not-found condition is checked using the %FOUND built-in function rather than testing Resulting Indicator 1.

118. Why doesn't the %CHAR built-in function work with numeric values?
Under the initial release of OS/400 Version 4, Release 2, the %CHAR built-in function was introduced. However, the function, as designed, only converted DATE values to character values. This proved to be too restrictive a use for this function. In the next release of OS/400 (V4R4) IBM will add function to %CHAR allowing it to convert all forms of non-character data to character. In that release %CHAR will function with numeric values.
D Amount C Eval 7P 2 Inz(123.45) text = 'The amount is: ' + %Char( amount )

The TEXT field would contain the following after the EVAL operation is performed: 'The amount is: 123.45' Unlike %EDITC, the %CHAR built-in function trims off leading blanks. However, %EDITC provides much more editing power than %CHAR. Use %CHAR for basic number to character conversion.

119. What's new in V4R4 and RPG IV?


There are a few significant enhancements in RPG IV in OS/400 Version 4, Release 4. The %CHAR built-in function has be fixed. It now functions like it was supposed to in the first place. You can wrap a numeric value in %CHAR and a nicely edited character form of the number is returned. The edited form includes the decimal, trimmed off leading blanks, and a negative sign.

The FOR loop provides a free-format version of the DO operation code. With the FOR operation, you can begin a loop operation and continue iterating through the loop until a variable equals a limit value. The syntax for the FOR operation is enhanced with the TO, BY and DOWNTO keywords. The TO operation indicators the upper limit for the looping, while the BY keyword identifies the increment value for the loop counter. Alternatively, you can specify the DOWNTO keyword to loop backwards from a large value to a small value. The OPENOPT keyword is added to the Header specification. This keyword can be used along with its one and only keyword *INZOFL to cause overflow indicators to be set off when their corresponding printer file is closed and then re-opened during the program. In subroutines, the LEAVESR operation can now be used to exit a subroutine immediately. Effectively this is a "glorified goto" operation that branches to the ENDSR statement of a subroutine.

120. How does the CONST keyword work with Procedure parameters?
If you are certain that the called procedure will NOT modify a parameter, the CONST keyword can provide several benefits. 1. It automatically converts a field of a similar data type, to the length and type required by the parameter. What this means, is say a parameter is a 15 position pack field, with 5 decimals. Normally, you'd have to specify a Pdk(15,5) field for the parameter. However, if the parameter is read-only, you can specify CONST on the Prototype and Procedure Interface for the parameter. When you do this, the compiler automatically converts the value (say it's a literal of 27) to the size and type required by the parameter. This works really cool with DATE fields. A date for any format can be passed as a parameter value when that parameter value is CONST. 2. Performance is improved because the compiler can generate more optimized code for the CONST parameter. CONST can be used on calls to procedures or programs. We use it all the time when calling QCMDEXC from within RPG IV. All three parameters of the QCMDEXC program are CONST values. The example code below can be used as the PROTOTYPE to call QCMDEXC from within RPG IV. To call it using this prototype, specify something like: CALLP run('addlible myLib' 14) in your calculation specs.
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++ D Run PR ExtPgm('QCMDEXC') D cmdstr 3000A Const Options(*VarSize) D cmdlen 15P 5 Const D cmdDbcs 3A Const Options(*NOPASS)

Note: if you're using CodeStudio or IBM's Code/400 as your RPG IV editor under Windows, you could simply highlight the above source code within your Internet Browser, and copy it to the Windows clipboard. Then activate CodeStudio (or Code/400) and use the Paste function to insert the code directly into the editor. Pretty cool, huh? <g>

121. Can you clear up the confusion in the different releases of RPG IV and OS/400 and ILE?
RPG IV is the next generation of the RPG language. RPG III is the original version of AS/400 RPG/400. The name "AS/400 RPG/400" is that given to the IBM compiler package for distribution on the AS/400. This compiler package compiles various versions of RPG, including RPGII and at least two releases of RPGIII. As of OS/400 Version 3 release 1, IBM changed the name of this compiler package to "AS/400 ILE RPG/400". The reason for this name change was to identify that fact that the compile now includes a version of RPG that targets the Integrated Language Environment (ILE), that is RPG IV. ILE was first shipped in OS/400 Version 2, Release 3. However, only the C language compiler produced code that targeted this environment. First, a word about ILE. ILE is the new, "native" runtime environment for Programs, on the AS/400. Under OS/400 Version 2 Release 3, IBM introduced a new program model. This basically means that new features and interfaces became available. However, IBM did not just port some runtime environment to the OS/400 operating system, it actually re-wrote code, and wrote new code that, essentially, changed the way OS/400 works. This new code provides support for a mixed set of high-level languages. Previously, RPG and CL had their own little runtime environment, COBOL had it's own, C had it's own, and so on. Under ILE, all programming languages run in ILE. The same "environment" is used for COBOL, C, RPG and CL. However, to take advantage of ILE, new compilers needed to be created. As for RPG, rather than convert the existing RPGII and RPGIII compilers, IBM, who was designing a new version of RPG anyway, decided to target ILE with the new compiler. This would simultaneously provide a new version of RPG and an ILE targeted compiler.

Names Are Important


A good friend of mine once said, "names are important" in the programming world. If a field is called "Rhinoceros", does it represent its use or purpose? Okay, so perhaps in traditional RPG "Iguana" is a better choice for this example. (Shorter name.) During the development of RPG IV, two distinct issues arose. First, the internal name for RPG IV, was "ILE RPG". This was not a code name, but rather the name IBM used to refer to the new compiler. After all, it was targeting ILE, why not refer to it as "ILE RPG"? Second, the rearchitecture of RPG came into question. Unfortunately, the internal name "ILE RPG" began to be leaked out to the public. Several magazine writers and IBMers not involved in the development of RPG IV continued to use the term "ILE RPG" when referring to RPG IV. I suppose these people still refer to the AS/400 as SilverLake or perhaps even Olympic. Then when IBM announced the compiler package or product name as "AS/400 ILE RPG/400" it only added to the confusion. IBM dropped the ball when promoting the RPG IV name. They are, after all, set up to market their products with their product names. The name of one programming language included in a product that contains nearly seven full compilers isn't high priority.

RPG IV is the version of RPG that targets ILE. OS/400 V3R1 compatible RPG IV can also target what is now called "the original program model" or simply OPM. OPM is just a name that has been given to the original runtime environment of RPG and CL under OS/400. This is the environment in which RPGIII and CL run. Under ILE, however, the original native environment is emulated, that is, ILE isn't an environment at all, it is native OS/400, whereas, OPM is now an environment under ILE. Some very clever programming and design went into this, don't you think? Not very many other operating systems, if any, provide this kind of continuity.

RPG IV -- Release what?


RPG IV was first shipped with OS/400 Version 3, Release 1. This is now referred to as RPG IV release 1. But don't worry about remembering releases of RPG IV. Under OS/400 Version 3, Release 6, IBM enhanced RPG with procedures, many more built-in functions, and several new data types. This is referred to as RPG IV release 2. Then, OS/400 Version 3, Release 2 was announced. It brought the original release of RPG IV (on the CISC boxes) up to the same level as RPG IV under V3R6. Are you confused yet? Me too! Under OS/400 Version 3, Release 7, IBM added a couple of enhancements, most notably they increased the length of a field name to a number so large not even magazine authors that don't write real-world code could complain about it anymore. They also added one or two new data types, rounding out RPG IV so that it supports all AS/400 data types, except variable length fields. This version of RPG IV is known as RPG IV Release 3. The following table identifies the current releases of RPG IV. Note that RPG IV releases do not necessarily coincide with releases of the operating system. RPG IV Release 1 2 2 3 4 4 OS/400 Version/Release CISC or RISC

V3 R1 V3 R6 V3 R2 V3 R7 V4 R2 V3 R5 See note 1 V4 R3 V4 R4 (February 1999) (speculation)

CISC RISC CISC RISC RISC CISC

5 5

RISC RISC

V4 R5 (Summer 2000)

RISC

NOTE 1: It is speculated that IBM may ship a final "clean up" release of OS/400 for CISC that would included a large level of compatibility with OS/400 V4 R5. The release levels of RPG IV are only important if you want to keep track of that kind of thing. One disappointing issue is that unless you stay on the most current release of OS/400, you don't get all the cool new features in RPG IV. Even if you stay current, you can't target prior releases if you use any of the new features. In fact, even if you use a new feature that doesn't depend on an operating system enhancement, it can't be used for back releases. This is because of the way the TGTRLS (target release) feature has been implemented. Basically, if you're on V4 R2 and you do a TGTRLS(V3R2M0) the compiler calls the actual compiler for V3 R2. It doesn't have a built-in syntax checker that says "This feature requires an OS/400 upgrade so don't allow it, or this one is okay so accept it." It iscalling the same "binary" compiler code that is on any old V3 R2 system. Which means, for example, that if you want to take advantage of the new compiler directives, but you often have to target a prior release, you can't use those directives. For example, /IF DEFINED does nothing for the executable code that's generated, but is not supported when TGTRLS(V3R2M0) is specified. ;( Bummer!) So now we know about RPG IV release levels and how the term "ILE RPG" got into our vocabulary. So let's clear up another term, the name of the RPG language. The big one is the term "RPG/400". There is not programming language called "RPG/400". The language most often called "RPG/400" is RPGIII. However, back in the System/38 days, the System/38 RPG language was called RPGIII. When the AS/400 was announced, programmers wanted to give themselves an advantage on their rsum. So they began calling AS/400 RPGIII, "RPG/400". Then to make matter worse, when RPG IV was announced, programmers thought that the number "IV" in "RPG IV" was less than the "400" in "RPG/400". So they decided to call RPG IV, "ILE RPG". Well let's set the record straight. The table below lists the RPG language names, their incorrect name, and the proper name. Commonly used Wrong Name RPG/36 RPG/38 RPG/400 ILE RPG Formal Name Proper Name (correct)

System/36-compatible RPGII System/38-compatible RPGIII RPGIII RPG IV

RPGII RPGIII RPGIII RPG IV

122. How do I declare an array with a dynamic number of elements?


In RPG IV, the new (V3 R7) ALLOC, REALLOC and DEALLOC operation codes can be used to allocate memory. This means that at run time, you can go out to the system and ask it to assign storage to the program that was not allocated to the program when it was evoked.

These operation codes can be used to allocate memory up to 16MB. The allocation can be assigned to a pointer variable. In RPG IV, pointers have the data-type of asterisk (*). All that is needed is to allocate memory to a pointer that is used with the BASED keyword of the desired dynamic array. The example that follows illustrates this technique:
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++ D DynoArr S 7P 0 Dim(10000) based( pDynoArr) D nSize S 10i 0 .....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++ C Eval nsize = %size(DinoArr) * 64 .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C Alloc nSize pDynoArr

** We now have enough storage allocated for 64 elements.


C Eval nsize = %size(DinoArr) * 70 C ReAlloc nSize pDynoArr ** We have changed the allocation to enough storage for 70 elements C* ... code to use the array goes here... C Dealloc(N) pDynoArr ** We have just returned the storage to the system.

To increase or decrease the number of elements in the dynamic array, use the REALLOC operation code. Simply change the number of bytes that need to be allocated, and call REALLOC with the new size in Factor 2 and the original pointer variable in the Result field. REALLOC allocates new storage of the size specified, and copies the original data to that new location. Then it frees ("deallocates") the original storage. IMPORTANT: Always remember to DEALLOC anything you ALLOC. That is always free up memory that you have allocated otherwise memory leaks will be created. If you are not on V3 R7, you can still use dynamic memory by calling one of the system APIs or linking into the QC2LE binding directory and calling the C runtime MALLOC and DEALLOC functions.
123. RPG IV - Built-in Functions

The original release of RPG IV included a set of built-in functions. These built-in functions were: %ADDR, %PADDR, %SIZE, %ELEM, %SUBST, %TRIM, %TRIML, %TRIMR In addition, under OS/400 V3R2 and V3R7 the %PARMS built-in function was introduced. Since then, several built-in functions have been added to RPG IV. The following table provides the OS/400 Version and Release that the specific built-in functions were introduced and/or enhanced. NOTE: IBM Seems to skip-ship the RPG IV compiler. So RPG IV in V4R1, V4R3 and V4R5 have no new functionality. The next scheduled upgrade is OS/400 V5R1 in Spring 2001.

Version Release V3R7

Built-in Function

Parameters

Return Value Description

%ABS

numeric expression

Absolute value of expression

%ADDR V5R1 V4R2 V4R4 V5R1 %ALLOC %CHAR

variable name memory size graphic, date, time, timestamp, or numeric expression compare-value : data-to-search { : start-position } compare-value : data-to-search { : start-position }

Address of variable Pointer to the allocated storage. Value in character data type

%CHECK

First position in the searched-data that contains a character not in the list of the characters in the compare value. Last position in the searched-data that contains a character not in the list of the characters in the compare value. (Search begins with the right-most character and proceeds to the left. A date data-type value after converting the "value" to the specified date format. If no value is specified, the current system date is returned. A duration value that can be used in an expression to add a number of days to a date value. Value in packed numeric format. If digits and decpos are specified the result value is formatted to fit in a variable of the number of digits specified. Half-adjusted value in packed numeric format. The length and decimal positions Number of decimal digits. Calculates the difference between two date fields. The type of difference returned is specified by the duration-code. Performs integer division and returns the quotient (result) of that division operation.

V5R1

%CHECKR

V5R1

%DATE

{ value { : dateformat-code }

V5R1

%DAYS

days

V3R7

%DEC

numeric expression {:digits : decpos}

V3R7

%DECH

numeric expression : digits : decpos numeric expression start-date : end-date : duration-code

V3R7 V5R1

%DECPOS %DIFF

V4R4

%DIV

Numerator Denominator

V3R7

%EDITC

non-float numeric expression : edit code {:*CURSYM | *ASTFILL | currency symbol} numeric expression non-float numeric expression : edit word array, table, or multiple occurrence data structure name {file name}

String representing edited value.

V3R7 V3R7

%EDITFLT %EDITW

Character external representation of float.

display

String representing edited value

%ELEM

Number of occurrences

elements

or

V4R2

%EOF

'1' if the most recent file input operation or write to a subfile (for a particular file, if specified) | ended in an end-of-file or | beginning-of-file condition '0' otherwise. '1' if the most recent SETLL (for a particular file, if specified) or LOOKUP operation found an exact match '0' otherwise. '1' if the most recent operation code with extender 'E' specified resulted in an error '0' otherwise.

V4R2

%EQUAL

{file name}

V4R2

%ERROR

V3R7 V4R2

%FLOAT %FOUND

numeric expression {file name}

Value in float format. '1' if the most recent relevant operation (for a particular file, if specified) found a record (CHAIN, DELETE, SETGT, SETLL), an element (LOOKUP), or a match (CHECK, CHECKR, SCAN) '0' otherwise. Converts character data to double-byte character set value. A duration value that can be used in an expression to add a number of hours to a time value. Value in integer format

V4R4 V5R1

%GRAPHIC %HOURS

Any character value hours

V3R7

%INT

numeric expression

V3R7 V3R7

%INTH %LEN

numeric expression any expression

Half-adjusted value in integer format 1. Returns the length of a variable or literal value, or the current length of a varying length field. 2. When used on the left side of the equal sign, sets the length of a varying length field. An array index of the element in the array where the search-data is located. *ON if the search is successful, otherwise *OFF. (NOTE: The indexes of the searched-table and alternate-table are set to the index of the search-data if *ON is returned.) A duration value that can be used in an expression to add a number of minutes to a time value. A duration value that can be used in an expression to add a number of months to a date value. A duration value that can be used in an expression to add a number of milliseconds to a time value.

V5R1

%LOOKUPxx

search-data : array { : start-index { : elements to search }} search-data : searched-table { : alternate-table }

V5R1

%TLOOKUPxx

V5R1

%MINUTES

minutes

V5R1

%MONTHS

months

V5R1

%MSECONDS

milliseconds

V3R7

%NULLIND

null-capable name data-structure

field

Value in indicator format representing the null indicator setting for the null-capable field. The current occurrence of the data structure, or sets the current occurrence of the data structure '1' if the specified file is open '0' if the specified file is closed. Consider this built-in to be an 'Is this file open?" operation. Address of procedure

V5R1

%OCCUR

V4R2

%OPEN

file name

%PADDR

procedure name

V3R2 V3R6 V5R1 V4R4

%PARMS %REALLOC %REM pointer : new-size Numerator Denominator :

Number of parameters passed to procedure Pointer to the allocated storage. Performs integer division and returns the remainder from the division operation. String produced by inserting replacement string into source string, starting at start position and replacing the specified number of characters. First position of search argument in string or zero, if not found. A duration value that can be used in an expression to add a number of seconds to a time value. *ON if the job is being shut down (e.g., when the PWRDWNSYS command is issued) otherwise *OFF is returned. variable, data structure, array, or literal {: *ALL} Number of bytes used by variable or literal. *ALL returns the number of bytes used by all the elements of the array, or all the occurrences of the data structure. The square root of the expression or value. 0 if no program or file error occurred since the most recent operation code with extender 'E' specified most recent value set for any program or file status, if an error occurred if a file is specified, the value returned is the most recent status for that file. Characters addressed by pointer argument up to but not including the first x'00'. The extracted component of the

V4R2

%REPLACE

replacement string: source string {:start position {:source length to replace}} search argument : string to be searched {:start position} seconds

V3R7

%SCAN

V5R1

%SECONDS

V5R1

%SHTDN

%SIZE

V5R1 V4R2

%SQRT %STATUS

expression or value {file name}

V3R7

%STR

pointer{:maximum length} date : duration-code

V5R1

%SUBDT

date value. (The equivalent of the operation code.) %SUBST string:start{:length}

functional EXTRCT

Substring value. If length is not specified, the substring begins with start and continues through the end of the string. Used for Java integration. Returns an Object reference.

V5R1 V5R1

%THIS %TIME { value { : timeformat-code }

A time data-type value after converting the "value" to the specified time format. If no value is specified, the current system time is returned. A timestamp data-type value with or without separators. String with left and right blanks trimmed (removed) String with left blanks trimmed String with right blanks trimmed Returns a varying length value. Value in unsigned format Half-adjusted value in unsigned format The converted string is returned.

V5R1

%TIMESTAMP %TRIM %TRIML %TRIMR

{value { : *ISO | *ISO0 } string string string Any character value numeric expression numeric expression from-table : to-table : string-to-convert { : starting-position } Array name

V4R4 V4R2 V4R2 V5R1

%UCS2 %UNS %UNSH %XLATE

V4R4

%XFOOT

Cross foots (totals) elements in an array.

all

the

Define General Keywords Subfile control record . . . . . . . . . : Type choices, press Enter. Related subfile record . . . . . . . Subfile cursor relative record . . . Subfile mode . . . . . . . . . . . . SCREENC1

Keyword SFLCTL SFLCSRRRN SFLMODE

SCREENS1

Name Name Name

Display subfile records . . . . . . Display control record . . . . . . .

SFLDSP SFLDSPCTL

Y=Yes Y Y

Indicators/+ 40 40

Initialize subfile fields Delete subfile area . . . Clear subfile records . . Indicate more records . . SFLEND parameter . . . SFLEND parameter . . . Record not active . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

SFLINZ SFLDLT SFLCLR SFLEND *MORE *SCRBAR SFLRNA Keyword SFLDROP SFLFOLD SFLENTER

N40 N40 40 *MORE ...

Y CFnn/CAnn Indicators/+

Subfile initially truncated . . . . Subfile initially folded . . . . . . Use instead of Enter key . . . . . . F3=Exit F12=Cancel

More...

-----Original Message----From: Rajagopal CV [mailto:rajagopal.cv@tatainfotech.com] Sent: Thursday, July 17, 2003 8:23 AM To: Gautam Bhandari; sumit.set@rebusis.com; prakashk@ggn.hcltech.com Subject: Re: Hi gautam, You are quite near the answer in all the cases. I have been working on this yesterday. Please find below my findings. 1. An existing Phy file's DDS has been changed What all steps do u take to create the new *FILE object. For this we have to do all the steps in a CL. No RPG pgm allowed. >First As you said redirect the output of DSPDBR into a file. >RCVF on that file and get the attached logical . (I got stuck here . I was not sure how to retrieve a DB file using RCVF Statement) >Before compiling the new DDS , delete the logicals. > Do CPYF and take backup. > Compile the new DDS. > Copy back the backed up file with *MAP,*DROP option > Recompile the logicals. You will get the SDource member and library from DSPDBR output. 3. Can a call a compiled module of an RPGLE pgm which has only a main procedure ? Yes u can call a compiled *MODULE object using CALLB. But the *MODULE object will have only HFDCO specs . No subprocedures with P . I am just trying to code a program . i.e do CRTPGM (Mod 1, mod2, mod3, Mod4) Mod 1 is your entry module. From Mod 1 you can do CALLB to MOD2, mod3, mod4 etc . I din know this 4. What is signature violation while running ILE programs. whats steps will u take to over come this. This happens in 2 cases 1. Your service program has changed, you have updated the service program using UPDSRVPGM , But you have not updated the program using UPDPGM 2. Your pgm is latest but you have forgotten to do a UPDSRVPGM He said we can find out a Signature attached to a service program using DSP Program refernce . I did not understand . My fundas in ILE is so so ....

6. What is to use of MONMSG. Is EXEC param mandatory ..If EXEC is not added what will happen to the program flow From where do I get the list of message id's corresponding to each Command (Apart from manuals)

The list of escape message is also available on the help of each command. Take F1 on a particular command . Just after the description of the command they have also given all escape messages attached to a command.

7. Does CHAIN statement lock the record beiing chained Is there a way I can lock a record using chain Statement. It seems along with CHAIN ststement we can specify H,N etc to lock your record exclusively ..Need to probe on that . I am yet to try this 8. A pgm has primary File defined in it. The Pri file has no recods. Will the program end normally or abnormally ? Yes it ends normally 9. What is overflow indicator ? Where do I defined it .Do we SETON or SETOF an overflow indicator what happens if I SETON the overflow indicator in the first statement of my program. Please send the pgm codes you have written with overflow indicators

----- Original Message ----From: Gautam Bhandari To: Rajagopal CV ; sumit.set@rebusis.com ; prakashk@ggn.hcltech.com Sent: Tuesday, July 15, 2003 7:13 PM Subject: RE:

HEY GUYS I HAVE TRIED TO ANSWER AS FAR AS I KNOW OR THINK I KNOW PLEASE CORRECT ME WHERE IM WRONG......

1)what did u do ...cpyf to some xyz file which u created within cpyf ....then crtpf (changed dds) and then copy data back from xyz to compiled file..........for dspdbr u took output in outfile and then read that file thru rpg to know name of dependents.......how did u do it this is interesting

3) i guess no but not really sure

4) i think it has some thing to do with identifiers(format or record level) created at compile time ...so whenever u recompile new identifiers are created so all programs using this object ....u may have to recompile to overcome this voilations

6) in library qsys there are message files QXXXMSG WHERE XXX IS FOR MESSAGES U WANT ESCAPE MESSAGES CPFSERIES RESIDE IN QCPFMSG FILE IN QSYS AND SO ON ....IF U HAVE as-400 ACCESS THEN JUST DO WRKMSGF QSYS/*ALL AND ULL FIND ALL THESE MESSAGE FILES.........

MONMSG I GUESS TRAPS THIS MESSAGE IDS AND USED TO MONITOR THESE MESSAGES SUCH AS ESCAPE...SO MONMSG MSGID(CPF000) MONITORS ALL CPF MESSAGES.

7) i think chain locks record .......u can chain with no lock by specifying chain(n).....and other one is CHAIN(E) what it does i don know....

8)should end normally.

9) overflow indicator at f specs with printer file......this is set on by itself when page length specified while compiling printer file ( take 14 and f10 on printer file being compiled ull see) is reached and on it being on you have the logic for skip page (write header again).....have written a couple of programs if u need i can send it to u

10) at openqryf u have to specify a parm open which can be *inp; *out;*upd;*all............. yes u can override a specific member also..... u can update records if u give lock state of record format as *shrupd but if u give *Shrunp u cannot

12) CMPPFM OR OPTION 54 ON WRKMBRPDM SCREEN

13) MULTI DIM ARRAY (THOUGH NOT VERY SURE THIS I TOO HAVE NEEDED IN FEW PROGRAMS BUT HAVE ALWAYS USED A WORKAROUND)

D D

XYZ XY1

DS 1 8 DIM(2)

14) single page subfiles are used instead of load all when the output may have huge number of records and you are not aware of its number ...what happens is load all will fst get alll the records and then display them which may take a lot of time and resource s if o/p is gigantic where as in single page you get the num of records specified in sflpag and display them then go back get other set and display them.......u have to handle page up and page down thru pollup and rolldown indicators which are set on and off in rpg....mind u roll up is page down

15) u have something as a fix numeric as a parm for create pgm which does something for this purpose -----Original Message----From: Rajagopal CV [mailto:rajagopal.cv@tatainfotech.com] Sent: Tuesday, July 15, 2003 5:26 AM To: Undisclosed-Recipient:@nepzmail.in.tatainfotech.com; Subject: Fw: Dear friends,

Jus wanted to share the type of questions asked during technical rounds of as400 skills

1. An existing Phy file's DDS has been changed What all steps do u take to create the new *FILE object.

Write all the steps in a CL program to create the new object of Physical file including back-up, creating new logicals etc etc. Even DSPDBRhas to be within the CL program..

I had to really sweat OUT writing the CL pgm

2. Is PGM and ENDPGM mandatory in CL Pgm. When is it mandatory ?

Not mandatory. But used if we have to pass a parameter to the CL program

3. Can a call a compiled module of an RPGLE pgm which has only a main procedure ?

4. What is signature violation while running ILE programs. whats steps will u take to over come this.

5. How do I debug a batch program ? Using STRSRVJOB How do I debug a batch program wriiten in RPG/400. i.e we have to run STRDBG on an RPG/400 program. How,

6. What is to use of MONMSG. Is EXEC param mandatory ..If EXEC is not added what will happen to the program flow From where do I get the list of message id's corresponding to each Command (Apart from manuals)

7. Does CHAIN statement lock the record beiing chained Is there a way I can lock a record using chain Statement.

It seems along with CHAIN ststement we can specify H,N etc to lock your record exclusively ..Need to probe on that .

8. A pgm has primary File defined in it. The Pri file has no recods. Will the program end normally or abnormally ?

9. What is overflow indicator ? Where do I defined it .Do we SETON or SETOF an overflow indicator what happens if I SETON the overflow indicator in the first statement of my program.

10. What is OPNQRYF. Do we need to OVRDBF the file before OPNQRYF. If yes then why ? Can I update the File's records which is opened using OPNQRYF statement?

There were questions on Multimember physical file. Can I override to a member of a Phy file. During OVRDBF what is *SHDUPD param do.

11.What is a join file . How do I create a join file. What is the necessary condition to create a join file.

12. Which command do I use to compare the sources of two Programs ?

13. Differences between Arrays ..What is an Array File ? How can I have multi-dimensional arrays in RPG.

14.Basic concepts of Subfile ..Keywords etc. ...Esp on SFLNXTCHG ..where is it defined and how READC is used etc etc ......Why should we go for Single page ..How do I view the 15th page if I am viewing the 25th page ..How is Page up,Page down handled in Single page subfiles

15. What is decimal data error... can I make a program ignore decimal data error.

It seems while CRTPGM we can mention it to *Ignore decimal-data errors.

That's all I can remember now

-----Original Message----From: Rajagopal CV [mailto:rajagopal.cv@tatainfotech.com] Sent: Tuesday, July 15, 2003 3:56 PM To: Undisclosed-Recipient:@nepzmail.in.tatainfotech.com; Subject: Fw: Dear friends, Jus wanted to share the type of questions asked during technical rounds of as400 skills 1. An existing Phy file's DDS has been changed What all steps do u take to create the new *FILE object. Write all the steps in a CL program to create the new object of Physical file including back-up, creating new logicals etc etc. Even DSPDBRhas to be within the CL program.. I had to really sweat OUT writing the CL pgm 2. Is PGM and ENDPGM mandatory in CL Pgm. When is it mandatory ? Not mandatory. But used if we have to pass a parameter to the CL program 3. Can a call a compiled module of an RPGLE pgm which has only a main procedure ? 4. What is signature violation while running ILE programs. whats steps will u take to over come this. 5. How do I debug a batch program ? Using STRSRVJOB How do I debug a batch program wriiten in RPG/400. i.e we have to run STRDBG on an RPG/400 program. How, 6. What is to use of MONMSG. Is EXEC param mandatory ..If EXEC is not added what will happen to the program flow From where do I get the list of message id's corresponding to each Command (Apart from manuals)

7. Does CHAIN statement lock the record beiing chained Is there a way I can lock a record using chain Statement. It seems along with CHAIN ststement we can specify H,N etc to lock your record exclusively ..Need to probe on that .

8. A pgm has primary File defined in it. The Pri file has no recods. Will the program end normally or abnormally ? 9. What is overflow indicator ? Where do I defined it .Do we SETON or SETOF an overflow indicator what happens if I SETON the overflow indicator in the first statement of my program. 10. What is OPNQRYF. Do we need to OVRDBF the file before OPNQRYF. If yes then why ? Can I update the File's records which is opened using OPNQRYF statement? There were questions on Multimember physical file. Can I override to a member of a Phy file. During OVRDBF what is *SHDUPD param do.

11.What is a join file . How do I create a join file. What is the necessary condition to create a join file. 12. Which command do I use to compare the sources of two Programs ? 13. Differences between Arrays ..What is an Array File ? How can I have multi-dimensional arrays in RPG. 14.Basic concepts of Subfile ..Keywords etc. ...Esp on SFLNXTCHG ..where is it defined and how READC is used etc etc ......Why should we go for Single page ..How do I view the 15th page if I am viewing the 25th page ..How is Page up,Page down handled in Single page subfiles

15. What is decimal data error... can I make a program ignore decimal data error. It seems while CRTPGM we can mention it to *Ignore decimal-data errors.

That's all I can remember now

AS/400 QUESTION BANK 1.Define library? A Library is a collection of objects. Type *LIB that is used to group related object and to find objects by name. A library is a directory to a group of objects. The number of objects contained in a library and the number of libraries on the system are limited only by the amount of storage available. All libraries are placed in the system library QSYS. Libraries provide a method for organizing objects. A library is an open-ended directory. A library can never become FULL as it has no finite size. Libraries themselves are objects. A library contain the object name, type, and the address Library list System library- 15 (QSYSLIB) QSYS QHLPSYS QUSRSYS Product library 2 Current library 1 User library - 25 (QUSRLIB) QGPL QTEMP MYLIB When you logon the first library to be load is QSYS. The system library is loaded at the first time. 2.Define object? Every thing that can be stored or retrieved on the system is known as an OBJECT. Objects exit to make users independent of the implementation used in the machine. The create object instruction establish the objects name and its type. All objects are structured with a common object header, and a type dependent functional portion. A user is not concerned with the space his object occupies. The system allocate space automatically WRKOBJPDM is used to display all object in such a library The library the object name and its type is Unique. 3.Define 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.Define physical file? It is a file, which physically occupies the portion of memory. A physical file contains one record format and one or more members. Its type PF. By using CRTPF command to create PF. Maximum number of fields included in a PF is 8000. Maximum no of key fields included is 120.

5.Define logical file?


Logical file does not occupies any memory space and logical file be derived from physical file. One or more logical file can be derived from a single physical file. A logical file can contain up to 32 record formats. It selects records dynamically. It cannot exist with out a physical file. 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 creating access path.

A logical file does not contain any data but provides the VIEWS of the data to satisfy endusers needs. There are two types Non join logical file Join logical file 6.Difference between physical file and logical file? Physical file Logical file

1. Occupies the portion of memory. Its Does not occupy any memory space. Does containing data. not contain any data. 2. A physical file contains one record A logical file can contain up to 32 record format formats.
3.Can be exist even with out LF 4. If you delete a LF, the PF can not be deleted 5.CRTPF command is used to create such object 6.The object type is PF Can not exist with out PF If you delete a LF, the PF can not be deleted CRTLF command is used to create such type object The object type is LF

7. What are the four levels of entries in physical file? (i). File level entries (optional): File level entries give the system information of the entire file. (UNIQUE, LIFO, FIFO, FCFO, REF) UNIQUE: A record cannot be entered or copied into a file if its key value is same as the key value of a record already existing in the file. LIFO: Last in first out FIFO: First in first out FCFO: First change first out. REF: This keyword is used to specify the name of the file from which the field descriptions are retrieved. Ex: you can specify whether the key is unique. (ii). Record format level entries: Record format level entries give the system information about specific record format in the file. For a PF the record format name is specified along with an optional text description. (FORMAT, TEXT) (i) FORMAT: This record-level keyword specifies that the record format being define is to share the field specifications of a previously defined record format. The name of the record format being defined must be the name of the previously defined record format. The format of this keyword is: FORMAT (LIB-NAME / FILE-NAME) (ii) TEXT: This record level keyword is used to supply a text description of the record format and it is used for documentation purposes only. The format of this keyword is: TEXT (description) (iii) Field level entries: The field names and field lengths are specified along with and optional text description for each field. (ALIAS, ALWNULL, CCSID, CHECK,

(v)

CHKMSGID, CMP, COLHDG, COMP, DATFMT, DATSEP, DFT, EDTCDE, EDTWRD, REFFLD, REFSHIFT, TEXT, TIMEFMT, TIMESEP, VALUES, VARLEN) Key field level entries: The field names used as key fields are specified. (DESCEND, SIGNED, ABSVAL, UNSIGNED, ZONE, NOALTSEQ, DIGIT)

8. What are the six levels of entries in logical file? (vii) File level entries (optional): File level entries give the system information of the entire file. You can specify whether the key is same as physical file. (viii) Record format level entries: Record format level entries give the system information about specific record format in the file. for examples ,for a logical file when a record format is described we can specify the physical file it is based on. (ix) JOIN Level entries: Join level entries give the system information about PF used in a JOIN LOGICAL FILE. (It is not applicable to NON JOIN LOGICAL FILES). (x) Field level entries (optional): The field level entries give the system information about individual fields in the record format. (xi) Key field level entries: The key field level entries give the system information about the key fields of a file. The field names used as key fields are specified. (xii) Select / Omit level entries: These entire give the system information about which records are to be returned to the program when processing the file. These specifications apply to logical file only. 9. Explain JDUPSEQ and JDFTVAL. JDUPSEQ: This join level keyword is used to specify the order in which records with duplicate join fields are presented when the JLF is read. The format for this keyword is: JDUPSEQ (Sequencing field-name [*DESCEND]) This keyword has no effect on the ordering of records with unique keys. If *DESCEND is not specified then the default is sequencing in ascending order. JDFTVAL: When this file-level keyword is used the system provides default values for all for 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 the secondary file is skipped. 10. What are the different between non-join logical files and join logical files. Non join logical file We can able to insert or delete or update records using non-logical file. DFU can be used to display non-join logical file. 1-32 record format is specified Commitment control is used Join logical file Insertion, updating or deletion of records is not possible in join logical files. DFU is not available Only one record format can be specified Commitment control cannot be used.

11. How many record formats can have physical & logical file. The physical file only one record format can be specified. The logical file 1-32 record format is specified

12. What is the advantage open query file? Dynamic selection of records It will sort the records based on the field values. We can retrieve records based on Virtual fields. Can create join logical files 13. Explain non-join logical file? Non-join logical files can either be a simple logical file, which contains only one record format or a multiple record format logical file, which contains more than one record format. Logical files can be derived from 1 to 32 physical files and so a logical file can have a maximum of 32 record formats. Single record format logical file: If a logical file is derived from single physical file it is called simple logical fie. Multiple record format logical file: Multiple record non-join logical files will select records from 2 or more physical files by referring to only one logical file. Each record format is always associated with one or more physical file. The same PF can be used in more than one record format. Specify the entries in single or multiple format logical files: 1.File-level entries (optional): (REFACCPTH, DYNSLT) REFACCPTH: The access path information for this logical file is to be copied from another PF or LF. Format of the keyword is: REFACCPTH (LIB name / DATABASE name) DYNSLT: This keyword is selection and omission tests in the file. This keyword specifies dynamic select/omit. 2.Record level entries:(PFILE) PFILE: The physical files containing the data to be accessed through the record formats being defined. Format of the keyword is: PFILE (LIB name / PF name) 3.Field-level entries (optional) 4. Key field level entries (optional) 5.Select and Omit field level entries (optional) REFACCPTHIt is applicable for non-join logical file only and meaning is referring the access path from the PF or LF in the file level entries. PFILE--- it is applicable only for non-join logical file in record level entries. 14. Explain join logical file? A join-logical file is a logical file that combines two or more PF. In the record format not all the fields need to exist in all the PF. A PF cannot be changed through a JLF. DFU cannot be used to display a JLF. Only one record format can be specified in a JLF. Commitment control cannot be used with a JLF. Key fields must be fields defined in the join record format and must be fields from the PRIMARY FILE. Specify the entries in join logical file: 1.File-level entries (optional): (JDFTVAL)

2.Record-level entries: (JFILE) 3.join-level entries :(JOIN, JFLD, JDUPSEQ) 4.field level entries (optional): (JREF, ALL, CONCAT, DYNSLT, RENAME, SST, TRNTBL) 5.Key field level entries (optional) 6.Select and Omit field level entries. (Optional) JFILE----It is similar to indicate that this is a join logical field and it must have more than 2 physical files. JOIN: It is similar that this file level entries to be represent the position of the files .There must one primary file and can have more than I secondary files.. JFLD: Which feels we are going to join. JREF: represents the primary file reference field JDFTVAL: represents that it as a left outer join.
SELECT OMIT Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMIT FMT PF. *************** Beginning of data ******************* 0001.00 R RECSEL 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ****************** End of data ************************ EMPNO EMPNAME 000001 10,001 SHYAM 000002 10,002 SANKA 000003 10,003 SHYAM 000004 10,004 SENTH 000005 10,005 SANKA 000006 10,006 SHYAM 000007 10,007 SANKA 000008 10,008 SENTH 000009 10,009 SHYAM 000010 10,010 SENTH ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF FMT LF... *************** Beginning of data ********************* 0001.00 R RECSEL PFILE (SELOMIT) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 10003) 0004.00 O EMPNAME CMP (EQ 'SHYAM') ****************** End of data ************************** Display Report EMPNO 000001 000002 000003 000004 000005 000006 000007 000008 ****** Columns SEU==> FMT LF 0001.00 0002.00 EMPNAME 10,002 SANKA 10,004 SENTH 10,005 SANKA 10,006 SHYAM 10,007 SANKA 10,008 SENTH 10,009 SHYAM 10,010 SENTH ******** End of report ******** . . . 1 71 Edit SELOMILF

KRAMANAVS/EXAMPLE

*************** Beginning of data ************************ R RECSEL PFILE (SELOMIT) K EMPNO

0003.00 0004.00

O EMPNAME CMP (EQ 'SHYAM') S EMPNO CMP (GT 10001) ****************** End of data ************************

EMPNO 000001 000002 000003 000004 000005 000006 ******

EMPNAME 10,002 SANKA 10,004 SENTH 10,005 SANKA 10,007 SANKA 10,008 SENTH 10,010 SENTH ******** End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMIT FMT PF. *************** Beginning of data ******************* 0001.00 R RECSEL 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ****************** End of data ************************

EMPNO EMPNAME 000001 20 SHYAM 000002 30 RAM 000003 40 TOM 000004 50 RAMESH 000005 60 SHYAM 000006 70 SHYAM 000007 80 TOM 000008 90 TOM 000009 100 VASU ****** ******** End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data ************************ 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 S EMPNAME VALUES ('SHYAM') ****************** End of data **************************

EMPNO

EMPNAME 000001 20 000002 60 000003 70 000004 80 000005 90 000006 100 ****** ********

SHYAM SHYAM SHYAM TOM TOM VASU End of report

********

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF. *************** Beginning of data ************************ 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 O EMPNO RANGE (20 40) ****************** End of data ***************************

EMPNO EMPNAME 000001 50 RAMESH 000002 60 SHYAM 000003 70 SHYAM 000004 80 TOM 000005 90 TOM 000006 100 VASU ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data **************** 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0004.00 S EMPNAME VALUES ('SHYAM') 0005.00 O EMPNO RANGE (70 90) ****************** End of data ******************** EMPNO EMPNAME 000001 20 SHYAM 000002 30 RAM 000003 40 TOM 000004 50 RAMESH 000005 60 SHYAM 000006 70 SHYAM 000007 80 TOM 000008 90 TOM 000009 100 VASU ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning of data ***************** 0001.00 R RECSEL PFILE (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO CMP (GT 50) 0005.00 O EMPNO RANGE (70 90) ****************** End of data ************************

EMPNO

EMPNAME SHYAM RAM TOM RAMESH SHYAM SHYAM TOM TOM VASU End of report

000001 20 000002 30 000003 40 000004 50 000005 60 000006 70 000007 80 000008 90 000009 100 ****** ********

********

15. Explain self join?


Joining a file to it self is known as self-join.

(Or) A physical file can be joined to itself to read records that are formed by combining two or more records from the PF itself.
Columns . . . 1 71 SEU==> SEJOIN FMT PF Edit KRAMANAVS/EXAMPLE

0001.00 0002.00 0003.00 0004.00 0005.00

*************** Beginning of data ******************** R EMP EMPID 5P 0 EMPNAME 20A MGRID 5P 0 K EMPID ****************** End of data *************************** EMPID EMPNAME MGRID 10,001 SEBI JOSEPH C. 50,001 10,002 PURUSHOTTAM 50,002 10,003 SAMEER DIGHE 50,003 10,004 SHARATA 50,004 10,005 PAUL 50,005 50,001 SHIVARAM 90,001 50,002 GAURAV 90,002 50,003 KING 90,003 50,004 SAM 90,004 50,005 ANIL 90,005 ******** End of report ******** . . . 1 71 Edit KRAMANAVS/EXAMPLE SELJOIN *************** Beginning of data ************************** R EMP JFILE (SEJOIN SEJOIN) J JOIN (1 2) JFLD (MGRID EMPID) EMPID JREF (1) EMPNAME JREF (1) MANAGER RENAME (EMPNAME) JREF (2) COLHDG ('MANAGER') ****************** End of data ***************************** EMPID 10,001 10,002 10,003 10,004 10,005 ******** EMPNAME MANAGER SEBI JOSEPH C. SHIVARAM PURUSHOTTAM GAURAV SAMEER DIGHE KING SHARATA SAM PAUL End of report ********

000001 000002 000003 000004 000005 000006 000007 000008 000009 000010 ****** Columns SEU==> FMT LF 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00

000001 000002 000003 000004 000005 ******

ANIL

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELJOIN1 FMT LF *************** Beginning of data************************ 0001.00 R EMP JFILE (SEJOIN SEJOIN) 0002.00 J JOIN (1 2) 0003.00 JFLD (MGRID EMPID) 0004.00 EMPID JREF (1) 0005.00 EMPNAME RENAME (EMPNAME) 0006.00 JREF (1) 0007.00 MGRID JREF (2) ****************** End of data *************************

EMPID EMPNAME MGRID 000001 10,001 SEBI JOSEPH C. 90,001 000002 10,002 PURUSHOTTAM 90,002 000003 10,003 SAMEER DIGHE 90,003 000004 10,004 SHARATA 90,004 000005 10,005 PAUL 90,005 ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELJOIN1 FMT LF *************** Beginning of data************************ 0001.00 R EMP JFILE (SEJOIN SEJOIN) 0002.00 J JOIN (1 2) 0003.00 JFLD (MGRID EMPID) 0004.00 EMPID JREF (1)

0005.00 MANAGER RENAME (EMPNAME) 0006.00 JREF (2) COLHDG ('MANAGER') 0007.00 MGRID JREF (2) ****************** End of data **************************** EMPID MANAGER MGRID 000001 10,001 SHIVARAM 90,001 000002 10,002 GAURAV 90,002 000003 10,003 KING 90,003 000004 10,004 SAM 90,004 000005 10,005 ANIL 90,005 ****** ******** End of report ********

16. Explain normalization?


It is the process of segregating and decomposing information held within a system into logically grouped, related. Uniquely identifiable entities

17. How to create user define command?


By using the CRTCMD command process the command definition statements to create the command definition object. The CRTCMD command may be run interactively or in a batch job.

Steps for creating CRTCMD commands 1.Enter the command definition statements into the source file Command type CMD
VRAMANA/CLP CMD1 *************** Beginning of data **************************** 0001.00 CMD ****************** End of data *******************************

2. Enter source program in any language


VRAMANA/CLP DLIB TYPE :CLP *************** Beginning of data ****************************** 0001.00 PGM 0002.00 DSPLIBL 0003.00 ENDPGM ****************** End of data *********************************

3. Create the command by using CRTCMD take f4


Command . . . . . . . . . . . . > KS Name Library . . . . . . . . . . . > VRAMANA Name, *CURLIB Program to process command . . . > DLIB Name, *REXX Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Source file . . . . . . . . . . > CLP Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Source member . . . . . . . . . > CMD1 Name, *CMD Threadsafe . . . . . . . . . . . *NO *YES, *NO, *COND Multithreaded job action . . . . *SYSVAL *SYSVAL, *RUN, *MSG, *NORUN Text 'description' . . . . . . . *SRCMBRTXT

18. How do copy a record in existing object to another object? By using CPYF command if you want data one position to another position. We can give the records coping position starting and ending of the records. We want particular records means. We can give the command in sq position. CPYF take F4
File name (source file) : PF01 Lib-name :VRAMANA New file name :PF02 Lib-name :VRAMANA :*FIRST Replace :*ADD :*NO

:*CHAR Start position End position Sql command :1000 :2000 : FILED EMPNO CONDITION *GT VALUE 40 :*MAP(add field) +DROP (delete field)

Record format mapping

19. Explain the command ADDPFCST?


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.

20.How will be establishing REFERENTIAL INTEGTITY in as/400 system? By using ADDPFCST command establish in as/400 system. Referential integrity concepts Referential constraint Parent and dependent files Unique key and primary keys Parent and foreign keys Delete rule Propagate delete from parent file to dependent file Restrict delete on parent file Update rule Restrict inconsistent updates Insert operations on dependent file are checked Referential constraint A referential constraint is a relation between two files, the parent file and the dependent file. This relationship establishes that every record in the dependent file has to have a matching record in the parent file. The key value of any record in the dependent file must match a key value in the parent file. We call parent key the key of the parent file and foreign key the key in the dependent file. The parent key has to be unique and cannot contain null values. The foreign key value has to match one (any only one) value of the parent key. Otherwise the foreign key can contain a null value. A record in the parent file may be related to multiple records in the dependent files; each record in the dependent file has to have just one parent or have a null foreign key. Primary key we means a unique and ascending key, which is the primary, access path for a PF and cannot contain null values. Primary access path for a database file on the AS/400 in the access path used to access the file by using OPNDBF command. Delete rule We can delete a record from parent file or dependent file first check for delete rule. CASCADE: If we want to delete a record from the parent file and its parent key is matching records in a dependent file, the DBMS will delete all the matching records of the dependent file.

SETNULL: If we delete a record from the parent file and parent key is matching some records in a dependent file, the DBMS will set to null the matching keys in the dependent file. SETDEFAULT: This is like previous case, but matching occurrences in the foreign key are set to their default values. The default value for the foreign key has to match a record in the parent file. RESTRICT: The DBMS will prevent any attempt to delete records in the parent file if its key is matching some records in the dependent file. NO ACTION: This has the same meaning as restrict, but different timing. When we use *NOACTION and an invalid delete operation is about to take place, DB2 /400 will delay any error message until the end of the operation itself, allowing for instance the activation of a before trigger attached to the PF. If *restrict is in use, the exception message is sent immediately. Deleting records in a dependent file is always permitted. Update rule RESTRICT: We cannot change the value in a parent key if the old values are matching some records in the dependent file. The remaining portion of the record can always be updated. We cannot update a foreign key in a dependent file if the new value for the key is not null and does not match any value of the parent key. NO ACTION: This is same as * restrict but with different timing considerations. Refer above; where we describe no action delete operations. Inserts There is no insert rule to be chosen, but referential integrity prevents any insert in the dependent file if the new record has no match in the parent file and its foreign key is not null. 21. How to create a trigger in AS/400? The trigger is an event to be performing before or after any change to a database. When a trigger is added to a physical file, three attributes need to be defined. The first is the event that will cause the trigger to fire. A trigger event can be an insert, an update, or a delete a record from the file. The second attribute to define is when to fire the trigger-before or after the event. The third attribute to define is the identification of the trigger program to by run. We can infer that up to six triggers can be defined for each PF. For each update, insert, and delete Two triggers can be defined One that runs before the event One that runs after the event These trigger are added using the ADDPFTRG Can be removed with the remove PF trigger command (RMVPFTRG) The command ADDPFTRG takes F4
PF LIB TRIGGER TIME TRIGGER EVEVT *UPDATE PROGRAM LIB REPLACE TRIGGER ALLOW REPEATED PF001 VRAMANA *AFTER *UPDATE PGM001 VRAMANA *NO *NO *NO *NO

*BEFORE *AFTER *INSERT *DELETE NAME *YES *YES

22.What is the data area? A data area is an object used to store data for access by any job running on the system. it is permanent storage . A data area can be used whenever you need to store information of limited size, independent of the existence of the programs or files. Typical uses of data areas are: To provide an area to pass information within job. To provide a field that is easily and frequently changed to control references within a job such as supplying the next check number. To provide a constant field for use in several jobs, such as tax rate To provide limited access to a large process that requires the data area. A data area can be locked to a single user, thus preventing other users from processing at the same time. To create a general data area use the command (CRTDTAARA) To retrieve values from data area use (RTVDTAARA) To change this value, use (CHGDTAARA) To display the current value, use (DSPDTAARA) To delete a data area use (DLTDTAARA) Type of data area created by the system Local data area Group data area Program initialization parameter (PIP) data area
VRAMANA/RPGILE DAREA *************** Beginning of data ****************************** 0001.00 DS S 10A 0002.00 DG S 10A INZ ('I LIKE YOU') 0003.00 C *DTAARA DEFINE DATA1 S 0004.00 C *LOCK IN S 0005.00 C EVAL S=G 0006.00 C OUT S 0007.00 C S DSPLY 0008.00 C SETON ****************** End of data *********************************** OUTPUT DSPLY I LIKE YOU AUTO NUMBER GENERATION VRAMANA/TEST TESTEX19 *************** Beginning of data ******************************* 0001.00 DA S 4S 0 0002.00 C *DTAARA DEFINE DATA2 A 0003.00 C *LOCK IN A 0004.00 C EVAL A=A+1 0005.00 C OUT A 0006.00 C A DSPLY 0007.00 C SETON 0008.00 C 0009.00 C 0010.00 C ****************** End of data *********************************** OUTPUT DSPLY 5 DSPLY 6

LR

LR

23.Define LDA, GDA, and PIP? LOCAL DATA AREA (LDA) A local data area is created for each job in the system automatically, when you submit a job. Only one LDA can be created by submitting a job.

The system create 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 jobs local data area is copied into the submitted jobs local data area. You can refer to your jobs local data area by specifying *LDA for the DTAARA keyword on the CHGDTAARA, RTVDTAARA, and DSPDTAARA commands or *LDA for the substring built-in function (%SST) The following is true of a local data area: The local data area cannot be refered to from any other job. You cannot create, delete or allocate a local data area. We can to change the contents of LDA by the by using CHGDTAARA command. No library is associated with the local data area. ACCESSING LDA: CHGVAR VAR (%SST (*LDA 3 5)) VALUE(123) OR CHGDTAARA DTAARA (*LDA (3 5)) VALUE(123) CHGVAR VAR(&ROLNO) VALUE( %SST (*LDA 3 5)) OR RTVDTAARA DTAARA (*LDA (3 5)) RTNVAR (&ROLNO) GROUP DATA AREA (GDA) The system creates a group data area when an interactive job becomes a group job. Only one group data area can exist for a group. The group data area is deleted when the last job in the group is ended, or when the job is no longer part of the group job. A group data area, which is initially filled with blanks, has a length of 512 and type *CHAR. The following is true for a group data area You cannot use the group data area as a substitute for a character variable on the substring built-in function. A group data area cannot be refered by jobs outside the group. You cannot create, delete, or allocate a group data area No library is associated with a group data area. Example CHGDTAARA DTAARA (*GDA) VALUE (DECEMBER 1996) RTVDTAARA DTAARA (*GDA) RTNVAR (&GRPARA) PROGRAM INITIALIZATION PARAMETER (PIP) DATA AREA A PIP data area is created for each pre-started job when the job is started. The object sub-type of the PDA is different then a regular data area. The PIP can only be refered to by the special value name *PDA. The size of the PDA is 2000 bytes but the number of parameter contained in it is not restricted.

24. What are various steps accessing data area in CL? The first create a general data area use the command (CRTDTAARA) To retrieve values from data area use (RTVDTAARA)

To change this value, use (CHGDTAARA) To display the current value, use (DSPDTAARA) To delete a data area use (DLTDTAARA) 25. Various types of message available in CL? Message is the interface between operating system and the programs or user and program. We can classify the message into two types namely Immediate message Predefined message Immediate message Which does the program or system user create when they are sent and are not permanently stored in the system? Control language SNDUSRMSG SNDPGMMSG SNDMSG SNDBRKMSG Display files ERRMSG SFLMSG INQUIRY and INFORMATIONAL message: Using SNDUSRMSG command to send type of message Predefined message Which are created before they are used. These messages are placed in a message file (queue) when they are created, and retrieved from the file when they are used. Control language SNDUSRMSG SNDPGMMSG RTVMSG Display files ERRMSGID SFLMSGID MSGCON MSGID COMPLETION and DIAGNOSTIC message Using SNDPGMMSG command these of message can be sent to any message queue. DIAGNOSTIC message tell the calling program about errors detected by the program. Completion message tell the result of work done by the program. STATUS messages Using SNDPGMMSG command status message can be sent to its callers program message queue or to the external message queue for the job. These message tell the receiving program the status of the work performed by the sending program. ESCAPE message

Using SNDPGMMSG command escape message from a CL program can be sent to its calling program. An escape message tells the calling program ended abnormally and why. NOTTFY message Notify message from a CL program can be sent to the message queue of calling program or to the external message queue. A notify message tells the calling program about a condition under which processing can continue. Predefined message are stored in message file To create a message file CRTMSGF MSGF (MFILE) SIZE () AUT() TEXT () Create and maintain messages ADDMSGD CHGMSGD OR WRKMSGD DSPMSGD RMVMSGD Message file QCPFMSG in library QSYS contain the system message 26. What will MONMSG command in do? The monitor message (MONMSG) command monitors the message send to the program message queue for the conditions specified in the command. If condition exists, the CL command specified on the MONMSG command is run. Types of monitor message Escape Message Status or Notify Message Escape Message Escape message are send to tell your program of am error condition that forced the sender to end. By monitoring for escape message, you can take corrective actions or clean up and end your program. Status or Notify Message Status and notify message are send to tell your program of an abnormal condition that is not serious enough for sender to end. By monitoring for status or notify message, your program can detect this condition and not allow the function to continue. Two levels of MONMSG command Program level Specific command level

Program level The MONMSG is specified immediately following the last declare command in your CL program. You can use as many as 100 program-level MONMSG commands in a program. Specific command level Here the MONMSG command immediately follows a CL command. You can use as many as 100 commands-level MONMSG commands for a single command.

Monitor message command syntax MONMSG MSGID () MSGID-Required Ex: MSGID (MCH1211)

CMPDTA ()

EXEC ()

CMPDTA (Optional) Ex: MONMSG MSGID (MCH1211) CMPDTA (LIB) EXEC - -(Optional) CL command 27 What are the disadvantages of using CL over RPG? We can able to read only records but we cannot able to write or update or delete records. We can have only one file to be used in a CL program We cannot able to use printer files in CL We cannot able to use subfile in a CL program 28 How you can read and write single command in CL? By using SNDRCVF command. Example Type: CLP
VRAMANA/CLP ADD *************** Beginning of data ******************************** 0000.01 /*ADDING TWO NUMBERS */ 0001.00 PGM 0002.00 DCLF FILE(VRAMANA/CLPSCR) RCDFMT(SECLP) 0003.00 SNDRCVF RCDFMT(SECLP) 0004.00 CHGVAR VAR(&RES) VALUE(&NUM1 + &NUM2) 0005.00 SNDRCVF RCDFMT(SECLP) 0006.00 ENDPGM ****************** End of data ********************************** OUTPUT FIRST NUMBER: 12 SECOND NUMBER: 12 ---------RESULT= 0000024 ----------

29 How to retrieve a date in CL? By using RTVSYSVAL command we can get the system dates. For getting date QDATE. The various format of date are *DMY, *MDY, *YMD, *YYMD, *JOL, *JOB 30 How to send the message to the screen SNDPGMMSG? BY passing unique message ID message data and message file. SNDPGMMSG syntax SNDPGM MSG MSGID (MSG0001) MSGF (MSGSUB)

31 What is the open query file? It is a dynamic record selection. The OPNQRYF command acts as a filter between the processing program and the database records. The database file can be a PF or LF. It will create open data pathway to access (retrieve) data file. The OPNQRYF command creates only a temporary file for processing the data; it does not create a permanent file. If you want to specify any SQL operation within a CL we have to use OPNQRYF Functions supplied by OPNQRYF are: Dynamic record selection. 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 Final total-only processing Improving performance Open query identifier (ID) 32. What is the different between OPNQRYF and SQLRPG? OPNQRYF SQLRPG

OPNQRYF will come along with OS/400 We need to have SQLRPG installed in system and no need to have any as/400 system which involves additional cost to the programmers additional package needed to execute it OPNQRYF is faster as compared to It is slower SQLRPG OPNQRYF is nothing but a dynamic SQLRPG is imbedding SQL statements logical files will be created and the directly within SQL statement records

33. What are the various steps in creating OPNQRYF? Totally five steps involve in creating OPNQRYF OVRDBF FILE (file PF) TOFILE (LIB/ PF) SHARE (*Yes) If a PF is having 100 records and if we want to override the PF so that it continues only the specific number of records we are using OVRDBF OPNQRYF FILE (LIB / PF) QRYSLT (EMPNO *EQ *BCAT &A) If you want to perform any SQL operation we have to declare in OPNQRYF command only. In case of OPNQRYF we can perform expression only based on characters but not on numeric. *BCAT

If you want to perform any charter expression are using *BCAT expression which will provide a blanks in between the 2 variables. %WLDCRD It is similar to %LIKE in SQL QRYSLT (EMPNAME *EQ %WLDCRD (S* )) It will fetch all the records whose empname starts from S. *CT It will fetch all the records, which conditions the particular charter. QRYSLT (EMPNAME *CT S ) %RANGE It will fetch the records within the specific range QRYSLT (EMPNO *Eq %RANGE (100 110)) CALL PGM (LIB/NAME) PARM () DLTOVR As we see early the main file logically overridden and after performing the necessary operation, we have to delete the logical file so that the main file contains the actual records for this DLTOVR will be used. DLTOVR FILE (OPNPF) CLOF We have to close the file, which has been opened CLOF OPNID (OPNPF) You will copy overridden file records using CPYFRMQRYF CPTFRMQRYF Since OVRDBF is logical we cannot able to list the variables, which satisfy the query condition. To see the records being selected we have to copy from the source file to a temporary file for this CPYFRMQRYF will be used CPYFRMQRYF FROMOPNID (OPNPF) TOFILE (LIB/NAME) MBR (*REPLACE) CRTFILE (*YES) FMTOPT (*NOCHK) RUNQRY We have copied the contents satisfy the query into a temporary file using CPYFRMQRYF. If we run the destination file we got the actual records, which satisfy the query. RUNQRY QRYFILE (LIN/NAME) Example: Database PF
VRAMANA/CLP OPENF *************** Beginning of data **************************** C UNIQUE C R OPNQFILE C OEMPNO 5S 0 C OEMPNAME 20A C OADDRESS 20A C ODOB 8S 0 C K OEMPNO ****************** End of data ******************************** Data file 0000.01 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00

Display Report
OEMPNO OEMPNAME OADDRESS ODOB

000001 1,001 RAMANAV 000002 1,002 KUMAR 000003 1,003 SHYAM 000004 1,004 RAMESH 000005 1,005 BALU 000006 1,007 KUMAR ****** ******** End of report CL program

SALEM1 TRICHY SALEM SALEM SALEM JJ ********

1,232,002 12,123,000 12,345,000 1,010,100 222 32,938

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0006.01 0006.02 0006.03 0006.04 0009.00 0010.00 0010.01 0011.00

VRAMANA/CLP OPNQFILE5 *************** Beginning of data ********************************* PGM DCL VAR(&A) TYPE(*CHAR) LEN(5) DCLF FILE(VRAMANA/OPNQFILE3) RCDFMT(OPNF3) SNDRCVF RCDFMT(OPNF3) CHGVAR VAR(&A) VALUE(&OEMPNO) OVRDBF FILE(OPENF) SHARE(*YES) OPNQRYF FILE((VRAMANA/OPENF)) QRYSLT('OEMPNO *EQ' + *BCAT &A) CPYFRMQRYF FROMOPNID(OPENF) TOFILE(VRAMANA/TEMP) + MBROPT(*REPLACE) CRTFILE(*YES) DLTOVR FILE(OPENF) CLOF OPNID(OPENF) RUNQRY QRYFILE((VRAMANA/TEMP)) ENDPGM ****************** End of data*********************************

OUTPUT EMPLOYEE NUMBER: 1001 OEMPNO OEMPNAME OADDRESS SALEM1 ******** ODOB 1,232,002

000001 1,001 RAMANAV ****** ******** End of report

34. How the records are accessed for using OPNQRYF? By creating open data pathway to access (retrieve) data file. 35. What is the journal? Any changes in PF will be recorded. A journal is an object of type *JRN which detects and records that cause a PF to change. The information recorded by the journal is stored in an object *JRNRCV called journal receiver. 36. What are the various steps creating journal? The steps to start journaling Create a journal receiver - CRTJRNRCV Create a journal - CRTJRN Start journaling of a PF -STRJRNPF Backup the PF -SAVOBJ The steps to end journaling End journaling a PF -ENDJRNPF Delete a journal -DLTJRN Delete the last journal receiver -DLTJRNRCV Save journal receivers -SAVOBJ The commands used for house keeping purposes Change journal -CHGJRN

Save object -SAVOBJ Delete a journal receiver -DLTJRNRCV The commands used in case of a failure are Display journal entries -DSPJRN Apply journal changes -APYJRNCHG Remove journal changes -RMVJRNCHG Restore a saved object -RSTOBJ 37. How you can list all the LF of a PF? By using DSPDBR command it is to list all the files, which are related to a PF. It displays all the LF that is referring the PF and also lists the child table if it is having a relation through ADDPFCST. 38. What is use of DSPFFD and DSPFD? DSPFD (display file description) It is used to display the details about the file when it is created. DSPFFD (display file field description) It is used for listing details about individual fields. 39. What is the data queue? It is a temporary storage. We can able to store and retrieve the data, but once data is retrieved the data is lost. First create the data queue by using CRTDTAARA command Sending a message to a data queue (QSNDDTAQ, QRCVDTAQ, And CLRDTAQ) Data query is nothing but a queue in which are program can send a data and other program or the same program can receive the program. QSNDDTAQ is stored in QSYS.

40. Explain QSNDDTAQ and QRCVDTAQ? QSNDDTAQ By using this command sent data same / another program. QSNDDTAQ PARM (QUEUE NAME LIB &LEN &DAT) QRCVDTAQ By using this command receive data same /another program QRCVDTAQ PARM (QUEUE NAME LIB &LEN &DAT &WAIT)
41. What are the mandatory parameters for declaring a Data queue? QUEUE NAME LIB NAME LENGTH DATA WAIT 42. What will RUNSQLSTM will do? If we want to execute set of SQL statement then we can write all the SQL statement to be including with the source. Type as SQL Only insert, update and delete and no select is allowed. Then use STRSQLSTM to execute the program RUNSQLSTM SRCFILE (LIB/TEST) SRCMBR (SQL01) COMMIT (*NONE)

43. What is a field reference file? This is PF, which does not have any data and contains only the field descriptions and these fields are referred in other PF by using REF and REFFLD

44. What is the difference between OPM, EPM and RPGLE? OPM Original program model is the old RPG/400 system, which will not allow a program type to call another program type. Like CL, RPG, COBOL, PL/I, BASIC only supported. EPM Extended program model will support C, PASCAL, FORTRAN and another programming concepts. RPGLE It supports mixed program support in which you can combine any program with another type of program. it supports modularity, copy book, better call performance. Version is V2R3

Version is V1R2

45. Explain WRKOBJPDM and DSPOBJD? WRKOBJPDM If we want to list all the source PF or files of particular type the WRKOBJPDM with file type as PFSRC for source PF IOR *file for listing all the files extra can be given DSPOBJD If we know library name and object name and we want to know the source PF where it is residing then DSPOBJD with option as *services instead of basic will give the source PF name 46. How to create RPG, RPGLE, CL, CLLE, PF, LF, PRN, and display file? RPG -by using CRTRPGPGM command RPGLE -by using CRTBNDRPG Command (or) 14 RPGLE -by using CRTRPGMOD (or) 15 /CRTPGM command CL -by using CRTCLPGM command CLLE -by using CRTBNDCL CLLE -by using CRTCLMOD/CRTPGM command PF -by using CRTPF command LF -by using CRTLF command PRN - by using CRTPRTF command DSPF -by using CRTDSPF command 47. It is possible to insert record to JOIN LF? NO, insertion, updating or deleting of records is not possible in JOIN LF. 48. What are the advantages of using AS/400 system? AS/400 is designed and build as a total system. This means that facilities such as relational database and networking capability (and much more) are fully integrated into the operating system and machine. The user communication with all these functions through a single control language Layered machine architecture Object orientation Single-level storage Hierarchy of microprocessors Security levels Layered machine architecture This insulates users from hardware characteristics. It enables them to move to new hardware technology at any time, without disrupting their application programs. We can able to change any layer without affecting the other layer. If any problem occurs in OS, then we can work with application program independently and this is the major advantage of AS/400 system. Object orientation Every that can be stored or retrieved on the system is known as an objects. Objects exist to make users independent of the internal structure of the machine. Single- level storage

It provides contiguous memory between main storage and disk storage. It provides authority to add any disk space so that use. Can access it without any problem. There is no need for the user to think where to store the application program. Hierarchy of microprocessors Various types of microprocessors are used in AS/400. Each and every microprocessor is allocated for specific purpose. If one chip is for input operation and other for output then we can do both input and output operation since both the microprocessor can perform independently. Security levels It will list the various security provided by the system. No security Password security Resource security OS security Certifiable security 49. What are the various types of Security in AS/400? AS/400 is designed for business that requires levels of security ranging from nothing at all to full government certifiable security. By setting a system value, we can configure five increasing level of security. No security Password security Resource security OS security Certifiable security When as AS/400 is configured, three system values dealing with security need to be specified. These values are QAUDJRL, QMAXSIGN & QSECURITY.

QSECURITY: This system value determines the level of security enforcement. S/38 and the original AS/400 only had three of system security. At VIR3 of OS/400 the fourth level of security was added, and the fifth level of security was added at V2R3. The valid values for QSECURITY are 10,20,30,40,50. QMAXSIGN: This system value determines the maximum number of signon attempts allowed. If the number of unsuccessful attempts to signon to the system exceeds this number, the terminal or device that attempted the signon is varied off. QAUDJRL: AS/400 supports an optional security auditing function. If this function is specified, certain security events are journal. The specific events that are logged in the security audit journal are determined by the value specified in the QAUDJRL system value and the level of system security specified. Level 10: No security System is shipped with minimum-security level and doesnt require any password to signon. If user profile doesnt exists with the same name as the Userid the system creates the user profile with that name. Level 20:Password security Minimum security is active and password is required to signon. The user profile must already exist for the user before we can signon the system Level 30:Resource security Password security is active and user must specify given authority to resources. This level is recommended because the system doesnt give the user authority to access the entire object on the system after the user signon.

Level 40:Operating system security

Password security, resource security and OS integrity are active. User must be especially given authority to resources this level providing more security than level 30. All attempts to access object using interfaces that are not supported fail. Programs that contains restricted instructions will not compile Users submitting jobs using the job description containing the user profile name, must have *USE authority to user profile. Level 50: C2 level security All the level 40 security attributes are included at level 50,and in addition some of the interfaces are modified to meet the C2 standards. 50. Explain user profile and group profile? User profiles are used to identify users to the systems and verify authorities on the system (DSPUSRPRF, CHGUSRPRF, EDTOBJAUT) User profiles tell the system who can signon and what functions the user can perform on the system on the system resources after signing on. The secutrity officer or security administrator can create it. The user profile defines the following capabilities for a particular user User class Object owned and authorized Authorization of objects Privileged instructions Password Current library Initial program and menu Delimited-capability user Limit device session Maximum storage allowed Priority limit Special environment User class When identifying a user on the system you can specify the user class in the user profile. AS/400 has five user classes that determine the level of systems access a user is permitted. The five user classes, starting the highest level of access, are Security officer (*SECOFR) Security administrator (*SECADM) Programmer (*PGMR) System operator (*SYSOPR) User (*USER) Authorization of objects Object authority, or the right to user to use or control an object comes in two categories. Object rights Data rights Object rights Object rights are concerned with the object itself. Object rights assign a user the following authority Operational rights (*OPER) Object management rights (*OBJMGT) Object existence rights (*OBJEXT) Operational right (*OPER) The authority to use an object, looks at its description, and restores it. A user must have operational rights to a program to execute it. Object management rights (*OBJMGT) The authority to grant and revoke and user rights move and rename object, and members to database file. Object existence rights (*OBJEXT) The authority to delete, free storage, save restore or transfer ownership of an object. Data rights Data rights apply to the data contained within the object.

Types of data rights Read (*READ) The authority to retrieve the contents of an object entry. Add (*ADD) The authority to add entries to an object. For example adding records to a database file requires ADD rights for the library. Update (*UPD) The authority to change the entries in an object requires UPD rights for the file. Delete (*DLT) The authority to remove object in an object. For example deleting a program from a library requires DLT rights for the library. Deleting records for a database the requires DLT rights the database file. 51. What are the various ways creating access path? Access path means the records are to be retrieved from a file. The records can be retrieved from a PF or a LF either ARRIVAL SEQUENCE or by KETED SEQUENCE. For LF you can also select records using select or omit keywords Arrival sequence access path Sequentially, where each record is taken from the next sequential physical position in the file. Directly by relative records number, where the record number is identified by its position from the start of the file.

Keyed sequence access path It is based on the contents of the key fields as defined in DDS. This type of access path is updated in the contents of a CALL TFRCTL key field is changed. 1.Call will transfer the control according with the CALL STACK 2. The CALL is used to different types of programs. Ex: RPGILE/400,CL/400,C/400,COBOL/400. Transfer Control (TFRCTL) will remove the CALL STACK and transfer the control to the calling program. TFRCTL is only used in CL programs. There are three ways of bounding the access path I m m e d

iate Rebuild Delayed Immediate Access path is always maintained for every opening in a file. Rebuild Access path is maintained when the file is open and various updates are recorded and the access path is rebuild every time when the access path is closed. Delayed Access path is maintained when the file is opened and updates recorded. When the file is closed all the updates to the records are closed together but it is not rebuild. When the recorded update percentage exceeds 25% then rebuild of records take place. 52.How many record formats PF, LF, DSPF and SFL? PF- 1 LF- 32 DSPF-1024 SFL-512 53.What is the command to create menu? CRTMNU CRTMNU MENU(*CURLIB/MVRMENU) TYPE(*DSPF / *PGM / UIM) After selection TYPE it changes the attributes. 54. What is the difference between CALL and Transfer Control (TFRCTL)?

55. Explain ADDDUR, SUBDUR, EXTRCT and TEST? ADDDUR: It is a powerful opcode, which is used to add any date related function to a particular date, time or timestamp. Example:
VRAMANA/DATE ADDDUR *************** Beginning of data ******************************** d*date function using the adddur DTIMESTE S Z DTIME5 S Z DDATE1 S D DDATE2 S D DDATE3 S D DDATE4 S D DTIME1 S T DTIME2 S T DTIME3 S T DTIME4 S T C MOVEL *DATE DATE1 C DATE1 ADDDUR 02:*Y DATE2 C DATE1 ADDDUR 05:*M DATE3 C DATE1 ADDDUR 01:*D DATE4 C TIME TIME1 C TIME TIMESTE C TIME1 ADDDUR 10:*H TIME2 C* TIME1 ADDDUR 10:*ML TIME3 C TIME1 ADDDUR 10:*S TIME4 C TIMESTE ADDDUR 10:*MS TIME5 C DATE2 DSPLY C DATE3 DSPLY C DATE4 DSPLY C TIME1 DSPLY C TIME2 DSPLY C TIME3 DSPLY C TIME4 DSPLY C TIME5 DSPLY C SETON LR ****************** End of data ********************************* 2004-06-27 2002-11-27 2002-06-28 12.18.36 22.18.36

0000.01 0001.00 0001.01 0002.00 0002.01 0002.02 0002.03 0003.00 0003.01 0003.02 0003.03 0004.00 0005.00 0006.00 0007.00 0007.01 0007.02 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0014.01 0014.02 0014.03 0014.04 0014.05 0015.00 OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY

DSPLY 00.00.00 DSPLY 12.18.46 DSPLY 2002-06-27-12.18.36.953010

SUBDUR: It is used to find the difference between two date (or) time (or) time stamp Example
VRAMANA/DATE SUBDUR *************** Beginning of data ******************************** d*date function using the SUBDUR DTIMESTE S Z DTIME5 S Z DDATE1 S D INZ (D'1977-06-20') DDATE2 S D DDATE3 S D DDATE4 S D DTIME2 S T INZ (T'12. 50.10) DTIME1 S T DTIME3 S T DTIME4 S T C DATE1 SUBDUR 02:*D DATE2 C DATE1 SUBDUR 05:*M DATE3 C DATE1 SUBDUR 01:*Y DATE4 C TIME TIME1 C TIME2 SUBDUR 10:*H TIME1 C TIME2 SUBDUR 10:*S TIME4 C DATE2 DSPLY C DATE3 DSPLY C DATE4 DSPLY C TIME1 DSPLY C TIME2 DSPLY C TIME3 DSPLY C TIME4 DSPLY C SETON LR ****************** End of data ***********************************

0000.01 0001.00 0001.01 0002.00 0002.01 0002.02 0002.03 0003.00 0003.01 0003.02 0003.03 0005.00 0006.00 0007.00 0007.01 0008.00 0010.00 0012.00 0013.00 0014.00 0014.01 0014.02 0014.03 0014.04 0015.00

OUT PUT DSPLY 1977-06-18 DSPLY 1977-01-20 DSPLY 1976-06-20 DSPLY 02.50.10 DSPLY 12.50.10 DSPLY 00.00.00 DSPLY 12.50.00

EXTRCT:

It is used to extract year, month, day, hours, minutes, seconds, and microseconds of a time stamp or date field. Example:
VRAMANA/DATE EXRCT *************** Beginning of data ******************************** d*FINT THE EXRCT DAY MONTH YEAR DTIMESTE S Z DDATE1 S D INZ (D'1977-06-20') DDATE3 S D DDATE2 S 5P 0 DDATE4 S 5P 0 DDATE5 S 5P 0 DDATE6 S 5P 0 DDATE7 S 5P 0 DDATE8 S 5P 0 DTIME0 S T INZ (T'12. 50.10) DTIME1 S T DTIME2 S 5P 0 DTIME4 S 5P 0 DTIME5 S 5P 0 DTIME6 S 5P 0 DTIME3 S 26P 0

0000.01 0001.00 0002.00 0002.01 0002.02 0002.04 0002.05 0002.06 0002.07 0002.08 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0003.06

0004.00 0004.01 0004.02 0005.00 0006.00 0007.00 0007.01 0007.02 0007.03 0007.04 0007.05 0007.06 0007.07 0011.00 0012.00 0013.00 0013.01 0013.02 0013.03 0014.00 0014.01 0014.02 0014.03 0014.04 0014.05 0015.00 OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY

C C C C C C C C C C C C C C C C C C C C C C C C C C

DATE2 DATE8 DATE4 DATE5 DATE6 DATE7 TIME2 TIME4 TIME5 TIME6 TIME3

MOVEL TIME TIME EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT EXTRCT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY SETON

*DATE

DATE1:*M DATE3:*M DATE1:*D DATE3:*D DATE1:*Y DATE3:*Y TIME1:*H TIME1:*H TIME0:*H TIME0:*S TIMESTE:*MS

DATE3 TIME1 TIMESTE DATE2 DATE4 DATE5 DATE6 DATE7 DATE8 TIME2 TIME4 TIME5 TIME6 TIME3

LR

6 2002 6 20 27 1977 12 12 12 10 441000

TEST: Test is the most powerful opcode, which will check a date is a valid, or not .The low level indicator is set on if the date is not valid or set off if the date is a valid one. Test will be given with extended factor like test (d), test (t), test (z) for date, time and time stamp and if test without extended factor default to date (z).
Example
VRAMANA/DATE TEST *************** Beginning of data ********************************* C*TEST FOR VALID DATE THE DATE VALID SETOFF OR SETON (NOTVALID) C MOVEL '13/03/1999 A 10 C TEST (D) A 30 C *IN30 DSPLY C IF *IN30=*ON C 'NOTVAILD' DSPLY C ELSE C 'VALID' DSPLY C ENDIF C SETON LR ****************** End of data ***********************************

0000.01 0001.00 0002.00 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0004.00

OUTPUT DSPLY 1 DSPLY NOTVAILD

56. Explain Multi Dimensional Array? The multi dimension data structure array will be implemented in occurs class.

The similar elements of same data type and same attributes size repeating many times this time using OCCUR opcode. Which can only be used with a multiple occurrence data structure, allow you to specify which occurrence of data structure is used for subsequent operation within the programs. 57.Explain about RTNCSRLOC? Type Y (Yes) in the Select parameters prompt to define parameters for the RTNCSRLOC keyword on the Define Return Cursor Location display. 58.Explain Assume and Overlay? Assume Type Y (Yes) to select the ASSUME keyword. It causes the AS/400 system to assume that this record appears on the display when the file is opened. Use this keyword to receive data that a previous program has left on the display. Overlay Type Y (Yes) to allow the overlaying of fields on this record without erasing the entire display. Note: If you type anything other than Y or blank, your entry will be ignored. You must specify the OVERLAY keyword to select the other keywords on this display, with the exception of PUTOVR. 59.Explain Compile time array, lookup, sorta, xfoot, and Run time array? Compile time array The compile time array means the elements of the array will be loaded before the execution of the programs. The value will be static. We must declare in keyword command DIM (), CTDTAT (), and PERRCD (). We are giving the value in after the SETON LR. Example
VRAMANA/ARRAY COMILE *************** Beginning of data ******************************** c*compile time array darr1 s 4 dim(3) ctdata perrcd(1) di s 2p 0 inz(1) c i do 3 c arr1(i) dsply c add 1 i c enddo c seton ** 1001 20 1000 ****************** End of data ********************************

0000.01 0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00

OUTPUT DSPLY 1001 DSPLY 20 DSPLY 1000

Run time array The run time array means the value will be loaded during the runtime only. The value will be dynamic.
VRAMANA/ARRAY RUNTIME *************** Beginning of data ***************************** c*runtime array darr1 s 10 dim(12) di s 2p 0 inz(1) da s 3p 0

0000.01 0001.00 0002.00 0002.01

0002.02 0003.00 0003.01 0003.02 0003.03 0003.04 0003.05 0004.00 0005.01 0006.00 0007.00

dj s 2p 0 inz(1) c i do 12 c dsply arr1(i) c* eval arr1(i)=a c add 1 i c enddo c j do 12 c arr1(j) dsply c add 1 j c enddo c seton lr ****************** End of data ********************************* lookup, sorta, xfoot : VRAMANA/ARRAY SORTARRAY *************** Beginning of data ********************************* c*lookup,xfoot&sorta examples darr1 s 4 0 dim(3) ctdata perrcd(1) di s 2p 0 inz(1) dj s 2p 0 inz(1) dd s 4p 0 c i do 3 c arr1(i) dsply c add 1 i c enddo c sorta arr1 c xfoot arr1 d c 1000 lookup arr1 40 c if *in40=*on c 'found' dsply c else c 'notfou' dsply c endif c d dsply c j do 3 c arr1(j) dsply c add 1 j c enddo c seton lr ** 1001 2000 1000 ****************** End of data *********************************** 1001 2000 1000 found 4001 1000 1001 2000

0000.01 0001.00 0002.00 0002.01 0002.02 0003.00 0004.00 0005.00 0006.00 0006.01 0006.02 0006.03 0006.04 0006.05 0006.06 0006.07 0006.08 0006.09 0006.10 0006.11 0006.12 0006.13 0007.00 0008.00 0009.00 0010.00 0011.00 DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY

Pre runtime array Pre runtime array is in between these 2 conditions where the value are static and the value will be retrieved from disk and loaded into the array. As a result there is no need to retrieve the value every time from the disk and usage of pre runtime array makes it fast. We must declare in keyword command DIM (), FROMFILE (),and PERRCD ().
60.Define data structure and types of data structure? The different types fields and sub field stored with in single area. This area in storage is called data structure. Data structure means program allows you to define an area in storage and the layout of the fields, called sub fields, with the area. This area in storage is called a data structure. Data structure can be used for Group non-contiguous data into contiguous internal storage locations Define the same internal area multiple times using different data formats. Operate on a field and change its contents

Divide a field into sub fields without using the MOVE or MOVEL Define a data structure and its sub fields in the same way a record is defined. Define multiple occurrences of a set of data There are four different types of data structure commonly used. General data structure Data area data structure File information data structure Program status data structure External Data Structure Data structure can be specified in D spec Type IPDS Data structure name I Globally initialized data structure S--Program status data structure U--Data area data structure BlanksGeneral (or) File status data structure Data area data structure A data area data structure, identified by a U in position 18 of the data structure statement, indicates to the RPGLE program that if should read in and lock the data area of the same name at program at program initialization and should write out and unlock the same data area at end of the program. The data area and data area structure must have the same name unless you rename the data within the program by using the *NAMVAR DEFINE statement. File information data structure A file information data structure provides you with status information on file exception /error occurs. This data structure name must be unique for each file. It consists of pre defined sub fields that provide information on the file exception/error that occurred. Program status data structure This data structure is identified by as S in position 18 of the data structure statement, provides program exception/error information to the program. The *ROUTINE, *STATUS, *PARM keywords mostly preferred to determine the PS DS. Example
VRAMANA/DATASTR DUMP *************** Beginning of data ************************* 0001.00 HDEBUG(*YES) 0002.00 DPSSR SDS 0004.00 DSTATUS *status 0005.00 DROUTINE *routine 0005.01 DPARMS *parms 0005.02 DRES S 2S 0 0007.00 C Z-ADD 1 NUM1 2 0 0007.01 C Z-ADD 0 NUM2 2 0 0010.00 C EVAL RES=NUM1/NUM2 0011.00 C 'NOTCOM' DSPLY 0012.00 C A TAG 0013.00 C 'COMING' DSPLY 0014.00 C SETON LR 0015.00 C *PSSR BEGSR 0016.00 C STATUS DSPLY 0017.00 C ROUTINE DSPLY 0018.00 C PARMS DSPLY 0019.00 C DUMP 0020.00 C GOTO A 0021.00 C ENDSR ****************** End of data ****************************** Output DSPLY 102 DSPLY *DETC DSPLY 0 DSPLY COMING

61. What is Lock? How you achieve in AS/400? To give the access permission for database file. The Locks are provided by AS/400 system itself. Type of lock Share lock

The share lock only reading operation (PF file). Exclusive lock The exclusive lock to perform insert, update, and delete operations. 62. How you will release the lock? By using RCLRSC [Reclaim Resource] command we can release the resources only. UNLOCK or CHAIN (N) command also helps to release the lock. By using WRKOBJLCK command and take F4. 63. How you execute CL command in RPGLE? By using QCMDEXC command we can execute CL command in RPGLE. Two parameters will be called use in the CL command to be executed and second is the length of the command. 64. Explain Commitment Control? The AS/400 system has an integrated transaction recovery function called commitment control. Commitment control is an extension of the journal function on the system. The records used during a complex transaction are locked from other user and at the end of the transaction; the program issues the commit operation, updating the records. If the system fails before the commit operation is performed, all database changes are rolled back to the previous commit operation and all the affected records are unlocked. COMMIT-The transactions are updated in the data file. Commit occurs on COMMIT command ROLLBACK- The transactions are NOT updated in the data file. Rollback occurs if there are uncommitted transactions and on ROLLBACK command 65. Explain about sub files in AS/400? A subfile is a group of records READ from or WRITTEN to a display device file in one single operation. It is a display file facility It is a group of records that can be stored in the main memory. The program can store a group of records in the subfile one by one in a sequence. LODING SUBFILES: Load all (Size >Page) Load on demand (Size >Page) Load on demand (Size =Page) Load all (Size >Page) All the records from the database file will be loaded in to the subfile in one shot. The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file. PAGEUP and PAGEDOWN are taken care of by the system. The total subfile size 9999 records. Load on demand (Size > Page) The number of records as mentioned in SFLPAG will be loaded initially. Then the remaining records can be loaded by pressing PAGEDOWN, which is taken care of by the programmer. Same time PAGEUP is taken care of by the system. The subfile size should be greater than the page size at least by one. (SFLSIZ =5, SFLPAG=4). The subfile size will dynamically grow when the subfile size mentioned is less than the number of records in the database file. All the records loaded will exist in the subfile. The total subfile size 9999 recorde. Load on demand (Size = Page) The number of records that will be loaded into the subfile must always be equal to the value mentioned in for SFLSIZ and SFLPAG. Every time the subfile should be cleared before paging up or paging down. PAGEUP and PAGEDOWN are taken care of the programmer. The number of records that can be in the subfile at any instance will be equal to SFLSIZ and SFLPAG values. Subfile points: Record formats: One display -1024 records formats One display file 512 subfile Record formats are 1.subfile record format (SFL)

2.subfile control record format (SFLCTL) subfile record format(SFL) This record format will have the multiple record definitions -Defining fields. -Defining database fields. Subfile Control record format (SFLCTL) This record format will control the subfile record format. -Defining texts -Defining control fields. Subfile Size (SFLSIZ) This keyword can be used to specify the maximum number of records that can be in the subfile (buffer) Default ->2 Maximum ->9999 Subfile Page (SFLPAG) This keyword can be used to specify the maximum number of records than can be in one subfile page. That is the maximum number of records that the system will display in the screen at a time. -Default ->1 -Maximum-> depends upon the display record size. If the subfile size is at least one greater than the subfile page then the subfile size will grow dynamically up to 9999.

General keywords
SFLDSP -> subfile display SFLDSPCTL -> subfile display control SFLCLR -> subfile clear SFLEND -> subfile end

Define General Keywords


Subfile control record . . . . . Type choices, press Enter. Related subfile record . . . . Subfile cursor relative record Subfile mode . . . . . . . . . Display subfile records . Display control record . . Initialize subfile fields Delete subfile area . . . Clear subfile records . . Indicate more records . . SFLEND parameter . . . SFLEND parameter . . . Record not active . . . . F3=Exit F12=Cancel . . . . . . . . . . . . . . . . . . . . . . : SENWLT1 Keyword . . . SFLCTL SENWND1 . . . SFLCSRRRN . . . SFLMODE Y=Yes . . . SFLDSP Y . . . SFLDSPCTL Y . . . SFLINZ . . . SFLDLT . . . SFLCLR . . . SFLEND . . . *MORE Y . . . *SCRBAR . . . SFLRNA Name Name Name Indicators/+ 25 26

28 30 *MORE ... More...

Subfile Display (SFLDSP) This keyword is used to insert the system that the subfile records format has to be displayed. The subfile record format without any record in it cannot be displayed. Subfile Display control (SFLDSPCTL) This keyword is used to instruct the system that the subfile control record format has to be displayed.

0009.00 C N30

SETON

2526

Subfile Clear (SFLCLR) This keyword is used to clear the records in the subfile records format. An indicator can control this keyword.

0005.00 C 0006.00 C 0007.00 C

SETON WRITE SENWLT1 SETOFF

28 28

Subfile End (SFLEND) This keyword is used to get the display of + sign or a text more or bottom in the bottom of the subfile.

+ or more indicates the existence of more records in the subfile which can be displayed by pressing PAGEDOWN key . Bottom indicates the end of the subfile. Instead of Enter Key - Help Type a CF or CA key number to specify that the operator is to use the Enter key as a Roll Up key. The specified CF or CA key acts as the Enter key. Mandatory keywords for subfile SFL SFLCTL SFLSIZ SFLPAG SFLDSP RRN (Relative record number) RRN is the numeric value (1 to 9999) associated with each subfile record for accessing Each record should have a unique RRN value This value has to be giving by the program. This has to be associated with the subfile record format in the F spec continuation line. This has to be declared in the program as numeric variable of maximum length 4 and decimal position 0. F spec format in continuation line with SFILE option

0002.00 FSENDESFILECF E WORKSTN 0003.00 F SFILE (SFL01:RRN1 ) Where RRN1 -> RRN variable name SFL01-> subfile record format name.
RPGLE Opcodes EXFMT If SFLDSP and SFLDSPCTL indicators are on, this opcode will send the two subfile record formats to the display device and waits for the users response. WRITE (SFL) This opcode is used to add a record to the subfile record format RRN value should be set with a non-existing value before adding the record in the subfile record format. WRITE (SFLCTL) This keyword is used for clearing & display the subfile SFLDROP (subfile drop) This record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in truncated form; subfile records are truncated to fit on one display line. When the user presses the specified key, the program displays the records in the folded form. Or Subfile Initially Truncated - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is first displayed in truncated form. The operator presses thespecified CF or CA key to switch from truncated form to folded form, or from folded form to truncated form. SFLFOLD (subfile fold) This record level keyword is used to assign a CA (command attention) or CF (command function) key. The program first displays the subfile in folded form. When the user presses the specified key, the program displays the records again in the truncated form. Or

Subfile Initially Folded - Help Type a command function (CF) or command attention (CA) key number to assign a CF or CA key to specify if a subfile control record requiring more than one display line should be truncated to one line, or should be folded to display on two lines. When this keyword is specified, the subfile is firstdisplayed in folded form. The operator presses thespecified CF or CA key to switch from folded form totruncated form, or from truncated form to folded form.
SFLINZ (subfile initialize)

This record level keyword is used to specify that the programis to initialize all records in the subfile on the output operation (read & updates) to the subfile control record format. The fields in each subfile record are initialized to CHAR->BLANKS NUME->ZEROS FLOAT->NULLS SFLNXTCHG (subfile next change) This record level keyword is used on the subfile control record format to force the user to correct program-detected keying error in the subfile records that have been read by the program. It does this by causing the record to be changed so that a get-next-changed operation must read the record. Or Return Record - Help Type Y (Yes) to instruct the system to return this subfile record to your program on a subsequent Get-Next-Changed input operation to the subfile. This record is returned whether or not the operator changes it. Note: You must type Y. If you do not, the entry will not be used.You can specify condition indicators for the SFLNXTCHG keyword. SFLROLVAL (subfile roll value) This field-level keyword is used to specify that the user can key a value into this field to tell the program how many records to PAGEUP or PAGEDOWN when the appropriate paging key is pressed. SFLRCDNBR (subfile record number) This field level keyword on the subfile control record format is used to specify that the page of the subfile to be displayed is the page containing the record whose relative record is in this field. If you do not specify this keyword, the program displays the first page of the subfile by default Example for load all
VRAMANA/SUBFILE NEWEMP *************** Beginning of data ******************* 0001.00 UNIQUE 0002.00 R EMPNEW 0003.00 EMPNOM 6P 0 TEXT('EMPLOYEE NUMBER') 0004.00 EMPNA 15A TEXT('EMPLOYEE NAME') 0005.00 SEX3 1A TEXT('EMPLOYEE SEX') 0006.00 AGE3 3P 0 TEXT('EMPLOYEE AGE') 0007.00 ADDRESS5 15A TEXT('ADDRESS') 0008.00 CITY5 10A TEXT('CITY') 0009.00 K EMPNOM ****************** End of data ********************************* DATA FILE Display Report EMPNOM EMPNA SEX3 AGE3 ADDRESS5 000001 101 K.RAMANAVKUMAR M 25 ATTUR 000002 102 R.SHYAMSUNDAR M 27 TRICHY 000003 103 B.MOHAN M 27 TCODE 000004 104 K.KUMAR M 25 SALEM 000005 105 A.ARUL M 25 SALEM 000006 106 BALU M 25 SALEM 000007 107 RAMANAV M 35 SALEM 000008 108 RAJ M 22 TCODWE 000009 109 HEMA M 33 SALEM 000010 110 VEL M 67 SALEM 000011 111 RAMESH M 56 ATTUR 000012 122 SUDHA M 28 SALEM 000013 123 KANDASAMY M 34 SALEM ****** ******** End of report ******** VRAMANA/SUBFILE CITY5 SALEM TRICHY SALEM SALEM NAMAKKAL SALEM TRICHY SALEM CHENNAI SALEM SALEM ATTUR ATTUR

SUB04 *************** Beginning of data **************************** 0002.00 FSENDESFILECF E WORKSTN 0015.00 C *IN03 DOWEQ *OFF 0016.00 C EXFMT MAIN1 0016.01 C IF *IN04=*ON AND EMPCUR='EMPNOM' 0016.02 C CALL 'SELOADALL3' 0016.03 C ENDIF 0017.00 C 03 LEAVE 0018.00 C ENDDO

0019.00 C SETON LR ****************** End of data ******************************* VRAMANA/SUBFILE SELOADALL3 *************** Beginning of data ***************************** FNEWEMP IF E DISK FSENDESFILECF E WORKSTN F SFILE(SENWND1:RRN1) C Z-ADD 1 RRN1 4 0 C SETON 28 C WRITE SENWLT1 C SETOFF 28 C READ EMPNEW 30 C N30 SETON 2526 C DOW *IN30=*OFF C WRITE SENWND1 C ADD 1 RRN1 C READ EMPNEW 30 C 30 LEAVE C ENDDO C DOW *IN03=*OFF C 03 LEAVE C* WRITE HEATER C* WRITE FOOTER1 C EXFMT SENWLT1 C ENDDO C SETON LR ****************** End of data *****************************

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00 0016.00 0016.01 0016.02 0016.03 0016.04 0020.00 0021.00

window main1 take 8


Select Record Keywords
Record . . . : MAIN1 Type choices, press Enter. General keywords . . . . . . . . Indicator keywords . . . . . . . Application help . . . . . . . . Y=Yes Y Y

Select General Keywords


Record . . . : MAIN1 Type choices, press Enter. If this record is not on display, write it to the display before issuing read . . . . Keep record on display . . . . . . . . . . . Assume record is on display . . . . . . . . Allow rolling of lines . . . . . . . . . . . Retain CLEAR HELP HOME and ROLL keys . . . . Retain command function (CFnn and CAnn) keys Change input defaults . . . . . . . . . . . Select parameters . . . . . . . . . . . . Menu-Bar display . . . . . . . . . . . . . . Select parameters . . . . . . . . . . . . Entry field attribute . . . . . . . . . . . Select parameters . . . . . . . . . . . . Return cursor location . . . . . . . . . . . Select parameters . . . . . . . . . . . . Keyword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . INZRCD KEEP ASSUME ALWROL RETKEY RETCMDKEY CHGINPDFT MNUBARDSP ENTFLDATR RTNCSRLOC Y Y=Yes

Define Return Cursor Location


Record . . . : MAIN1 Keyword number 1 of 1 Type parameters, press Enter. Return cursor location . . . . . . . . . . Type indicator *RECNAME . . . . . . . . Cursor record . . . . . . . . . . . . . Keyword RTNCSRLOC Y Y RECSD Y=Yes Y=Yes Name Roll Y +/F4 for list

Cursor field . . . . . . . . . . . . . . Cursor position . . . . . . . . . . . . CF03 03 CF04 04

EMPCUR

Name Name

TAKE 12 AND F4 Work with Fields


Record . . . : MAIN1 Type information, press Enter. Number of fields to roll . . . . . . . . . . . . . . . . . . 6 Type options, change values, press Enter. 1=Select keywords 4=Delete field Option Order Field Type Use Length Row/Col Ref Condition 70 AGE C 21 15 014 80 RECSD A H 10 90 EMPCUR A H 10 100 ---------C 76 21 003 110 F3->EXIT C 37 22 005 120 EMPNOM S B 6,0 09 036 Y Add Add Add H M P Hidden Message Program-to-system

Overlap

More...

TEKE 12

SENWLT1 Select Window Keywords


Window record . . . . . . . . . . . . . : SENWLT1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Select record keywords . . . . . Y General SFLCTL keywords . . . . . Y Subfile display layout . . . . . Y Subfile messages . . . . . . . . Y Select General Keywords Window record . . . . . . . . . . . . . : SENWLT1 Type choices, press Enter. Keyword Window parameters . . . . . . . . . . . . WINDOW Select parameters . . . . . . . . . . . Window borders . . . . . . . . . . . . . . WDWBORDER Select parameters . . . . . . . . . . . Remove windows . . . . . . . . . . . . . . RMVWDW User Restore Display . . . . . . . . . . . USRRSTDSP

Y=Yes Y Y

Indicators/+

Define Window Parameters


Record . . . : SENWLT1 Keyword . . : WINDOW Referenced window . . . . . . . . . . . . -ORWindow definition Default start positioning . . . . . . . -ORStart line Program-to-system field . . . . . . . Actual line . . . . . . . . . . . . . 2 Start position Program-to-system field . . . . . . . Actual position . . . . . . . . . . . 2 Window lines . . . . . . . . . . . . . . 20 Window position . . . . . . . . . . . . 40 Message line . . . . . . . . . . . . . . Y Restrict cursor to window . . . . . . . Y Select Record Keywords Record . . . : SENWLT1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Name

Y=Yes

Name 1-25 Name 1-128 1-25 1-128 Y=Yes Y=Yes

Indicator keywords Application help . Help keywords . . . Output keywords . . CF12 CF03

. . . .

. . . . 12 03

. . . .

. . . .

. . . .

. . . .

. . . .

Define General Keywords Subfile control record . . . . . . . . . : SENWLT1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL SENWND1 Subfile cursor relative record . . . SFLCSRRRN Subfile mode . . . . . . . . . . . . SFLMODE Y=Yes Display subfile records . . . . . . SFLDSP Y Display control record . . . . . . . SFLDSPCTL Y Initialize subfile fields . . . . . SFLINZ Delete subfile area . . . . . . . . SFLDLT Clear subfile records . . . . . . . SFLCLR Indicate more records . . . . . . . SFLEND SFLEND parameter . . . . . . . . *MORE Y SFLEND parameter . . . . . . . . *SCRBAR Record not active . . . . . . . . . SFLRNA F3=Exit F12=Cancel

Name Name Name Indicators/+ 25 26

28 30 *MORE ... More...

Define Display Layout Subfile control record . . . . . . . . . : SENWLT1 Type values, press Enter. Keyword Number Records in subfile . . . . . . . . . . SFLSIZ 6 Program-to-system field . . . . . . Records per display . . . . . . . . . SFLPAG 5 Spaces between records . . . . . . . . SFLLIN OUTPUT EMPLOYEE DETAILS 1.SELECT OPT EMPNUMBER NAME 000101 K.RAMANAVKUMAR 000102 R.SHYAMSUNDAR 000103 B.MOHAN 000104 K.KUMAR 000105 A.ARUL More... EMPLOYEE DETAILS: 1.SELECT OPT EMPNUMBER 000106 000107 000108 000109 000110 NAME BALU RAMANAV RAJ HEMA VEL More... EMPLOYEE DETAILS 1.SELECT OPT EMPNUMBER NAME 000111 RAMESH 000122 SUDHA 000123 KANDASAMY

66. ILE advantages over RPG? Better call performance Modularity Multiple-language integration Enhancements to the ILE compilers Reusable components Control over application run-time environment Code optimization

Tool availability Foundation for the future 67. What is a Module? A module is a non-executable program and it contains one or more procedures. If you have modules without procedure then it means that it is having only one default procedure and in case we can use CALLB. We are creating a RPGLE module by CRTRPGMOD and a CL module by CRTCLMOD commands. 68.How to the create module? A module is created as a separate object type (*MODULE). Using the CRTRPGMOD command creates an RPGLE module. A module object cannot be run directly. You must use the CRTPGM command to bind module object into a program object. First option 15 or CRTRPGMOD command to create a module. The CRTPGM command is used to cerate a program from one or more module.
*************** Beginning C CALLB C CALLB C CALLB C SETON ****************** End of VRAMANA/RPGILE MAIN of data ******************************* 'ADD' 'SUB' 'MUL' LR data ********************************** VRAMANA/RPGILE ADD of data ******************************* 4 A 4 0 5 B 4 0 B C 4 0

0001.00 0002.00 0003.00 0004.00

*************** Beginning C Z-ADD C Z-ADD C A ADD C C DSPLY C SETON LR ****************** End of data ********************************* VRAMANA/RPGILE SUB *************** Beginning of data ******************************* 002.00 C Z-ADD 10 A 4 0 002.01 C Z-ADD 5 B 4 0 004.00 C A SUB B C 4 0 005.00 C C DSPLY 006.00 C SETON LR ****************** End of data ********************************* VRAMANA/RPGILE MUL *************** Beginning of data ****************************** 0002.00 C Z-ADD 10 A 4 0 0002.01 C Z-ADD 5 B 4 0 0004.00 C A MULT B C 4 0 0005.00 C C DSPLY 0006.00 C SETON LR ****************** End of data ********************************* CRTPGM Take F4 Program . . . . . . . . . . . . > MAIN Name Library . . . . . . . . . . . > VRAMANA Name, *CURLIB Module . . . . . . . . . . . . . > MAIN Name, generic*, *PGM, *ALL (PEP) Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB... > ADD > VRAMANA > SUB > VRAMANA + for more values > MUL > VRAMANA Text 'description' . . . . . . . *ENTMODTXT 0002.00 0002.01 0004.00 0005.00 0006.00 OUTPUT DSPLY DSPLY DSPLY

9 5 50

69. What is the difference in between CALL, CALLB, and CALLP?

CALL is a dynamic call where the control will be transferred when the program is executed. (Control will be transfer the another program (run time) so it is dynamic call). Where as CALLB and CALLP are static calls. A module is a non-executable program and it contains one or more procedures. If you have modules without procedure then it means that it is having only one default procedure and in case we can use CALLB. A module is having more than one procedure then we can give explicitly the procedure name to be called in case of CALLP out of these three CALLP is the most efficient one. (Using the CALLB, CALLP a program or module is bind in the program so it is static.) 70. What is the difference between Bind by value and Bind by reference? Bind by value Bind by Reference Here the entire modules to be bounded are In this case we are binding the programs physically copied into the main program by using service programs, which contain a reference to the module that has been object. called, and the modules are not physically copied into the program object. The program will be executed even when The program will not executed when the you delete the entire module that has been bind modules are deleted. called. Bind by value is faster than bind by It is not as faster as bind by value. (All reference. (All the modules to be bind in the modules cant bind the main program it is refer the pointer) the main program, so it is fast) 71. Define pass by value and pass by reference? Pass by reference: Pass by reference we are passing the address of the parameters and not the actual value and so the changes in the called procedure will affect the value in the calling programs. In OPM programs we are using only call by reference. Pass by value: Pass by value we are passing the value of the parameter, changes made to the formal arguments in the called function have no effect on the values of the actual arguments in the calling function it is used in c program. In RPGLE we have the option to pass the parameter by value by giving the keyword VALUE. 72. What are Program Entry Procedure (PEP) and User Entry Procedure (UEP)? If we are binding many modules together to form a program then we have to specify which module has to take control first when it has been called and that module is called as PEP for that program. User entry procedure (UEP) is the first statement that takes the control when a program has been called. For example in C programs main () will be executed first when it has been called and like wise in RPG the statement coded in C Spe will take the control first. 73. Define Copybook in RPGLE? It will copy a Subroutine (or) any group of codes physically into the program, which is copying it.
VRAMANA/RPGILE COP *************** Beginning of data ****************************** 0002.00 C DSPLY A 5 0 0002.01 C EXSR ADD 0004.00 C SETON LR

0005.00 C/COPY RPGILE, COPY ****************** End of data ******************************** VRAMANA/RPGILE COPY *************** Beginning of data ****************************** 0000.01 0001.00 C ADD BEGSR 0002.00 C ADD 5 A 0003.00 C A DSPLY 0004.00 C ENDSR ****************** End of data ******************************* OUTPUT 13 DSPLY 18 74.What will FOR opcode will do? VRAMANA/DOLOOP FOR *************** Beginning of data ***************************** di s 5p 0 inz(1) dn s 5p 0 inz(10) c for i=1 to n c i dsply c endfor c for i=n downto 1 c i dsply c endfor * for(I=5;I<40;i=i+10) c for i=5 by n to 40 c i dsply c endfor c for i=5 to 40 by n c i dsply c endfor c seton ****************** End of data ***************************** DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY 10 9 8 7 6 5 4 3 2 1 5 15 25 35

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0008.01 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00

lr

OUTPUT DSPLY 1 DSPLY 2 DSPLY 3 DSPLY 4 DSPLY 5 DSPLY 6 DSPLY 7 DSPLY 8 DSPLY 9 DSPLY 10 DSPLY 5 DSPLY 15 DSPLY 25 DSPLY 35

75. What are the various stages for a job after it is submitted? Job queue, Active job, ant OUTQ is the three stages after the job has been submitted. 76. What is the equivalent command to setll *loval in CL? POSDBF with file position as *start will set the file to the beginning (or) using OVRDBF and specify the key field value by RRN value (or) by giving *start. 77. How to create a service program and what are the steps involved in this? The service program means most commonly used modules are grouped (binding) together to form it is called service program. A service program is not bound to its caller until activation time While creating service program we can create a binder program where we can refer the modules (or) procedures (or) even data types to be used by the program. Which is using service program.

Advantages of service programs

They do not take up auxiliary storage space. There is only one copy for all users. There is only a single copy of the read-only code in main storage for all users in this service programs is the same as a program that you call dynamically. Each user of the service program has an independent work area. You can pass parameters to a service programs by using the traditional parameter list (or) by importing and exporting variables. Service programs can be maintained independently of the programs that use the functions. In most cases, changing a service programs does not cause a program using the function to be changed or re-created.
Disadvantages of service programs

Service programs are less desirable for a function you may or may not need. The reason is that it is slower to call a main program that refer to a service program 78. What is an activation group? Activation group is the boundary set for similar programs. Activation group is also a storage space in memory. CLP has a OVRDBF command and calls a RPGLE program RPGLE program performs a read operation and the pointer is now in the second program and now call the program 3 RPGLE program that also do a read operation which will read the second record Since the pointer is in the second position and then return to 2nd program in the above situation when the control transfer from 3rd record since the 2 rd record is already read in program 3. But we need to need the 2nd record according to the logic but this is not possible in any OPM programs. But in RPGLE there is a solution for this problem by giving a common activation group for 1st and 2nd program and have a separate activation group for the 3rd program while creating the program itself and this will avoid all the problem we faced before. In some situation we want to share between 2 program then we can give the activation group in *job level in which the changes in one program will be affected in another program. Types of activation group levels: *New: In this case every time you call the program an new activation group will be created which this case will not be used mostly. *caller: If we dont know the type of the program that is calling then we can specify *caller where the activation group will be the same of the program that is calling. Named activation group: We can give our own named for different activation group. 79.What are the statements that are affected by activation group? OVRDBF OPNDBF OPNQRYF STRCMTCTL DLTOVR 80. What are the statements, which is not used in CLLE that is used in CLP? RCLRSC which is replaced by RCLACTGRP TFRCTL 81. What is the difference between FMTDTA and OPNARYF?

82.What is the new name for AS/400?


I series 400 is the new name given to AS/400 by IBM now.

83.How to see source of copybooks include in a program while compiling or debugging? While compiling the program give *list instead of *source which will expand all the copybooks. 84. Explain inner join or natural join and left outer join? Inner join Inner join means the matching records in between the joining file will be selected.
Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JPF01 FMT PF *************** Beginning of data ****************************

FMTDTA

OPNQRY

It will sort the records sequentially based It will sort the records based o the field on the position of the record values. If any change in the attribute size of a PF If there is any change in the attribute size it then we have to change the program will not affect the program specification also. specification also FMTDTA is bit faster in process than OPNQRYF is slower as compare to OPNQRYF. FMTDTA if we are processing millions of records.
***************************** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JPF02 FMT PF. *************** Beginning of data *************************** 0001.00 R JP2REC 0002.00 EMPNO 5S 0 0003.00 EMPSAL 10P 2 0004.00 K EMPNO ****************** End of data ******************************** Display Report

0001.00 R JP1REC 0002.00 EMPNO 5S 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ******* ******* **** End of data

EMPNAME 1,001 SHYAMBABU 1,002 RAMANAVKUMAR 1,003 RAMESH ******** End of report ******** EMPNO EMPSAL 000001 1,001 100.00 000002 1,002 20.00 000003 1,004 300.00 ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JOFILE FMT LF. *************** Beginning of data ************************ 0001.00 R JREC1 JFILE (JPF01 JPF02) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNO EMPNO) 0004.00 EMPNO JREF (JPF01) 0005.00 EMPNAME 0006.00 EMPSAL

EMPNO 000001 000002 000003 ******

0007.00

K EMPNO ****************** End of data*********************

EMPNO EMPNAME 000001 1,001 SHYAMBABU 000002 1,002 RAMANAVKUMAR ****** ******** End of report

EMPSAL 100.00 20.00 ********

Left outer join Left outer join all the records from primary file and matching records from the secondary file will be selected.
Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JOOUT FMT LF. *************** Beginning of data********************* 0001.00 JDFTVAL 0002.00 R JREC1 JFILE (JPF01 JPF02) 0003.00 J JOIN (1 2) 0004.00 JFLD (EMPNO EMPNO) 0005.00 EMPNO JREF (JPF01) 0006.00 EMPNAME 0007.00 EMPSAL 0008.00 K EMPNO ****************** End of data********************

EMPNO 000001 1,001 000002 1,002 000003 1,003

EMPNAME EMPSAL SHYAMBABU 100.00 RAMANAVKUMAR 20.00 RAMESH .00 ****** ******** End of report ********

SEQUENCING DUPLICATE RECORDS Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SEQ1 FMT PF. *************** Beginning of data *********************** 0001.00 R SEQREC1 0002.00 EMPNO 5P 0 0003.00 EMPNAME1 20A 0004.00 ADDRESS 20A 0005.00 K EMPNO ****************** End of data ************************** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SEQ2 FMT PF *************** Beginning of data**************** 0001.00 R SEQREC2 0002.00 EMPNO 5P 0 0003.00 EMPNAME 20A 0004.00 TEL 10P 0 ****************** End of data ****************** EMPNO 10,001 10,002 10,003 ******** EMPNAME1 BOB DANNY PRINC End of report ADDRESS 23,OLD MADIWALA 50,LONG ISLAND 90,ATTUR ******** TEL 825,777 825,999 825,888 4,222,600 ********

000001 000002 000003 ******

EMPNO EMPNAME 000001 10,001 BOB 000002 10,001 BOB 000003 10,001 BOB 000004 10,002 DANNY ****** ******** End of report

Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JDFTSEQ FMT LF *************** Beginning of data ****************** 0001.00 R RECSEQ JFILE (SEQ1 SEQ2) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNAME1 EMPNAME) 0004.00 JDUPSEQ (TEL) 0005.00 EMPNO JREF (2) 0006.00 EMPNAME1 0007.00 ADDRESS 0008.00 TEL ****************** End of data************************ EMPNO EMPNAME1 ADDRESS TEL 000001 10,001 BOB 23,OLD MADIWALA 825,777 000002 10,001 BOB 23,OLD MADIWALA 825,888 000003 10,001 BOB 23,OLD MADIWALA 825,999 000004 10,002 DANNY 50,LONG ISLAND 4,222,600 ****** ******** End of report ********

JOIN DESCEND Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> JDFTSEQ FMT LF *************** Beginning of data *********************** 0001.00 R RECSEQ JFILE (SEQ1 SEQ2) 0002.00 J JOIN (1 2) 0003.00 JFLD (EMPNAME1 EMPNAME) 0004.00 JDUPSEQ (TEL *DESCEND) 0005.00 EMPNO JREF (2) 0006.00 EMPNAME1 0007.00 ADDRESS 0008.00 TEL ****************** End of data ************************* EMPNO EMPNAME1 ADDRESS TEL 000001 10,001 BOB 23,OLD MADIWALA 825,999 000002 10,001 BOB 23,OLD MADIWALA 825,888 000003 10,001 BOB 23,OLD MADIWALA 825,777 000004 10,002 DANNY 50,LONG ISLAND 4,222,600 ****** ******** End of report ********

85. Explain Build in function in ILE? %SUBST (String name: String position: length) %ABS (Absolute value by omitting sign) %EDITC (string: X) In a application if we want to concatenate a string with a numeric then we can use this %EDITC Example:
VRAMANA/BULID EDITC *************** Beginning of data ******************************* 0001.00 da s 10a inz('shyam') 0002.00 db s 10p 0 inz(20) 0003.00 dc s 10a inz('sundar') 0004.00 dd s 10s 0 inz(12) 0005.00 de s 10a inz('rambabu') 0006.00 dout s 50a 0007.00 c eval out=a+%editc(b:'X')+c+%editc(d:'X')+e 0009.00 c out dsply 0010.00 c seton lr

0011.00 ****************** End of data *********************************** OUTPUT DSPLY shyam 0000000020sundar 0000000012rambabu

%REPLACE (Replacing string, actual string, starting position, offset) Here we are replacing RAMANAVkumar from position 4 to 3 by kum. The output will be Ramkumvkumar.
VRAMANA/BULID REPLACE *************** Beginning of data **************************** d*replace the string using keyword %replace dc s 16a inz('RAMANAVRaman') db s 20a c eval b=%replace('Ram':c:4:3) c b dsply c seton lr ****************** End of data *****************************

0000.01 0001.00 0002.00 0003.00 0004.00 0005.00

OUTPUT DSPLY RamRamvRaman

%TRIM (%TRIML, %TRIMR) The use of the TRIM functions is very limited, in that they support only the use of character variables and data structures. Numeric fields, and zero-fill values are not supported. They do, however, provide some useful function for string handling. For example, in RPG IV, one line of code is all that's needed to left-adjust a value within a field. For example:
CCRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C ExFmtCustMaint CustName=%TrimL(CustName) C Eval

Typically, the %TRIM function is the only one of the three that get used. The other two, however, do have their place. %TRIM removes trailing and leading blanks from a field, and returns the remaining value, in place, within the expression. The returned value is treated similar to a constant value with leading or trailing blanks. %TRIML removes leading blanks (trim-left) from a field, and returns the value in place, within the expression. %TRIMR removes trailing blanks (trim-right) from a field, and returns the value in place, within the expression. %FOUND, %EOF, %EQUAL,%OPEN OS/400 Version 4, Release 2 RPG IV supports the elimination of the Resulting Indicators. In their place, several new built-in functions have been introduced. Most of these new built-in function provide information about the result of File operations similar to the Result indicators. But instead of coding Resulting indicator 3, for example, to check for the end-of-file condition, you simply check the value of the %EOF built-in function. The built-in functions that replace the Resulting Indicators include:

%FOUND, %EOF, %EQUAL. In addition, there are %OPEN, %STATUS, and %ERROR. Mysteriously missing is %LOCK to check for a record lock condition. %FOUND returns an *ON or *OFF condition if the previous File operation returns a record-found condition. This is particularly useful on the CHAIN operation. Realize, however, that when CHAIN sets on Resulting indicator 1, a not-found condition is signaled. Whereas, without coding Resulting Indicator 1, the %FOUND built-in function returns the found condition. %EOF can be used to check for end-of file, beginning of file, or subfile full conditions. A READ and READE return %EOF=*ON if the end of file is reached. READP and READPE return %EOF=*ON if the beginning of file is reached. The WRITE operation returns %EOF=*ON if the WRITE operation to a subfile detail record returned a subfile-full condition. %EQUAL is used by the SETLL operation to indicate that it detected a record in the file with a key equal to that of the value specified in Factor 1. Since SETLL does not read the record, does not lock the record, and does not copy the data into the input buffer, SETLL is much faster and less of an impact on the performance of the application than other operations, such as CHAIN. Use CHAIN when you need to retrieve the record, use SETLL and %EQUAL when you need to only check for the existence of a record. %OPEN is used to check to see if a file has already been opened. The built-in function returns *ON if the file is opened, otherwise it returns *OFF. %ELEM %ELEM will display the array dimension
0001.00 0002.00 0003.00 0004.00 0005.00 ELEM *************** Beginning of data ****************************** darr1 s 3s 0 dim(100) dc s 3s 0 c eval c=%elem(arr1) c c dsply c seton lr ****************** End of data **********************************

OUTPUT DSPLY 100

%SIZE %SIZE will display the size of the variable


VRAMANA/BULID SIZE *************** Beginning of data ***************************** 0000.01 D*BY USING THIS COMMAND FIND SIZE OF DATA VALUE 0001.00 darr1 s 10p 0 dim(10) 0002.00 dds1 s 10p 0 dim(20) 0003.00 dnum s 20p 0 0004.00 c z-add 2 a 20 0 0005.00 c movel 'RAMANAV' b 10 0006.00 c eval num=%size(a) 0007.00 c 0008.00 c num dsply 0009.00 c eval num=%size(b) 0010.00 c num dsply 0011.00 c eval num=%size(arr1) 0012.00 c num dsply 0013.00 c eval num=%size(arr1:*all) 0014.00 c num dsply 0015.00 c eval num=%size(ds1) 0016.00 c num dsply 0017.00 c eval num=%size(ds1:*all) 0018.00 c num dsply 0019.00 c seton lr

****************** End of data ********************************** OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY 6 11 10 6 60 6 120

%EDITW 86.Explain keyword in ILE? Overlay Rename Prefix Options Const 87.How you can schedule a job to run periodically? We have to create a job scheduler for running a job periodically. Here we can make a job to run once or periodically at a given date and time. We can create a job scheduler by using ADDJOBSCDE command. We can list all the job scheduler running by using the command WRKJOBSCDE command and we can delete a job scheduler by using RMVJOBSCDE or we can reschedule the job by using CHGJOBSCDE. 88.How to debug a batch job? Hold the batch job to be debugged by using WRKACTJOB command and having option 3. Set the pointer in the batch program to be debugged by using STRDBG and call the STRSRVJOB command and start the service program, which will enter into the debug mode. After entering into debug mode release the job that is hold before. 89.Define KLIST? KLIST operation is a declarative operation that gives a name to list of KFLD. This KLIST can be used as a search argument to retrieve records from files that have a composite key. 90.Define PLIST? The declarative PLIST operation defines symbolic name for a parameter list to be specified in a CALL operation. 91.Define composite key? It is a key for a file, which is composed of more than one field. 92.Explain procedure used in RPGLE? A procedure is a non-executable program. If a module is having more than one procedure then we can give explicitly the procedure name to be called in case of CALLP.

Defining the prototype: Prototype will specify the following things Parameter type Sequence of the parameter Return variable and its type It tells the name of the procedure and also the type of the call. It will avoid all the run time problems like parameter mismatch by specifying the prototype. Prototype interface It is like *entry parameter where we will specify the parameters that are received in this program. Import and export If you want to specify the procedures to be the external programs then we can specify EXPORT in your procedure.

Global and local variables If you declare a variable in main procedure then it will be accessible in all sub procedure and this is global declaration and if you specify the declaration in the sub procedures then it will not be accessed in other procedures or in the main procedure. Return If we specify return in the sub procedure then it means that we are returning something to the calling program. We can return a maximum of only one variable to the calling program. Recursion A procedure calling to it self is known as recursion. Pass by value/pass by reference In case of pass by reference we are passing the address of the parameters and not the actual value and so the changes in the called procedure will affect the value in the calling program. In OPM program we are using only call by reference and in RPGLE we have the option to pass the parameter by giving the keyword VALUE. CALLP/Expression We can call the procedure by using CALLP command if it is not having any return type and by an expression if it returns any value. 93.How you can import and export a data type between 2 programs? If you are using an export statement when declaring a variable then the data type can be imported in any modules that is bind either by value or by reference. So in this case we can pass values in between modules instead of using PLIST and *ENTRY. 94. Message subfile record format keywords? SFLMSGRCD (subfile message record) This keyword is used to give the line number to get the first message in the display.

SFLMSGKEY (subfile message key) This keyword is used to specify that the program message queue is built one at a time. SFLPGMQ (subfile program queue) It is a message queue created for every program active in the call stack. This keyword is used to specify the field that can have the name of the program message queue. 95. How to create Message subfile? Create message subfile CRTMSGF MKSFILE/LIB WRKMSGF FILE/ANME
OPTION 12
Add Message Description (ADDMSGD) Type choices, press Enter. Message identifier . . . . . . . MKS0001 Name Message file . . . . . . . . . . > MKSFILE Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB First-level message text . . . . EMPLOYEE NUMBER &1 CANNOT BE ZEROS PAGE DOWN Message data fields formats: Data type . . . . . . . . . . *CHAR *NONE, *QTDCHAR, *CHAR... Length . . . . . . . . . . . . 10 Number, *VARY WRKMSGF MKS0001 MKS0002 MKS0003 MKS0004 MKS0005 MKS0006 MKS0007 MKS0008 MKS0009 MKS0010 10

0 0 0 0 0 0 0 0 0 0

EMPLOYEE NUMBER CANNOT BE ZEROS EMPLOYEE &1 NUMBER AIREADY EXIST EMPLOYEE NAME CANNOT BE BLANKS ADDRESS(1) CANNOT BE BLANKS CITY CANNOT BE BLANKS MARITAL STATUS WILL BE WITH (M/S) EMPLOYEE NUMBER &1 ADDED SUCCESFULLY EMPLOYEE NUMBER DOES NOT EXISTS EMPLOYEE UPDATED SUCCESSFULLY EMPLOYEE NUMBERDELETE SUCCESFULLY SFLMSG SFLCTL 06/27/02 06/27/02

Create message subfile


MSGREC1 20 MSGCTL1 USING 8 SELETION MSGREC1

Select Subfile Keywords Subfile record . . . . . . . : MSGREC1 Type choices, press Enter Y=Yes General keywords . . . . . . . . Y Indicator keywords . . . . . . . Y Message record . . . . . . . . . Y TEXT keyword . . . . . . . . . . Define Message Record Subfile record . . . . . . . : MSGREC1 Type choices, press Enter. Keyword Line number for first message . . . . SFLMSGRCD Message ID field . . . . . . . . . . SFLMSGKEY (if program message queue is built one message at a time) Program message queue field . . . . . SFLPGMQ Generate a 276 byte field . . . . . MESSAGE SUBFILE (SFTCTL) Subfile control record . . . . . . . . . : MSGCTL1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Subfile display layout . . . . . Y Subfile messages . . . . . . . . Y Select record keywords . . . . . Y

24 DUMMY

1-27 Name

QUEUE

Name Y=Yes

. . . . . . . . . . Define General Keywords Subfile control record . . . . . . . . . : MSGCTL1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL MSGREC1 Subfile cursor relative record . . . SFLCSRRRN Subfile mode . . . . . . . . . . . . SFLMODE Program message queue field . . . . SFLPGMQ QUEUE Generate a 276 byte field . . . . Y=Yes Display subfile records . . . . . . SFLDSP Y Display control record . . . . . . . SFLDSPCTL Y Initialize subfile fields . . . . . SFLINZ Y Delete subfile area . . . . . . . . SFLDLT Clear subfile records . . . . . . . SFLCLR Indicate more records . . . . . . . SFLEND SFLEND parameter . . . . . . . . *MORE SFLEND parameter . . . . . . . . *SCRBAR Record not active . . . . . . . . . SFLRNA F3=Exit F12=Cancel Select Record Keywords Record . . . : MSGCTL1 Type choices, press Enter. General keywords . . . . . . . . Indicator keywords . . . . . . . Overlay keywords . . . . . . . . Y Y=Yes Y Y

TEXT keyword

Name Name Name Name Y=Yes Indicators/+

*MORE ... More...

Select Overlay Keywords Record . . . : MSGCTL1 Type choices, press Enter. Overlay without erasing . . . . . . Create CL program for SNDPGMMSG Keyword OVERLAY Y=Yes Y Indicators/+ Roll

VRAMANA/EMPCUSTOR MSG *************** Beginning of data ***************************** 0001.00 PGM PARM(&MSGID &MSGFI &MSGDTA) 0002.00 DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) 0003.00 DCL VAR(&MSGFI) TYPE(*CHAR) LEN(7) 0004.00 DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(10) 0005.00 SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFI) MSGDTA(&MSGDTA) 0006.00 ENDPGM ****************** End of data****************************** Create CL program for RMVMSG VRAMANA/EMPCUSTOR RMO *************** Beginning of data ***************************** 0001.00 RMVMSG PGMQ(*PRV) CLEAR(*ALL) ****************** End of data ******************************* Design the screen Generate RPG program 0000.01 FMESSTAB IF A E K DISK 0001.00 FMKSSCR CF E WORKSTN 0001.01 C MOVEL MSTATUS S 1 0002.02 C MOVEL '*' QUEUE 0003.00 C MOVEL 'MKSFILE' MSGFI 0004.00 C PL01 PLIST 0005.00 C PARM MSGID 7 0006.00 C PARM MSGFI 10 0007.00 C PARM MSGDTA 10 0008.00 C DOW *IN03=*OFF 0008.01 C MOVEL 0 ERROR 1 0 0008.02 C MOVEL 0 ERROREMP 1 0 0012.00 C WRITE MSGCTL1 0013.00 C EXFMT MKSSEN 0013.01 C CALL 'RMO' 0014.00 C IF EMPNUMB=*ZEROS 0014.01 C MOVEL 1 ERROR 0014.02 C MOVEL 1 ERROREMP

0015.00 0016.00 0017.00 0017.01

C C C C

MOVEL MOVEL CALL ENDIF

'MKS0001' *ZEROS 'MSG'

MSGID MSGDTA PL01

96.What is active subfile? Subfile, which are in the main memory, are called as active subfiles. A maximum of 24 subfile can be active at a time. 97. Navigation between two screens?
VRAMANA/TABLES EX21 *************** Beginning of data ***************************** FEXDSPF CF E WORKSTN C Z-ADD 1 SCR1 2 0 C *IN03 DOWEQ *OFF C SCR1 DOWEQ 1 C EXFMT DSPF1 C 03 LEAVE C IF *IN08=*ON C Z-ADD 2 SCR1 C LEAVE C ENDIF C ENDDO C SCR1 DOWEQ 2 C EXFMT DSPF2 C 03 LEAVE C IF *IN07=*ON C Z-ADD 1 SCR1 C LEAVE C ENDIF C ENDDO C 03 LEAVE C ENDDO C SETON LR ****************** End of data *******************************

0001.00 0002.00 0003.00 0004.00 0005.00 0006.00 0007.00 0008.00 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00 0016.00 0017.00 0018.00 0019.00 0020.00 0021.00 0022.00

98. What is the different between READE and CHAIN opcodes? READE 1.The matching records for table 2. We are using the looping concept 3.The indicator setin the EQ 4. We are most using in SETGT or SERLL CHAIN The first matching records only Looping is not necessary The indicator setin the HI It is not necessary

99. Define indicator & MOVEA? It is a 1-bit flag where value will be either 0 or 1 AS/400 provider 99 indicator for the business user. 1-24 ->assigned functions keys 25-99 ->our own purpose 100. Define ITER / LEAVE? ITER-> Transfer the control before do loop. LEAVE-> Transfer the control after do loop. 101.CL commands? 1. WRKMBRPDM
2. CRTSRCPF

By using this command to create source physical file. Default PF size is 92. 3.DSPFD It is used to display the details about the file when it is created. 4. DSPFFD

It is used for listing details about Individual Fields 5.STRDFU It is used to add Data into the records 6.STRSDA It is used to go into screen Designing or Menu Designing 7.CRTMSGF For creating the Message file 8.WRKMSGF If you want to create or change or delete any message we can use this command. 9.CRTDTAARA For creating The Data Area 10.DSPDTAARA For listing the content of Data area. 11.CHGDATARA For changing the content of Data area. 12.DSPLIBL For listing the contents of library 13.ADDLIBLE For Adding a library into the current library. 14.RMVLIBLE For Removing a library into the current library. 15.CHGCURLIB For changing the Current Library to a new library 16.EDTLIBL It is used to the edit of the library file. (Change library file it is temporary delete the library file) For Adding or Removing library lists. 17.SNDBRKMSG Used for sending message to all user.

18.CRTPF It is used to create a PF. Using this command we can set the maximum number of records, whether delete or update operation is allowed or not, maximum storage allocation, waiting time etc can be determined 19.CRTLF To create the logical files. 20.STRRLU To go into the RLU we are using this command. Default length of RLU is 132 if you give it and creating it very first time else it set the page width value of last edited RLU. We can give the page width value from 1 to 378 in page width option. 21.DSPSBS It is used to list the various subsystems running under AS/400 environment. Various subsystems running are QINTER, QACTIVE, and QBATCH etc. 22.CRTRPGPGM It is used to create an RPG program. We can determine what sort of source file is generated. For example when we need the entire source compile as it is since source is default. If we give *NOSOURCE only syntax errors is generated NOSECLVL will not allows secondary message where as other setting is allowed it and so on 23.CRTCLPGM To create CL program

24.EDTOBJAUT It is used to give authority to a particular source PF. For giving authority to other user we must give authority to library, user profile and the source PF. 25.DSPOBJD If we know library name and object name and we want to know the source PF where it is residing then DSPOBJD with option as services instant of basic will give the source PF name. It describes various object descriptions like created Date, Created by, Source Physical file, which it is being created, and so on. 26.STRSQL To start into SQL. 27.WRKSPLF To work with Spool file 28.DLTSPLF To delete the spool file 29.CRTDUPOBJ By using this command to create duplicate object. If you want to compile a PF having 1000 of records and when we compile it all the data will be lost else if you want to add or delete a attribute data for other fields will have to copied. For that we a duplicate object. 30.CPYF Records are being copied from PF to temporary file and after compiling it we have to again copy back from temporary file to the original file. If we Add a attribute we have to give *map and if we want to delete a attribute we have to give *drop in the map entry field.

31.DLTF After copying into the original file we have to delete the temporary file or if you want to delete any file we are using this command. DLTF will only remove the object 32.RMVM It is used to delete the member as well as the object. 33.RUNQRY To display all the records in a PF. 34.CRTCMD It is the powerful command used to create user define commands. 35.CMPPFM It is used to compare two programs or files. It can be coded by taking option 54 in Subfile screen. 36.MRGSRC It is used to merge a file with another file. We have to mention three files one is the root file, which is just a root and does not contain any code even. The second file is target file where we can have the ready-made we can copy the target source. 37.RTVCLSRC If you delete a CL Source then we can retain the source if you are having the object by using this command. 38.SBMJOB If you want to submit the job in certain interval i.e. on a specified date and time we can use this command 39.DSPJOB It will display all the jobs. 40.DSPUSRPRF It will display all the entries regarding the particular user profile. It displays information like what is the user. Profile name; date previously, user class, printing and all.

41.CPYSRCF If we want to copy all the members in a source PF to another source PF. 42.WRKACTJOB To display the active jobs running in AS/400 systems. 43.DSPJOBLOG By using this command display the output console. 44.SNDMSG This command is to send the message to an user. 45.DSPMSG This command is display all the message. 46.CHGCURLIB Change the current library file. 47.ADDLIBLE It is used to add the library. It is fully administrator authority. 48.RMVLIBLE This command is to remove a library from the list. 49.CRTUSRPRF It is used to display the rights given to a user. The system administrator can change authority he can give the authority as a system administrator. 50.DSPDBR (data base relation) This is used to list all the files, which are related to a PF. It displays all the LF that is referring the PF and also lists the child table if it is having a relation through ADDPFCST. 51.DSPJOB It will display all the jobs submitted within the specific interval and display the entire user who worked on the system at that time 52.WRKMSGQ It will list all the messages of different user in the job queue.

53.CPYSRCF If we want to copy all the members in a source PF to another source PF we can use this command. 54.CPYTODKT If we want to copy from source PF to a diskette file 55.CPYTOTAP If we want to copy source PF to a tape then we can use this command. 56.STRDBG If we want to debug a ILE program then we can use this command .We have to create a ILE program by compiling with 15 which is CRTRPGMOD command and take F10 give debugging values as *Source. This will create a module. Then we have the create the program by giving program name and module name as the same and if we are calling any other modules also in that include that in the CRTPGM command Ex: CRTPGM PGM (LIB/PNAME) MODULE (LIB/PNAME) (LIB/SPNAME) Now the program as well as the module is created. Then we have to start the debug by using the command. STRDBG PGM (LIB/PNAME) UPDPROD (*YES) It will shoe the source code of the program and we have to press F6 set the break point and press F10 key and call the program

CALL PNAME F11-> display the variable Shift + F11 -> go to module 102. Data types in CL?

103. String operation in CL? *CAT ->Concatenate without editing. *BCAT->Trailing blanks in the first character string are truncated. One blanks is inserted, then the two character strings are concatenated. Any leading blanks of the second operand are not truncated *TCAT->All trailing blanks in the first character string are truncated, and then the two character strings are concatenated. Any leading blanks of the second operand are not truncated.
VRAMANA/CLP STRING *************** Beginning of data ******************************** 0000.01 /*STRING *CAT *BCAT *TCAT FUNCTION */ 0001.00 PGM PARM(&STR &STR1 &STR2 &STR3 &STR4)

LEN ()

VALUE () Default (0) Default (b) Default (0)

TYPE ()
*DEC *CHAR *LGL
Default (15 5)

Max (15 9) Default (32) 1

0001.02 DCL VAR(&STR) TYPE(*CHAR) LEN(15) 0001.03 DCL VAR(&STR1) TYPE(*CHAR) LEN(15) 0001.04 DCL VAR(&STR2) TYPE(*CHAR) LEN(15) 0001.05 DCL VAR(&STR3) TYPE(*CHAR) LEN(15) 0001.06 DCL VAR(&STR4) TYPE(*CHAR) LEN(40) 0001.07 CHGVAR VAR(&STR2) VALUE(&STR *CAT &STR1) 0001.08 CHGVAR VAR(&STR3) VALUE(&STR *BCAT &STR1) 0001.09 CHGVAR VAR(&STR4) VALUE(&STR *TCAT &STR1) 0001.10 SNDMSG MSG(&STR3) TOUSR(SKANDASAMY) 0001.11 SNDMSG MSG(&STR4) TOUSR(SKANDASAMY) 0001.12 SNDMSG MSG(&STR2) TOUSR(SKANDASAMY) 0006.00 ENDPGM ****************** End of data ********************************** run call program name (string) f4 Program . . . . . . . . . . . . > STRING Name Library . . . . . . . . . . . > VRAMANA Name, *LIBL, *CURLIB Parameters . . . . . . . . . . . > VENKATA > RAMANA > '' > '' + for more values > '' DSPMSG

112. How to set the cursor position in particular field in particular position? Using the curpos 113. How will retrieve the data in data area? In retrieve a data area Out-write a data area 106.Built in function in CL? %SUBSTRING or %SST

The sub string built-in function produces a character string that is a subset of an existing character string and can only be used with a CL program. %SUBSTRING (Character-variable-name Starting-position length) Or %SST (Character-variable-name Starting-position length) %SWITCH 114. Define indicator in CL? We can set on or setoff the indicator by the command. CHGVAR (&IN30) VALUE (0) ->setoff CHGVAR (&IN30) VALUE (1)->seton 115. Message subfile in CL? Subfile cannot be used in CL but we can use message subfiles in CL. 116. CL processing commands & program control commands? PROCESSING -> CHGVAR, SNDPGMMSG, OVRDBF, AND DLTF. PROGRAM CONTROL ->CALL, RETURN, TFRCTL 117. How to CL code has to change to use a call procedure? By using CALLPRC command. This is the bound call in CL that calls a procedure within a module. 118. Figurative constants in RPGLE? *HIVAL, *LOVAL, *ZERO, *ZEROS, *BLANKS, SETLL, SETGT. 119. Rename of fields and prefix? 112. How you will avoid multiple users updating the same records? The displaying the records in the screen we will be getting the timestamp along with the actual data. Store this in output data structure and while updating check weather the previous time stamp is the same timestamp before updating. If the record is updated by another user than the time stamp will be changed and if it does not matches then throw the error message Record is already updated by another user else update the records with current time stamp.

Program 1
Store the time stamp and this time stamp will come as a input to the second program

Program2
Here wstmst1 contains the input time stamp and check this matches with the database. If matches Update else send error message. 113.Define binder program? The binder program means binding the procedure it is called binder program. 114.question details? DEFAULT CL MSGID? CPF0000 Dspf windows type? WINDOW How many key define in logical file? All the PF fields are create in key. What is the level check error?

The level check error means RPGLE program is compiled and PF or LF are compile suppose the PF or LF compile after the compiling the RPGLE program this type of error is called level check error. If you want to copy a PF without making any modification to it then FORMAT keyword is used. Default access path maintenance is *IMMED Maximum no of printer files included in a RPGLE program is 8 Maximum no of files declared in RPGLE is 50 and CL is l Maximum no of key fields included is 120 Maximum no of fields included in a PF is 8000 Maximum no of arrays included is a RPG is 200 Maximum no of parameter passed in a RPG is 255 and CL 40 Total no of system library is 15 and user library is 25 While logging on the first library to be included is QSYS QGPH and QTEMP are user library Printer file default length is 132. Default size of a member is CRTSRCPF command for ordinary files is 92.

115. What's the difference between CHAIN and SETLL? Is there a performance advantage?
There are two important differences between CHAIN and SETLL. 3. The CHAIN operation applies a record lock to files that are open or update. The SETLL operation does not apply the lock. 4. The CHAIN operation copies the record's data to the input buffer for the program. The SETLL operation does not.

More Details
The CHAIN operation performs a random GET operation to the database file. If the operation is successful, the data in the record is copied to the input buffer. If the CHAIN operation fails, a record-not-found condition is signaled, typically via Resulting Indicator 1. If the database file has been opened for UPDATE, the CHAIN operation places a record lock on the retrieved record. No other application can access this record for update while this lock is applied. Furthermore, if another program has issued a lock to the recording being accessed, the CHAIN operation will wait for the database time-out period. If the record is released during that period, the CHAIN operation continues. If the other program does not release the record, the CHAIN operation fails with an exception. CHAIN with NO LOCK The CHAIN operation supports the NO LOCK operation extender (the old "half-adjust" column). In RPG III you specify an N in the operation extender column, in RPG IV, you specify CHAIN (n) for the operation code. Using NO LOCK allows you to access a record without a record lock being applied, regardless of the way in which the file is open. The record's data, however, is still copied to the input buffer when NO LOCK is specified. The SETLL operation performs a quasi READ LESS THAN OR EQUAL operation. If the operation is successful, a READ PRIOR is performed. The database record's data, however, is not

copied to the input buffer, nor is there a record lock applied to the accessed record. Hence, SETLL is probably the operation code to use for testing the existence of a record. However, if the record needs to be retrieved, CHAIN more effective.

Performance
If your requirement is to check for the existence of a record, traditionally the CHAIN operation is used. However, since CHAIN copies the record's data to your program's input buffer, there is additional overhead required for the CHAIN operation. The SETLL can be used to effectively accomplish the same task as the CHAIN test. Use SETLL with resulting indicator 3 (equal). If this indicator is set on, a record exists whose key matches they value specified in Factor 1. If your requirement is that the record eventually be updated, subsequent to the existents test, you should consider using of CHAIN.

116. How do I debug a remote (i.e. "batch") job from an interactive job?
The ability to debug another job has been a long-standing requirement for AS/400, now iSeries programmers. It isn't as difficult as it may seem. Whether you need to debug a batch job, another interactive job, or an HTTP server job (browser/CGI program), the following steps can get you started.

Starting Debug for a Remote Job


7. Determine the job name of number for the job you need to debug. Use WRKACTJOB and note the Job name, number and user profile ID. If debugging a CGI program, look in the job log of the job for CPF message HTP2001. 8. Run the Start Service Job (STRSRVJOB) command specifying the job to be debugged E.g., STRSRVJOB JOB (012345/usrid/jobname) 9. Run Start Debug (STRDBG) on the program to be debugged E.g., STRDBG PGM (libnam/pgmname) UPDPROD(*YES | *NO) 10. At this point the program in the remote job is under debug control from your job You can now set break points (if you're debugging an RPG IV program, the source will have already been displayed). Press F12 from within the debugger to return to CMD entry after setting your break points. 11. Evoke the program in the remote job. If you you're doing a web browser session, hit the SUBMIT button. 12. You interactive job will "break" at the debug break points and you can debug application normally.

Ending Debug for a Remote Job


Ending the debug session should be done in the following sequence. 3. From your debugging session, run the End Debug (ENDDBG) command 4. Then run the (End Service Job) ENDSRVJOB command Your session is no longer controlling the remote job. The remote job continues normally.

Special Considerations when Debugging a Web Browser/CGI Program


To debug a CGI program that is evoked from a Web Browser session running from the standard IBM HTTP Web Server, you need to do the following in addition to the above.

Before Starting Debug for a Web Browser/CGI Session/Program


End the HTTP Server using the following CL command: ENDTCPSVR *HTTP WARNING!!! -- You MUST include *HTTP as the parameter for ENDTCPSVR otherwise all TCP/IP server jobs (including telnet, ftp, smtp, etc.) will be ended. And this is a bad thing. IBM sucks for making *ALL the default for ENDTCPSVR. Restart the HTTP Server using the following CL command: STRTCPSVR *HTTP HTTPSVR(DEFAULT '-minat 1 -maxat 1') This restarts the HTTP server with once instance of each job type (one for CGI, one for Java, etc.) Using WRKACTJOB in the QHTTPSVR subsystem location the jobs running. The job whose joblog contains the CPF message HTP2001 is the one to be debugged. After Finishing the Debug Session End the HTTP server using the following CL command: ENDTCPSVR *HTTP Restart the HTTP server using the following CL command, unless your shop has another process for starting the HTTP server: STRTCPSVR *HTTP Your system should be back to normal.

117. What is the new E operation extender used for? The new (E) operation extender is used to cause the %ERROR and %STATUS built-in functions to be initialized after an operation is performed. That

is, these built-in functions and the E operation extender are used in place of Resulting Indicator 2 on all operation codes that currently support Resulting Indicator 2 as an error condition.
For example, to check to see if a record is locked, you would code the following:
.....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C CustNO Chain(E) CustMast %ERROR = *ON C if C Select C When %STATUS = 1221 C exsr UpdateNoRead %STATUS = 1218 C When C exsr RecdLocked C endSL C ELSE C if %FOUND( CustMast ) C exsr whatever... C endif C endif

The concept is to first check %ERROR for a generalized error condition, and then check %STATUS for the specific error. Note that no resulting indicators are used in the previous example. The normal not-found condition is checked using the %FOUND built-in function rather than testing Resulting Indicator 1.

118. Why doesn't the %CHAR built-in function work with numeric values?
Under the initial release of OS/400 Version 4, Release 2, the %CHAR built-in function was introduced. However, the function, as designed, only converted DATE values to character values. This proved to be too restrictive a use for this function. In the next release of OS/400 (V4R4) IBM will add function to %CHAR allowing it to convert all forms of non-character data to character. In that release %CHAR will function with numeric values.
D Amount C Eval 7P 2 Inz(123.45) text = 'The amount is: ' + %Char( amount )

The TEXT field would contain the following after the EVAL operation is performed: 'The amount is: 123.45' Unlike %EDITC, the %CHAR built-in function trims off leading blanks. However, %EDITC provides much more editing power than %CHAR. Use %CHAR for basic number to character conversion.

119. What's new in V4R4 and RPG IV?


There are a few significant enhancements in RPG IV in OS/400 Version 4, Release 4. The %CHAR built-in function has be fixed. It now functions like it was supposed to in the first place. You can wrap a numeric value in %CHAR and a nicely edited character form of the number is returned. The edited form includes the decimal, trimmed off leading blanks, and a negative sign.

The FOR loop provides a free-format version of the DO operation code. With the FOR operation, you can begin a loop operation and continue iterating through the loop until a variable equals a limit value. The syntax for the FOR operation is enhanced with the TO, BY and DOWNTO keywords. The TO operation indicators the upper limit for the looping, while the BY keyword identifies the increment value for the loop counter. Alternatively, you can specify the DOWNTO keyword to loop backwards from a large value to a small value. The OPENOPT keyword is added to the Header specification. This keyword can be used along with its one and only keyword *INZOFL to cause overflow indicators to be set off when their corresponding printer file is closed and then re-opened during the program. In subroutines, the LEAVESR operation can now be used to exit a subroutine immediately. Effectively this is a "glorified goto" operation that branches to the ENDSR statement of a subroutine.

120. How does the CONST keyword work with Procedure parameters?
If you are certain that the called procedure will NOT modify a parameter, the CONST keyword can provide several benefits. 2. It automatically converts a field of a similar data type, to the length and type required by the parameter. What this means, is say a parameter is a 15 position pack field, with 5 decimals. Normally, you'd have to specify a Pdk(15,5) field for the parameter. However, if the parameter is read-only, you can specify CONST on the Prototype and Procedure Interface for the parameter. When you do this, the compiler automatically converts the value (say it's a literal of 27) to the size and type required by the parameter. This works really cool with DATE fields. A date for any format can be passed as a parameter value when that parameter value is CONST. 3. Performance is improved because the compiler can generate more optimized code for the CONST parameter. CONST can be used on calls to procedures or programs. We use it all the time when calling QCMDEXC from within RPG IV. All three parameters of the QCMDEXC program are CONST values. The example code below can be used as the PROTOTYPE to call QCMDEXC from within RPG IV. To call it using this prototype, specify something like: CALLP run('addlible myLib' 14) in your calculation specs.
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++ D Run PR ExtPgm('QCMDEXC') D cmdstr 3000A Const Options(*VarSize) D cmdlen 15P 5 Const D cmdDbcs 3A Const Options(*NOPASS)

Note: if you're using CodeStudio or IBM's Code/400 as your RPG IV editor under Windows, you could simply highlight the above source code within your Internet Browser, and copy it to the Windows clipboard. Then activate CodeStudio (or Code/400) and use the Paste function to insert the code directly into the editor. Pretty cool, huh? <g>

121. Can you clear up the confusion in the different releases of RPG IV and OS/400 and ILE?
RPG IV is the next generation of the RPG language. RPG III is the original version of AS/400 RPG/400. The name "AS/400 RPG/400" is that given to the IBM compiler package for distribution on the AS/400. This compiler package compiles various versions of RPG, including RPGII and at least two releases of RPGIII. As of OS/400 Version 3 release 1, IBM changed the name of this compiler package to "AS/400 ILE RPG/400". The reason for this name change was to identify that fact that the compile now includes a version of RPG that targets the Integrated Language Environment (ILE), that is RPG IV. ILE was first shipped in OS/400 Version 2, Release 3. However, only the C language compiler produced code that targeted this environment. First, a word about ILE. ILE is the new, "native" runtime environment for Programs, on the AS/400. Under OS/400 Version 2 Release 3, IBM introduced a new program model. This basically means that new features and interfaces became available. However, IBM did not just port some runtime environment to the OS/400 operating system, it actually re-wrote code, and wrote new code that, essentially, changed the way OS/400 works. This new code provides support for a mixed set of high-level languages. Previously, RPG and CL had their own little runtime environment, COBOL had it's own, C had it's own, and so on. Under ILE, all programming languages run in ILE. The same "environment" is used for COBOL, C, RPG and CL. However, to take advantage of ILE, new compilers needed to be created. As for RPG, rather than convert the existing RPGII and RPGIII compilers, IBM, who was designing a new version of RPG anyway, decided to target ILE with the new compiler. This would simultaneously provide a new version of RPG and an ILE targeted compiler.

Names Are Important


A good friend of mine once said, "names are important" in the programming world. If a field is called "Rhinoceros", does it represent its use or purpose? Okay, so perhaps in traditional RPG "Iguana" is a better choice for this example. (Shorter name.) During the development of RPG IV, two distinct issues arose. First, the internal name for RPG IV, was "ILE RPG". This was not a code name, but rather the name IBM used to refer to the new compiler. After all, it was targeting ILE, why not refer to it as "ILE RPG"? Second, the rearchitecture of RPG came into question. Unfortunately, the internal name "ILE RPG" began to be leaked out to the public. Several magazine writers and IBMers not involved in the development of RPG IV continued to use the term "ILE RPG" when referring to RPG IV. I suppose these people still refer to the AS/400 as SilverLake or perhaps even Olympic. Then when IBM announced the compiler package or product name as "AS/400 ILE RPG/400" it only added to the confusion. IBM dropped the ball when promoting the RPG IV name. They are, after all, set up to market their products with their product names. The name of one programming language included in a product that contains nearly seven full compilers isn't high priority.

RPG IV is the version of RPG that targets ILE. OS/400 V3R1 compatible RPG IV can also target what is now called "the original program model" or simply OPM. OPM is just a name that has been given to the original runtime environment of RPG and CL under OS/400. This is the environment in which RPGIII and CL run. Under ILE, however, the original native environment is emulated, that is, ILE isn't an environment at all, it is native OS/400, whereas, OPM is now an environment under ILE. Some very clever programming and design went into this, don't you think? Not very many other operating systems, if any, provide this kind of continuity.

RPG IV -- Release what?


RPG IV was first shipped with OS/400 Version 3, Release 1. This is now referred to as RPG IV release 1. But don't worry about remembering releases of RPG IV. Under OS/400 Version 3, Release 6, IBM enhanced RPG with procedures, many more built-in functions, and several new data types. This is referred to as RPG IV release 2. Then, OS/400 Version 3, Release 2 was announced. It brought the original release of RPG IV (on the CISC boxes) up to the same level as RPG IV under V3R6. Are you confused yet? Me too! Under OS/400 Version 3, Release 7, IBM added a couple of enhancements, most notably they increased the length of a field name to a number so large not even magazine authors that don't write real-world code could complain about it anymore. They also added one or two new data types, rounding out RPG IV so that it supports all AS/400 data types, except variable length fields. This version of RPG IV is known as RPG IV Release 3. The following table identifies the current releases of RPG IV. Note that RPG IV releases do not necessarily coincide with releases of the operating system. RPG IV Release 1 2 2 3 4 4 OS/400 Version/Release CISC or RISC

V3 R1 V3 R6 V3 R2 V3 R7 V4 R2 V3 R5 See note 1 V4 R3 V4 R4 (February 1999) (speculation)

CISC RISC CISC RISC RISC CISC

5 5

RISC RISC

V4 R5 (Summer 2000)

RISC

NOTE 1: It is speculated that IBM may ship a final "clean up" release of OS/400 for CISC that would included a large level of compatibility with OS/400 V4 R5. The release levels of RPG IV are only important if you want to keep track of that kind of thing. One disappointing issue is that unless you stay on the most current release of OS/400, you don't get all the cool new features in RPG IV. Even if you stay current, you can't target prior releases if you use any of the new features. In fact, even if you use a new feature that doesn't depend on an operating system enhancement, it can't be used for back releases. This is because of the way the TGTRLS (target release) feature has been implemented. Basically, if you're on V4 R2 and you do a TGTRLS(V3R2M0) the compiler calls the actual compiler for V3 R2. It doesn't have a built-in syntax checker that says "This feature requires an OS/400 upgrade so don't allow it, or this one is okay so accept it." It iscalling the same "binary" compiler code that is on any old V3 R2 system. Which means, for example, that if you want to take advantage of the new compiler directives, but you often have to target a prior release, you can't use those directives. For example, /IF DEFINED does nothing for the executable code that's generated, but is not supported when TGTRLS(V3R2M0) is specified. ;( Bummer!) So now we know about RPG IV release levels and how the term "ILE RPG" got into our vocabulary. So let's clear up another term, the name of the RPG language. The big one is the term "RPG/400". There is not programming language called "RPG/400". The language most often called "RPG/400" is RPGIII. However, back in the System/38 days, the System/38 RPG language was called RPGIII. When the AS/400 was announced, programmers wanted to give themselves an advantage on their rsum. So they began calling AS/400 RPGIII, "RPG/400". Then to make matter worse, when RPG IV was announced, programmers thought that the number "IV" in "RPG IV" was less than the "400" in "RPG/400". So they decided to call RPG IV, "ILE RPG". Well let's set the record straight. The table below lists the RPG language names, their incorrect name, and the proper name. Commonly used Wrong Name RPG/36 RPG/38 RPG/400 ILE RPG Formal Name Proper Name (correct)

System/36-compatible RPGII System/38-compatible RPGIII RPGIII RPG IV

RPGII RPGIII RPGIII RPG IV

122. How do I declare an array with a dynamic number of elements?


In RPG IV, the new (V3 R7) ALLOC, REALLOC and DEALLOC operation codes can be used to allocate memory. This means that at run time, you can go out to the system and ask it to assign storage to the program that was not allocated to the program when it was evoked.

These operation codes can be used to allocate memory up to 16MB. The allocation can be assigned to a pointer variable. In RPG IV, pointers have the data-type of asterisk (*). All that is needed is to allocate memory to a pointer that is used with the BASED keyword of the desired dynamic array. The example that follows illustrates this technique:
.....DName+++++++++++EUDS.......Length+TDc.Functions++++++++++++++++++ D DynoArr S 7P 0 Dim(10000) based( pDynoArr) D nSize S 10i 0 .....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++ C Eval nsize = %size(DinoArr) * 64 .....CSRn01Factor1+++++++OpCode(ex)Factor2+++++++Result++++++++Len++DcHiLoEq C Alloc nSize pDynoArr

** We now have enough storage allocated for 64 elements.


C Eval nsize = %size(DinoArr) * 70 C ReAlloc nSize pDynoArr ** We have changed the allocation to enough storage for 70 elements C* ... code to use the array goes here... C Dealloc(N) pDynoArr ** We have just returned the storage to the system.

To increase or decrease the number of elements in the dynamic array, use the REALLOC operation code. Simply change the number of bytes that need to be allocated, and call REALLOC with the new size in Factor 2 and the original pointer variable in the Result field. REALLOC allocates new storage of the size specified, and copies the original data to that new location. Then it frees ("deallocates") the original storage. IMPORTANT: Always remember to DEALLOC anything you ALLOC. That is always free up memory that you have allocated otherwise memory leaks will be created. If you are not on V3 R7, you can still use dynamic memory by calling one of the system APIs or linking into the QC2LE binding directory and calling the C runtime MALLOC and DEALLOC functions.
123. RPG IV - Built-in Functions

The original release of RPG IV included a set of built-in functions. These built-in functions were: %ADDR, %PADDR, %SIZE, %ELEM, %SUBST, %TRIM, %TRIML, %TRIMR In addition, under OS/400 V3R2 and V3R7 the %PARMS built-in function was introduced. Since then, several built-in functions have been added to RPG IV. The following table provides the OS/400 Version and Release that the specific built-in functions were introduced and/or enhanced. NOTE: IBM Seems to skip-ship the RPG IV compiler. So RPG IV in V4R1, V4R3 and V4R5 have no new functionality. The next scheduled upgrade is OS/400 V5R1 in Spring 2001.

Version Release V3R7

Built-in Function

Parameters

Return Value Description

%ABS

numeric expression

Absolute value of expression

%ADDR V5R1 V4R2 V4R4 V5R1 %ALLOC %CHAR

variable name memory size graphic, date, time, timestamp, or numeric expression compare-value : data-to-search { : start-position } compare-value : data-to-search { : start-position }

Address of variable Pointer to the allocated storage. Value in character data type

%CHECK

First position in the searched-data that contains a character not in the list of the characters in the compare value. Last position in the searched-data that contains a character not in the list of the characters in the compare value. (Search begins with the right-most character and proceeds to the left. A date data-type value after converting the "value" to the specified date format. If no value is specified, the current system date is returned. A duration value that can be used in an expression to add a number of days to a date value. Value in packed numeric format. If digits and decpos are specified the result value is formatted to fit in a variable of the number of digits specified. Half-adjusted value in packed numeric format. The length and decimal positions Number of decimal digits. Calculates the difference between two date fields. The type of difference returned is specified by the duration-code. Performs integer division and returns the quotient (result) of that division operation.

V5R1

%CHECKR

V5R1

%DATE

{ value { : dateformat-code }

V5R1

%DAYS

days

V3R7

%DEC

numeric expression {:digits : decpos}

V3R7

%DECH

numeric expression : digits : decpos numeric expression start-date : end-date : duration-code

V3R7 V5R1

%DECPOS %DIFF

V4R4

%DIV

Numerator Denominator

V3R7

%EDITC

non-float numeric expression : edit code {:*CURSYM | *ASTFILL | currency symbol} numeric expression non-float numeric expression : edit word array, table, or multiple occurrence data structure name {file name}

String representing edited value.

V3R7 V3R7

%EDITFLT %EDITW

Character external representation of float.

display

String representing edited value

%ELEM

Number of occurrences

elements

or

V4R2

%EOF

'1' if the most recent file input operation or write to a subfile (for a particular file, if specified) | ended in an end-of-file or | beginning-of-file condition '0' otherwise. '1' if the most recent SETLL (for a particular file, if specified) or LOOKUP operation found an exact match '0' otherwise. '1' if the most recent operation code with extender 'E' specified resulted in an error '0' otherwise.

V4R2

%EQUAL

{file name}

V4R2

%ERROR

V3R7 V4R2

%FLOAT %FOUND

numeric expression {file name}

Value in float format. '1' if the most recent relevant operation (for a particular file, if specified) found a record (CHAIN, DELETE, SETGT, SETLL), an element (LOOKUP), or a match (CHECK, CHECKR, SCAN) '0' otherwise. Converts character data to double-byte character set value. A duration value that can be used in an expression to add a number of hours to a time value. Value in integer format

V4R4 V5R1

%GRAPHIC %HOURS

Any character value hours

V3R7

%INT

numeric expression

V3R7 V3R7

%INTH %LEN

numeric expression any expression

Half-adjusted value in integer format 3. Returns the length of a variable or literal value, or the current length of a varying length field. 4. When used on the left side of the equal sign, sets the length of a varying length field. An array index of the element in the array where the search-data is located. *ON if the search is successful, otherwise *OFF. (NOTE: The indexes of the searched-table and alternate-table are set to the index of the search-data if *ON is returned.) A duration value that can be used in an expression to add a number of minutes to a time value. A duration value that can be used in an expression to add a number of months to a date value. A duration value that can be used in an expression to add a number of milliseconds to a time value.

V5R1

%LOOKUPxx

search-data : array { : start-index { : elements to search }} search-data : searched-table { : alternate-table }

V5R1

%TLOOKUPxx

V5R1

%MINUTES

minutes

V5R1

%MONTHS

months

V5R1

%MSECONDS

milliseconds

V3R7

%NULLIND

null-capable name data-structure

field

Value in indicator format representing the null indicator setting for the null-capable field. The current occurrence of the data structure, or sets the current occurrence of the data structure '1' if the specified file is open '0' if the specified file is closed. Consider this built-in to be an 'Is this file open?" operation. Address of procedure

V5R1

%OCCUR

V4R2

%OPEN

file name

%PADDR

procedure name

V3R2 V3R6 V5R1 V4R4

%PARMS %REALLOC %REM pointer : new-size Numerator Denominator :

Number of parameters passed to procedure Pointer to the allocated storage. Performs integer division and returns the remainder from the division operation. String produced by inserting replacement string into source string, starting at start position and replacing the specified number of characters. First position of search argument in string or zero, if not found. A duration value that can be used in an expression to add a number of seconds to a time value. *ON if the job is being shut down (e.g., when the PWRDWNSYS command is issued) otherwise *OFF is returned. variable, data structure, array, or literal {: *ALL} Number of bytes used by variable or literal. *ALL returns the number of bytes used by all the elements of the array, or all the occurrences of the data structure. The square root of the expression or value. 0 if no program or file error occurred since the most recent operation code with extender 'E' specified most recent value set for any program or file status, if an error occurred if a file is specified, the value returned is the most recent status for that file. Characters addressed by pointer argument up to but not including the first x'00'. The extracted component of the

V4R2

%REPLACE

replacement string: source string {:start position {:source length to replace}} search argument : string to be searched {:start position} seconds

V3R7

%SCAN

V5R1

%SECONDS

V5R1

%SHTDN

%SIZE

V5R1 V4R2

%SQRT %STATUS

expression or value {file name}

V3R7

%STR

pointer{:maximum length} date : duration-code

V5R1

%SUBDT

date value. (The equivalent of the operation code.) %SUBST string:start{:length}

functional EXTRCT

Substring value. If length is not specified, the substring begins with start and continues through the end of the string. Used for Java integration. Returns an Object reference.

V5R1 V5R1

%THIS %TIME { value { : timeformat-code }

A time data-type value after converting the "value" to the specified time format. If no value is specified, the current system time is returned. A timestamp data-type value with or without separators. String with left and right blanks trimmed (removed) String with left blanks trimmed String with right blanks trimmed Returns a varying length value. Value in unsigned format Half-adjusted value in unsigned format The converted string is returned.

V5R1

%TIMESTAMP %TRIM %TRIML %TRIMR

{value { : *ISO | *ISO0 } string string string Any character value numeric expression numeric expression from-table : to-table : string-to-convert { : starting-position } Array name

V4R4 V4R2 V4R2 V5R1

%UCS2 %UNS %UNSH %XLATE

V4R4

%XFOOT

Cross foots (totals) elements in an array.

all

the

Define General Keywords Subfile control record . . . . . . . . . : Type choices, press Enter. Related subfile record . . . . . . . Subfile cursor relative record . . . Subfile mode . . . . . . . . . . . . SCREENC1

Keyword SFLCTL SFLCSRRRN SFLMODE

SCREENS1

Name Name Name

Display subfile records . . . . . . Display control record . . . . . . .

SFLDSP SFLDSPCTL

Y=Yes Y Y

Indicators/+ 40 40

Initialize subfile fields Delete subfile area . . . Clear subfile records . . Indicate more records . . SFLEND parameter . . . SFLEND parameter . . . Record not active . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

. . . . . . .

SFLINZ SFLDLT SFLCLR SFLEND *MORE *SCRBAR SFLRNA Keyword SFLDROP SFLFOLD SFLENTER

N40 N40 40 *MORE ...

Y CFnn/CAnn Indicators/+

Subfile initially truncated . . . . Subfile initially folded . . . . . . Use instead of Enter key . . . . . . F3=Exit F12=Cancel

More...

-----Original Message----From: Rajagopal CV [mailto:rajagopal.cv@tatainfotech.com] Sent: Friday, July 25, 2003 12:09 PM To: Prakash Kumar , Gurgaon; sumit.seth@RebusIS.com; sangeet.arora@tatainfotech.com; RohitCh@niit.com; gauravmi@niit.com Subject: Re: AS400, Ques & Ans.

Thanks Prakash. Some more questions ...(These were asked at IBM) 1. Why/ How do i use data queues in my pgm ? Like a fool I had to tell them that I have nver used data queues.. In case anyone has come across data queues please do reply. i ZIMBLY donno what a dataqueue is used for ...Got to see some CL manuals.

2. Diff between SETON and

LR SETON RT

Is SETON RT same as a RETRN statement ?

I am still not sure how exactly program performs with LR and RT.

3. Diff between CLEAR and RESET

The CLEAR operation sets elements in a structure (record format, data structure, array, or table) or a variable (field, subfield, or indicator), to zero, blank or '0', depending on field type (numeric, character, or indicator). It allows you to clear structures on a global basis, as well as element by element, during run time. The RESET operation sets elements in a structure (record format, data structure, array, or table), or a variable (field, subfield, or indicator) to its initial value. The initial value for a variable is the value the variable had at the end of the *INIT operation of the program. This value can be set using data structure initialization, or you can use the initialization subroutine to assign an initial value to the structure or variable. Courtsey : RPG/400 manual ---------------------------------------

Regards Rajagopal

PS : More IBM questions later

----- Original Message ----From: "Prakash Kumar , Gurgaon" <Prakashk@ggn.hcltech.com> To: <sumit.seth@RebusIS.com>; <sangeet.arora@tatainfotech.com>; <RohitCh@niit.com>; <rajagopal.cv@tatainfotech.com>; <gauravmi@niit.com> Sent: Friday, July 25, 2003 11:44 AM Subject: FW: AS400, Ques & Ans.

>

Change User Space (QUSCHGUS) API

Required Parameter Group: 1 Qualified user space name Input Char(20) 2 Starting position Input Binary(4) 3 Length of data Input Binary(4) 4 Input data Input Char(*) 5 Force changes to auxiliary storage Input Char(1) Optional Parameter: 6 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Change User Space (QUSCHGUS) API changes the contents of the user space (*USRSPC) object by moving a specified amount of data to the object. This API allows you to change the contents of a user space if you are using either: A language that does not support pointers System-domain user spaces Note: To determine the starting position for the QUSCHGUS API, you must add 1 to the offset value. In contrast to the OS/400 list APIs, which use an offset value based on 0 for the starting position, the QUSCHGUS API uses a value based on 1. For the QUSCHGUS API, the first character in the user space is at position 1. Authorities and Locks Library Authority *EXECUTE User Space Authority *CHANGE User Space Lock *EXCLRD Required Parameter Group Qualified user space name INPUT; CHAR(20) The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. The special values supported for the library name are *LIBL and *CURLIB. Starting position INPUT; BINARY(4) The first byte of the user space that is to be changed. It must have a value greater than 0. Length of data INPUT; BINARY(4) The length of the new data in the input data parameter. The length must be greater than 0. Input data INPUT; CHAR(*)

The new data to be placed into the user space. The field must be at least as long as the length of data parameter. Force changes to auxiliary storage INPUT; CHAR(1) The method of forcing changes made to the user space to auxiliary storage. The valid values are as follows: 0 Does not force changes. Normal system management writes the changes to auxiliary storage. 1 Forces changes asynchronously. This interrupts the normal system management and ensures that the user space is written to auxiliary storage. 2 Forces changes synchronously. This interrupts the normal system management and ensures that the user space is written immediately to auxiliary storage. Optional Parameter Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. If this parameter is omitted, diagnostic and escape messages are issued to the application. Error Messages Message ID Error Message Text CPF24B4 E Severe error while addressing parameter list. CPF3CF1 E Error code parameter not valid. CPF3C0F E Value &1 for starting position parameter is not valid. CPF3C04 E User space &1 not changed. CPD3C0F D Value &1 for starting position parameter is not valid. CPD3C12 D Length of data is not valid. CPD3C13 D Value &1 for force option is not valid. CPD3C14 D Starting position &1 and length &2 cause space overflow. CPD3C15 D New value &1 is shorter than the length specified. CPD3C17 D Error occurred with input data parameter. CPF3C12 E Length of data is not valid. CPF3C13 E Value &1 for force option is not valid. CPF3C14 E Starting position &1 and length &2 cause space overflow. CPF3C15 E New value &1 is shorter than the length specified. CPF3C17 E Error occurred with input data parameter. CPF3C36 E Number of parameters, &1, entered for this API was not valid. CPF3C90 E Literal value cannot be changed. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9801 E Object &2 in library &3 not found. CPF9802 E Not authorized to object &2 in &3. CPF9803 E Cannot allocate object &2 in library &3. CPF9807 E One or more libraries in library list deleted. CPF9808 E Cannot allocate one or more libraries on library list. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.
Change User Space Attributes (QUSCUSAT) API

Required Parameter Group: 1 Returned library name Output Char(10) 2 Qualified user space name Input Char(20) 3 Attributes to change Input Char(*) 4 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Change User Space Attributes (QUSCUSAT) API changes the attributes of a user space object. This API can be used to: Extend or truncate a user space Mark or unmark the user space as automatically extendible by the system Change the initial value to which future extensions of the user space will be set Change the number of pages transferred between main storage and auxiliary storage Authorities and Locks Library Authority *EXECUTE User Space Authority *CHANGE, *OBJMGT User Space Lock *EXCL Required Parameter Group Returned library name OUTPUT; CHAR(10) The name of the library that contains the changed user space object. If the space attributes are successfully changed, the name of the library in which the user space was found is returned. Qualified user space name INPUT; CHAR(20) The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. The special values supported for the library name are *LIBL and *CURLIB. Attributes to change INPUT; CHAR(*) The attributes of the user space object that you want to change. The information must be in the following format: Number of variable length records BINARY(4) The total number of all of the variable length records. Variable length records The attributes of the user space to change and the data used for the change. For the specific format of the variable length record, refer to Format for Variable Length Records.

Error code I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error Code Parameter. Format for Variable Length Records Offset Type Field Dec Hex 0 0 BINARY(4) Key 4 4 BINARY(4) Length of data 8 8 CHAR(*) Data If you specify a length of data that is longer than the key field's defined data length, the data will be truncated at the right. No error message will be returned. If you specify a length of data that is shorter than the key field's defined data length, an error message will be returned. You may specify a key more than once. If duplicate keys are specified, the last specified value for that key is used. Each variable length record must be 4-byte aligned. If not, unpredictable results may occur. Field Descriptions Data. The value to which a specific user space attribute is to be changed. All values are validity checked. Key. The user space attribute to be changed. Only specific attributes can be changed. Refer to Keys for more information. Length of data. The length of the new user space attribute value. The length of data field is used to get addressability to the next attribute record. Keys The following table lists the keys that can be used in the attribute record. Key Type Attribute 1 BINARY(4) Space size 2 CHAR(1) Initial value 3 CHAR(1) Automatic extendibility 4 BINARY(4) Transfer size request Field Descriptions Automatic extendibility. Whether or not the user space is automatically extended by the system when the end of the space is encountered. 0 The user space is not automatically extendible. 1 The user space is automatically extendible.

Initial value. The initial value to which future extensions of the user space will be set. You will achieve the best performance if you set this byte to hexadecimal zeros (X'00').

Space size. The size in bytes of the user space object. If this value is smaller than the current size of the space, the user space is truncated. If it is larger, the space is extended. Transfer size request. The number of pages to be transferred between main storage and auxiliary storage. This is only a request, as the machine may use a value of its choice in some circumstances. Allowable values range between 0 and 32 pages. A value of 0 is an indication that the machine should use the default transfer size for the user space. A larger transfer size may allow for better performance of applications processing the user space. Error Messages Message ID Error Message Text CPF24B4 E Severe error while addressing parameter list. CPF3C4B E Value not valid for field &1. CPF3C4C E Value not valid for field &1. CPF3C4D E Length &1 for key &2 not valid. CPF3C90 E Literal value cannot be changed. CPF3CF1 E Error code parameter not valid. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9801 E Object &2 in library &3 not found. CPF9802 E Not authorized to object &2 in &3. CPF9803 E Cannot allocate object &2 in library &3. CPF9807 E One or more libraries in library list deleted. CPF9808 E Cannot allocate one or more libraries on library list. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9838 E User profile storage limit exceeded. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

Create User Space (QUSCRTUS) API Required Parameter Group: 1 Qualified user space name Input Char(20) 2 Extended attribute Input Char(10) 3 Initial size Input Binary(4) 4 Initial value Input Char(1) 5 Public authority Input Char(10) 6 Text description Input Char(50) Optional Parameter Group 1: 7 Replace Input Char(10) 8 Error code I/O Char(*) Optional Parameter Group 2: 9 Domain Input Char(10) Optional Parameter Group 3: 10 Transfer size request Input Binary(4) 11 Optimum space alignment Input Char(1) Default Public Authority: *USE Threadsafe: Yes The Create User Space (QUSCRTUS) API creates a user space in either the user domain or the system domain. A system-domain user space cannot be saved to a release prior to Version 2 Release 3 Modification 0. A user-domain user space can be directly manipulated with machine interface (MI) instructions or can be accessed using system APIs. On systems with a QSECURITY system value of 40 or greater, applications can only access system-domain user spaces using APIs. The user space objects you create are larger than or equal to the size specified. They have a fixed length and can be extended or truncated using the Change User Space Attributes (QUSCUSAT) API of the Modify Space (MODS) MI instruction (for user-domain user spaces). (The MODS instruction will not work on system-domain user spaces if the security level of the system is 40 or greater.) Note: For performance reasons, the *USRSPC object is created before checking to see if it exists in the library specified for the qualified user space name. If you have an application using this API repeatedly, even if you are using *NO for the replace parameter, permanent system addresses will be used. Change User Space Attributes (QUSCUSAT) API or the Modify Space (MODS) MI instruction (for user-domain user spaces). (The MODS instruction will not work on system-domain user spaces if the security level of the system is 40 or greater.) Authorities and Locks User Space Authority *OBJMGT, *OBJEXIST, and *READ. These authorities are required only if the replace parameter is used and if there is an existing user space to replace. User Space Library Authority *READ and *ADD. User Space Lock *EXCL. This applies to both the user space being created and an existing user space being replaced.

Required Parameter Group Qualified user space name INPUT; CHAR(20) The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. The only special value supported for the library name is *CURLIB. User spaces created in the QTEMP and QRPLOBJ libraries are not forced to permanent storage; they are deleted when those libraries are cleared at sign-off and system IPL, respectively. Extended attribute INPUT; CHAR(10) The extended attribute of the user space. For example, an object type of *FILE has an extended attribute of PF (physical file), LF (logical file), DSPF (display file), SAVF (save file), and so on. The extended attribute must be a valid *NAME. You can enter this parameter in uppercase, lowercase, or mixed case. The API converts it to uppercase. Initial size INPUT; BINARY(4) The initial size of the user space being created. This value must be from 1 byte to 16, 776, 704 bytes. Initial value INPUT; CHAR(1) The initial value of all bytes in the user space. You will achieve the best performance if you set this byte to X'00'. Public authority INPUT; CHAR(10) The authority you give users who do not have specific private or group authority to the user space. Once the user space has been created, its public authority stays the same when it is moved to another library or restored from backup media. If the replace parameter is used and a user space exists to be replaced, this parameter is ignored. All authorities are transferred from the replaced user space to the new one. The valid values for this parameter are: *ALL The user can perform all authorized operations on the object. Authorization list name The user space is secured by the specified authorization list, and its public authority is set to *AUTL. The specified authorization list must exist on the system when this API is called. If it does not exist, the create process fails, and an error is returned to the application. *CHANGE The user can read the object description and has read, add, update, and delete authority to the object. *EXCLUDE The user cannot access the object in any way. *LIBCRTAUT The public authority for the user space is taken from the CRTAUT value for the target library when the object is created. If the CRTAUT value for the library changes later, that change does not affect user spaces already created. If the CRTAUT value contains an authorization

list name and that authorization list secures an object, do not delete the list. If you do, the next time you call this API with the *LIBCRTAUT parameter, it will fail. *USE The user can read the object and its description but cannot change them. Text description INPUT; CHAR(50) This text briefly describes the user space. Optional Parameter Group 1 Replace INPUT; CHAR(10) Whether you want to replace an existing user space. Valid values for this parameter are: *NO Do not replace an existing user space of the same name and library. *NO is the default value. *YES Replace an existing user space of the same name and library. If the user space already exists, it is replaced by a new user space of the same name and library, and is subject to the same authorities. The user space being replaced is destroyed if both: The allow user domain (QALWUSRDMN) system value is not set to *ALL or does not contain the library QRPLOBJ. The user space you are replacing is in the user domain. If the user space is in the system domain, it is moved to QRPLOBJ. If QALWUSRDMN is set to *ALL or if it contains QRPLOBJ, the replaced user space is moved to QRPLOBJ, which is cleared at system IPL. For details about authorities, ownership, and renaming, see the discussion of the REPLACE parameter in the Control Language (CL) information in the iSeries Information Center. Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. If this parameter is omitted, diagnostic and escape messages are issued to the application. Optional Parameter Group 2 Domain INPUT; CHAR(10) The domain into which the user space is created. If this parameter is not specified, the value of *DEFAULT is assumed by the API. Valid values for this parameter are: *DEFAULT Allows the system to decide into which domain the object should be created. *SYSTEM Creates the user space object into the system domain. The API can always create a user space into the system domain regardless of the security level in effect. However, you must use APIs to access system-domain user spaces if you are running at security level 40 or greater. *USER Attempts to create the user space object into the user domain. This is not always possible. If the library you are creating the user space into does not appear in the QALWUSRDMN system value, the API cannot create the user space into the user domain. An error will be returned.

The API uses the following values to determine into which domain to create the user space. The destination library is the library you specified in the qualified user space name parameter. The optional domain parameter is the information specified in the domain parameter. QALWUSRDMN System Value Destination Library Optional Domain Parameter Domain of Created Object *ALL Any *DEFAULT User domain *ALL Any *SYSTEM System domain *ALL Any *USER User domain QTEMP QTEMP *DEFAULT User domain QTEMP QTEMP *SYSTEM System domain QTEMP QTEMP *USER User domain Does not contain library name Library name *DEFAULT System domain Does not contain library name Library name *SYSTEM System domain Does not contain library name Library name *USER None; error is returned Note: The QALWUSRDMN system value lists the libraries into which user domain objects can be created. The libraries can be the special value *ALL or a list of one or more library names. You must use APIs to access data or information in system-domain user spaces on systems with a QSECURITY level of 40 or greater. You cannot use MI instructions to directly access systemdomain user objects. The Retrieve Object Description (QUSROBJD) or List Objects (QUSLOBJ) API can be used to determine into which domain the user-space object was created. Optional Parameter Group 3 Transfer size request INPUT; BINARY(4) The number of pages to be transferred between main storage and auxiliary storage This is only a request, as the machine may use a value of its choice in some circumstances. Allowable values range between 0 and 32 pages. A value of 0 is an indication that the machine should use the default transfer size for the user space. If this parameter is not specified, the default is 0. A larger transfer size may allow for better performance of applications processing the user space. Optimum space alignment INPUT; CHAR(1) Allows the machine to choose optimum alignment for the user space. Optimum alignment may allow for better performance of applications that manipulate the user space. Allowable values are: 0 Do not choose optimum space alignment. 0 is the default value. 1 Choose optimum space alignment. Note: If not using the optimum space alignment, the user space has a maximum size of 16MB minus 512 bytes (16,776,704 bytes). If optimum alignment is specified, the maximum size of the user space is 16MB minus one disk page (current page size is 4096 bytes, giving a maximum space size of 16,773,120 bytes).

Error Messages

Message ID Error Message Text CPF2143 E Cannot allocate object &1 in &2 type *&3. CPF2144 E Not authorized to &1 in &2 type *&3. CPF2283 E Authorization list &1 does not exist. CPF24B4 E Severe error while addressing parameter list. CPF3CF1 E Error code parameter not valid. CPF3CF2 E Error(s) occurred during running of &1 API. CPF3C01 E User space &2 in library &1 not created. CPD3C01 D Object name &1 is not valid. CPD3C03 D Extended attribute &1 is not valid. CPD3C04 D Value &1 for size parameter is not valid. CPD3C05 D Value &1 for authority parameter is not valid. CPF3C2B E Extended attribute &1 is not valid. CPF3C2C E Value &1 for size parameter is not valid. CPF3C2D E Value &1 for authority parameter is not valid. CPF3C29 E Object name &1 is not valid. CPF3C34 E Value &1 for replace option is not valid. CPF3C36 E Number of parameters, &1, entered for this API was not valid. CPF3C45 E Value &1 not valid for domain parameter. CPF3C49 E Request for user domain object cannot be granted. CPF3C90 E Literal value cannot be changed. CPF3C91 E Value &1 not valid for transfer size request parameter. CPF3C92 Value &1 not valid for optimum space alignment parameter. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9838 E User profile storage limit exceeded. CPF9870 E Object &2 type *&5 already exists in library &3. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

Delete User Space (QUSDLTUS) API Required Parameter Group: 1 Qualified user space name Input Char(20) 2 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Delete User Space (QUSDLTUS) API deletes user spaces created with the Create User Space (QUSCRTUS) API. The QUSDLTUS API performs the same function as the Delete User Space (DLTUSRSPC) command. Authorities and Locks Library Authority *EXECUTE User Space Authority *OBJEXIST User Space Lock *EXCL Required Parameter Group Qualified user space name INPUT; CHAR(20) The name of the user space and the name of the library in which it resides. The first 10 characters contain the user space name, and the second 10 characters contain the library name. The user space name can be either a specific name or a generic name, a string of one or more characters followed by an asterisk (*). If you specify a generic name, QUSDLTUS deletes all user spaces that have names beginning with the string for which the user has authority. You can use these special values for the library name: *ALL All libraries *ALLUSR All user-defined libraries, plus libraries containing user data and having names starting with Q. For information on the libraries included, see *ALLUSR. *CURLIB The job's current library *LIBL The library list *USRLIBL The user portion of the job's library list Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. Error Messages Message ID Error Message Text CPF2105 E Object &1 in &2 type *&3 not found. CPF2110 E Library &1 not found. CPF2113 E Cannot allocate library &1. CPF2114 E Cannot allocate object &1 in &2 type *&3.

CPF2117 E &4 objects type *&3 deleted. &5 objects not deleted. CPF2125 E No objects deleted. CPF2176 E Library &1 damaged. CPF2182 E Not authorized to library &1. CPF2189 E Not authorized to object &1 in &2 type *&3. CPF24B4 E Severe error while addressing parameter list. CPF3C90 E Literal value cannot be changed. CPF3CF1 E Error code parameter not valid. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

Retrieve Pointer to User Space (QUSPTRUS) API Required Parameter Group: 1 Qualified user space name Input Char(20) 2 Return pointer Output PTR(SPP) Optional Parameter: 3 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Retrieve Pointer to User Space (QUSPTRUS) API retrieves a pointer to the contents of a userdomain user space. The data in that user space then can be directly manipulated by high-level language programs that support pointers, such as C or COBOL. The QUSPTRUS API will not return a pointer to a system-domain user space; you must use system APIs to access system-domain user spaces. If you attempt to retrieve the pointer to a system-domain user space, an error will be returned. The QUSPTRUS API even returns a pointer to an object that is subject to an exclusive (*EXCL) lock. If you create application programs using HLLs that can directly update user spaces using pointers (instead of using the Change User Space (QUSCHGUS) API), you should use your own synchronization data methods. You can use one of the following methods to avoid updates at the same time to the same location within a user space: CMPSW MI instruction CMPSWP MI instruction LOCK MI instruction LOCKSL MI instruction Allocate Object (ALCOBJ) command Use of the QUSPTRUS API does not update the object usage information (such as last changed date, last date used, and so on). You should use the Change User Space or the Retrieve User Space API to update the object usage information if needed. Examples of the API are in API examples. Authorities and Locks Library Authority *EXECUTE User Space Authority *USE Required Parameter Group Qualified user space name INPUT; CHAR(20) The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. The special values supported for the library name are *LIBL and *CURLIB.

Return pointer OUTPUT; PTR(SPP) The variable containing the pointer to the user space after the QUSPTRUS API has completed running. This parameter must be on a 16-byte boundary alignment. Optional Parameter Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. If this parameter is omitted, diagnostic and escape messages are issued to the application. Error Messages Message ID Error Message Text CPF24B4 E Severe error while addressing parameter list. CPF3CF1 E Error code parameter not valid. CPF3C05 E One or more errors found while trying to retrieve a pointer. CPF3C18 E Pointer parameter is not on a 16-byte boundary. CPD3C18 D Pointer parameter is not on a 16-byte boundary. CPF3C36 E Number of parameters, &1, entered for this API was not valid. CPF3C48 E Operation not valid on system domain object. CPF3C90 E Literal value cannot be changed. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9801 E Object &2 in library &3 not found. CPF9802 E Not authorized to object &2 in &3. CPF9803 E Cannot allocate object &2 in library &3. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

Retrieve User Space (QUSRTVUS) API Required Parameter Group: 1 Qualified user space name Input Char(20) 2 Starting position Input Binary(4) 3 Length of data Input Binary(4) 4 Receiver variable Output Char(*) Optional Parameter Group: 5 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Retrieve User Space (QUSRTVUS) API allows you to retrieve the contents of a user space. The QUSRTVUS API does not retrieve descriptive information about the user space object, such as its size. To retrieve information about the attributes of a user space, refer to the Retrieve User Space Attributes (QUSRUSAT) API. If you are repeatedly accessing the contents of a user space and are using an HLL that supports pointers, see the Retrieve Pointer to User Space (QUSPTRUS) API; this API provides a pointer to the user space for improved performance. When you have obtained a pointer, you use pointer arithmetic to access the contents of a user space. Note: To determine the starting position for the QUSRTVUS API, you must add 1 to the offset value. In contrast to the OS/400 list APIs, which use an offset value based on 0 for the starting position, the QUSRTVUS API uses a value based on 1. For the QUSRTVUS API, the first character in the user space is at position 1. Authorities and Locks Library Authority *EXECUTE User Space Authority *USE User Space Lock *SHRNUP Required Parameter Group Qualified user space name INPUT; CHAR(20) The first 10 characters contain the user space name, and the second 10 characters contain the name of the library where the user space is located. The special values supported for the library name are *LIBL and *CURLIB. Starting position INPUT; BINARY(4) The first byte of the user space to be retrieved. A value of 1 will identify the first character in the user space.

Length of data INPUT; BINARY(4) The length of the data to retrieve. This length must not be larger than the size of the variable that is to receive the data. It must also be greater than 0. Receiver variable OUTPUT; CHAR(*) The variable that will receive the contents of the user space being retrieved. Optional Parameter Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. If this parameter is omitted, diagnostic and escape messages are issued to the application. Error Messages Message ID Error Message Text CPF24B4 E Severe error while addressing parameter list. CPF3CF1 E Error code parameter not valid. CPF3C0F E Value &1 for starting position parameter is not valid. CPF3C06 E Information not retrieved from user space &1. CPD3C0F D Value &1 for starting position parameter is not valid. CPD3C12 D Length of data is not valid. CPD3C14 D Starting position &1 and length &2 cause space overflow. CPD3C16 D Receiver area too small for length of data &1 specified. CPD3C20 D Error occurred with receiver variable specified. CPF3C12 E Length of data is not valid. CPF3C14 E Starting position &1 and length &2 cause space overflow. CPF3C16 E Receiver area too small for length of data &1 specified. CPF3C19 E Error occurred with receiver variable specified. CPF3C36 E Number of parameters, &1, entered for this API was not valid. CPF3C90 E Literal value cannot be changed. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9801 E Object &2 in library &3 not found. CPF9802 E Not authorized to object &2 in &3. CPF9803 E Cannot allocate object &2 in library &3. CPF9807 E One or more libraries in library list deleted. CPF9808 E Cannot allocate one or more libraries on library list. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

Retrieve User Space Attributes (QUSRUSAT) API Required Parameter Group: 1 Receiver variable Output Char(*) 2 Length of receiver variable Input Binary(4) 3 Format name Input Char(8) 4 Qualified user space name Input Char(20) 5 Error code I/O Char(*) Default Public Authority: *USE Threadsafe: Yes The Retrieve User Space Attributes (QUSRUSAT) API retrieves information about the current attributes and the current operational statistics of the user space. You can also retrieve information about user space attributes by using one of the following: The Materialize Space (MATS) machine interface (MI) instruction The Retrieve Object Description (QUSROBJD) API described on page The Retrieve Object Description (RTVOBJD) command Authorities and Locks User Space Library Authority *EXECUTE User Space Authority *USE User Space Lock *SHRNUP Required Parameter Group Receiver variable OUTPUT; CHAR(*) The variable that is to receive the information requested. You can specify the size of this area to be smaller than the format requested as long as you specify the length parameter correctly. As a result, the API returns only the data that the area can hold. Length of receiver variable INPUT; BINARY(4) The length of the receiver variable. If the length is larger than the size of the receiver variable, the results may not be predictable. The minimum length is 8 bytes. Format name INPUT; CHAR(8) The format of the space information to be returned. The format names supported are: SPCA0100 Basic information Refer to SPCA0100 Format for details on the format.

Qualified user space name INPUT; CHAR(20) The user space for which you want to retrieve information, and the library in which it is located. The first 10 characters contain the user space name, and the second 10 characters contain the library name. You can use these special values for the library name: *CURLIB The job's current library *LIBL The library list Error code I/O; CHAR(*) The structure in which to return error information. For the format of the structure, see Error Code Parameter. SPCA0100 Format The following information about a user space is returned for the SPCA0100 format. For detailed descriptions of the fields in the table, see Field Descriptions. Offset Type Field Dec Hex 0 0 BINARY(4) Bytes returned 4 4 BINARY(4) Bytes available 8 8 BINARY(4) Space size 12 C CHAR(1) Automatic extendibility 13 D CHAR(1) Initial value 14 E CHAR(10) User space library name Field Descriptions Automatic extendibility. Whether or not the space is extended automatically by the system when the end of the space is encountered. 0 Space is not automatically extendible 1 Space is automatically extendible Bytes available. The length of all data available to return. All available data is returned if enough space is provided. Bytes returned. The length of the data actually returned. Initial value. The initial value to which future extensions of the user space will be set. Space size. The size of the user space object in bytes. User space library name. The library in which the user space is located. This is helpful when *LIBL or *CURLIB is specified as the library name in the qualified user space name parameter.

Error Messages

Message ID Error Message Text CPF24B4 E Severe error while addressing parameter list. CPF3C19 E Error occurred with receiver variable specified. CPF3C21 E Format name &1 is not valid. CPF3C24 E Length of the receiver variable is not valid. CPF3C90 E Literal value cannot be changed. CPF3CF1 E Error code parameter not valid. CPF8100 E All CPF81xx messages could be returned. xx is from 01 to FF. CPF9801 E Object &2 in library &3 not found. CPF9802 E Not authorized to object &2 in &3. CPF9803 E Cannot allocate object &2 in library &3. CPF9807 E One or more libraries in library list deleted. CPF9808 E Cannot allocate one or more libraries on library list. CPF9810 E Library &1 not found. CPF9820 E Not authorized to use library &1. CPF9830 E Cannot assign library &1. CPF9872 E Program or service program &1 in library &2 ended. Reason code &3.

SEU Info Sequence number The Sequence number prompt displays the sequence number of the record and is used for entering line commands. You can use user defined line commands or system defined line commands. To use a line command, type the command over the digits that make up the sequence number. If the sequence number area does not contain a sequence number, type the command starting in the first position of the sequence number area followed by a blank. Choose from the following: A=After Type A in the Sequence number prompt to move or copy records after this record. An=After with repeat n times Type An in the Sequence number prompt to move or copy records after this record and repeat these records n times. B=Before Type B in the Sequence number prompt to move or copy records before this record. Bn=Before with repeat n times Type Bn in the Sequence number prompt to move or copy records before this record and repeat these records n times. C=Copy a line Copy this line to a specified target. Cn=Copy n lines Copy this line plus the next n-1 lines to the specified target. CC=Block Copy Copy all lines between the boundaries formed by the two CC commands. CR=Copy records and retain command Copy this record to the specified targets and keep this command on the display. CRn=Copy n records and retain command specified targets and keep this command on the display. CCR=Copy block records and retain command Copy the block of records defined by a pair of CCR commands to the specified targets and keep this command on the display. COLS=Column Copy n records to the

Type COLS to make a free-form format line appear just before the line the command was entered on. D=Delete a line Type D to delete this line. Dn=Delete n lines Type Dn to delete this line and the next n-1 lines. DD=Block Delete Delete all lines between the two DD boundaries. F=Display format line Type F to display a format line. Fxx=Display the xx format line Type Fxx to display the xx format line. F?=Show the Select Format display Type F? to show the Select Format display. From this display choose the format to use. I=Insert a line Type I to insert a blank line after this record. In=Insert n lines Type In to insert n blank lines after this record. IF=Insert line and display format Type IF to insert a blank line and display the current format before this new line. IFn=Insert n lines and display format Type IFn to insert n blank lines and display the current format before the first new line. IFxx=Insert a blank line and display xx format Type IFxx to insert a line and display the xx format before this new line. IFxxn=Insert n blank lines and display xx format Type IFxxn to insert n lines and display the xx format before these new lines. IF?=Show the Select Format display Type IF? to show the Select Format display and insert a line with a format selected from that display before this new line. IF?n=Show the Select Format display and insert lines Type IF?n to show the Select Format display and insert n lines with a format selected from that display before this new line.

IP=Insert line and prompt Type IP to insert a blank line and display the line in a prompt. The format of the previous record determines the type of prompt to display. IPxx=Insert line with an xx prompt Type IPxx to insert a line and display the line in the xx prompt, where xx is the name associated with an IBM-supplied or user-defined prompt. IP?=Show Select Prompt Display. Type IP? to show the Select Prompt Display. An insert line will be shown in the prompt selected from this display. IS=Insert skeleton line Type IS to insert a line and initialize it to the data saved as the skeleton line. ISn=Insert n skeleton lines Type ISn to insert n lines and initialize them to the data saved as the skeleton lines. L=Shift data 1 char left Type L to shift data in this record one character position to the left. If there is any data in the first column, the record will only shift up to the start of the data. Ln=Shift data n chars left Type Ln to shift data in this record n character positions to the left. If there is any data in the first n columns, the record will only shift up to the start of the data. LL=Shift block 1 char to the left Shift the data that is defined by the boundary between and including the two LL line commands one character position to the left. If there is any data in the first column, the record will only shift up to the start of the data. LLn=Shift block n chars to the left Shift the data that is defined by the boundary between and including the LLn and LL line commands n character positions to the left. If there is any data in the first n columns, the record will only shift up to the start of the data. LP=Line Print a line Print this line. LPn=Line Print n lines Print this line plus the next n-1 lines.

LLP=Block Line Print Print all lines between the boundaries formed by the two LLP commands. LT=Shift data 1 char left with truncate Type LT to shift data in this record one character position to the left. Any data that appeared in the first column will be removed. LTn=Shift data n chars left with truncate Type LTn to shift data in this record n character positions to the left. Any data that appeared in the first column through the nth column will be removed. LLT=Shift block left with truncate Shift the data that is defined by the boundary between and including the two LLT line commands one position to the left. Any data that appeared in the first column will be removed. LLTn=Shift block n chars left with truncate Shift the data that is defined by the boundary between and including the LLTn and LLT line commands n positions to the left. Any data that appeared in the first column through the nth column will be removed. M=Move a line Type M to move a line to a specified target. Mn=Move n lines Type Mn to move this line and the following n-1 lines to a specified target. MM=Block Move Move all records between and including the boundaries defined by the MM line commands to a specified target. O=Overlay Type O to overlay this line with the first line defined by the move, copy, or copy repeated line command. On=Overlay n lines Type On to overlay this line and the following n-1 lines with the first n lines defined by the move, copy, or copy repeated line command. OO=Block overlay Overlay all the records between and including the boundaries defined by two OO line commands with the lines defined by the move, copy, or copy repeated line command. P=Display prompt

Type P to display this line in a prompt. Pxx=Display xx prompt Type Pxx to display this line in the xx prompt, where xx is the name associated with an IBM-supplied or user-defined prompt. P?=Show the Select Prompt display Type P? to show the Select Prompt display and look at the line in the prompt chosen from this display. R=Shift data 1 char right Type R to shift the data in this record one character position to the right. If there is any data in the last column, the record will only shift up to the end of the data. Rn=Shift data n chars right Type Rn to shift the data in this record n character positions to the right. If there is any data in the last n columns, the record will only shift up to the end of the data. RR=Block shift 1 char to the right Shift the data that is defined by the boundary between and including the two RR line commands one character position to the right. If there is any data in the last column, the record will only shift up to the end of the data. RRn=Block shift n chars to the right Shift the data that is defined by the boundary between and including the RRn and RR line commands n character positions to the right. If there is any data in the last n columns, the record will only shift up to the end of the data. RRT=Shift block right with truncate Shift the data that is defined by the boundary between and including the two RRT line commands one position to the right. Any data that appeared in the last column will be removed. RRTn=Shift block n chars right with truncate Shift the data that is defined by the boundary between and including the RRTn and RRT line commands n positions to the right. Any data that appeared in the last column through the nth column will be removed. RT=Shift data 1 char right with truncate Type RT to shift the data in this record one character position to the right. Any data in the last column will be removed. RTn=Shift data n chars right with truncate Type RTn to shift the data in this record n character positions to the right. Any data in the last column through the nth column will be removed.

RP=Repeat line Type RP to repeat this line once before the following line. RPn=Repeat line n times Type RPn to repeat this line n times before the following line. RPP=Block repeat Repeat all lines defined by the boundary between the two RPP line commands. RPPn=Block repeat n times Repeat all lines defined by the boundary between the two RPP line commands n times. S=Skeleton line Type S to define this data line as the skeleton line. SF=Show first record Type SF to show the first record of the exclude group. SFn=Show first n records Type SFn to show the first n records of the exclude group. SL=Show last record Type SL to show the last record of the exclude group. SLn=Show last n records Type SLn to show the last n records of the exclude group. TABS=Display tabs record Type TABS to set and show the tabs for the display. Before you can use the tabs you set, you must specify Y (Yes) for the Tabs on prompt on the Change Session Defaults display. W=Display member from column 1 Type W to display the member beginning in column 1. Wn=Display member from column n Type Wn to display the member beginning in column n. X=Exclude a line Type an X next to the record to exclude it from the display. Xn=Exclude n lines Type Xn to exclude this record and the next n-1 records. XX=Block Exclude Exclude all lines between the boundaries formed by the two XX line commands. + (plus sign)=Roll member forward 1 line Type + to roll the member forward one line.

+n=Roll member forward n lines Type +n to roll the member forward n lines. - (minus sign)=Roll member backward 1 line. Type - to roll the member backward one line. -n=Roll member backward n lines Type -n to roll the member backward n lines. n=Absolute Positioning Type a sequence number to position the line identified by that value as the first record on the display. You can specify an entire sequence number, or a value in the form n, .n, or n.n, optionally followed by a blank. For example, if line 1001.00 is shown at the top of the Edit display, and you want to move to line 2001.00, you can do any one of the following: o Specify the sequence number 2001.00 by changing the first 1 in 1001.00 to a 2:

SEU - Select Prompt Type choice, press Enter. Prompt type . . . . . . . . . . . . Values listed below

ILE RPG/400: H,F,FX,I,IX,J (I cont),JX,D,DX,C,CF,CX,OD,P (O cont),PR PX,* (Comment),** ILE COBOL/400: CB,C* REFORMAT/SORT: RH,RR,RF,RC DDS: LF (Logical file),PF (Physical file), BC (Interactive Communications Feature file), DP (Display and Printer file), A* (Comment) MNU: MS,MH,MD,MC (MD cont),CC (Comment) FORTRAN: FT, F* Other: NC (No syntax checking),** (Free format)

User Defined Line Commands - Help


In addition to the regular SEU line commands, you can key in any line command on the Sequence Number field which is not defined as an SEU line command. When SEU encounters this type of line command, it will attempt to call a user exit program to process it. SEU uses the information provided by the user in the Change Session Defaults panel to try to resolve this line command to the corresponding exit program.

Summary of Line Commands


The following table lists the line commands for SEU. All line commands are valid for full edit and split edit sessions. This table indicates the line commands that are valid for browse sessions. Command, Browse, Display Line Commands Absolute Positioning Y n .n n.n After, Before N A A n B Bn Columns Y COLS Copy Y/N1 C Cn CC Copy Repeat Y/N1 CR CR n CCR Delete Y/N2 D Dn DD Exclude Y X X n XX Format Y F F? F xx Insert N I I n Insert-with-Format N IF IF n IF? IF? n IF xx IF xxn Insert-with-Prompt N IP IP? IP xx Line Print Y LP LP n LLP Move N M Mn MM Overlay N O O n OO Prompt N P P? P xx Relative Positioning Y + + n n

Repeat N RP RP n RPP RPP n Shift Left N L L n LL LL n Shift Right N R R n RR RR n Shift-Left-withTruncate N LT LTnLLT LLT n Shift-Right-withTruncate N RTRTnRRT RRT n Show Y SF SF n SL SL n Skeleton N S IS IS n Tabs N TABS Window Y W Wn Notes: 1 Valid only in split edit/browse sessions with a target command in the edit session. 2 Valid only on special records (for example, format lines).

Debug batch job Specific steps have to be followed in sequence in order to use the Source Debug facilities to debug a batch job: 1.Submit job to run in batch with HOLD(*YES). 2.Use WRKSBMJOB to obtain information about the job you want to debug, that is: ? Job Id ? User Name ? Job Number 3.Enter the command STRSRVJOB for the Job above using the information that you retrieved via WRKSBMJOB. 4.Enter the STRDBG command for the program that the batch job is running. The source view of the program is displayed. 5.Press F21 to obtain a command line. 6.Enter WRKSBMJOB from the command line to release the batch job - a System Message will appear allowing you to press F10 to enter Debug commands or Enter to run the program. 7.Press F10 - a Command Entry screen will appear. 8.Use DSPMODSRC from the Command Entry display and set breakpoints where desired. 9.Exit DSPMODSRC (F3). 10.Exit the Command Entry screen (F12) - the System Message from Step 6).will appear again. 11.Press enter to run the program. 12.Program will now halt at breakpoint. 13.Debug program as normal. 14.When the program/Job has completed execution, close out the process with ENDDBG and ENDSRVJOB.

Potrebbero piacerti anche