Sei sulla pagina 1di 195

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 end-users needs. There are two types Non join logical file Join logical file 6. Difference between physical file and logical file? Physical file 1. Occupies the portion of memory. Its containing data. 2. A physical file contains one record format Logical file Does not occupy any memory space. Does not contain any data. A logical file can contain up to 32 record formats.

3.Can be exist even with out Can not exist with out PF LF 4. If you delete a LF, the PF If you delete a LF, the PF can can not be deleted not be deleted

5.CRTPF command is used CRTLF command is used to to create such object create such type object 6.The object type is PF 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, CHKMSGID, CMP, COLHDG, COMP, DATFMT, DATSEP, DFT, EDTCDE, EDTWRD, REFFLD, REFSHIFT, TEXT, TIMEFMT, TIMESEP, VALUES, VARLEN)

(iv) 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 nonlogical 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 EMPNAME 000001 10,002 SANKA 000002 10,004 SENTH 000003 10,005 SANKA 000004 10,006 SHYAM 000005 10,007 SANKA 000006 10,008 SENTH 000007 10,009 SHYAM 000008 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 O EMPNAME CMP (EQ 'SHYAM') 0004.00 S EMPNO CMP (GT 10001) ****************** End of data ************************ EMPNO EMPNAME 000001 10,002 SANKA 000002 10,004 SENTH 000003 10,005 SANKA 000004 10,007 SANKA 000005 10,008 SENTH 000006 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

******** Edit

Columns . . . 1 71 KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF *************** Beginning ************************ 0001.00 R RECSEL (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO 0004.00 S EMPNAME ('SHYAM') ****************** End ************************** EMPNO EMPNAME 000001 20 000002 60 000003 70 000004 80 000005 90 000006 100 ****** ********

of

data PFILE

CMP (GT 50) VALUES of data

SHYAM SHYAM SHYAM TOM TOM VASU End of report 1 71

******** Edit

Columns . . . KRAMANAVS/EXAMPLE SEU==> SELOMILF1 FMT LF.

*************** Beginning ************************ 0001.00 R RECSEL (SELOMIT1) 0002.00 K EMPNO 0003.00 S EMPNO 0004.00 O EMPNO 40) ****************** End ***************************

of

data PFILE

CMP (GT 50) RANGE (20 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 000001 000002 000003 000004 000005 000006 EMPNAME 20 SHYAM 30 RAM 40 TOM 50 RAMESH 60 SHYAM 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 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

********

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 Edit KRAMANAVS/EXAMPLE SEU==> SEJOIN FMT PF *************** Beginning of data ******************** 0001.00 R EMP 0002.00 EMPID 5P 0 0003.00 EMPNAME 20A 0004.00 MGRID 5P 0

0005.00

K EMPID ****************** ***************************

End

of

data

EMPID EMPNAME MGRID 000001 10,001 SEBI JOSEPH C. 50,001 000002 10,002 PURUSHOTTAM 50,002 000003 10,003 SAMEER DIGHE 50,003 000004 10,004 SHARATA 50,004 000005 10,005 PAUL 50,005 000006 50,001 SHIVARAM 90,001 000007 50,002 GAURAV 90,002 000008 50,003 KING 90,003 000009 50,004 SAM 90,004 000010 50,005 ANIL 90,005 ****** ******** End of report ******** Columns . . . 1 71 Edit KRAMANAVS/EXAMPLE SEU==> SELJOIN 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 JREF (1) 0006.00 MANAGER RENAME (EMPNAME) JREF (2) 0007.00 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 ******

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)

****************** **************************** EMPID MANAGER 000001 10,001 SHIVARAM 000002 10,002 GAURAV 000003 10,003 KING 000004 10,004 SAM 000005 10,005 ANIL ****** ******** End of report

End MGRID 90,001 90,002

of

data

90,003 90,004 90,005 ********

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
*************** **************************** 0001.00 CMD ****************** ******************************* VRAMANA/CLP CMD1 Beginning of data

End

of

data

2. Enter source program in any language


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

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 :1000 End position :2000 Sql command : FILED EMPNO CONDITION *GT VALUE 40 Record format mapping :*MAP(add field) +DROP (delete field)

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 PF001 LIB VRAMANA TRIGGER TIME *AFTER *BEFORE *AFTER TRIGGER EVEVT *UPDATE *UPDATE *INSERT *DELETE PROGRAM PGM001 LIB VRAMANA REPLACE TRIGGER *NO ALLOW REPEATED *NO NAME *NO *NO *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 LR ****************** End of data *********************************** OUTPUT DSPLY I LIKE YOU AUTO NUMBER GENERATION VRAMANA/TEST *************** ******************************* 0001.00 DA S 0002.00 C *DTAARA DEFINE 0003.00 C *LOCK IN 0004.00 C EVAL 0005.00 C OUT 0006.00 C A DSPLY 0007.00 C LR 0008.00 C 0009.00 C 0010.00 C ****************** *********************************** OUTPUT DSPLY 5 DSPLY 6 TESTEX19 Beginning 4S 0 DATA2 A A=A+1 A of data

SETON

End

of

data

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 () CMPDTA ()

EXEC ()

MSGID-Required Ex: MSGID (MCH1211) 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 We need to have SQLRPG with OS/400 system and no installed in as/400 system need to have any additional which involves additional cost

package needed to execute it OPNQRYF is faster compared to SQLRPG

to the programmers as It is slower

OPNQRYF is nothing but a SQLRPG is imbedding SQL dynamic logical files will be statements directly within SQL statement created and the 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 CPYFRMQRYFFROMOPNID (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 **************************** 0000.01 C 0001.00 C R OPNQFILE 0002.00 C OEMPNO 5S 0 0003.00 C OEMPNAME 20A 0004.00 C OADDRESS 20A 0005.00 C ODOB 8S 0 0006.00 C K OEMPNO ****************** End ******************************** Data file of UNIQUE data

of

data

Display Report

OEMPNO

OEMPNAME

OADDRESS SALEM1 TRICHY SALEM SALEM SALEM JJ ******** VRAMANA/CLP

ODOB 000001 1,001 RAMANAV 1,232,002 KUMAR 000002 1,002 12,123,000 000003 1,003 SHYAM 12,345,000 000004 1,004 RAMESH 1,010,100 000005 1,005 BALU 222 000006 1,007 KUMAR 32,938 ****** ******** End of report CL program

OPNQFILE5 *************** Beginning of data ********************************* 0001.00 PGM 0002.00 DCL VAR(&A) TYPE(*CHAR) LEN(5) 0003.00 DCLF FILE(VRAMANA/OPNQFILE3) RCDFMT(OPNF3) 0004.00 SNDRCVF RCDFMT(OPNF3) 0005.00 CHGVAR VAR(&A) VALUE(&OEMPNO) 0006.00 OVRDBF FILE(OPENF) SHARE(*YES) 0006.01 OPNQRYF FILE((VRAMANA/OPENF)) QRYSLT('OEMPNO *EQ' + 0006.02 *BCAT &A) 0006.03 CPYFRMQRYF FROMOPNID(OPENF) TOFILE(VRAMANA/TEMP) + 0006.04 MBROPT(*REPLACE) CRTFILE(*YES) 0009.00 DLTOVR FILE(OPENF) 0010.00 CLOF OPNID(OPENF) 0010.01 RUNQRY QRYFILE((VRAMANA/TEMP)) 0011.00 ENDPGM ****************** End of data********************************* OUTPUT EMPLOYEE NUMBER: 1001 OEMPNO ODOB OEMPNAME OADDRESS

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

SALEM1 ********

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 PF-SRC 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 RPGLE RPGLE -by using CRTRPGPGM command -by using CRTBNDRPG Command (or) 14 -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 key field is changed. There are three ways of bounding the access path Immediate 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)?

CALL

TFRCTL

1.Call will transfer the control according Transfer Control with the CALL STACK (TFRCTL) will remove the CALL STACK and transfer the control to the calling program. 2. The CALL is used to different types of TFRCTL is only used in programs. CL programs. Ex: RPGILE/400,CL/400,C/400,COBOL/400.
R, SUBDUR, EXTRCT and TEST? ADDDUR:

55. Explain ADDDU

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 ******************************** 0000.01 d*date function using the adddur 0001.00 DTIMESTE S Z 0001.01 DTIME5 S Z 0002.00 DDATE1 S D 0002.01 DDATE2 S D 0002.02 DDATE3 S D 0002.03 DDATE4 S D 0003.00 DTIME1 S T 0003.01 DTIME2 S T 0003.02 DTIME3 S T 0003.03 DTIME4 S T 0004.00 C MOVEL *DATE 0005.00 C DATE1 ADDDUR 02:*Y 0006.00 C DATE1 ADDDUR 05:*M 0007.00 C DATE1 ADDDUR 01:*D 0007.01 C TIME 0007.02 C TIME 0008.00 C TIME1 ADDDUR 10:*H 0009.00 C* TIME1 ADDDUR 10:*ML 0010.00 C TIME1 ADDDUR 10:*S 0011.00 C TIMESTE ADDDUR 10:*MS 0012.00 C DATE2 DSPLY 0013.00 C DATE3 DSPLY 0014.00 C DATE4 DSPLY 0014.01 C TIME1 DSPLY 0014.02 C TIME2 DSPLY 0014.03 C TIME3 DSPLY 0014.04 C TIME4 DSPLY 0014.05 C TIME5 DSPLY 0015.00 C LR ****************** End ********************************* OUTPUT DSPLY 2004-06-27 DSPLY 2002-11-27 DSPLY 2002-06-28 DSPLY 12.18.36 DSPLY 22.18.36 DSPLY 00.00.00 DSPLY 12.18.46 DSPLY 2002-06-27-12.18.36.953010 of data

DATE1 DATE2 DATE3 DATE4 TIME1 TIMESTE TIME2 TIME3 TIME4 TIME5

SETON of data

SUBDUR: It is used to find the difference between two date (or) time (or) time stamp Example
VRAMANA/DATE SUBDUR *************** Beginning ******************************** 0000.01 d*date function using the SUBDUR 0001.00 DTIMESTE S Z 0001.01 DTIME5 S Z 0002.00 DDATE1 S 20') 0002.01 DDATE2 S D 0002.02 DDATE3 S D 0002.03 DDATE4 S D 0003.00 DTIME2 S T 0003.01 DTIME1 S T 0003.02 DTIME3 S T 0003.03 DTIME4 S T 0005.00 C DATE1 SUBDUR 02:*D 0006.00 C DATE1 SUBDUR 05:*M 0007.00 C DATE1 SUBDUR 01:*Y 0007.01 C TIME 0008.00 C TIME2 SUBDUR 10:*H 0010.00 C TIME2 SUBDUR 10:*S 0012.00 C DATE2 DSPLY 0013.00 C DATE3 DSPLY 0014.00 C DATE4 DSPLY 0014.01 C TIME1 DSPLY 0014.02 C TIME2 DSPLY 0014.03 C TIME3 DSPLY 0014.04 C TIME4 DSPLY 0015.00 C LR ****************** End *********************************** 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 of data

