Pli Qa
Pli Qa
Pli Qa
PL/1 Data Type FIXED DECIMAL FIXED BINARY FLOAT DECIMAL FLOAT BINARY PICTURE Numeric CHARACTER BIT IBM Data Format Packed Decimal Fixed Point Floating Point Zoned Decimal Storage 4 bits / decimal digit, sign Half word or Full word 32 | 64 | 128 Bits Basic Usage Arithmetic Operations Arithmetic Operations Arithmetic Operations
Character Bit
DECLARE PRICE DECIMAL FIXED(5,2); Precision of five digits of which two are decimal fraction Scale Attribute Base attribute Identifier (variable) PL/1 Keyword DECLARE PRICE FLOAT DECIMAL(6); PRICE = 3.12345 DECLARE PRICE DECIMAL FIXED(6,2); PRICE = 1234.56; DECLARE PRICE FIXED BINARY(15);/* 15 bits + sign bit */ PRICE = 123456; DECLARE PRICE FIXED BINARY(31);/* 31 bits + sign bit */ PRICE = 123456; DECLARE PRICE FIXED BINARY(15,2);/* 15 bits + sign. implied 2 bits fraction 1111111111111.11 fraction max .75 decimal*/ 2. What are the data types you used in your project? FIXED DECIMAL FIXED BINARY PICTURE CHARACTER BIT 3. What are default and maximum sizes of FIXED DECIMAL, FIXED BINARY, FLOATDECIMAL, FLOAT BINARY, CHAR and BIT data types?
FIXED DECIMAL Data Format Packed Decimal Type of Data Coded Arithmetic Default Precision 5 decimal digits Max. Precision 15 decimal digits Examples DECLARE EXAMPLE_1 FIXED DEC(7); DECLARE EXAMPLE_2 FIXED DEC(9,2) INIT (24.00); DECLARE EXAMPLE_3 FIXED DEC; FIXED BINARY Data format Fixed-point Type of Data Coded arithmetic Default Precision 15bits(32,767 in decimal) Max. Precision 31bits(2,147,483,647 in decimal) Examples DCL EXAMPLE_1 FIXED BIN(15); DCL EXAMPLE_2 FIXED BIN(31) INIT(2147483647); DCL EXAMPLE_3 FIXED BIN(31,6); FLOAT DECIMAL Data Format Type of Data Default Precision Max Precision Range of Exponent Examples DCL EX_1 DCL EX_2 DCL EX_3 DCL EX_4 DCL EX_5 FLOAT BINARY Data Format Type of Data Default Precision Max Precision Range of Exponent Examples DCL EX_1 DCL EX_2 DCL EX_3 DCL EX_4 DCL EX_5 BIT Data Format Type of Data Default length Maximum Length Floating-point Coded arithmetic 6 decimal digits 16 decimal digits -76 +75 10 to 10 FLOAT DEC(6); DEC(6); FLOAT(6); FLOAT DEC(16) INIT(6E+12); FLOAT DEC INIT(5280); Floating-point Coded arithmetic 21 bits(1,048,576 in decimal) 53 bits -260 +252 2 to 2 FLOAT BIN(6); BIN(6); FLOAT(6); FLOAT BIN(16) INIT(6E+12); FLOAT BIN INIT(5280); Bit Logical none 8000 bits for constants 32767 bits for variables
Examples DCL EX_1 DCL EX_2 DCL EX_3 CHARACTER Data Format Type of Data Default length Maximum Length Examples DCL EX_1 DCL EX_2
Character Alphanumeric none 1000 chars for constants 32767 chars for variables CHAR(20); CHAR(4) INIT(PL/1);
4. What is the storage format of FIXED DECIMAL? Fixed decimal is a packed decimal format as per IBM format. 5. What is the default Scale attribute of DECIMAL and BINARY? Float for Binary Float for Decimal 6. What is the default Base attribute of FIXED and FLOAT? Decimal for Float Decimal for Fixed 7. How many bytes will occupy for FIXED DECIMAL, FIXED BINARY, FLOAT DECIMAL and FLOAT BINARY? PL/1 Data Type FIXED DECIMAL FIXED BINARY FLOAT DECIMAL FLOAT BINARY IBM Data Format Packed Decimal Fixed Point Floating Point Storage 4 bits / decimal digit, sign Half word or Full word 32 | 64 | 128 Bits Basic Usage Arithmetic Operations Arithmetic Operations Arithmetic Operations
8. If a variable first character is starting with A-H or O-Z, then what is the default data type? Float decimal 9. If a variable first character is starting with I-N, then what is the default data type? Fixed binary. 10. How many bytes will occupy for DCL Salary Fix Dec (15,5)?
Fixed Decimal is a packed decimal so for Odd it is (n+1)/2 and for Even (n/2)+1 11. How many bytes will occupy for DCL Salary Fix Dec? Default is 5 hence the value is 3 bytes 12. How many bytes will occupy for DCL Salary Fix Bin (10,2)? The SIGNED and UNSIGNED attributes affect storage requirements, as shown in Table 10 and Table 11. Table 10. FIXED BINARY SIGNED data storage requirements This precision: Occupies this amount of storage (bytes): precision <= 7 1 7 < precision <= 15 2 15 < precision <= 31 4 31 < precision <= 63 8 Table 11. FIXED BINARY UNSIGNED data storage requirements This precision: Occupies this amount of storage (bytes): precision <= 8 1 8 < precision <= 16 2 16 < precision <= 32 4 32 < precision <= 64 8 Hence for this question it will occupy 2 bytes. Mapping DB2 data types to PL/I data types SQL Data Types the Pre-compiler Uses for PL/I Declarations SQLTYPE of SQLLEN of Host PL/I Data Type Host Variable Variable SQL Data Type BIN FIXED(n) 1<=n<=15 500 2 SMALLINT BIN FIXED(n) 16<=n<=31 496 4 INTEGER DEC FIXED(p,s) 484 p in byte 1, s in DECIMAL(p,s) 0<=p<=15 and byte 2 0<=s<=p(1) BIN FLOAT(p) 480 4 REAL or FLOAT(n) 1<=p<=21 1<=n<=21 BIN FLOAT(p) 480 8 DOUBLE PRECISION or 22<=p<=53 FLOAT(n) 22<=n<=53 DEC FLOAT(m) 480 4 FLOAT (single 1<=m<=6 precision) DEC FLOAT(m) 480 8 FLOAT (double 7<=m<=16 precision)
CHAR(n) 452 n CHAR(n) CHAR(n) VARYING 448 n VARCHAR(n) 1<=n<=254 CHAR(n) VARYING n>254 456 n VARCHAR(n) SQL TYPE IS 972 4 Result set locator RESULT_SET_LOCATOR 13. How many bytes will occupy for DCL Salary Fix Bin (30,5)? 4 bytes. Refer above answer for more detail. 14. How many bytes will occupy for DCL Salary Fix Bin? 2 bytes since default is 15 bits. 15. How many bytes will occupy for DCL Salary Fix? 3 bytes since default for fixed decimal is 5 decimal digits. 16. How many bytes will occupy for DCL Salary Bin? 17. How many bytes will occupy for DCL Salary Float? For Float the default attributes is Decimal hence the size is 18. How many bytes will occupy for DCL Salary Dec? For Decimal the default attribute is Float hence the size is 19. How many bytes will occupy for DCL Salary? If there is no data type defined then it will take the 1st character of the variable, here the S belongs to Float Decimal and the size is 20. How many bytes will occupy for DCL Interest? If there is no data type defined then it will take the 1st character of the variable, here the I belong to Fixed Binary and the size is 2 byte. 21. How many bytes will occupy for DCL Sex Char? Default for char is 1 byte. 22. How many bytes will occupy for DCL Flag BIT? Default for BIT is 1 byte. 23. How many bytes will occupy for DCL Name Char (15)? 15 byte
24. What is the equivalent data type of DECIMAL (it is from DB2) in PL/1? Fixed Decimal 25. What is the equivalent data type of SMALL INT (it is from DB2) in PL/1? It is equal to the variable defined with Fixed Decimal of size 3 or 2. 26. What is the equivalent data type of INTEGER (it is from DB2) in PL/1? It is equal to the variable defined with Fixed Decimal of size 3 or 2. 27. What is the equivalent data type of COMP (it is from COBOL) in PL/1? Float binary 28. What is the equivalent data type of COMP-3 (it is from COBOL) in PL/1? Fixed Decimal 29. What is the use of pointer? It points the memory location hence the access is faster. 30. How can you initialize the data into a variable in the declaration? Using INIT attribute. DCL A FIXED DEC(5) INIT(0);
INITIAL attribute Function To set an identifier to an initial value Example DCL EX_1 CHAR(14) INIT(PL/1 TRAINING); 31. How can you initialize the repeated data into a variable in the declaration? Using REPEAT built-in function REPEAT(m,n) Concatenates the given string itself a specified no.of times NAME=REPEAT(PL/1,2); /* NAME=PL/1PL/1 */
32. What is the use of Varying attribute? DCL FIELD CHAR(100) VARYING; It will allocate the size as required and release the rest of the memory space, it can be used for other storage. 33. What is the use of Define attribute? What is the equivalent declaration in COBOL? DEFINED attribute(overlay definition)
Function To equate or share two or more variables to the same storage area Requirement Base identifier must be defined before referenece Example DCL EX_1 CHAR(5); DCL EX_2 DEFINED EX_1; 34. What is the use of Position attribute? POSITION attribute Function To overlay specific part of base identifier Requirement DEFINED attribute must be present Example DCL EX_1 CHAR(5); DCL EX_2 DEFINED EX_1 POSITION(3); 35. What is the use of Aligned and Unaligned attributes? /* http://publib.boulder.ibm.com/infocenter/ratdevz/v7r5/index.jsp? topic=/com.ibm.ent.pl1.zos.doc/topics/lsh-aligned-z.htm - for reference */ ALIGNED specifies that the data element is aligned on the storage boundary corresponding to its data-type requirement. UNALIGNED specifies that each data element is mapped on the next byte boundary, except for fixed-length bit strings, which are mapped on the next bit.
>>-+-ALIGNED---+----------------------------------------------->< '-UNALIGNED-'
Defaults are applied at element level. UNALIGNED is the default for bit data, character data, graphic data, widechar data and numeric character data. ALIGNED is the default for all other types of data. Requirements for the ALIGNED attribute are shown in Table 26. Alignment and storage requirements for program control data can vary across supported systems. Complex data requires twice as much storage as its real counterpart, but the alignment requirements are the same. ALIGNED or UNALIGNED can be specified for element, array, structure, or union variables. The application of either attribute to a structure or union is equivalent to applying the attribute to all contained elements that are not explicitly declared ALIGNED or UNALIGNED. The following example illustrates the effect of ALIGNED and UNALIGNED declarations for a structure and its elements:
Declare 1 S, 2 X 2 A 3 3
/* /* /* /* /* /* /* /* /*
unaligned by default aligned explicitly aligned from A unaligned explicitly unaligned from C aligned explicitly unaligned from C aligned from A aligned by default
*/ */ */ */ */ */ */ */ */
For more information about structures and unions, refer to Structures and Unions.
36. What is the use of ENTRY variable? ENTRY indicates the variable is an external subroutine. ENTRY STATEMENT Allows us to direct the compiler to generate coding to convert one or more arguments to conform to the attribute of the corresponding parameters, should arguments and their corresponding parameters have different attributes. e.g. DCL SUBRT ENTRY (FIXED DEC(7,2),FIXED DEC(7,2),FIXED DEC(7,2)); DCL (X,Y,Z) FLOAT DEC(6); ................ CALL SUBRT(X,Y,Z); When the subroutine SUBRT is invoked X,Y,Z are converted to FIXED DEC(7,2). 37. What are the default alignments of FIXED DECIMAL, FIXED BINARY, FLOAT DECIMAL, FLOAT BINARY, CHAR and BIT data types? CHAR and BIT default is UNALIGNED and for rest of the data types it is ALIGNED. 38. What are the iterative statements in PL/1? DO LOOPS DO UNTIL(expression) /* test is after the loop body */ /* loop terminates when the condition becomes true */ DO WHILE(expression) /* test is before the loop body */ /* loop terminates when the condition becomes false*/ DO UNTIL (expression); . . END;
Expression can be a logical expression or a flag variable (BIN (1)). A flag variable with a value of binary one is true. A binary value of zero is false. Iterative DO loop value DO control-variable = initial value TO limit value BY modification [WHILE(expression) | UNTIL(expression)]; Example: J=10; K=5; L=2; DO I=J TO K BY L; . . END; Example(s): DO I=1 TO 100 BY 1; */ DO I=100 TO 1 BY -1; DO I=1 BY 1; /*termination condition must be inside the loop*/ DO I=0.1 BY 0.1 TO 1.0; DO I=1 TO 5,10 TO 20, 25 TO 50 BY 2; DO I=1,4,7,22; DO I=1 TO 100 WHILE(X<100); /* loop terminates when I reaches 100 or >=100*/ Commas separate specifications as below DO I=1 TO 10, 11 BY 0 WHILE(A=B); /* after I = 1 to 10, continuous looping at I = 11 takes place */ A=B. At this time loop terminates only when A is not = B DO I='ABC','DEF','GHI' 39. What is the difference between DO-WHILE and DO-UNTIL? DO-WHILE: /* DO I=1 BY 1 TO 100 is also OK
while
loop execute until fail 1st time itself it will check the condition
40. What is the use of SELECT statement? Can you write the syntax? It is equal to switch in C and evaluate in COBOL. Its compulsory to give OTHERWISE option also else the job will tho ONCODE = 3 Select Statement SELECT (expression which is optional); WHEN (expression) action 1; WHEN (expression) action 2; WHEN (expression) action 3; OTHERWISE action 3; END; Example: SELECT (CODE) WHEN (1) DO; . . END; WHEN (2) CALL SUBRTN; OTHERWISE CALL INVCODE; END; SELECT; WHEN(CODE<10) DO; . . END; WHEN (CODE>=10) CALL SUBRTN; OTHERWISE CALL ERRORTN; END; 41. What is the equivalent SELECT statement in COBOL? EVALUATE in COBOL 42. What are the Storage classes in PL/1? Storage Control AUTOMATIC specifies that storage is allocated upon each entry to the block that contains the storage declaration. The storage is released when the block is exited. STATIC specifies that storage is allocated when the program is loaded. The storage is not freed until program execution is completed. CONTROLLED specifies that you maintain full control over the allocation and freeing of storage with the ALLOCATE and FREE statements. Multiple allocations of the same controlled variable in the same task, without intervening freeing, stack generations of the variable.
BASED, like CONTROLLED, specifies that you maintain full control over storage allocation and freeing. Multiple allocations are not stacked but are available at any time. Each allocation can be identified by the value of a locator variable. The default storage class is AUTOMATIC Automatic Based Static Controlled Automatic and based variables can have internal scope only. Static and controlled variables can have internal and external scope. 43. What is the difference between Auto and Static storage class? Automatic Internal scope Static Internal/External scope, the value will not change until the pgm or application terminates. 44. What is the difference between Defined attribute and Based storage class? DCL P POINTER; DCL A(100) FIXED DEC(5) BASED(P); DCL EX_1 CHAR(5); DCL EX_2 DEFINED EX_1; Both are same, in defined the structure is same and use the same memory allocation. In based it points the pointer and accessing the same memory allocations. 45. What is the use of Controlled Storage class? For dynamic allocation. Controlled Storage DCL A(100) FIXED DEC(5) CONTROLLED; /* A does not exist here ALLOCATE A; /* Storage for A is allocated here GET LIST(A); . . . use A here FREE A; /* Storage for A is de-allocated here */ */ */
Note that controlled variables after allocation exist until they are explicitly freed. They are not affected by block boundaries. For arrays the size specification may be deferred until ALLOCATE DCL A(*) FIXED DEC(5) CONTROLLED; ALLOCATE A(100); DCL TABLE(*,*) BIN(1) CONTROLLED; ALLOCATE TABLE(100,100);
Note that a repeat allocation before a free results in a new generation of the variable. The previous generation is pushed into a stack meant for storing multiple generations of controlled variables. A free will then cause the previous generation to be popped out of the stack. Example follows: DCL BUFF CHAR(100) CONTROLLED; ALLOCATE BUFF; BUFF = 'THIS IS FIRST GENERATION OF BUFF'; PUT LIST(BUFF); /* this is first generation of buff */ ALLOCATE BUFF; BUFF = 'THIS IS SECOND GENERATION OF BUFF'; PUT LIST(BUFF); /* this is second generation of buff*/ FREE BUFF; PUT LIST(BUFF); /* this is first generation of buff */ FREE BUFF; /* No BUFF in existence */ The ALLOCATION(X) built in function returns a FIXED BINARY(31) value indicating the number of generations of X that exist. DCL 1 PRODUCT BASED(Q), 2 DESCRIPTION CHAR(20), 2 CODE FIXED DEC(4); DCL P POINTER; ALLOCATE PRODUCT SET(P); /* note that Q is not changed by this */ P->PRODUCT.DESCRIPTION = 'SCREW'; /* PRODUCT is referenced by a locator qualifier */ FREE P->PRODUCT; /* FREE the storage for the variable this way*/
DCL NULL BUILTIN; /* NULL is a builtin function which returns a NULL pointer */ 46. What is the use of ADDR ()? Instead of using PTR we can use ADDR(), both are same. 47. What is the implicit and explicit reference? Implicit reference is the one we assigned the value to the variable at the time of declaration. Explicit reference is the one we assigned the value to the variable depends on the program functionality. Example for Implicit reference: DCL A CHAR(5) INIT (INDIA); Example for Explicit reference: DCL A CHAR(5); IF Country = 1 THEN A = INDIA;
IF Country = 2 THEN A = PAKISTAN; 48. Explain about Based Storage class? Declare two variables with implicit and explicit reference in Based storage class? BASED storage class functionality is similar to DEFINED attribute; both are going to use memory location of other variable. The only difference is the BASED will do complete redefine of the memory allocation where DEFINED can go with partial memory allocation. Example for Implicit reference: DCL 1 RGF_KEY1, 2 CUSIP 2 REC_DATE CHAR (09) INIT((9)' '), FIXED(09) INIT(0);
DCL 1 RGF_KEY1_R CHAR(14) BASED(ADDR(RGF_KEY1)); Example for Explicit reference: DCL P POINTER; P = ADDR(RGF_KEY1); DCL 1 RGF_KEY1_R CHAR(14) BASED P; IF KEY = 1 THEN P = ADDR(RGF_KEY1); IF KEY = 2 THEN P = ADDR(RGF_KEY2); 49. What are Allocate and Free statements? Can you write the syntaxes? DCL A(100) FIXED DEC(5) CONTROLLED; /* A does not exist here ALLOCATE A; /* Storage for A is allocated here */ GET LIST(A); . . . use A here FREE A; /* Storage for A is de-allocated here 50. What is an Array? Collection of values of same data type. Arrays DCL DCL DCL DCL DCL STUD_AVG (365) FIXED DEC(4,2); TABLE(0:11) FIXED DEC(5); GRAPH(-3:3) FIXED DEC(5,2); LIST(-2:6) FIXED BIN(15,0) INIT(1,2,4,21,2,3,4,80,90); TABLE(3,2) FIXED DEC(5); COLUMN 1 (1,1) (2,1) (3,1) COLUMN 2 (1,2) (2,2) (3,2) */
*/
DCL AXIS(-3:3,-4:4) FLOAT DEC(6) INIT((63)0); DCL B(10) FIXED DEC(3) INIT((7)0,1,2,3); DCL TABLE(10) CHAR(2) INIT((10)(2)'A');
DCL TABLE(10) CHAR(5) INIT((10)(1)'EMPTY'); /* note the (1) !. It is required ! */ Access an element as below AXIS(-3,-4) /* first element) Subscripts can be nested as below DCL X(5) FIXED BIN(15,0) INIT(10,20,30,40,50); DCL Y(3) FIXED BIN(15,0) INIT(3,2,1); I=3; Z=X(Y(I)); /* Z is 10 */ 51. How many elements are in the following arrays: A A A A A A (10) (1:10) (10, 20) (1:10, 1:20) (-5:5, 1:7, -2:2) (11, 7, 5) 10 elements 10 elements 10 * 20 elements 10 * 20 elements 11 * 7 * 4 3 dimensional 11 * 7 * 5 3 dimensional 52. What is Lower bound and Upper bound? DCL ARRAY(*) FIXED BIN(31); DCL LOW FIXED BIN(31); DCL HIGH FIXED BIN(31); DCL (HBOUND,LBOUND) BUILTIN; LOW = LBOUND(ARRAY,1); /* second parm is the dimension we are looking at*/ HIGH = HBOUND(ARRAY,1); /* LOW and HIGH are now the bounds of ARRAY*/ Eg: A (1:10, 1:20) In the above example 1 LBOUND and 10,20 HBOUND 53. How can you calculate the extents of an array? We need to multiply the position in the array dimension. E.g.: In two dimensional array A of size (10, 10) extend of A (5,6) is 30. (i.e. 5*6=30.) 54. What are the disadvantages of an Array? We can store only same data type. 55. What is the definition of Structure?
Structures DCL
EMP_ADDRESS, 2 NAME CHAR(20), 2 STREET CHAR(20), 2 CITY CHAR(20), 2 STATE CHAR(20); READ FILE(INFILE) INTO (EMP_ADDRESS); Notes: Level 1 is the Major structure level which does not have attributes. However other storage qualifiers like BASED(P) are to be specified here. Any number > 1 can represent lower levels Attributes and INIT are defined only at elementary levels There is no equivalent to the COBOL FILLER STRING(EMP_ADDRESS) concatenates all the elements into one character string. STRING(structure variable) can also be used as a pseudo variable (on the LHS of an assignment statement.
56. What is the difference between Array and Structure? Array can store many values of same data type. Structure can store variables/values of different data type. Array is the subset of structure. 57. What are the maximum level numbers in PL/1? Maximum level number is 255 and the maximum level is 15. 58. Can you declare a sample structure with the name of Student? Refer ans of 55. 59. What is the use of LIKE and BYNAME option? LIKE: need to create a structure which is the replica of existing one then we can use this. Eg; DCL 1 MYOBJDESC LIKE MQOD; BYNAME: need to move the elementary variable between two structures but in different order in two structures. Both the elementary variable should be in same elementary level. 60. Explain about pointer variable? POINTER VARIABLES A pointer variable is a special type of variable you can use to locate data - i.e to point to data in main storage. Before a reference can be made to a based variable , a value must be given to the pointer . This can be done in one of the following ways.
1. By assignment of the value returned by the ADDR built-in function. This facilitates Overlay-defining of identifiers that do not have same base, scale and precision. e.g. DCL VALUE1 BIT (32) BASED (P); DCL VALUE2 FLOAT (6); P=ADDR(VALUE2);
2. By assignment of the value of another pointer. Facilitates POINTER values for subsequent use by the program. e.g. DCL (P,Q) POINTER; P=ADDR(AREA); Q=P; 3. With the SET option of a READ or LOCATE statement. Facilitates processing of records in their buffers rather than in storage work areas. e.g. READ FILE(INPUT) SET(P); LOCATE FILE (OUTPUT) SET(Q); 4. By an ALLOCATE statement. Facilitates List processing. e.g. DCL (P,Q) POINTER; DCL AREA CHAR(100) BASED(P); ALLOCATE(AREA); ALLOCATE(AREA) SET(Q); 61. Declare 1 Payroll, _/* major structure name */ 2 Name, _/* minor structure name */ 3 Last char (20), _/* elementary name */ 3 First char (15), 2 Hours, 3 Regular fixed dec (5,2), 3 Overtime fixed dec (5,2), 2 Rates, 3 Regular fixed dec (3,2), 3 Overtime fixed dec (3,2); In the above structure how can you initialize the value into Overtime, Regular and First variables? We need to initialize each variable at its elementary level with INIT attribute. 62. Can you use array in the structure? Yes. 63. What is the difference between the following Declare 1 Payroll (10), 2 Name, 3 Last char (20), 3 First char (15), Declare 1 Payroll, 2 Name, 3 Last (10) char (20), 3 First (10) char (15),
In the second one elementary level has one value only but in first it has array. 64. What are the BUILTIN functions in PL/1? String-Handling Built In Functions The string-handling built-in functions simplify the processing of bit and character strings. They are: BIT HIGH MPSTR TRANSLATE
UNSPEC VERIFY
Arithmetic Built In Functions The arithmetic built-in functions allow you to: 1. Control conversion of base, scale, mode, and precision both directly and during basic arithmetic operations. 2. Determine properties of arithmetic values. For example, the SIGN function indicates the sign of an arithmetic value. They are: ABS ADD BINARY CEIL COMPLEX CONJG DECIMAL DIVIDE FIXED FLOAT FLOOR IMAG MAX MIN MOD MULTIPLY PRECISION REAL ROUND SIGN TRUNC
Mathematical Built In Functions The mathematical built-in functions provide mathematical operations. They are: ACOS COSD LOG SINH ASIN COSH LOG2 SQRT ATAN ERF LOG10 TAN ATAND ERFC SIN TAND ATANH EXP SIND TANH result. All of these functions operate on floating-point values to produce a floating-point
Array-Handling Built In Functions The array-handling built-in functions operate on array arguments and return an element Value. They are: ALL LBOUND ANY POLY DIM PROD HBOUND SUM Condition-Handling Built In Functions The condition-handling build-in functions allow you to investigate the cause of enabled conditions. They are: DATAFIELD ONCHAR ONCODE ONCOUNT ONFILE ONKEY ONLOC ONSOURCE
Use of these functions is in context (returns a meaningful value) when within the scope of an ON-unit entered for the condition specific to the built-in function, or within an ON-unit for the ERROR or FINISH condition when raised as an implicit action. All other uses are out of context.
Storage Control Built In Functions The storage-control built in functions allow you to determine the storage requirements and location of variables, to assign special values to area and locator variables, to perform conversion between offset and pointer values, and to obtain the number of generations of a controlled variable. They are: ADDR ALLOCATION BINARYVALUE CURRENTSTORAGE EMPTY ENTRYADDR NULL OFFSET POINTER POINTERADD POINTERVALUE STORAGE SYSNULL
Input / Output Built In Functions The Input / Output built-in functions allow you to determine the current state of a file. They are: COUNT LINENO SAMEKEY
Miscellaneous Built In Functions The built-in functions that do not fit into any of the foregoing classes are: DATE DATETIME PLIRETV TIME PLIRETC 65. What are the syntaxes of SUBSTR, VERIFY, TRANSLATE And INDEX? What is the use of each function? Function 1.CHAR 2.CHAR(x,n) n is the length of the result BIT INDEX LENGTH Purpose Converts a given value to a character string Example(s) DCL A FIXED DEC (5); DCL B CHAR(5); A=175; B=CHAR(A); /* B= 175 */ X=BIT(NUMBER); /* X=BIT STRING */ NAME=PL/1 LANG; IND=INDEX(NAME,PL/1); /* IND=1 */ DCL NAME CHAR(20) VARYING; NAME = PL/1; LTH=LENGTH(NAME); /* LTH=4 */ NAME=REPEAT(PL/1,2); /* NAME=PL/1PL/1 */ X=PL/1 LANGUAGE; Y=SUBSTR(X,1,4); /* Y=PL/1 */ NAME=ABCD;
Converts a coded arithmetic data item or char string to a bit-string Searches a string for a specified bit or char string Finds the length of a given char string or bit string
Concatenates the given string itself a specified no.of times To manipulate smaller part of larger char or bit string Substitutes one char with
another VERIFY Examines two strings to verify that each char or bit of the first string is represented in the second string
66. What is Pseudovariable? Pseudo-variables Pseudo-variables represent receiving fields. Except when noted in the description, Pseudo-variables : Can appear on the left of the assignment symbol in an assignment.
the
Can appear in a data list of a GET statement or in the STRING option of a PUT statement. Some of the commonly used Pseudo-variables are: ONCHAR ONSOURCE STRING SUBSTR 67. How can you declare a BUILIN function? DCL (built in function name) BUILTIN; 68. How many types of procedures in PL/1? Two types are there. Internal and External procedure (Subroutine). 69. Can you write the first statement in PL/1? MYPROG:PROCEDURE OPTIONS(MAIN); 70. What is the use of Recursive? RECURSIVE PROCEDURES When a procedure invokes itself , it is called as recursive procedure. To specify a procedure as RECURSIVE we need to give RECURSIVE option with PROCEDURE statement. e.g. N-FACTORIAL: PROCEDURE (N) RECURSIVE; K=N-1; IF K = 1 THEN I=N; ELSE I=N*N_FACTORIAL(K); RETURN(I); END N_FACTORIAL; 71. Difference between RETURNS and RETURN?
//USERAA1 JOB MSGCLASS=A,NOTIFY=USERAA //MYSTEP EXEC PROC=IEL1CLG,REGION.PLI=1M //PLI.SYSIN DD * MYPROG: PROCEDURE OPTIONS(MAIN); DCL FIELD1 FIXED DECIMAL(7,2); DCL FIELD2 FIXED DECIMAL(7,2); GET DATA (FIELD1,FIELD2); PUT SKIP LIST(SUM(FIELD1,FIELD2)); SUM:PROCEDURE (A,B) RETURNS(FIXED DECIMAL(7,2)); DCL A FIXED DECIMAL(7,2); DCL B FIXED DECIMAL(7,2); RETURN (A+B); END SUM; END MYPROG; /* //GO.SYSIN DD * FIELD2=1.23,FIELD1=3.45; /* // RETURNS We need to give in the definition RETURN It will return the value. RETURN Statement The RETURN statement terminates execution of the procedure that contains the RETURN statement. RETURN (expression); The RETURN statement with expression is used to terminate a procedure invoked by a function reference. 72 What is the difference between Function and Procedure? Function: Returns a single value. It will be called inside the same program. Procedure: We can pass and get more than one value. It may be internal or external Internal procedure max length is 44. External procedure nothing but subroutine needs to declare with entry statement. 73. What is the difference between External and Internal procedures? External procedure or subroutines needs to DCL with ENTRY statement and it are outside the main program. It can be invoked by call statement. Internal proc needs to start with alphabetic and can be length of 44; it will be invoked inside the main program itself.
74. What is REORDER? The functionality of REORDER is to avoid dead lock situation in the program execution. It is mainly related to performance. 75. How can you declare External procedure? DCL SUM ENTRY(FIXED DEC(3),FIXED DEC(3)) RETURNS(FIXED DEC(3)) EXTERNAL; ENTRY keyword denotes that it is an External proc. 76. What is the maximum length of procedure name for Internal and External procedures? Maximum length of internal proc is 44. Maximum length of external proc is 8. 77. What is Call by value and Call by reference? Format for PROCEDURE statement entry-constant: PROCEDURE (parameter, parameter,) RETURNS(attribute) OPTIONS (Options-list) Format for ENTRY statement entry-constant: ENTRY (parameter, parameter,) RETURNS(attribute) OPTIONS (Options-list) Important OPTIONS are BYADDR or BYVALUE Specify how all parameters defined for this procedure entry are passed. If you specify BYADDR, parameters are received by address. If you specify BYVALUE, parameters are received by value. Any change to a parameter that is being passed by value is not reflected in the argument passed by the caller. BYADDR is the default BYVALUE can be specified for EXTERNAL PROCEDURE statements, but it cannot be specified for internal procedures or ENTRY statements. Additionally BYVALUE entry points can only have scalar arguments and return values that are either POINTER or REAL FIXED BINARY(31,0) BYADDR is the default. 78. How you will call Internal and External procedures? Both we need to invoke tho CALL statement but for external proc we need to declare the subroutine name with ENTRY keyword. Internal: CALL P1000_INITIAL_PROCESS; P1000_INITIAL_PROCESS: PROC; External:
DCL SUM ENTRY(FIXED DEC(3),FIXED DEC(3)) RETURNS(FIXED DEC(3)); CALL SUM(Parameter); 79. What is the Call statement? Tho CALL statement only we can invoke any procedures. 80. What is Parameter and Argument? Parameter is the values/variables passed from the main program. Argument is the values/variables used in the subroutine. 81. How can you pass the data from JCL to PL/1? How many methods are there? Two methods, either through SYSIN parameter or through PARM parameter. 82. How can you return the return code from PLI to JCL? PLIRETC (value) 83. What are PLIRETC and PLIRETV? PLIRETC is a user defined return code that we can pass to the JCL to display after job execution. PLIRETV is used to capture the return value, from a sub-program, returned by PLIRETC function. 84. How can you access the data from PARM parameter (it is JCL parameter) to PL/1? MYPROG:PROCEDURE (PARM) OPTIONS(MAIN); 85. What is the first executable statement in PL/1? Main statement is the first executable statement. 86. What are Signal and Revert conditions? SIGNAL Statement You can raise a condition by means of the SIGNAL statement. This statement can be used in program testing to verify the action of an ON-unit and to determine whether the correct action is associated with the condition. The established action is taken unless the condition is disabled. If the specified condition is disabled, the SIGNAL statement becomes equivalent to a null statement. The syntax for the SIGNAL statement is: SIGNAL Condition; REVERT statement
null on-Unit The effect of a null statement on-unit is to execute normal return from the condition. Use of the null on-unit is not the same as disabling, for two reasons: A null ON-unit can be specified for any condition, but not all conditions can be disabled. Disabling a condition, if possible, can save time by avoiding any checking for this condition. (If a null ON-unit is specified, the system must still check for the raising of the condition). The execution of an ON statement establishes an action specification for a condition. Once this action is established, it remains established throughout that block and throughout all dynamically descendent blocks (blocks entered via CALL or a function reference) until it is overridden by the execution of another ON statement or a REVERT statement or until termination of the block in which the ON statement is executed. Example for REVERT:PROC1: PROCEDURE; ON CONVERSION BEGIN; END; B: PROC2; ON CONVERSION BEGIN; END; . . REVERT CONVERSION; END PROC2; END PROC1; Note: Dynamic descendency refers to the fact that ON-units are inherited from the calling procedure in all circumstances. Dynamic descendency is not known until run time, since a procedure can be called from anywhere where it is visible. /* Overrides ON unit in PROC1 */
87. A) what are the ON-UNIT conditions in PL/1? Can you give some conditions? ONCODE - returns the error code, binary value, for diagnostic purposes ONLOC - returns the procedure/function name, as a string, where the error occurred ONFILE returns the file in which error occurs ONSOURCE return the field name ONCHAR ONKEY 87. B) Explain about conditional handling.
Condition Handling Condition Prefixes You can specify whether or not some conditions are enabled or disabled. If a condition is enabled, the raising of the condition executes an action. If a condition is disabled, the raising of the conditions does not execute an action. Enabling and disabling can be specified for the eligible conditions by a condition prefix. Example: (SIZE): L1 X=(I**N); /* enable SIZE condition for this statement only */ The conditions that are always enabled unless they are explicitly disabled by condition prefixes are: CONVERSION FIXEDOVERFLOW OVERFLOW UNDERFLOW ZERODIVIDE Each of the preceding conditions can be disabled by condition prefix specifying the condition name preceded by NO with intervening blanks as below. NOCOVERSION NOFIXEDOVERFLOW NOOVERFLOW NOUNDERFLOW NOZERODIVIDE The conditions that are always disabled unless they are enabled by a condition prefix are: SIZE SUBSCRIPTRANGE STRINGRANGE STRINGSIZE All other conditions are always enabled and cannot be disabled . These conditions are: AREA ATTENTION CONDITION ENDFILE ENDPAGE ERROR FINISH KEY NAME RECORD TRANSMIT UNDEFINEDFILE
87. C) Explain about the ON-UNITS conditions classification. Classification of Conditions The conditions are classified as follows: Computation conditions-those associated with data handling, expression evaluation, and computation. The conditions are:
CONVERSION SIZE FIXEDOVERFLOW UNDERFLOW OVERFLOW ZERODIVIDE If a computational conditional (except UNDERFLOW) is raised and the condition is disabled, the program is in error; Input/output conditions-those conditions associated with input and output. They are: ENDFILE When end of file is reached KEY Incorrect KEY for a keyed data set UNDEFINEDFILE File could not be opened ENDPAGE End of page on PRINT file TRANSMIT I/O error NAME On GET DATA when incorrect items in input RECORD Typically when buffer is too small for For read. For write of fixed length records it Can occur if buffer is larger than record size. Program-checkout conditions-those conditions that facilitate the debugging of a program. They are STRINGSIZE STRINGRANGE SUBSCRIPTRANGE If SUBSCRIPTRANGE is raised is disabled, the program is in error. Because this checking involves a substantial overhead in both storage space and run time, it usually is used only in programs testing. It is removed for production programs, because the above are normally disabled conditions. Miscellaneous conditions, which are: AREA, ERROR, FINISH, CONDITION
record
88. What is exceptional handling? Exceptional handling is nothing but the error handling using SIGNAL statement and ONUNIT conditions. 89. What is the error codes received from your project in PL/1? How do you resolve?
ONCODE meaning of the ONCODE in a SELECT group, no WHEN clause is selected and no OTHERWISE clause is 3 present 4 SIGNAL FINISH, STOP or EXIT statement executed 9 SIGNAL ERROR statement executed 10 SIGNAL NAME statement executed or NAME condition occurred 20 SIGNAL RECORD statement executed 21 Record variable smaller than record size 22 Record variable larger than record size
23 24 40 41 42 43 44 45 46 50 51 52 53 54 55 56 57 58 70 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
Record variable length is zero or is too short to contain the key a record with a length of zero was read from a REGIONAL data set SIGNAL TRANSMIT statement executed. transmission error in output data set transmission error in input data set transmission error on output to VSAM index set transmission error on input from VSAM index set transmission error on output to VSAM sequence set transmission error on input from VSAM sequence set SIGNAL KEY statement executed specified key can not be found specified key already exists key is out of sequence during creation of a INDEXED or REGIONAL data set key conversion error either the specified key is the null string or begins with X'FF' or a REWRITE was attempted but the embedded key has changed key is outside of the data set limits No space available to insert a record key is outside of range SIGNAL ENDFILE statement executed or ENDFILE condition occurred SIGNAL UNDEFINEDFILE statement executed conflicting attributes between DECLARE statement and OPEN statement Conflict between file attributes and physical organization of data set data set specification is incomplete DD statement is missing in JCL an I/O error occurred during initialization of DIRECT OUTPUT file LINESIZE greater than maximum conflicting attributes between DECLARE statement and JCL DD statement conflicting attributes between DECLARE statement and JCL DD statement password not specified or invalid SIGNAL ENDPAGE statement executed or ENDPAGE condition occurred ENV() option invalid for file accessing VSAM data set. error while opening a VSAM data set error while opening a data set REUSE specified, but data set is not reusable Alternate index specified for an empty VSAM data set.
96 100 150 151 300 310 320 330 340 341 350 360 361 362 400 500 510 520 521 600 601-639 1002 1003 1004 1005 1007 1008 1009 1011 1012 1013 1014
Attempt to OPEN the MSGFILE(SYSPRINT) file after a subtask has been created SIGNAL PENDING statement executed or PENDING condition occurred SIGNAL STRINGSIZE statement executed or STRINGSIZE condition occurred truncation occurred while assigning a mixed-character string SIGNAL OVERFLOW statement executed or OVERFLOW condition occurred SIGNAL FIXEDOVERFLOW statement executed or FIXEDOVERFLOW condition occurred SIGNAL ZERODIVIDE statement executed or ZERODIVIDE condition occurred SIGNAL UNDERFLOW statement executed or UNDERFLOW condition occurred SIGNAL SIZE statement executed or SIZE condition occured SIZE condition occured during I/O operation SIGNAL STRINGRANGE statement executed or STRINGRANGE condition occurred insufficient free storage for allocation of a based variable insufficient space in target area for assignment of source area SIGNAL AREA statement executed SIGNAL ATTENTION statement executed or ATTENTION condition occurred SIGNAL CONDITION (name) statement executed SIGNAL CHECK statement executed SIGNAL SUBSCRIPTRANGE statement executed, or SUBSCRIPTRANGE condition occured subscript of iSUB-defined variable lies outside bounds of corresponding dimension of base variable SIGNAL CONVERSION statement executed Invalid conversion attempted during input/output of a character string. GET or PUT STRING specifies data exceeding size of string output not allowed due to previously raised TRANSMIT or KEY condition PAGE, LINE or SKIP attempted for nonprint file. DISPLAY() REPLY () statement uses zero length expression REWRITE or a DELETE statement not preceded by a READ statement invalid data for a GET STRING DATA statement. I/O statement conflicts with the file attributes I/O error with no more information provided by OS READ SET or READ INTO statement not preceded by a REWRITE statement REWRITE or DELETE statement can not be executed as the preceding READ statement has not yet completed number of incomplete operations reaches maximum
event variable for an input/output operation is already in use. file is not open due to an UNDEFINEDFILE condition EOF encountered in data before end of data-list or format-list attempt to close file not opened in current task I/O attempted before WAIT statement executed to ensure completion of previous 1020 READ 1021 record can not be accessed as it is locked by another file in this task 1022 unable to extend VSAM data set 1023 file closed but records still locked by a subtask 1024 sequence of I/O operations on device-associated file is incorrect 1025 Insufficient virtual storage available for VSAM to complete request 1026 no position established in VSAM data set 1027 Record or VSAM control interval already held in exclusive control 1028 volume not mounted 1029 repositioning failed in VSAM data set 1030 error occurred during index upgrade on a VSAM data set 1031 invalid sequential write attempted on VSAM data set 1040 no more space available for output data set 1500-1564 computational error while executing a builtin-function 2002 WAIT statement cannot be executed because of restricted system facility 2050 WAIT statement would cause a permanent wait 3000 edit directed I/O would lead to a loss of significant digits or sign 3001 value of W field in F format specification too small 3006 PIC description of target does not match source 3009 mixed-character string contains a shift-out but no shift-in 3010 mixed-character string contains invalid data 3011 MPSTR built-in function contains invalid character 3012 retry for graphic conversion error not allowed. 3013 graphic string is too long 3014 graphic or mixed string does not conform to the continuation rules 3015 X or GX constant has an invalid number of digits 3016 Improper use of graphic data in stream I/O Invalid graphic, mixed, or DBCS continuation when writing stream I/O to a file 3017 containing fixed-length records 3797 attempt to convert to or from graphic data 3798 ONCHAR or ONSOURCE pseudovariable used out of context
3799 3800 3801 3808 3809 3810 3901 3904 3906 3907 3909 3910 3911 3912 3913 3914 3915 3920 3951 3952 3953 4001 8091 8092 8093 8094 8095 8096 8097 9002 9050 9200 9201
ON-unit was entered due to a CONVERSION condition and the character that caused the condition is used but has not been corrected by use of the ONSOURCE or ONCHAR pseudovariables. length of data aggregate exceeds system limit Array structure element not mapped Aggregate cannot be mapped in COBOL or FORTRAN data aggregate exceeded the maximum length extent of an array exceeds maximum task variable is already used COMPLETION pseudovariable specifies an event variable that is already in use assignment to an event variable that is already active DISPLAY statement specifies an event variable that is already active insufficient main storage available to create subtask ( using CALL statement ) maximum number of subtasks reached WAIT statement in ON-unit references an event variable already being waited for CALL with TASK option in block invoked while executing PUT FILE(SYSPRINT) statement CALL statement with TASK option specifies an unknown entry point FORTRAN or COBOL already invoked by an other task multitasking library not selected in the link-edit step An out-of-storage abend occurred OpenEdition callable service BPX1MPI failed OpenEdition callable service BPX1MP failed OpenEdition callable service BPX1PTB failed CONTROLLED variable not allocated during GET DATA operation exception privileged operation exception EXECUTE exception protection exception addressing exception specification exception data exception GOTO statement references label in an inactive block program terminated by an abend program check in SORT/MERGE program VM does not support SORT
procedure to be fetched cannot be found transmission error during fetch of a procedure FETCH/RELEASE not supported in VM debugging tool not available a MAIN procedure from a PL/I routine can not be fetched under CICS attempt to release a load module containing a high-level language program, which is not PL/1 attempt to fetch a subroutine using the PLICALLA entry point invocation of an Language Environment for MVS & VM service failed
90. What are the Preprocessors in PL/1? %ACTIVATE %PAGE %assignment %DEACTIVATE %DECLARE %DO %END %GOTO %IF %INCLUDE %INSCAN %ITERATE %LEAVE %NOTE %null %REPLACE %SELECT 91. What are the different files in PL/1? TYPES OF DATA SETS SUPPORTED BY PL/I Type of data set PL/I organization Sequential CONSECUTIVE Indexed sequential INDEXED Direct REGIONAL KSDS, ESDS, RRDS VSAM FILE INPUT / OUTPUT Action PL/I statement Define the File DECLARE filename FILE Open the File OPEN FILE(filename); Process the File READ/WRITE/REWRITE/DELETE/LOCATE for access by record GET/PUT for stream access Close the File CLOSE FILE(filename) A file used within a PL/I program has a PL/I file name. If you have the following file declaration in your program:
DCL
STOCK FILE
STREAM INPUT;
Ensure that the DDNAME of the DD statement that defines the data set is the same as either the declared PL/I file name. If the file name is longer than 7 characters, the default DDNAME is composed of a compiler generated truncated name (first 4 and last 3 characters). FILE ATTRIBUTE OF A DATA ITEM Main attributes are GROUP ALTERNATIVES Usage STREAM | RECORD Function INPUT | OUTPUT | UPDATE Access SEQUENTIAL | DIRECT Scope EXTERNAL | INTERNAL
Notes on Attributes RECORD Associated verbs OPEN, CLOSE, READ, WRITE, REWRITE, DELETE, LOCATE STREAM Associated verbs OPEN, CLOSE, GET, PUT INPUT OUTPUT UPDATE SEQUENTIAL DIRECT ENVIRONMENT KEYED Input only Output only Valid only for RECORD mode. Transmission in either direction Valid in RECORD MODE only. Records accessed in physical sequence Valid in RECORD MODE only. Records accessed in any order by KEY. Implies KEYED attribute. VSAM | CONSECUTIVE F | FB | V | VB, BLKSIZE(N), RECSIZE (N) Only RECORD files. It means records can be accessed using one of KEY, KEYTO, KEYFROM of data transmission statements /*both*/ /*use only one*/ /*UPDATE for record only*/ /*record only */ /*record only */ /*stream only*/ /*both */ /*stream output only*/ /*stream only with PRINT*/ /*Stream I/O*/ /*Stream I/O*/
Input / Output Verbs OPEN FILE (file-reference) [STREAM | RECORD] [INPUT | OUTPUT | UPDATE] [DIRECT | SEQUENTIAL] [KEYED] [PRINT] [TITLE(expression)] [LINESIZE(expression)] [PAGESIZE(expression)] GET PUT FILE(file-reference). FILE(file-reference).
READ FILE(file-reference).. /*Record I/O*/ WRITE FILE(file-reference) /*Record I/O*/ REWRITE FILE(file-reference). /*Record I/O*/ DELETE FILE(file-reference) /*Record I/O*/ CLOSE FILE(file-reference) /*Both forms I/O*/
92. How can you declare a variable? DCL/DECLARE PRICE DECIMAL FIXED(5,2); Precision of five digits of which two are decimal fraction Scale Attribute Base attribute Identifier (variable) PL/1 Keyword 93. What is the syntax of a file declaration? DCL FUNDIN FILE RECORD INPUT; DCL OUTFILE FILE RECORD SEQUENTIAL OUTPUT; DCL SYSPRINT FILE STREAM OUTPUT PRINT; DCL EXTRACT FILE RECORD DIRECT UPDATE KEYED ENV (VSAM); 94. What are the attributes in PL/1? Explain about each mode? File Attributes:
Usage
STREAM or RECORD
STREAM
Function
INPUT
Access
SEQUENTIAL or DIRECT
SEQUENTIAL
Buffering
BUFFERED or UNBUFFERED
Group Type
Alternative Attributes
Default Attribute
Scope
EXTERNAL or INTERNAL
EXTERNAL
Type of transmission
Attribute
Stream-oriented
ENVIRONMENT
STREAM
Record-oriented
ENVIRONMENT
KEYED
RECORD
File Type
S T R E A M
RECORD
Legend: SEQUENTIAL DIRECT I D Must be specified Default Optional Must be specified Invalid or implied
C o n s e c u t i v e
C o n s e c u t i v e
R e l a t i v e
I n d e x e d
R e l a t i v e
O I n S d e x e d
File Attributes
Attributes Implied
FILE
INPUT1
D FILE
OUTPUT
O FILE
ENVIRONMENT
O FILE
STREAM
- FILE
PRINT1
RECORD
I FILE
UPDATE
O FILE RECORD
SEQUENTIAL
- FILE RECORD
KEYED2
I FILE RECORD
DIRECT
Notes:
1
A file with the INPUT attribute cannot have the PRINT attribute KEYED is required for indexed and relative output
RECORD and STREAM attributes The RECORD and STREAM usage attributes specify the kind of data transmission used for the file.
Default: STREAM RECORD indicates that the file consists of a collection of physically separate records, each of which consists of one or more data items in any form. Each record is transmitted as an entity to or from a variable.
STREAM indicates that the data of the file is a continuous stream of data items, in character form, assigned from the stream to variables, or from expressions into the stream. A file with the STREAM attribute can be specified only in the FILE option of the OPEN, CLOSE, GET, and PUT input/output statements. A file with the RECORD attribute can be specified only in the FILE option of the OPEN, CLOSE, READ, WRITE, REWRITE, LOCATE, and DELETE input/output statements. INPUT, OUTPUT, and UPDATE attributes The INPUT, OUTPUT, and UPDATE function attributes specify the direction of data transmission allowed for a file. INPUT specifies that data is transmitted from a data set to the program. OUTPUT specifies that data is transmitted from the program to a data set, either to create a new data set or to extend an existing one. UPDATE, which applies to RECORD files only, specifies that the data can be transmitted in either direction. A declaration of UPDATE for a SEQUENTIAL file indicates the update-in-place mode.
Default: INPUT SEQUENTIAL and DIRECT attributes The SEQUENTIAL and DIRECT access attributes apply only to RECORD files, and specify how the records in the file are accessed.
Abbreviation: SEQL for SEQUENTIAL Default: SEQUENTIAL The DIRECT attribute specifies that records in a data set are directly accessed. The location of the record in the data set is determined by a character-string key. Therefore, the DIRECT
attribute implies the KEYED attribute. The associated data set must be on a direct-access storage device. The SEQUENTIAL attribute specifies that records in a consecutive or relative data set are accessed in physical sequence, and that records in an indexed data set are accessed in key sequence order. For certain data set organizations, a file with the SEQUENTIAL attribute can also be used for direct access or for a mixture of random and sequential access. In this case, the file must have the additive attribute KEYED. Existing records of a data set in a SEQUENTIAL UPDATE file can be modified, ignored, or, if the data set is indexed, deleted. BUFFERED and UNBUFFERED attributes The buffering attributes apply only to RECORD files.
Abbreviations: BUF for BUFFERED, and UNBUF for UNBUFFERED Defaults: BUFFERED is the default for SEQUENTIAL files. UNBUFFERED is the default for DIRECT files. The BUFFERED attribute specifies that during transmission to and from a data set, each record of a RECORD file must pass through intermediate storage buffers. This allows both move and locate mode processing. The UNBUFFERED attribute indicates that a record in a data set need not pass through a buffer but can be transmitted directly to and from the main storage associated with a variable. This allows only move mode processing. ENVIRONMENT attribute The characteristic list of the ENVIRONMENT attribute specifies various data set characteristics that are not part of PL/I. For a full description of the characteristics and their uses, refer to the Programming Guide. Note: Because the characteristics are not part of the PL/I language, using them in a file declaration can limit the portability of your application program.
The following characteristics can be specified on the ENVIRONMENT attribute. For descriptions of the characteristics, refer to the Programming Guide.
KEYED attribute The KEYED attribute applies only to RECORD files, and must be associated with indexed and relative data sets. It specifies that records in the file can be accessed using one of the key options (KEY, KEYTO, or KEYFROM) of record I/O statements.
>>-KEYED-------------------------------------------------------><
The KEYED attribute need not be specified unless one of the key options is used. PRINT attribute The PRINT attribute is described in PRINT attribute.
95. What are the different opening modes? INPUT Input only OUTPUT Output only UPDATE Valid only for RECORD mode. Transmission in either direction 96. What are the syntaxes of READ/ WRITE/ REWRITE/ DELETE commands? READ FILE (POSIN) INTO (POSIN_REC); READ FILE (EXTRACT) INTO (EXT_REC) KEY (EXT_REC.FUND || EXT_REC.CUSIP || EXT_REC.MAT_DATE || EXT_REC.CPN_RATE || EXT_REC.LT_ST_IND); WRITE FILE (OUTFILE) FROM (OUT_REC); WRITE FILE (EXTRACT) FROM (EXT_REC) KEYFROM (EXT_REC.FUND || EXT_REC.CUSIP ||
CURR_MAT_DATE || CURR_RATE || 'S'); REWRITE FILE (EXTRACT) FROM (EXT_REC) KEY (EXT_REC.FUND || EXT_REC.CUSIP || EXT_REC.MAT_DATE || EXT_REC.CPN_RATE || EXT_REC.LT_ST_IND); DELETE FILE (EXTRACT) KEY (CURR_KEY); 97. How can you declare VSAM files in PL/1? What are the attributes are required? DCL EXTRACT FILE RECORD DIRECT UPDATE KEYED ENV (VSAM); 98. What is the use of GENKEY? GENKEY is a keyword used as partial string search in indexed file processing. 99. What are the different file access modes? Access modes are SEQUENTIAL and DIRECT. Default is SEQUENTIAL mode. 100. What is the syntax of OPEN statement? OPEN FILE (INFILE1); 101. What is the syntax of CLOSE statement? CLOSE FILE (INFILE1); 102. What are the advantages and disadvantages of INDEXED files? 103. What is the use of KEYED attribute? 104. What is the use of RECORD/STREAM attribute? RECORD STREAM Associated verbs OPEN, CLOSE, READ, WRITE, REWRITE, DELETE, LOCATE Associated verbs OPEN, CLOSE, GET, PUT
105. What type of files used in your project? I mean STREAM or RECORD, mostly we will use RECORD 106. Explain about LOCATE statement? LOCATE based-variable FILE(file-reference) Locate mode sequential write DCL BUFFER CHAR(80) BASED(P); LOCATE BUFFER FILE(OUTFILE);
Locate mode keyed write DCL BUFFER CHAR(80) BASED(P); DCL KEYFLD CHAR(5); LOCATE BUFFER FILE(OUTFILE) KEYFROM(KEYFLD); /* using locate mode output */ DCL DATA BASED(P); NEXT: LOCATE DATA FILE(OUTFILE); DATA = ...; GO TO NEXT; 107. Write the syntax of GET LIST, PUT LIST, GET DATA, PUT DATA, GET EDIT and PUT EDIT? GET LIST (A,B,C,D,E); /*Reads from SYSIN */
PUT LIST (A,5,C*D); /* note use of an expression C*D */ PUT PAGE LIST ('ABC'); /* ABC prints in next page */ PUT SKIP LIST(123); /* Skip one line before print */ PUT SKIP(0) LIST (123); /* Print without spacing */ PUT SKIP(2) LIST (123); /* Skip two lines before print */ PUT PAGE LINE (10) LIST (123); /* Skip to line 10 of new page and print */ PUT PAGE LIST ((100)'-'); /* new page and 100 dashes */ The input stream could contain A=12.13,B=570,C='SED',D='1011'B; GET DATA(A,B,C,D); GET DATA(B,D,A,C); /* would work just as well GET DATA(A,B,C,D,E); ignored */ */
GET DATA(A,C,D); /*ERROR!. Identifier in input stream but not in ET*/ */ GET DATA; /* this raises the NAME condition which can be handled /* by an ON NAME(SYSIN) */
/* all items in stream up to the semicolon are input. However the data names must have been defined prior to this point */
The COUNT(filename) returns the data items input during last GET PUT DATA; /* output all variables and values PUT DATA (A,B,C); Outputs -> A=0 B=0 Note that A is in TAB position 1 B is in TAB position 25 C is in TAB position 49 C=175; */
PUT STRING (FIELD_1) EDIT (A,B,C) (A(20),A(10),F(3)); GET STRING (FIELD_1) EDIT (A,B,C) (A(20),A(10),F(3)); 108. What is the use of LEAVE statement? Leave statement The leave statement transfers control from within a DO loop to the statement following the end statement that delimits the group and terminates the DO group. Example A: DO;
. LEAVE;/* transfers control to the next statement after this block*/ . END; next statement; Example A: DO I =1 to 10; DO J = 1 to 10; IF X(I,J)=0 THEN LEAVE A; /* to statement outside group A */ ELSE.. . END; END; statement after group A. ABS ACOS ADDR ALL ALLOCATION ANY ASIN ATAN ATAND ATANH BINARYVALUE BINVALUE1 BIT BOOL CHAR COMPLETION COS COSD COSH COUNT CSTG2 CURRENTSTORAGE DATAFIELD DATE DATETIME DIM EMPTY ENTRYADDR ERF ERFC EXP GRAPHIC HBOUND HEX HIGH IMAG LBOUND LENGTH LINENO LOG LOG1 LOG2 LOW MPSTR NULL OFFSET ONCHAR ONCODE ONCOUNT ONFILE ONKEY ONLOC ONSOURCE PLIRETV POINTER POINTERADD POINTERVALUE PTRADD3 PTRVALUE4 REAL REPEAT SAMEKEY SIN SIND SINH SQRT STATUS STORAGE STRING SUBSTR SYSNULL TAN TAND TANH TIME TRANSLATE UNSPEC VERIFY