INZ (D'1977-06-

INZ (T'12. 50.10)

DATE2 DATE3 DATE4 TIME1 TIME1 TIME4

SETON of data

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 ******************************** 0000.01 d*FINT THE EXRCT DAY MONTH YEAR 0001.00 DTIMESTE S Z 0002.00 DDATE1 S D INZ (D'1977-0620') 0002.01 DDATE3 S D 0002.02 DDATE2 S 5P 0 0002.04 DDATE4 S 5P 0 0002.05 DDATE5 S 5P 0 0002.06 DDATE6 S 5P 0 0002.07 DDATE7 S 5P 0 0002.08 DDATE8 S 5P 0 0003.00 DTIME0 S T INZ (T'12. 50.10) 0003.01 DTIME1 S T 0003.02 DTIME2 S 5P 0 0003.03 DTIME4 S 5P 0 0003.04 DTIME5 S 5P 0 0003.05 DTIME6 S 5P 0 0003.06 DTIME3 S 26P 0 0004.00 C MOVEL *DATE DATE3 0004.01 C TIME TIME1 0004.02 C TIME TIMESTE 0005.00 C EXTRCT DATE1:*M DATE2 0006.00 C EXTRCT DATE3:*M DATE4 0007.00 C EXTRCT DATE1:*D DATE5 0007.01 C EXTRCT DATE3:*D DATE6 0007.02 C EXTRCT DATE1:*Y DATE7 0007.03 C EXTRCT DATE3:*Y DATE8 0007.04 C EXTRCT TIME1:*H TIME2 0007.05 C EXTRCT TIME1:*H TIME4 0007.06 C EXTRCT TIME0:*H TIME5 0007.07 C EXTRCT TIME0:*S TIME6 0011.00 C EXTRCT TIMESTE:*MS TIME3 0012.00 C DATE2 DSPLY 0013.00 C DATE8 DSPLY 0013.01 C DATE4 DSPLY 0013.02 C DATE5 DSPLY 0013.03 C DATE6 DSPLY

0014.00 0014.01 0014.02 0014.03 0014.04 0014.05 0015.00 LR OUTPUT DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY

C C C C C C C

DATE7 TIME2 TIME4 TIME5 TIME6 TIME3

DSPLY DSPLY DSPLY DSPLY DSPLY DSPLY SETON

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 ********************************* 0000.01 C*TEST FOR VALID DATE THE DATE VALID SETOFF OR SETON (NOTVALID) 0001.00 C MOVEL '13/03/1999 A 10 0002.00 C TEST (D) A 30 0003.00 C *IN30 DSPLY 0003.01 C IF *IN30=*ON 0003.02 C 'NOTVAILD' DSPLY 0003.03 C ELSE 0003.04 C 'VALID' DSPLY 0003.05 C ENDIF 0004.00 C SETON LR

****************** End *********************************** OUTPUT DSPLY 1 DSPLY NOTVAILD

of

data

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 ******************************** 0000.01 c*compile time array 0001.00 darr1 s perrcd(1) 0002.00 di s 0003.00 c i do 0004.00 c arr1(i) dsply 0005.00 c add 0006.00 c enddo 0007.00 c seton 0008.00 ** 0009.00 1001 0010.00 20 0011.00 1000 ****************** End ******************************** OUTPUT DSPLY 1001 DSPLY 20 DSPLY 1000

of

data

dim(3) ctdata 2p 0 inz(1)

3 1 i

of

data

Run time array The run time array means the value will be loaded during the runtime only. The value will be dynamic.
*************** ***************************** 0000.01 c*runtime array 0001.00 darr1 s 0002.00 di s 0002.01 da s 0002.02 dj s 0003.00 c i do 0003.01 c dsply 0003.02 c* eval 0003.03 c add 0003.04 c enddo 0003.05 c j do 0004.00 c arr1(j) dsply 0005.01 c add 0006.00 c enddo 0007.00 c lr ****************** ********************************* VRAMANA/ARRAY RUNTIME Beginning of data

10 dim(12) 2p 0 inz(1) 3p 0 2p 0 inz(1) 12 arr1(i) arr1(i)=a 1 12 1 j seton End of data i

lookup, sorta, xfoot : VRAMANA/ARRAY SORTARRAY *************** Beginning of data ********************************* 0000.01 c*lookup,xfoot&sorta examples 0001.00 darr1 s 4 0 dim(3) ctdata perrcd(1) 0002.00 di s 2p 0 inz(1) 0002.01 dj s 2p 0 inz(1) 0002.02 dd s 4p 0 0003.00 c i do 3 0004.00 c arr1(i) dsply 0005.00 c add 1 i 0006.00 c enddo 0006.01 c sorta arr1 0006.02 c xfoot arr1 d 0006.03 c 1000 lookup arr1 40 0006.04 c if *in40=*on 0006.05 c 'found' dsply 0006.06 c else 0006.07 c 'notfou' dsply 0006.08 c endif 0006.09 c d dsply 0006.10 c j do 3 0006.11 c arr1(j) dsply 0006.12 c add 1 j 0006.13 c enddo 0007.00 c seton lr 0008.00 ** 0009.00 1001 0010.00 2000 0011.00 1000 ****************** End of data *********************************** DSPLY 1001 DSPLY 2000 DSPLY 1000 DSPLY found DSPLY 4001 DSPLY 1000 DSPLY 1001 DSPLY 2000

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 *************** Beginning of ************************* 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 2 0 0 0007.01 C Z-ADD 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 LR 0015.00 C *PSSR BEGSR 0016.00 C STATUS DSPLY 0017.00 C ROUTINE DSPLY 0018.00 C PARMS DSPLY DUMP data

NUM1 NUM2

SETON

0019.00 C DUMP 0020.00 C GOTO 0021.00 C ENDSR ****************** ****************************** Output DSPLY 102 DSPLY *DETC DSPLY 0 DSPLY COMING

A End of data

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 . . . . . . . . . : SENWLT1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL SENWND1 Name record . . . SFLCSRRRN Subfile cursor relative Name Subfile mode . . . . . . . . . . . . SFLMODE Name Y=Yes Indicators/+ Display subfile records . . . . . . SFLDSP Y 25 Display control record . . . . . . . SFLDSPCTL Y 26 Initialize subfile fields . . . . . SFLINZ Delete subfile area . . . . . . . . SFLDLT Clear subfile records . . . . . . . SFLCLR 28 Indicate more records . . . . . . . SFLEND 30 SFLEND parameter . . . . . . . . *MORE Y SFLEND parameter . . . . . . . . *SCRBAR *MORE ...

Record not active More... F3=Exit

. . . . . . . . .

SFLRNA

F12=Cancel

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 *************** ******************* 0001.00 0002.00 R EMPNEW 0003.00 TEXT('EMPLOYEE NUMBER') 0004.00 TEXT('EMPLOYEE NAME') 0005.00 TEXT('EMPLOYEE SEX') 0006.00 TEXT('EMPLOYEE AGE') 0007.00 TEXT('ADDRESS') 0008.00 CITY5 0009.00 K EMPNOM ****************** ********************************* DATA FILE Beginning of UNIQUE EMPNOM EMPNA SEX3 AGE3 ADDRESS5 10A End of 6P 0 data

15A 1A 3P 0 15A TEXT('CITY') data

Display Report EMPNOM EMPNA K.RAMANAVKUMAR R.SHYAMSUNDAR B.MOHAN K.KUMAR A.ARUL BALU RAMANAV RAJ HEMA VEL RAMESH SUDHA KANDASAMY of report ******** VRAMANA/SUBFILE SEX3 M M M M M M M M M M M M M AGE3 25 27 27 25 25 25 35 22 33 67 56 28 34 ADDRESS5 ATTUR TRICHY TCODE SALEM SALEM SALEM SALEM TCODWE SALEM SALEM ATTUR SALEM SALEM

CITY5 000001 101 SALEM 000002 102 TRICHY 000003 103 SALEM 000004 104 SALEM 000005 105 NAMAKKAL 000006 106 SALEM 000007 107 TRICHY 000008 108 SALEM 000009 109 CHENNAI 000010 110 SALEM 000011 111 SALEM 000012 122 ATTUR 000013 123 ATTUR ****** ******** End

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 LR

C of

SETON data

****************** End ******************************* VRAMANA/SUBFILE

SELOADALL3 *************** Beginning of ***************************** 0001.00 FNEWEMP IF E DISK 0002.00 FSENDESFILECF E WORKSTN 0003.00 SFILE(SENWND1:RRN1) 1 0004.00 C Z-ADD 4 0 0005.00 C 28 0006.00 C WRITE SENWLT1 0007.00 C 28 0008.00 C READ 30 0009.00 C N30 2526 0010.00 C DOW *IN30=*OFF 0011.00 C WRITE SENWND1 0012.00 C ADD 1 RRN1 0013.00 C READ 30 0014.00 C 30 LEAVE 0015.00 C ENDDO 0016.00 C DOW *IN03=*OFF 0016.01 C 03 LEAVE 0016.02 C* WRITE HEATER 0016.03 C* WRITE FOOTER1 0016.04 C EXFMT SENWLT1 0020.00 C ENDDO 0021.00 C LR ****************** ***************************** End of

data

F RRN1 SETON

SETOFF EMPNEW SETON

EMPNEW

SETON

data

window main1 take 8

Select Record Keywords


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

Select General Keywords


Record . . . : MAIN1 Type choices, press Enter. Y=Yes If this record is not on display, write it to the display before issuing read . . . . Keep record on display . . . . . . . . . . . Assume record is on display . . . . . . Y 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 . . . . . . . . . . Y Select parameters . . . . . . . . . . . . Keyword

. . . INZRCD . . . KEEP . . . . . ASSUME . . . . . . . . . . . . ALWROL . . RETKEY . . RETCMDKEY . . CHGINPDFT . . . . MNUBARDSP . . . . ENTFLDATR . . . . . RTNCSRLOC

. . .

Define Return Cursor Location


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

Cursor Name CF03 CF04

position

. 03 04

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 Condition Overlap 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 More... Add Add Add

Ref

H M P

Hidden Message Program-to-system

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 Indicators/+ Window parameters . . . . . . . . . . . . WINDOW Select parameters . . . . . . . . . . .

Y=Yes Y Y

Window borders . . . Select parameters Remove windows . . . User Restore Display

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

. . . .

WDWBORDER RMVWDW USRRSTDSP

Define Window Parameters


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

. 1-

. 111Y Y

Define General Keywords Subfile control record . . . . . . . . . : SENWLT1

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

F12=Cancel

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 000111 000122 000123 NAME RAMESH SUDHA 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.
VRAMANA/RPGILE MAIN *************** Beginning ******************************* 0001.00 C CALLB 'ADD' 0002.00 C CALLB 'SUB' 0003.00 C CALLB 'MUL' 0004.00 C LR ****************** End ********************************** VRAMANA/RPGILE ADD *************** Beginning ******************************* 0002.00 C Z-ADD 4 0 0002.01 C Z-ADD 4 0 0004.00 C A ADD 4 0 0005.00 C C DSPLY 0006.00 C LR ****************** End ********************************* VRAMANA/RPGILE SUB *************** Beginning ******************************* 002.00 C Z-ADD 4 0 002.01 C Z-ADD 4 0 004.00 C A SUB 4 0 005.00 C C DSPLY 006.00 C LR ****************** End ********************************* VRAMANA/RPGILE MUL of data

SETON of data

of 4 5 B

data A B C

SETON of data

of 10 5 B

data A B C

SETON of data

*************** Beginning of data ****************************** 10 A 0002.00 C Z-ADD 4 0 5 B 0002.01 C Z-ADD 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 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 In this case we are binding the bounded are physically copied programs by using service into the main program object. programs, which contain a reference to the module that has been called, and the modules are not physically copied into the program object. The program will be executed The program will not executed even when you delete the entire when the bind modules are deleted. module that has been called. Bind by value is faster than bind by reference. (All the modules to be bind in the main program, so it is fast) It is not as faster as bind by value. (All the modules cant bind the main program it is refer the pointer)

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 *************** Beginning ****************************** 0002.00 C DSPLY 5 0 0002.01 C EXSR ADD 0004.00 C LR 0005.00 C/COPY RPGILE, COPY ****************** End ******************************** VRAMANA/RPGILE COPY *************** Beginning ****************************** 0000.01 0001.00 C ADD BEGSR 0002.00 C ADD 5 0003.00 C A DSPLY 0004.00 C ENDSR ****************** End ******************************* OUTPUT 13 DSPLY 18 74.What will FOR opcode will do? VRAMANA/DOLOOP FOR Beginning of COP data A

SETON

of

data

of

data

of

data

*************** ***************************** 0001.00 di s 0002.00 dn s 0003.00 c for 0004.00 c i dsply 0005.00 c endfor 0006.00 c for 0007.00 c i dsply

of

data

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

i=n downto 1

0008.00 0008.01 0009.00 0010.00 0011.00 0012.00 0013.00 0014.00 0015.00 lr

endfor * for(I=5;I<40;i=i+10) c for c i dsply c endfor c for c i dsply c endfor c

i=5 by n to 40

i=5 to 40 by n

seton End of data

****************** ***************************** OUTPUT DSPLY 1 DSPLY 10 DSPLY 2 DSPLY 9 DSPLY 3 DSPLY 8 DSPLY 4 DSPLY 7 DSPLY 5 DSPLY 6 DSPLY 6 DSPLY 5 DSPLY 7 DSPLY 4 DSPLY 8 DSPLY 3 DSPLY 9 DSPLY 2 DSPLY 10 DSPLY 1 DSPLY 5 DSPLY 5 DSPLY 15 DSPLY 15 DSPLY 25 DSPLY 25 DSPLY 35 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 FMTDTA OPNQRY copybooks. It will sort the records It will sort the records based o sequentially based on the the field values. position of the record 84. Explain inner If any change in the attribute If there is any change in the join or natural join size of a PF then we have to attribute size it will not affect and left outer join? change the program the program specification also. Inner join specification also Inner join means FMTDTA is bit faster in OPNQRYF is slower as the matching process than OPNQRYF. compare to FMTDTA if we are records in between processing millions of records. the joining file will be selected.
Columns . . . 1 71 KRAMANAVS/EXAMPLE SEU==> JPF01 FMT PF *************** Beginning **************************** 0001.00 R JP1REC 0002.00 EMPNO 5S 0 0003.00 EMPNAME 20A 0004.00 K EMPNO ****************** End ***************************** Columns . . . 1 71 KRAMANAVS/EXAMPLE Edit

of

data

of

data Edit

SEU==> JPF02 FMT PF. *************** Beginning of *************************** 0001.00 R JP2REC 0002.00 EMPNO 5S 0 0003.00 EMPSAL 10P 2 0004.00 K EMPNO ****************** End of ******************************** Display Report

data

data

EMPNO EMPNAME 000001 1,001 SHYAMBABU 000002 1,002 RAMANAVKUMAR 000003 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 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 EMPNAME 000001 1,001 SHYAMBABU 000002 1,002 RAMANAVKUMAR 000003 1,003 RAMESH ****** ******** End of report SEQUENCING DUPLICATE RECORDS

EMPSAL 100.00 20.00 .00 ********

Columns . . . 1 71 KRAMANAVS/EXAMPLE SEU==> SEQ1 FMT PF. *************** Beginning *********************** 0001.00 R SEQREC1 0002.00 EMPNO 5P 0 0003.00 EMPNAME1 20A 0004.00 ADDRESS 20A 0005.00 K EMPNO ****************** End ************************** Columns . . . 1 71 KRAMANAVS/EXAMPLE SEU==> SEQ2

Edit

of

data

of

data Edit

FMT PF 0001.00 0002.00 0003.00 0004.00 *************** Beginning of data**************** R SEQREC2 EMPNO 5P 0 EMPNAME 20A 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 ********

000001 000002 000003 ******

EMPNO EMPNAME TEL 000001 10,001 BOB 825,777 000002 10,001 BOB 825,999 000003 10,001 BOB 825,888 000004 10,002 DANNY 4,222,600 ****** ******** 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 4,222,600 ****** ******** End of report

50,LONG ISLAND ********

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 **************************** 0000.01 d*replace the string using keyword %replace 0001.00 dc s 16a inz('RAMANAVRaman') 0002.00 db s 20a 0003.00 c eval b=%replace('Ram':c:4:3) 0004.00 c b dsply 0005.00 c seton lr ****************** End of data ***************************** 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++DcHiL oEq ExFmtCustMaint C C Eval CustName=%TrimL(CustName)

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
*************** ****************************** ELEM Beginning of data

0001.00 0002.00 0003.00 0004.00 0005.00 lr

darr1 dc c c c c

s s eval dsply

3s 0 dim(100) 3s 0 c=%elem(arr1) seton End of data

****************** ********************************** OUTPUT DSPLY 100

%SIZE %SIZE will display the size of the variable


VRAMANA/BULID *************** 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 2 a 0004.00 c z-add 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 6 DSPLY 11 DSPLY 10 DSPLY 6 SIZE Beginning

DSPLY DSPLY DSPLY

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 Type choices, press Enter. Message identifier . . . . Message file . . . . . . . Library . . . . . . . *CURLIB Message Description (ADDMSGD) . . . MKS0001 Name . . . > MKSFILE Name . . . . > VRAMANA Name, *LIBL,

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 MSGREC1 20

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 MSGCTL1 06/27/02 MSGREC1

Create message subfile


SFLCTL 06/27/02 USING 8 SELETION 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 24 1-27 Message ID field . . . . . . . . . . SFLMSGKEY DUMMY Name (if program message queue is built one message at a time) Program message queue field . . . . . SFLPGMQ QUEUE Name Generate a 276 byte field . . . . . Y=Yes

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 TEXT keyword . . . . . . . . . . Define General Keywords Subfile control record . . . . . . . . . : MSGCTL1 Type choices, press Enter. Keyword Related subfile record . . . . . . . SFLCTL MSGREC1 Name Subfile cursor relative record . . . SFLCSRRRN Name Subfile mode . . . . . . . . . . . . SFLMODE Name Program message queue field . . . . SFLPGMQ QUEUE Name Generate a 276 byte field . . . . Y=Yes Y=Yes Indicators/+ 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 *MORE ... Record not active . . . . . . . . . SFLRNA More... F3=Exit

F12=Cancel Select Record Keywords

Record . . . : MSGCTL1 Type choices, press Enter. Y=Yes General keywords . . . . . . . . Y Indicator keywords . . . . . . . Y Overlay keywords . . . . . . . . Y

Select Overlay Keywords Record . . . : MSGCTL1 Type choices, press Enter. Keyword Y=Yes Indicators/+ Roll Overlay without erasing . . . . . . OVERLAY Y Create CL program for SNDPGMMSG 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 1 0 0012.00 0013.00 0013.01 0014.00 0014.01 0014.02 0015.00 0016.00 0017.00 0017.01

C C C C C C C C C C C

MOVEL WRITE EXFMT CALL IF MOVEL MOVEL MOVEL MOVEL CALL ENDIF

ERROREMP

MSGCTL1 MKSSEN 'RMO' EMPNUMB=*ZEROS 1 ERROR 1 ERROREMP 'MKS0001' MSGID *ZEROS MSGDTA 'MSG' 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 ***************************** 0001.00 FEXDSPF CF E WORKSTN 0002.00 C Z-ADD 1 2 0 0003.00 C *IN03 DOWEQ *OFF 0004.00 C SCR1 DOWEQ 1 0005.00 C EXFMT DSPF1 0006.00 C 03 LEAVE 0007.00 C IF *IN08=*ON 0008.00 C Z-ADD 2 0009.00 C LEAVE 0010.00 C ENDIF 0011.00 C ENDDO 0012.00 C SCR1 DOWEQ 2 0013.00 C EXFMT DSPF2 0014.00 C 03 LEAVE 0015.00 C IF *IN07=*ON 0016.00 C Z-ADD 1 0017.00 C LEAVE 0018.00 C ENDIF 0019.00 C ENDDO 0020.00 C 03 LEAVE 0021.00 C ENDDO 0022.00 C LR of data

SCR1

SCR1

SCR1

SETON

****************** *******************************

End

of

data

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) 0001.02 LEN () VALUE () TYPE () DCL

*DEC *CHAR *LGL

Default (15 5)
Max (15 9) Default (32) 1

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

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 *CURLIB Parameters . . . . . . . . . . . > VENKATA > RAMANA > '' > '' + for more values > '' DSPMSG

Name, *LIBL,

104. 105.

How to set the cursor position in particular field in particular position? Using the curpos

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 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. Figurative constants in RPGLE?

109.

110.

*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-notfound 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 C C C C C C C C C C

Select When exsr When exsr endSL ELSE if exsr endif endif

%STATUS = 1221 UpdateNoRead %STATUS = 1218 RecdLocked

%FOUND( CustMast ) whatever...

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 reopened 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 re-architecture 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 realworld 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 OS/400 Release Version/Release 1 2 2 3 4 4 5 V3 R1 V3 R6 V3 R2 V3 R7 V4 R2 V3 R5 (speculation) CISC See note 1 V4 R3 RISC CISC RISC RISC

CISC RISC
CISC

or

RISC

5 6

V4 R4 (February 1999) V4 R5 2000) (Summer

RISC 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 (correct) Name RPGII RPGIII RPGIII RPG IV

System/36-compatible RPGII System/38-compatible 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)Extendedfactor2++++++++++++++++++ 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 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. Eval nsize = %size(DinoArr) *

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, %TRIML, %TRIMR %SIZE, %ELEM, %SUBST, %TRIM,

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 Built-in Release Function V3R7 %ABS %ADDR V5R1 V4R2 V4R4 %ALLOC %CHAR

Parameters

Return Value Description


Absolute value of expression Address variable of

numeric expression variable name memory size

Pointer to the allocated storage. in data

graphic, date, time, Value timestamp, or character

numeric expression V5R1 %CHECK

type

compare-value : First position in data-to-search { : the searched-data that contains a start-position } character not in the list of the characters in the compare value. compare-value : Last position in data-to-search { : the searched-data that contains a start-position } character not in the list of the characters in the compare value. (Search begins with the rightmost character and proceeds to the left. { value { : date- A date data-type format-code } value after converting the "value" to the specified date format. If no value is specified, the current system date is returned. days A duration value that can be used in an expression to add a number of days to a date value.

V5R1

%CHECKR

V5R1

%DATE

V5R1

%DAYS

V3R7

%DEC

numeric expression Value in packed {:digits : decpos} numeric format. If digits and decpos are specified the result value is formatted to fit in a variable of the number of digits specified. numeric expression Half-adjusted : digits : decpos value in packed numeric format. The length and decimal positions numeric expression Number of decimal digits.

V3R7

%DECH

V3R7 V5R1

%DECPOS %DIFF

start-date : end-date Calculates the : duration-code difference between two date fields. The type of difference returned is specified by the duration-code. Numerator Denominator : Performs integer division and returns the quotient (result) of that division operation.

V4R4

%DIV

V3R7

%EDITC

non-float numeric String expression : edit representing code {:*CURSYM edited value. | *ASTFILL |

currency symbol} V3R7 %EDITFLT

numeric expression

Character external display representation of float.

V3R7

%EDITW

non-float numeric String expression : edit representing edited value word array, table, or Number multiple occurrence elements data structure name occurrences {file name} of or

%ELEM

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-offile 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'

V4R2

%EQUAL

{file name}

V4R2

%ERROR

otherwise. V3R7 V4R2 %FLOAT %FOUND numeric expression {file name} Value in format. float

'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.

V4R4

%GRAPHIC

Any value

character 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 Half-adjusted value in integer format

V5R1

%HOURS

hours

V3R7 V3R7

%INT %INTH

numeric expression numeric expression

V3R7

%LEN

any expression

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.

V5R1

%LOOKUPxx

search-data : array { : start-index { : elements to search }}

An array index of the element in the array where the search-data is located.

V5R1

%TLOOKUPxx search-data : *ON if the search searched-table { : is successful, alternate-table } otherwise *OFF. (NOTE: The indexes of the searched-table and alternatetable are set to the index of the search-data if *ON is returned.) %MINUTES minutes A duration value that can be used in an expression

V5R1

to add a number of minutes to a time value. V5R1 %MONTHS months 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. 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

V5R1

%MSECONDS

milliseconds

V3R7

%NULLIND

null-capable name

V5R1

%OCCUR

data-structure

V4R2

%OPEN

file name

open?" operation. %PADDR V3R2 V3R6 %PARMS procedure name Address procedure Number parameters passed procedure pointer : new-size Numerator Denominator of of to

V5R1 V4R4

%REALLOC %REM

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.

V4R2

%REPLACE

replacement string: source string {:start position {:source length to replace}}

V3R7

%SCAN

search argument : string to be searched {:start position} seconds

V5R1

%SECONDS

V5R1

%SHTDN

*ON if the job is being shut down (e.g., when the PWRDWNSYS command is issued) otherwise *OFF is returned. variable, data Number of bytes structure, array, or used by variable literal {: *ALL} or literal. *ALL returns the number of bytes used by all the elements of the array, or all the occurrences of the data structure. expression or value

%SIZE

V5R1

%SQRT

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

V4R2

%STATUS

{file name}

status file. V3R7 %STR pointer{:maximum length}

for

that

Characters addressed by pointer argument up to but not including the first x'00'.

V5R1

%SUBDT

date : duration-code The extracted component of the date value. (The functional equivalent of the EXTRCT operation code.) string:start{:length} 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. { value { : time- A time data-type format-code } value after converting the "value" to the specified time format. If no value is specified, the

%SUBST

V5R1

%THIS

V5R1

%TIME

current system time is returned. V5R1 %TIMESTAMP {value { : *ISO | A timestamp *ISO0 } data-type value with or without separators. %TRIM string String with left and right blanks trimmed (removed) String with left blanks trimmed String with right blanks trimmed character Returns a varying length value. Value in unsigned format Half-adjusted value in unsigned format

%TRIML %TRIMR V4R4 V4R2 V4R2 %UCS2 %UNS %UNSH

string string Any value

numeric expression numeric expression

V5R1

%XLATE

converted from-table : to- The table : string-to- string is returned. convert { : startingposition } Array name Cross foots (totals) all the elements in an array.

V4R4

%XFOOT

Define General Keywords Subfile control record . . . . . . . . . :

SCREENC1 Type choices, press Enter. Related subfile record . . . . . . . SCREENS1 Name Subfile cursor relative record . . . Name Subfile mode . . . . . . . . . . . . Name Keyword SFLCTL SFLCSRRRN SFLMODE

Y=Yes Indicators/+ Display subfile records . Y 40 Display control record . . Y 40 Initialize subfile fields Y N40 Delete subfile area . . . Clear subfile records . . N40 Indicate more records . . 40 SFLEND parameter . . . SFLEND parameter . . . *MORE ... Record not active . . . . Y

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

SFLDSP SFLDSPCTL SFLINZ SFLDLT SFLCLR SFLEND *MORE *SCRBAR SFLRNA

Keyword CFnn/CAnn Indicators/+ Subfile initially truncated . . . . Subfile initially folded . . . . . . Use instead of Enter key . . . . . . More... F3=Exit SFLDROP SFLFOLD SFLENTER

F12=Cancel

CL/400 Quiz (15 Marks) 1. 2. 3. 4. The maximum no. of objects that can be declared in a CL program are __One__. The command used to trap errors in a CL program is ___MONMSG_____. ___PARM____ is the keyword used to pass parameters in a CL program. How many datatypes are available in CL/400? What are they? 2 marks Three - *CHAR, *DEC, *LGL 5. The command analogous to DSPLY opcode is __ SNDPGMMSG MSG(xxxxxx)__. 6. Write the code to move a decimal value into a character variable. CHGVAR VAR(&C) VALUE(&D) where &A is character variable and &D is decimal value. 7. How will you execute the format of a display file in CL/400? SNDRCVF 8. What is the length of a CL variable name? 11 characters including & 9. What is a data area? How many types of data area are there? 2 marks A Data Area is an Object on AS/400 of the type *DTAARA. This stores a single value of data in a flat format and can be used by one or many programs. The different types are: a) *LDA local data area b) General Data area c) Group Data Area d) Program initialized parameter data area 10. Write the command to get the system date and display it? 2 marks RTVSYSVAL SYSVAL(QDATE) RTNVAR(&M) SNDPGMMSG MSG(DATE IS *CAT &M) where &M is a character variable of length 6 11. What is the syntax to convert the date from one format to the other? 2 marks CVTDAT DATE(&D1) TOVAR(&D2) FROMFMT(*EUR) + TOFMT(*JIS) TOSEP(/)

Common Questions 1. How many files can be used in a CL. 2. How many files can be used in RPG (3). 3. What is the difference between RPG3 AND RPG4. 4. What is static binding and dynamic binding? 5. How do you check for error in CL? 6. What is the use of Ovrdbf? 7. What is the use of open query (OPNQRY)? 8. How do you use the Open Query file in the RPG? 9. How do you submit a job? 10. What is the difference between Move and Movel? 11. What is the difference between Move and Eval? 12. What does Seton LR do? 13. What is the difference between Seton LR and Seton RT? 14. How do you check for error in RPG? 15. Can we execute a statement after Seton LR?

16. How do we control the opening of the files and Closing of the files in RPG? 17. What are the various kinds of Subfiles? 18. When do we use a load all Subfile? 19. What are the basic keywords required for a subfile? 20. Can we use SFLRCDNBR for a Page = Size Subfile. Will it compile (DDS) 21. Why a LF is required? What are the benefits and Overhead? 22. How many formats can a PF/LF/JLF contain? 23. What is the use of multiple member file? 24. What happens if the RRN is Zero in a Subfile and Display Subfile Indicator is Seton and Exfmted? 25. How do I change the PF without losing the data? 26. What are the implications of the same? 27. How the same can be overcome? 28. I do change the PF with the CHGPF command and use one of its logical in a PGM what happens to the PGM? 29. How many kinds of Arrays are available? 30. How many kinds of Data Areas are available? 31. I have a Select statement and When clause/s there are cases where the When clause satisfies, how many clauses gets executed. 32. What is the difference between DOW and DOUNTIL? 33. What is the data type of the Indicator? 34. How can I retrieve the value of a particular element in an Array? 35. How do you journal a file? 36. What is the use of commitment control? 37. 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? 38. What are the uses of procedures? 39. How to invoke the procedure? 40. How do we write a procedure? (Steps) 41. How do we execute a CL command from a RPG? 42. Some keywords that can be used in Printer file/ Display file. 43. How do we monitor for the end of file in CL? 44. How do you handle for end of file in RPG (Built ins for Chain/ Read / Reade) 45. What are the I/O operations that can be done on the Subfile? 46. If we modify a value of Subfile record, how do we retrieve the same? 47. What if the changed value in the Subile is erroneous? How can we check it and ask the user to rectify the same? 48. What is the use of SFLNXTCHG? Explain what is MDT. 49. What is the accpth?

RPG
1) Three types of subfiles. Single page / Load All / Expanding 2) What are the keywords that distinguish between the three types of subfiles Single Page SFLSIZ = SFLPAG Expanding subfile SFLSIZ > SFLPAG Expanding subfile SFLSIZ > SFLPAG What are the opt codes that are used to read subfile records. READC, CHAIN 3) How can I read a changed record in the second cycle of read of a subfile Keyword- SFLNXTCHG 4) In a Selec /When/ Endsl sequence if all the WHEns evaluate to true which statements execute. 5) Evaluate this statement MOVE 1 FLD1 FLD1 IFNE 1 FLD2 ORNE 1 Y DSPLY ELSE N DSPLY ENDIF 6) Evaluate this statement Z-ADD 0 FLD1 MOVE 103.25 FLD1 FLD1 DSPLY FLD1 = 10.325 7) Evaluate this statement KEYVAL SETLL FILE1 *IN01 DSPLY

10,3

XXXX01

Value = 1 8) Evaluate this statement KEYVAL READE FILE1 *IN01 DSPLY Value = 0 9) Format level identifier and its use. Follow it with Can I change a structure of a file and then not compile the RPG program. 10) Describe exception handling

XXXX01

CLP
11) How to read a database file in a CL program 12) How to check for end of file Ans:- CPF0864 13) Can I use an override to position in a database file 14) Display a record format in CL program 15) How to submit a program in batch 16) How do you debug an RPG program. 17) Three ways of copying a file. CRTDUPOBJ CPYF INSERT INTO

I have a program object I need to identify the location of the source DSPPGM PGM (XXXX) (*SERVICE) How to check an object exists on the system in a CL program. How to display record locks 1) Where do system libraries reside? 2) How to get the length of data in a variable? Not the length of variable. 3) How to use TEST opcode for a alphanumeric variable? 4) Why use LF with key and not PF with key if no maintenance considerations. 5) Whats FIFO? 6) Can u have a PF with fields derived from 2 field reference files? 7) Can u have an LF defined on all the members of a PF at once? If so how? 8) How do u know when a Batch Job has ended? 9) How will u use a pgm to change current library list? 10) job? 11) 12) 13) 14) What are job Difference between activation group and job ? What are the types of activation group and their significance? What are modules, service programs, can u see the code of service pgms if u How will u use a pgm to change library list for an interactive job after a batch

browse through them? 15) 16) How is ILE different from other HLLs? What is difference between *SRVPGM and a normal RPGLE pgm both can

have modules. Why prefer *SRVPGM? 17) 18) 19) 20) Service programs are mare by pass by reference? What are the types of access path maintenance? Explain each of them. How to copy 1000 record from 10000 records using CPYF, tell the keywords. Whats the difference between CALL, CALLB, CALLP when are they used?

21) 22) 23)

What are the different ways of transferring control from one pgm to another? DataQs, what happens to the dataq after the data has been sent? What is an access path?

24)
25) 26)

CL variable types, max length, default length


Why is SFLNXTCHG used? 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? 27) 28) 29) 30) 31) 32) 33) 34) 35) Difference between ODP and Access path? What is an ODP does it exist if so where? RPGILE is faster than RPG why? How many overflow indicators can u have in a pgm? What are the different kinds of indicators in RPGLE? What is primary file, secondary file, fully procedural file. How many secondary files/printer files can be there in a pgm? Can I specify a update for a primary/secondary file/fully procedural file? What happens if I specify UC (user controlled) for a primary/secondary/fully

procedural file? 36) 37) 38) 39) 40) 41) 42) 43) What is level check (LVLCHK)? What is *Namvar DEFINE? What are the error handling subroutines? What are the different kind of MONMSGs Can u se a subfile in a CL pgm? Message Subfile ? What is the difference between CALL and Transfer Control (TFRCTL) ? Explain Multi Dimensional Array? Explain Commitment Control?

44)

How can u send data from a production environment to a development

environment? 45) 46) READC why n when used? How do you send a Packed decimal value from a CL program to a RPGILE

program as parameter? 47) 48) How does CL pgm end if no ENDPGM, is PGM mandatory? Can data be copied from an LDA into a SBMJOB?

RPG/400 Quiz (25 Marks) 1. The maximum no. of files that can be declared in an RPG/400 program is __50 ___. 2. Write the syntax to define a data area in an RPG/400 program. *NAMVAR DEFN MYAREA 20 where MYAREA is a data area. 3. What are the two programming styles in RPG/400? RPG Logic Cycle and User Logic 4. Justify why only 8 printer files can be used in an RPG/400 program. Only 8 overflow indicators are available in RPG/400 OA-OG, OV which can be used to handle only 8 printer files at the most. 5. What are the data types supported by RPG/400? Character and Numeric and exceptionally Binary 6. What are the uses of I-specs? 2 marks I specs can be used to define Data Structures, Named Constants, and Program Described file definition 7. How many types of arrays are there in RPG/400? Define them. 2 marks Pre-run time array The array gets loaded into the memory before the execution of the program. Values to this array are loaded by the system from a predefined table. Run time array Gets populated during the run-time by the user. Compile time array Gets values during the compile time specified in IP** prompt after the code. 8. The maximum no. of arrays in one RPG/400 program are ___256____. 9. The maximum no. of sub-routines in RPG/400 program are __256__. 10. The sub-routine which is automatically called by the RPG/400 program is __*INZSR or initialization subroutine __. 11. What is INFDS?

INFDS File information data structure 12. What are the set of keywords in their order to define a subfile? 2 marks SFLDSP subfile display, SFLDSPCTL - subfile control display, SFLCLR subfile clear, SFLSIZ subfile size, SFLPAG subfile page 13. How many sub-files can be defined in a display file? 512 14. Differentiate ITER and LEAVE. Iter - This Opcode will make the loop to continue. Leave This Opcode will make the loop to terminate 15. How many times are the printing operations performed in a RPG Logic cycle? What are they? 2 marks 4 a) Heading time b) Detail Time c) Total Time d) Exception Time 16. Define XFOOT. Opcode to add all the array elements and store in a result. 17. What is the maximum no. of records in a subfile? 9999 18. Name the various read operations in RPG/400 & explain. 2 marks READ, READP, READE, REDPE, CHAIN, READC 19. The opcode which replaces SETLL and READ is _____CHAIN_____. 20. Differentiate DOU and DOWxx. DOU executed atleast once and then condition is checked for. DOW executed only if condition is satisfied. DB2/400 Quiz (25 Marks) 1. What are the files that you can create in DB2/400? Physical Files and Logical Files (PFs and LFs) 2. What are the essential parts of a PF? Explain pictorially. 2 marks There are three essential parts of a PF, viz., Record Format, Access Path, Data Members. 3. What is the maximum no. of key fields? 120 4. Name the possible methods to feed data into a PF. DFU, IDDU, Programmatically, Interactive SQL 5. What is the maximum no. of records a PF can have by default? 10000 + 3*1000 6. Keywords can be specified at ___4___ different levels in a PF. 7. _ DESCEND _ is the keyword used to sort the duplicate record in descending order. 8. The ___ REF ___ keyword is used at the file level to obtain a reference of a field from some other PF.

9. By using what keywords and at what levels can we obtain reference of fields from multiple files. Give the syntax. 2 marks REF at file level REFFLD at field level REF(LIB/FILE) REFFLD(FIELD FILE) 10. What are the different constraints that can be applied on a PF? 2 marks PRIKEY Primary Key Constraint UNQCST Unique Key Constraint REFCST Referential Integrity CHKCST Check Constraint 11. Write the syntax to make a field not null? Field Name CHECK(ME) 12. What are the data types supported by DB2/400? 2 marks 13. A alphanumeric P packed decimal S zoned decimal L Long date Z Time stamp T Time F Floating point H Hexadecimal 14. What are the essential keywords in their order to define a Join Logical File? JFILE, JOIN, JFLD 15. How many record formats can a non-join logical file contain? 32 16. How do you join two files in a join logical file? JOIN keyword 17. What are the types of join logical files? Left outer Join, Inner Join, Intersection (Any two may be considered) 18. _____ DYNSLT at the file level _____ keyword is used to specify select and omit criteria. 19. How can you refer to the access path of a PF in an LF? ACCPTH keyword 20. How do you define a left outer join? JDFTVAL keyword 21. How do you handle duplicate record occurrence in a Join Logical File? JDUPSEQ keyword 22. Logical Files cannot have data members. (T/F) False

Questions: 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 definations 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.
Data Types: CL/400 has only 3 data types. 1. Character 2. Numeric 3. Logical

1) CL PROGRAMMING TO ADD TWO NUMBERS Columns: 1 71 Edit STDLIB/SAMMAN SEU==> FMT** +12+3+4+5+6+7 ***********Beginning of data********************* 01.0 PGM * Starting of the program is done by PGM 0002.00 DCL VAR(&A) TYPE(*DEC)LEN(3 0) VALUE(100) * Any variable declaration is done by DCL 0003.00 DCL VAR(&B) TYPE(*DEC)LEN(3 0) VALUE(150) 0004.00 DCL VAR(&C) TYPE(*DEC)LEN(3 0) VALUE(0) 0005.00 DCL VAR(&D)TYPE(*CHAR)LEN(3) 0006.00 CHGVAR VAR(&C)VALUE(&A+&B) * CHGVAR is used to replace the value of a variable with some other value. 0007.00 CHGVAR VAR(&D)VALUE(&C) 0008.00 SNDPGMMSG MSG(THE SUM IS: *CAT&D) * This will send a message on the console. 0009.00 ENDPGM * ENDPGM ends the program **************End of data******************** 2) DECIDE VOTING STATUS DEPENDING ON AGE 0001.00 PGM PARM(&NM&AGE &NA) 0002.00 DCL &NM *CHAR 15 0003.00 DCL &AGE *CHAR 3 0004.00 DCL &NA *CHAR10 0005.00 DCL &NAGE *DEC(3 0)0 0006.00 CHGVAR&NAGE &AGE 0007.00 IF(&NAGE>=18*AND&NA=INDIAN) 0008.00 THEN(DO) 0009.00 SNDPGMMSG MSG(&NM*CAT CAN VOTE) 0010.00 ENDDO 0011.00 ELSE (SNDPGMMSG MSG(&NM*CAT CANNOT VOTE)) 0012.00 ENDPGM **************End of data******************** 3) Work with system values: **************Beginning of data****************** 0001.00 PGM 0002.00 DCL &M*CHAR 4 0003.00 DCL &S*CHAR 8 0004.00 RTVSYSVAL SYSVAL(QMODEL) RTNVAR(&M) * RTVSYSVAL retrieve system value 0005.00 RTVSYSVAL QSRLNBR &S 0006.00 SNDPGMMSG MSG(YOUR AS/400MODEL IS: *CAT &M*CAT + 0007.00 AND SR. NO. IS: *CAT &S)

0008.00 ENDPGM **************End of data******************** 4) CL PGM FOR CONVERSION OF DATE FORMAT Columns: 1 71 Edit STDLIB/SAMMAN SEU==> CLFRTH FMT** ...+.1+2+3+4+5+6+7 ****************Beginning of data******************** 0001.00*CL PGM FOR CONVERSION OF DATE FORMAT* 0002.00 PGM 0003.00 DCL &D1*CHAR 1015/08/1947 0004.00 DCL&D2 *CHAR 0005.00 CVTDAT DATE(&D1) TOVAR(&D2) FROMFMT(*EUR)+ 0006.00 TOFMT(*JIS) TOSEP(/) * CVTDAT convert dat 0007.00 SNDPGMMSG MSG(DATE *CAT &D2) 0008.00 ENDPGM **************End of data********************

5) CL PGM FOR REVERTING A STRING: Columns. . .: 1 71 Edit STDLIB/SAMMAN SEU==> CLFIFITH FMT** +1+2+3+4+5+6+7 **************Beginning of data****************** 0001.00 PGM PARM(&NM) 0002.00 DCL &NM *CHAR 15 0003.00 DCL &C *CHAR 15 0004.00 DCL &E *DEC (2 0) 16 0005.00 LABEL: 0006.00 CHGVAR &e(&E - 1) 0007.00 CHGVAR &C (&C *TCAT%SST(&NM &E 1)) 0008.00 IF (&E>1) GOTO LABEL 0009.00 SNDPGMMSG MSG(REVERTED NAME: *CAT &C) 0010.00 ENDPGM **************End of data********************

6) CL PROGRAM DEMONSTRATING DYNAMIC OVERRIDE OF SOME DATABASE ATTRIBUTES Columns. . .: 1 71 Edit STDLIB/SAMMAN SEU==> CLSEVEN FMT** +1+2+3+4+5+6+7 **************Beginning of data****************** 0001.00 PGM 0002.00 OVRDBF FILE(KIRAN3) TOFILE(STDLIB/KIRAN3) SHARE(*YES) 0003.00 OPNQRYF FILE(STDLIB/KIRAN3) QRYSLT(BASIC *GT 5000 *AND DEPT *GT 10) + KEYFLD ((EMPCD *ASCEND)) 0004.00 CALL PGM(STDLIB/HLLPGM12) 0005.00 DLTOVR FILE(KIRAN4)

0006.00 CLOF OPNID(KIRAN3) 0007.00 ENDPGM **************End of data********************

Columns. . .: 1 71 Edit STDLIB/SAMMAN SEU==> HLLPGM12 0001.00 FKIRAN3 IF E K DISK 0002.00 C READ EMPREC 55 0003.00 C *IN55 DOWEQ*OFF 0004.00 C BASICDSPLY 0005.00 C DEPT DSPLY 0006.00 C READ EMPREC 55 0007.00 C ENDDO 0008.00 C SETON LR

TEST ON CL Programming
Total Time: 1 hr Tot. Marks: 50

Tick one or more correct choice/s (1 Mark each)


1. Which of the following is not a valid CL datatype? (a) (b) (c) (d) 2. *dec *char *log *lgl

Max no. of files that can be declared in a CL program (a) 0 (b) 1 (c) 50 (d) 9999 How many files can be updated through CL (a) 0 (b) 1 (c) 20 (d) 50 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)

3.

4.

Pgm4 , pgm2, pgm1 5. Which of the following files can be used in the TOFILE parameter of CPYF? Logical file

a)

b) Join Logical file c) Tape file d) None of the above

6.

Which of the following commands cannot be used on the command line? a) RTVDTAARA b) CRTDTAARA c) CHGDTAARA d) All the above

(A) 7. What is the command used to find all logical files based on one physical file? DSPDBR DSPOBJD DSPPFM a and b

a) b) c) d)

(a) 8. Which is the command used to find the access path of a file? DSPFFD DSPFD DSPOBJD All the above

a) b) c) d)

9.

a) b) c) d)

Which of the following combination of files can be declared in CLP? Printer file, Database file Display subfile, Message subfile Message subfile, Database file Database file, Display subfile

10.

a) b) c) d)

What is the function of DSPPGMREF? Displays list of all files referred in the program Displays the list of all objects used in the program Displays all copy books used in the program Displays list of all call programs used in the program

Use Short Answers: (2 Marks each)


1. 2. 3. 4. 5. 6. What is the difference between program level and command level MONMSG? What is the difference between TFRCTL command and CALL command? How can the data be shared across different jobs? Differentiate between data base files and data areas How do you compile RPG program having compile time override? What is wrong in the following program: PGM MONMSG CPF0000 DCLF FILE (INPUT) ENDPGM How do you know the keys used in a physical file without using SEU?

7.

8. 9. 10.

How to extract a word hello from the string hello world? Which has the highest priority if you give both program level MONMSG and command level How to use multiple files in CLP? MONMSG?

Mention True/False: (1 Mark each)


1. 2. 3. 4. 5. 6. 7. 8. 9. 10. Two objects with same name and type cannot exist in different libraries The built-in menu called MAJOR organizes all the AS/400 commands 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 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. 2. 3. 4. 6. Not all CL commands can be used in a CL program (TRUE/FALSE) Declare commands must precede all other commands except the PGM command. (TRUE/FALSE) ENDPGM command is a mandatory command in a CL program. (TRUE/FALSE) ____________________________ Monitors for escape, status, and notify messages sent to a program's message queue __________________ 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 ser of command used is a) WRKACTJON, WRKSBMJOB, DSPJOB, WRKUSRJOB b) WRKSBMJON, WRKSBSJOB, WRKUSRJOB c) WRKACTJOB, WRKSBSJOB, DSPJOB, WRKUSRJOB Ans : - c) 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 Ans : - c) 12. In join Logical File Min. files required are a) 1 b) 6 c) 32 d) None of the above Ans : - a) 13. In join logical file Max files required are a) 2 b) 4 c) 6 d) 32 Ans : - d) 14. To find a string CL command used is a) FNDSTRPDM b) ALCOBJ c) DSPFD

d) None of the above Ans : - a) 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 OVRDKTF 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 subfile. . This statement is a) True b) False c) None of the above Ans : True 18. QCMDEXC is a system supplied API. This statement is a) True b) False c) None of the above Ans : - True 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 Ans : - b) 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 Ans : - c 24. Wait command is used in CL program only. This statement is a) True b) False c) None of the above Ans : - a) QUESTIONS : simple ################### 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.

QUESTIONS : medium difficulty ########################## 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. QUESTIONS : difficult ################### 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 tablespacelevel 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.
Printed 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.

CLP Question Bank


Choose correct answer: 1. What is the maximum number of files which can be declared in CLP? a) 3

b) c) d) 2.

2 1 No limit (a)

Which of the following commands cannot be used on the command line? a) RTVDTAARA b) CRTDTAARA c) CHGDTAARA d) All the above 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 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 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 What is the command used to delete program object? a) DLTOBJ b) DLTPGM c) DLTF d) All the above (b) (b)

3.

(a)

4.

5.

(b)

6.

7.

8.

(b)

9.

Which is the command to retrieve system date? a) RTVSYSVAL b) RTVJOBA c) RTVJOBD d) a and b 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 Following method is used to load the messages in Message subfile a) Load All b) Expanding c) Single Page(Equal subfile) d) None

(a)

10.

11.

(a)

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) PGMQ b) MSGQ c) External MSGQ d) None
14.

(a)

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 What is the command used to change the value of a data area? a) DSPDTAARA b) RTVDTAARA c) CHGDTAARA d) None

15.

Answer the following briefly:


1.

Name three CL commands which cannot be used on the command line.

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. 21. Can a CL use Subfile?(MSGSFL) 22. How many record formats can you specify for a display file in a CL program? 23. How many number of files can you declare in a CL program? 24. 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?
2.

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? 62. How to enter a system command? 63. How do you start source debugger? 64. Which keyword will effect the messages to come at particular line on the screen? 65. To which queue will you send messages? 66. How will you clear the messages from message queue? 67. In DDS coding for Message subfile, will you need SFLCLR keyword? 68. What is the default value for SFLPAG in Message subfile? 69. 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?
41.

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.
81.

State whether true or false:


1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37.

Two objects with same name and type cannot exist in different libraries. (F) Not all commands typed on command line are CL commands . (F) A CL command can be an IBM or user defined command. (T) DCLF is used to declare a display or database file in CL. (T) All variables in the file being declared gets implicitly defined in the CL program. (T) CL command is a statement that requests the system to perform a function. (T) The built-in menu called MAJOR organizes all the AS/400 commands. (T) RCVF reads a record from a display or data base file. (T) SNDF writes a record to a display or a data base file. (F) OVRDBF is used to qualify the library where the file is located. (T) The submit job command is used to submit a job to a job queue for interactive processing. (F) A message subfile is a repository of all the predefined messages. (F) A library is an object used to group related objects. (T) The declare commands (DCL & DCLF) must precede all other CL statements. (T) A CL program can contain only CL commands. (T) Program variables are stored in libraries. (F) The value of a CL variable can be changed using CHGVAR. (T) The CHGVAR command can be used to retrieve and to change the LDA. (T) The current library cannot be a duplicate of any library in the library list. (F) We should not create a library with a name that begins with Q. (T) *CHANGE (change authority) allows the user to access the objects in the library. (T) The two types of files that are supported in CL programs are display and data base files. (T) The GOTO command processes a conditional branch. (F) The DO command repeats a group of commands. (F) Embedded IF commands are permitted up to 12 levels, in CL programming. (F) The MONMSG command is used to monitor for escape, notify, or status messages sent to its program queue. (T) CVTDAT command is used to change the format of the date in a CL program. (T) The name of the user who called the program can be retrieved using RTVUSRPRF command. (T) When the TFRCTL command is used, control returns to the program containing the TFRCTL 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)

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. 69. 70. 71. 72. 73. 74.

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) 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)

75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88.

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)

IBMS DB2
Introduction
DB2 is the relational database system that runs in an MVS environment. It was developed by IBM and interfaces with SQL. With the use of SQL, DB2, databases can be accessed by wide range of host languages. SQL is the relational database application language that interfaces with DB2. Because of its capabilities, SQL and , in turn, DB2 have gained considerable acceptance. Thus, a working knowledge of DB2 increases ones marketability. The questions and answers that follow are intended for those with working knowledge of DB2 as a self-test. If you need to brush up, the nearest book store is your next step.

Questions and Answers


Q: A: What is DB2 (IBM Database 2)? DB2 is a subsystem of MVS operating system. It is a database Management system (DBMS) for that operating system. What is an access path? The path that is used to get to data specified in SQL statements. What is an alias? A: It is an alternate name that can be used in SQL statements to refer to a table or view in the same or a remote DB2 subsystem.

Q: A: Q:

Q:

Explain what a plan is. A: A plan is a DB2 object (produced during the bind process) that associates one or more database request modules with a plan name. What is meant by concurrency? A: Concurrency is what allows more than one DB2 application process to access the same data at essentially the same time. Problems may occur, such as lost updates, access to uncommitted data and unrepeatable reads. What is cursor stability? A: It is cursor stability that tells DB2 that database value read by this application are protected only while they are being used. (Changed values are protected until this application reaches a commit point) .As soon as a program moves from one row to another, other programs may read or change the first row. What is the function of the Data Manager? A: The Data Manager is a DB2 component that manages the physical database(s). It invokes other system components, as necessary, to perform detailed functions such as locking, logging and physical I/O operations (such as search, retrieval, update and index maintenance). What is a Database Request Module (DBRM)? A: A DBRM is a DB2 component created by the DB2 precompiler containing the SQL source statements extracted from the application program. DBRMs are input to the bind process. What is data page? A: A data page is a unit of retrievable data either 4k or 32k (depending on how the table is defined), containing user or catalog information. What are data types? They are attributes of columns, literals and host variables. The data types are SMALLINT, INTEGER, FLOAT, DECIMAL, CHAR, VARCHAR, DATE and TIME. What is a Declarations Generator (DCLGEN)? A: DCLGEN is a facility that is used to generate SQL statements that describe a table or view. These table or view descriptions are then used to check the validity of other SQL statements at pre compile time. The table or view declares are used by the DB2 pre compiler to verify that correct column names and data types have been specified in the SQL statement. What does DSNDB07 database do?

Q:

Q:

Q:

Q:

Q:

Q: A:

Q:

Q:

A: DSNDB07 IS WHERE db2 does its sorting. It includes DB2s sort workarea and external storage. Q: What is meant by dynamic SQL? A: Dynamic SQL are SQL statements that are prepared and executed within a program while the program is executing. The SQL source is contained in host variables rather than being hard coded into the program. The SQL statement may change from execution to execution. What is DB2 bind? A: A bind is a process that builds access paths to DB2 tables. A bind uses the Database Request Module(s) (DBRMS) from the DB2 precompile step as input and produces an application plan. It also checks the users authority and validates the SQL statements n the DBRMS. What information is used as input to the bind process? 1. The database request model produced during the precompile 2. The SYSIBM.SYSTEM table of the DB2 catalog. What is meant by AUTO COMMIT? A: AUTO COMMIT is a SPUFI option that commits the effects of SQL statements automatically if they are successfully executed.

Q:

Q: A:

Q:

Q: A:

What is a base table? A base table is a real table a table that physically exist in that there are physical stored records. What is the function of Buffer Manager? A: The Buffer Manager is the DB2 component responsible for physically transferring data between an external medium and (virtual) storage (performs the actual I/O operations). It minimizes the amount of physical I/O actually performed with sophisticated buffering techniques (i.e., read-ahead buffering and look-aside buffering) What is a buffer pool? A: A buffer pool is main storage that is reserved to satisfy the buffering requirements for one or more tablespaces or indexes and is made up of either 4k or 32k pages. How many buffer pools are there in DB2? A: There are four buffer pools BP0,BP1,BP2 and BP32. On the create tablespace, what does the CLOSE parameter do.

Q:

Q:

Q:

Q:

A: CLOSE physically closes the tablespace when no one is working on the object. DB2 (release 2.3) will logically close tablespaces. Q: A: What is a clustering index? It is a type index that (1) locates table rows and (2) determines how rows are grouped together in the tablespace. What will the COMMIT accomplish? A: COMMIT will allow data changes to be permanent. This then permits the data to be accessed by other units of work. When a COMMIT occurs, locks are freed so other applications can reference the just-committed data. What is meant by embedded SQL? A: They are SQL statements that are embedded within an application program and are prepared during the program preparation process before the program is executed. After it is prepared the statement itself does not change (although values of the host variables specified within the statement might change). What is meant by entity integrity? A: Entity integrity is when the primary key is in fact unique and not null.

Q:

Q:

Q:

Q:

What will the EXPLAIN do? A: EXPLAIN obtains information (which indexes are used, whether sorting is necessary, which level of locking is applied) about how SQL statements in the DBRM will be executed, inserting this information into the X PLAN TABLE where X is the authorization id of the owner of the plan. What is a foreign key? A: A foreign key is a column for combination of columns in a table whose values are required to match those of the primary key in some other table. What will the FREE command do to a plan? A: It will drop (delete) the existing plan. What will the GRANT option do? It will grant privileges to a list of one or more users. If the GRANT options is used in conjunction with the PUBLIC option, then all users will be granted privileges. Also, you can grant privileges by objects and types.

Q:

Q:

Q: A:

Q:

What does the term Grant Privileges mean? A: Grant Privileges means giving access/authority to DB2 users. What is a host variable? A: This is a data item that is used in an SQL statement to receive a value or to supply a value. It must be preceded by a colon(:) to tell DB2 that the variable is not a column name. What is an image copy? A: It is an exact reproduction of all or part of the tablespace. DB2 provides utility programs to make full-image copies (to copy the entire tablespace) or incremental image copies to copy only those pages that have been modified since the last image copy. What is meant by an index? A: An index is a set of row identifiers (RIDs) or pointers that are logically ordered by the values of a column that has been specified as being an index. Indexes provide faster access to data and can enforce uniqueness on the row in the table. What is an index key? A: It is a column or set of columns in a table used to determine the order of index entries.

Q:

Q:

Q:

Q:

Q:

What is meant by an index scan? A: When an entire index (or a portion thereof) is scanned to locate rows, we call this an index scan. This type of access can be used, for example, to select all rows of a table in some order and avoid a sort for a query. What is meant by indicator variable? A: An indicator variable is an integer variable used to show whether its associated host variable has been assigned a null value. What is a join? A: A join is a relational operation that allows retrieval of data from two or more tables based on matching column values. What is meant by locking? A: Locking is a process that is used to ensure the integrity of data. It also prevents concurrent users from accessing inconsistent data. The data (row) is locked until a commit is executed to release the updated data.

Q:

Q:

Q:

Q:

What is a nonleaf page? A: This is a page that contains keys and page numbers of other pages in the index. Nonleaf pages never point to actual data. What is meant by null? A: This is a special value that indicates the absence of data in a column. This value is indicated by a negative value, usually 1. What is an object? A: An object is anything that is managed by DB2 (that is, databases, tablespaces, tables, views, indexes or synonyms), but not the data itself.

Q:

Q:

Q:

What will the DB2 optimizer do? A: The optimizer is a DB2 component that processes SQL statements and selects the access paths. What is a page? A: This is the unit of storage within a tablespace or index space that is accessed by DB2. what is a pagespace? A: Pagespace refers either to an unpartitioned table, to an index space or to a single partition of a partitioned table of index space.

Q:

Q:

Q:

What is a predicate? A: A predicate is an element of a search condition that expresses or implies a comparison operation. Describe a primary key? A: A primary key is a key that is unique, non null and is part of the definition of a table. A table must have a primary key to be defined as a parent. What is recovery log? A recovery log is a collection of records that describes the sequence of events that occur in DB2. The information is needed for recovery in the event of a failure during execution. What is a Resource Control Table (RCT)? Describe its characteristics.

Q:

Q: A:

Q:

A:

The RCT is a table that is defined to a DB2/CICS region. It contains control characteristics which are assembled via the DSNCRCT macros. The RCT matches the CICS transaction ID to its associated DB2 authorization ID and plan ID (CICS attachment facility). Where are plans stored? A: Each plan is defined uniquely in the SYSIBM.SYSPLAN table to correspond to the transaction(s) that are to execute that plan. Describe referential integrity. A: Referential integrity refers to a feature in DB2 that is used to ensure consistency of the data in the database.

Q:

Q:

Q: What is meant by repeatable read? A: When an application program executes with repeatable read protection, rows referenced by the program cannot be changed by other program until the program reaches a commit point.

Q: What is a row? A: A row is a single occurrence of the columns(of data) described by the table definition.

Q:

Describe what a storage group (STOGROUP) is. A: STOGROUP is a named collection of DASD volumes to be used by tablespaces and index spaces of databases. The volumes of a STOGROUP must be of the same device type. What is meant by synonym? A: A synonym is an alternate name for a table or view which is stored in the SYSIBM.SYSSYNONYMS table. Describe what a table is A: A table is a DB2 structure in which column names are used to specify the information that is being stored by row. What is a tablespace? A tablespace is a VSAM dataset, which is used to store one or more tables. The physical page can consist of 4k or 32k pages. How would you move a tablespace (using STOGROUP) to a different DASD volume allocated to that tablespace? A: 1. If the tablespace used is only allocated to the STOGROUP:

Q:

Q:

Q: A:

Q:

ALTER STOGROUP add volume (new) delete volume(old) REORG TABLESPACE or RECOVER TABLESPACE 2. Create a new stogroup that points to the new volume. ALTER the tablespace and REORG or RECOVER the tablespace. Q: What is the format (internal layout) of TIMESTAMP?

A: This is a seven-part value that consists of a date (yymmdd) and time (hhmmss and microseconds). Q: A: Q: What is a unique index? An index specified as unique is an index for which no duplicates are allowed. What is meant by a unit of recovery?

A: This is a sequence of operations within a unit of work (i.e., work done between commit points). Q: What is a view?

A: A view is an alternative representation of data contained in one or more tables. A view can include all or some of the columns contained in the table or tables. Q: A: Q: A: Q: A: What does a view do? A view restricts access to specific columns and rows. What is a data model? A data model is a way of representing entities, attributes and relationships. When a transaction issues a commit, to what is the commit writing? A commit triggers a write to a log record.

Q: Can DASD types assigned to storage groups to be intermixed (i.e., 330s and 3380s)? A: Q: NO.

What type of information is contained on the BSDS? A: The BSDS contains information about active and archive logs, their dataset names and the volumes on which they reside.

Q:

What are the three types of page locks that can be held? A: Exclusive, update, and share. Can TSO users access DB2? If yes, which command is used to invoke DB2. A: TSO users can invoke DB2 by using the DSN RUN command. What are the names of the different types of DB2 tablespaces? Simple, Segmented and partitioned. What is the maximum number of partition allowed in a partitioned tablespace? A: The maximum is 64. How are write I/Os from the buffer pool executed? Asynchronously. After a table is recovered, which flag is turned on? A: The Copy Pending Flag is turned on.

Q:

Q: A: Q:

Q: A: Q:

Catalogs
Q: What is the DB2 catalog? A: The DB2 catalog is a set of tables that contain information about all of the DB2 objects (tables, views, plans, etc). In which column of which DB2 catalog would you find the length of the rows for all tables? In the RECLENGTH column of SYSIBM.SYSTABLES. What information is held in SYSIBM.SYSCOPY? A: The SYSIBM.SYSCOPY table contains information about image copies made of the tablespace. Q: What information is contained in a SYSCOPY entry?

Q: A: Q:

A: Included is the name of the database, the tablespace name, and the image copy type (full, incremental, etc.,) as well as the date and time each copy was made.

Q:

What information can you find in SYSIBM.SYSLINKS table?

A: The SYSIBM.SYSLINKS table contains information about the links between tables created by referential constraints. Q: Where would you find information about the type of database authority held by a user? A: SYSIBM.SYSDBAUTH.

Q: Where could you look if you had a question about whether a column has been defined as an index? A: Q: This information can be found in SYSIBM.SYSINDEXES. Once you create a view, where would information about the view be stored?

A: When a view is created, system information about the view is stored in SYSIBM.SYSVIEWS. UTILITIES Q: What will the copy utility do?

A: The copy utility will create an image copy of a tablespace or a dataset within a tablespace. There are two types of image copies : full and incremental. A full image copy copies all pages in a tablespace or dataset. An incremental image copy copies only pages that have been modified since the last use of the COPY utility. Q: What will the load utility do?

A: The LOAD utility will load data into one or more tables in a tablespace or partition. The LOAD can also replace the contents of a single partition or of an entire tablespace. Q: What can the MERGECOPY utility do?

A: It can merge several incremental copies of a tablespace to make a single incremental copy and it can merge incremental copies with a full-image copy to make a new full-image copy. Q: What will the RECOVER utility do?

A: This utility recovers data to the current state or a previous state. The largest unit of data recovery is the tablespace; the smallest is a page. Data is recovered from image copies of a tablespace and database log change records.

Q:

What will REORG utility do?

A: It will reorganize a tablespace to improve access performance and reorganize indexes so that they are more efficiently clustered. Q: What will the REPAIR utility do?

A: It will repair invalid data with valid data and / or reset status conditions. The data may be your own data or data you would not normally access; space amp pages and index entries. Q: What will the RUNSTATS utility do?

A: RUNSTATS will scan tablespaces and indexes gathering information about utilization of space and efficiency of indexes. The information is stored in the DB2 catalog and is used by the SQL optimizer to select access paths to data during the bind. Q: What will the STOSPACE utility do?

A: This utility updates DB2 catalog columns that tell how much space is allocated for storage groups ,related tablespace and indexes. Q: While the copy pending flag is on, is the tablespace that was just recovered available for use? A: No, it is not available.

Question Bank
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. Ans:6. Which OPCODE to use in RPG for showing compilers to go to O specs Ans:7. DOW & DOU (Difference). Ans:8. OVRDBF for what purpose. Ans:9. Return & TFRCTL (main usage). Ans:10. Sub file option for what purpose. Ans: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 Ans:13. By parm only 75 parameters. Ans:14. OPNQRYF Ans:15. ADDPFCST Ans:16. ADDPFTRG Ans:-

17. SQL if ve will cause an error if + ve > 0 then unsuccessful if 0 then successful,100 no rows found. Ans:18. To get a message 7 char message 132 char Ans:19. SSFLDSPCTL Ans:20. SFLINZ Ans:21. SFLCLR Ans:22. SFCTL Ans:23. SFLSIZ Ans:24. SFLPAG Ans: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. Run-time array. 2. Compile time Array. 3. Pre-run time array 28. How to retrieve the user information in case of a RPGLE Program. Ans:-

29. Which command to be used for backup purpose Ans:30. How to search an element from an array (which OPCODE to use). Ans: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. Ans:32. If we will not use the index with the array variable, what would happen Ans:33. How to define a table in an RPG. Ans: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 Ans:36. What would happen if we use two OVRDBF Command in CLP? Ans:37. The usage of indicators with difference OPCODE (VVP). Ans:38. How to declare SQL statement in RPG/400. Ans:39. Where is the statement Used. (PREPARED) I mean to say in which type of Program Ans:40. DYSLT where to used in Logical or in Physical or in Both of these Ans:41. Function of OPNQRY, LF, is they all objects. Ans:42. Are LF and OPNQRY only used for physical files? Ans:-

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 II) Others System values related to security. III) System values that control password IV) system values that control audit map 44. Difference between DOW & DOU. Ans :45. Difference between Physical file & Source Physical File. Ans :46. I have deleted the source of a CL program. Is it possible for me to retrieve the source of the same. Ans :47. Usage of journal, why is it necessary & incase we dont journal a Phy. File what will happen. Ans:48. How many files could be used in Query 400 at a time. Ans :49. Usage of PGM & ENDPGM. Are they necessary command in CL Program. Ans: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. Ans :51. Difference between LF & Open Query which one is dynamic & which one static. Ans :52. What do you mean by PEP. Ans :53. Type of Data Structures. Ans:54. Can we retrieve the name of user from RPG Ans:55. How to call a program in batch mode from another program. Ans: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. Ans:60. Different method by which you can pass parameters from a program to another. Ans:61. Question related to sub files & there usages of different key words like SFLDSP, SFLCTL, SFLDLT, SFLCLR SFLENDD SFLNVTCHG Ans:62. At what position on a screen can generate a message line. Ans:-

63. Type of Message. Ans:64. What do you means by service program. Ans:65. What is the main difference between RPG/400, RPG IV & RPGILE Ans: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. Ans:68. Can we change the sign on screen for any one subsystem, if yes how? Ans:69. What is the usage of QTEMP library can we store any of our Physical file on QTEMP library. Ans:70. Type of System values Ans: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.
Explain the severity 10, 20 , 30 and 40 errors. Why is %Switch is used in CL What is MONMSG in CL. What is CPF9000 for? DLCOBJ can be used to remove record lock or not? Using UNLOCK opcode, record lock is removed or not? Four ways of defining help on AS/400 Benefits of using Externally described files in RPGLE programs Message subfile gets all the records from Message file. True or False? Explain Activation group What is ODP? Explain access paths in database file. What is the difference between Production Library and Test Library 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

81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93.

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

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

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. CPF9999 Monitors for function check messages for all generic message identifiers. If an error message is not monitored, it becomes a CPF9999 (function check).

Metamor Global Solutions Academy Hyderabad Test on Introduction to AS/400 concepts Batch : Date : Name : Topics : 1. Architecture 2. Source Entry Utility 3. Physical Files 4. Logical Files 5. Display Files Scheme of the Test paper. Section Tot al no. of Qns . 10 5 15 10 Questions from Topic Total Marks : 50 Duration : 1 Hr.

1. True/False 2. Multiple Choice 3. Fill-in the blanks 4. Subjective

1 2 3 4 5 1 1 3 3 2 1 1 1 1 1 2 2 4 4 3 1 - 4 4 1

Fill in the Blanks : Type of AS/400 Architecture is ____________. (Layered) 1.2 Any thing which occupies space in the memory is ___________. (Object) 1.3 Single-level storage means _____________. 1.4 The Library which contains all libraries is _____________. 1.5 ____________ library contains OS/400 and all other libraries. 1.6 The Library which is created for each job is _____________. (QTEMP) 1.7 _______________ is not one library , but many. (QTEMP) 1.8 What are system security levels _______________. (10,20,30,40,50) 1.9 QGPL stands for ______________. (General Purpose library) 1.10 Product Libraries contains _________. 1.11 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 ____
1.1

2.1 this
2.2 2.3 2.4 2.5

_____________ line command is used to copy a block of records to the targets and retain

command. _____________ line command is used to copy a record n times immediately below this record. TABS is a ____________command . Line command to shift the data in a block of records to left by n positions is ______________ Line command to shift the data in a block of records to right by n positions is _____________

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 __________________
2.6 3.1 3.2 3.3 3.4 3.5 3.6 4.1 4.2 4.3 4.4

Physical file contain ___________ no. of record formats. Field reference file is used for _____________________ Keywords used for validity checking are _________________ ____________________ keyword is used for mandatory fill of the field. ____________ keyword is used to provide a default value for the field. _______ is the default usage mode in a Physical File if a blank is specified in usage column. Logical file may contain ____________ no. of record formats. ____________ key word is mandatory for creation of Logical file. Select/Omit key words may be defined in __________________ files. ______________ is a record level key word to identify physical files containing the data to be accessed through the join logical file. Neither (usage) field can be defined in _________________ files.

4.5
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 1.2 1.3 1.4 2.1

OS/400 has got built-in database. A Library cannot contain other Libraries with exception to QSYS. All IBM-supplied libraries have names beginning with the letter Q. All libraries with names beginning with the letter Q are IBM-supplied libraries. SEU can syntax-check HLL and CL source statements

2.2 3.1 3.2 3.3

SEU provides predefined prompts and format lines for HLL and CL. A Physical File cannot be deleted if Logical Files are defined on it. Data in a Physical File can be updated through a Logical File. RANGE (5 10) allows only to have values from 5 to 10 excluding the both.

4.1
4.2 4.3 4.4 4.5 4.6

4.7
5.1 5.2 5.3 5.4 5.5

Join logical file may contain more than one record format. Logical file contains Data. CONCAT and SUBST keywords are valid for Logical Files only. 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. In Multiple Format Logical File separate PFILE keywords are required for each record. C is used for Combined use of input and output of field in Display Files. ERRMSG keyword in Display Files is used to display the system messages. If COLOR keyword is given at record level it applies to the entire record. DSPATR(MDT) will become *ON if Data moves from field OVERLAY keyword is used to display the record format over the previous display.

Multiple-choice :
1.1 a.

No. of layers in AS/400 architecture 1 b. 3 c. 5 d. None of the above

2.1
a.

Command Line command to exclude the records in a member X b. HIDE c. EXCL d. None of the above

3.1
a.

The keyword used to ignore the sign of the field is ALTSEQ b. ABSVAL c. NOSIGN d. None of the above

3.2
a.

REF Keyword is not used with Physical File b. Logical File c. Display File d. None of the above

4.1
a. 4.2

Mandatory Keyword for creation of Join logical file. PFILE b. JFILE c. JLFILE d. None of the above

RENAME is a ______ level keyword and used with ________ files.

a. File , Logical
5.1

b. Record , Logical

c. Field , PF

d. Field , LF

Maximum no. of record formats in a Display File


a.

100

b. 2024

c. 1024

d. 1000

5.2 a. 5.3 a. b. c. d. 5.4 a. 5.5

To protect a field from input keying the keyword used is DSPATR(PC) b. DSPATR(PR) c. DSPPTR d. None of the above

The keywords that are used to specify the system name, date, time and user name are SYSTEMNAME, DATE, TIME, USERNAME SYSTEM, DATE, TIME, USER SYSNAME, DATE, TIME, USER SYSTEMNAM, DAT, TIME, USER To change the attributes of a field ______ must be entered at attribute position. * b. ? c. d. None of the above.

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. Consider the following PF & LF PF1: A A A LF1: A A A A A A R RMT3 FLD1 FLD2 K *NONE S FLD1 FLD2 PFILE(PF1) R RMT0 FLD1 FLD2 5P 0 5P 0

3.1

COMP(EQ 2) COMP(EQ 3)

What is the output of the above LF.

3.1.1 LF2:

Consider PF described in Question 3.1

A A A A A A

R RMT4 FLD1 FLD2 K *NONE S FLD1 S FLD2

PFILE(PF1)

COMP(EQ 2) COMP(EQ 3)

What is the output of the above LF.

3.1.2

Consider PF in Question 3.1.

LF3: A A A A A What is the output of the LF. R RMT5 FLD1 K *NONE S FLD1 O PFILE(PF1)

VALUES(2) ALL

3.2.

Is the LF given below is correct. If not, What is wrong in it. PFILE(PF1)

R REC1 NAME EMPNO DESG SAL S SAL K EMPNO

COMP(GT 5000)

3.3

Consider the following PF and LF PF : PFEMP R RECPF NAME DESG SAL JAIN RAO JAIN Data in PF SE 12000

20A 10A 7S 2

SSE 15000 FACULTY 10000 VIKAS SE RAMARAO SE 9000 SHARMA OB 5000 Write the output of LF

16000

LF : LFEMP R RECLF NAME DESG SAL *NONE NAME SAL DESG PFILE( PFEMP)

K S O S

COMP(EQ JAIN) COMP(LE 12000) COMP(EQ SE)

3.4 3.5

What is the difference between EDTCDE and EDTWRD. Write down the various file level access path key words. In how many ways a record format in a Physical File can be specified. Explain. Write the situations where defining DYNSLT is a must. Define the mandatory keywords for a join logical file. Explain about different types of Logical Files. What are the various Keywords used to define a Join Logical File. Explain.

3.6
4.1 4.2 4.3

4.4

5.1

What is the difference between CAnn key and CFnn key.

Metamor Global Solutions Academy Hyderabad Test on RPG Batch : Date : Name : Topics : 1. RPG Fundamentals 2. RPG Programming 3. Subfiles 4. Printer Files Scheme of the Test Paper. Section Tot Question s from al Topic no. of Qns . 1 2 3 4 10 2 6 2 1 3 - 1 4 7 2 2 1 7 2 Total Marks : 50 Duration : 1 Hr.

1. True/False 2. Multiple 5 Choice 3. Fill-in the 15 blanks 4. 10 Subjective

State True or False.


1.1 1.2 1.3 1.4

1.5 1.6 1.7 1.8 1.9

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.1

2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10

In Compile time array data must be given after SET ON LR statement. (F) Pre-run time array is loaded before compilation. (F) loaded bfore calc op AND operation is given higher precedence than the OR operation. (T) CABxx opcode compares and branches to a subroutine. (F) branched to a label CALL opcode is used to invoke a subroutine. (F) 4 a program Parameters must be passed when CALL opcode is used. (F) CHAIN opcode retrieves the record randomly and reads it. (T) CHAIN opcode is used only with Full procedural files. (T) 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) SFLDSP keyword must be activated only if there are records in the subfile. (T) SFLRCDNBR is a mandatory keyword for Expand subfiles (T) Subfiles are used just for displaying the records. (F) 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) 3.1 3.2 3.3 3.4

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.7 Record description for Program-described files is given in _________ spec. (I)

1.8 __________ file allows a program to communicate interactively with the workstation 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) ____________ 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.1

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, 4digit, 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. a. H-spec 1.2 b. F-spec c. C-spec d. E-spec (c) d. E-spec (a) d. I-spec (a) c. Array d. Output (b) c. I-spec d. Control (b)

Named constants are defined in ____ spec. a. F-spec b. C-spec c. I-spec

1.3

Currency symbol is specified in which spec. a. H-spec b. F-spec c. C-spec

1.4
a.

________ file is processed by Cycle. Primary b. Full procedural

1.5

Opcodes are given in which spec. a. F-spec b. C-spec

2.1

For which array, data is given in the program. a. Compile-time b. Pre-run time c. Run time

(a) d. Compile-run (d) d. 200 (a)

2.2

A maximum of _____ arrays are allowed in a program. a. 100 b. 50 c. 1024

2.3

Which Opcode is used to pass control to the specified program.

a. CALL 2.4

b. EXSR

c. EXEC

d. None (a) d. None

Which Opcode is used to Concatenate Two Character Strings a. CAT b. CONCAT (in LF) c. CATCON

2.5 _____Opcode verifies that each character in the given string is from the given set of characters. (a) a. CHECK 2.6 b. VERFY c. CHRCH d. None (a) d. None (a)

Which opcode is used for division operation. a. DIV b. DIVDE c. DIVD

2.7

Opcode to remove a program from the list of activated programs is 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 (c) d. None (b) c. Tables d. None (c)

2.9

To find the product of 2 fields _________ opcode is used a. MULTI b. MUPLY c. MULT

2.10 OCUR opcode is associated with a. Arrays b. Data structures

2.11 Which of the below mentioned opcodes is associated with Subfiles a. READE b. READP c. READC d. None (a) d. None

2.12 Which opcode is used to find the Square root a. SQRT b. SQR c. SQTR

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. I. Load-all a. I II. Expand b. II III. Single-page c. III

(d)

d. I & II (a)

4.2

The maximum number of record formats in a printer file is a. 1024 b. 1000 c. 2410 d. 2024

4.3

_________ 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 (a) c. 80 d. 738

4.4

Maximum page with in RLU is a. 378 b. 132

Subjective questions.

1.1 1.2
1.3

How many kinds of specifications are there in RPG/400. What are they. What is the purpose of various specifications of RPG/400. 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 | |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 Cspecs) 2.20 What is the out put of KEY1, KEY2 and KEY3 in the following program ? 0000.01 0000.02 0000.03 0000.04 C C C C MOVE 'CBMEDCLT KEY1 7 DSPLY MOVEL'CBMEDCL' KEY2 8 DSPLY b. A

KEY1 KEY2

0001.00 C 0002.00 C 0003.0 0 C

MOVEL'CBMEDC' KEY3 8 P KEY3 DSPLY SETON LR

2.21 What is the output of A,B, C and D in the following program? 0001.00 0002.00 0003.00 0004.00 0006.00 0008.00 0009.00 0010.00 0011.00 0013.0 C C C C C C C C C C Z-ADD1000 Z-ADD2000 MOVE '3000' MOVE '4000' MOVE A MOVE D DSPLY DSPLY DSPLY SETON A B C D C B 40 40 4 4

A B C

LR

2.22 What is the output of $TMP1 and $TMP2 in the following program? 0002.00 0003.00 0004.00 0005.00 0007.00 0008.00 0009.00 C C C C C C C MOVEL*BLANKS $TMP1 DSPLY MOVEL*BLANKS MOVEL'I' 'RMTP' CAT $TMP2 $TMP2 DSPLY SETON $TMP1 8 $TMP2 5 $TMP2 $TMP2 LR

2.23 What is the output of $PAY, $PAYC, $PAYD and $ARR,I in the following program? 0001.01 0003.00 0004.00 0005.00 0006.00 0006.01 0006.02 0007.00 0009.00 0010.00 E I I I I C C C C C $ARR DS 1 10 $PAY 1 8 $PAYD 9 10 $PAYC Z-ADD*ZEROS $VAL 80 MOVE 'ARRAY' $RSN 5 Z-ADD 0217199 $TEMP 82 MOVE $TEMP $PAY DSPLY 3 8

$PAY

0010.01 C 0010.02 C 0011.00 C 0012.01 C 0012.02 C 0012.03 C 0013.0 3 C

$PAYD DSPLY $PAYC DSPLY MOVE *BLANKS $ARR Z-ADD1 I 20 MOVE $RSN $ARR,I $ARR,I DSPLY SETON LR

2.24 What is the output of SUM in the following program?


0001.0 0001.1 0001.2 0001.3 0001.4 0001.5 0001.6

C C C C C C C

SUM

Z-ADD5 Z-ADD0 DOWLE ADD ADD ENDDO DSPLY

A 30 SUM 50 100 I SUM 15 I

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.

3.1

Potrebbero piacerti anche