This action might not be possible to undo. Are you sure you want to continue?
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
8 bits per digit Character
8 bits per Char One byte min
Alphabetic Character Logical Data
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
BIT(9) BIT(16) BIT(8)
INIT(‘111100001’B); INIT((8)’10’B); INIT(‘0001’B); /* EX_3 = ‘00010000’ */
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) │
15. How many bytes will occupy for “DCL Sex Char”? Default for char is 1 byte. 21. How many bytes will occupy for “DCL Name Char (15)”? 15 byte .5)”? 4 bytes. How many bytes will occupy for “DCL Salary Fix Bin (30. 23. How many bytes will occupy for “DCL Flag BIT”? Default for BIT is 1 byte. 22. How many bytes will occupy for “DCL Salary Fix”? 3 bytes since default for fixed decimal is 5 decimal digits.├───────────────────────┼──────────────┼──────────────────┼────────────────────┤ │ 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. Refer above answer for more detail. How many bytes will occupy for “DCL Salary Bin”? 17. here the ‘S’ belongs to Float Decimal and the size is 20. here the ‘I’ belong to Fixed Binary and the size is 2 byte. 16. 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. How many bytes will occupy for “DCL Salary Dec”? For Decimal the default attribute is Float hence the size is 19. 14. 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. How many bytes will occupy for “DCL Salary Fix Bin”? 2 bytes since default is 15 bits. How many bytes will occupy for “DCL Salary Float”? For Float the default attributes is Decimal hence the size is 18.
31. What is the use of pointer? It points the memory location hence the access is faster. 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. It will allocate the size as required and release the rest of the memory space.n) Concatenates the given string itself a specified no. 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 COMP (it is from COBOL) in PL/1? Float binary 28. What is the use of Define attribute? What is the equivalent declaration in COBOL? DEFINED attribute(overlay definition) . How can you initialize the data into a variable in the declaration? Using INIT attribute. 30. 33. /* NAME=‘PL/1PL/1’ */ 32.of times NAME=REPEAT(‘PL/1’. 26. INITIAL attribute Function To set an identifier to an initial value Example DCL EX_1 CHAR(14) INIT(‘PL/1 TRAINING’). What is the equivalent data type of COMP-3 (it is from COBOL) in PL/1? Fixed Decimal 29. 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. DCL A FIXED DEC(5) INIT(0). How can you initialize the repeated data into a variable in the declaration? Using REPEAT built-in function REPEAT(m. 27.24. What is the use of Varying attribute? DCL FIELD CHAR(100) VARYING. it can be used for other storage.2).
Alignment and storage requirements for program control data can vary across supported systems. structure.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).jsp? topic=/com. character data.com/infocenter/ratdevz/v7r5/index.ibm.for reference */ ALIGNED specifies that the data element is aligned on the storage boundary corresponding to its data-type requirement. widechar data and numeric character data. DCL EX_2 DEFINED EX_1 POSITION(3).doc/topics/lsh-aligned-z. ALIGNED is the default for all other types of data. UNALIGNED is the default for bit data. 34. What is the use of Aligned and Unaligned attributes? /* http://publib. which are mapped on the next bit. ALIGNED or UNALIGNED can be specified for element. The following example illustrates the effect of ALIGNED and UNALIGNED declarations for a structure and its elements: .ent. 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). graphic data.htm . array. 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.zos. but the alignment requirements are the same. 35. except for fixed-length bit strings. >>-+-ALIGNED---+----------------------------------------------->< '-UNALIGNED-' Defaults are applied at element level. or union variables.pl1.ibm. Requirements for the ALIGNED attribute are shown in Table 26. UNALIGNED specifies that each data element is mapped on the next byte boundary. DCL EX_2 DEFINED EX_1. Complex data requires twice as much storage as its real counterpart.boulder.
What are the default alignments of FIXED DECIMAL. What is the use of ENTRY variable? ENTRY indicates the variable is an external subroutine..2)..Y. 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). /* /* /* /* /* /* /* /* /* 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. 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. 37. . 2 X 2 A 3 3 bit(2).. 2 H.FIXED DEC(7.Y. e..Z).. 4 F.FIXED DEC(7.. END. .. FLOAT BINARY.. When the subroutine SUBRT is invoked X. DCL (X. FIXED BINARY..Y. 36. aligned.. should arguments and their corresponding parameters have different attributes.. C unaligned.2).Declare 1 S..Z) FLOAT DEC(6).2)).Z are converted to FIXED DEC(7. 4 E aligned. 38. FLOAT DECIMAL. 3 G. refer to Structures and Unions. .. CALL SUBRT(X.g.2). 4 D. CHAR and BIT data types? CHAR and BIT default is UNALIGNED and for rest of the data types it is ALIGNED. B.. DCL SUBRT ENTRY (FIXED DEC(7. ..
Example(s): DO I=1 TO 100 BY 1. DO I=1 TO 100 WHILE(X<100). Example: J=10.'GHI' 39. 25 TO 50 BY 2. 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 DO-UNTIL • loop execute until success . A binary value of zero is false. A flag variable with a value of binary one is true.4.10 TO 20.7. . L=2. K=5. DO I=J TO K BY L. /* after I = 1 to 10. 11 BY 0 WHILE(A=B).Expression can be a logical expression or a flag variable (BIN (1)). /*termination condition must be inside the loop*/ DO I=0. DO I=1 TO 5. END. continuous looping at I = 11 takes place */ A=B. .1 TO 1. Iterative DO loop value DO control-variable = initial value TO limit value BY modification [WHILE(expression) | UNTIL(expression)].'DEF'.1 BY 0. */ DO I=100 TO 1 BY -1. /* loop terminates when I reaches 100 or >=100*/ Commas separate specifications as below DO I=1 TO 10. DO I=1. DO I=1 BY 1.0. At this time loop terminates only when A is not = B DO I='ABC'.22.
WHEN (2) CALL SUBRTN. WHEN (expression) action 3. END.• 1st time it will skip the condition. END. OTHERWISE action 3. Example: SELECT (CODE) WHEN (1) DO. . . • STATIC specifies that storage is allocated when the program is loaded. . 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 not freed until program execution is completed. SELECT. WHEN (expression) action 1. OTHERWISE CALL INVCODE. . WHEN(CODE<10) DO. . What is the use of SELECT statement? Can you write the syntax? It is equal to switch in ‘C’ and evaluate in ‘COBOL’. 41. END. Multiple allocations of the same controlled variable in the same task. stack generations of the variable. • CONTROLLED specifies that you maintain full control over the allocation and freeing of storage with the ALLOCATE and FREE statements. WHEN (expression) action 2. OTHERWISE CALL ERRORTN. END. without intervening freeing. What is the equivalent SELECT statement in COBOL? EVALUATE in ‘COBOL’ 42. 40. Its compulsory to give OTHERWISE option also else the job will tho ONCODE = 3 Select Statement SELECT (expression which is optional). The storage is released when the block is exited. END. WHEN (CODE>=10) CALL SUBRTN.
• BASED. 45. /* Storage for A is de-allocated here */ */ */ Note that controlled variables after allocation exist until they are explicitly freed. ALLOCATE A(100). For arrays the size specification may be deferred until ALLOCATE DCL A(*) FIXED DEC(5) CONTROLLED. Controlled Storage DCL A(100) FIXED DEC(5) CONTROLLED. . the value will not change until the pgm or application terminates. ALLOCATE TABLE(100. What is the difference between Auto and Static storage class? Automatic – Internal scope Static – Internal/External scope. DCL EX_2 DEFINED EX_1. DCL A(100) FIXED DEC(5) BASED(P).*) BIN(1) CONTROLLED. DCL TABLE(*. /* A does not exist here ALLOCATE A. specifies that you maintain full control over storage allocation and freeing. 44. use A here FREE A. The default storage class is AUTOMATIC Automatic Based Static Controlled Automatic and based variables can have internal scope only. They are not affected by block boundaries. Each allocation can be identified by the value of a locator variable. Multiple allocations are not stacked but are available at any time. 43. In based it points the pointer and accessing the same memory allocations. What is the use of Controlled Storage class? For dynamic allocation. .100). Static and controlled variables can have internal and external scope. What is the difference between Defined attribute and Based storage class? DCL P POINTER. . . DCL EX_1 CHAR(5). like CONTROLLED. Both are same. in defined the structure is same and use the same memory allocation. /* Storage for A is allocated here GET LIST(A).
. /* NULL is a builtin function which returns a NULL pointer */ 46. /* FREE the storage for the variable this way*/ DCL NULL BUILTIN. PUT LIST(BUFF). What is the implicit and explicit reference? Implicit reference is the one we assigned the value to the variable at the time of declaration. /* this is first generation of buff */ ALLOCATE BUFF. /* PRODUCT is referenced by a locator qualifier */ FREE P->PRODUCT. PUT LIST(BUFF). What is the use of ADDR ()? Instead of using PTR we can use ADDR(). PUT LIST(BUFF). ALLOCATE BUFF. BUFF = 'THIS IS SECOND GENERATION OF BUFF'. /* this is first generation of buff */ FREE BUFF. both are same. 47. Example for Implicit reference: DCL A CHAR(5) INIT (‘INDIA’). /* note that Q is not changed by this */ P->PRODUCT. A free will then cause the previous generation to be popped out of the stack. Example for Explicit reference: DCL A CHAR(5). IF Country = 1 THEN A = ‘INDIA’. DCL P POINTER.DESCRIPTION = 'SCREW'. 2 DESCRIPTION CHAR(20). ALLOCATE PRODUCT SET(P). /* this is second generation of buff*/ FREE BUFF. 2 CODE FIXED DEC(4). BUFF = 'THIS IS FIRST GENERATION OF BUFF'. Example follows: DCL BUFF CHAR(100) CONTROLLED. The previous generation is pushed into a stack meant for storing multiple generations of controlled variables. /* 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). Explicit reference is the one we assigned the value to the variable depends on the program functionality.Note that a repeat allocation before a free results in a new generation of the variable.
80.0) INIT(1.4. COLUMN 1 (1.2. Arrays DCL DCL DCL DCL DCL STUD_AVG (365) FIXED DEC(4.2. TABLE(0:11) FIXED DEC(5). .3. IF KEY = 2 THEN P = ADDR(RGF_KEY2).IF Country = 2 THEN A = ‘PAKISTAN’. DCL 1 RGF_KEY1_R CHAR(14) BASED(ADDR(RGF_KEY1)).2) (3. 2 CUSIP 2 REC_DATE CHAR (09) INIT((9)' ').2).1. TABLE(3. FIXED(09) INIT(0).2) FIXED DEC(5). DCL B(10) FIXED DEC(3) INIT((7)0. 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. What are Allocate and Free statements? Can you write the syntaxes? DCL A(100) FIXED DEC(5) CONTROLLED.2) (2. GRAPH(-3:3) FIXED DEC(5.-4:4) FLOAT DEC(6) INIT((63)0). DCL 1 RGF_KEY1_R CHAR(14) BASED P. What is an Array? Collection of values of same data type.2).90). . both are going to use memory location of other variable.1) (2.1) (3.2. 49.1) COLUMN 2 (1. Example for Explicit reference: DCL P POINTER. IF KEY = 1 THEN P = ADDR(RGF_KEY1). Example for Implicit reference: DCL 1 RGF_KEY1.3). . use A here FREE A. . The only difference is the BASED will do complete redefine of the memory allocation where DEFINED can go with partial memory allocation. DCL TABLE(10) CHAR(2) INIT((10)(2)'A').4.21. /* Storage for A is de-allocated here 50. P = ADDR(RGF_KEY1). /* A does not exist here ALLOCATE A.2) */ */ ROW 1 ROW 2 ROW 3 DCL AXIS(-3:3. 48. /* Storage for A is allocated here */ GET LIST(A). LIST(-2:6) FIXED BIN(15.
I=3. What are the disadvantages of an Array? We can store only same data type. 1:20) (-5:5. /* second parm is the dimension we are looking at*/ HIGH = HBOUND(ARRAY. 5*6=30. Z=X(Y(I)). DCL HIGH FIXED BIN(31). /* note the (1) !.1). 1:7.LBOUND) BUILTIN. What is Lower bound and Upper bound? DCL ARRAY(*) FIXED BIN(31). 5) • 10 elements • 10 elements • 10 * 20 elements • 10 * 20 elements • 11 * 7 * 4 3 dimensional • 11 * 7 * 5 3 dimensional 52.0) INIT(10. DCL (HBOUND.1).g. (i. DCL Y(3) FIXED BIN(15. 1:20) In the above example 1 LBOUND and 10.0) INIT(3.: In two dimensional array A of size (10. What is the definition of Structure? .50). 55.e.-4) /* first element) Subscripts can be nested as below DCL X(5) FIXED BIN(15. 20) (1:10. 7. How many elements are in the following arrays: A A A A A A (10) (1:10) (10.2. How can you calculate the extents of an array? We need to multiply the position in the array dimension.) 54. DCL LOW FIXED BIN(31).1).20.40. LOW = LBOUND(ARRAY. -2:2) (11. /* LOW and HIGH are now the bounds of ARRAY*/ Eg: A (1:10. It is required ! */ Access an element as below AXIS(-3.6) is 30.30. 10) extend of A (5.20 HBOUND 53. E. /* Z is 10 */ 51.DCL TABLE(10) CHAR(5) INIT((10)(1)'EMPTY').
1 56. DCL VALUE1 BIT (32) BASED (P).e to ‘point’ to data in main storage. a value must be given to the pointer . What is the difference between Array and Structure? Array can store many values of same data type. DCL 1 MYOBJDESC LIKE MQOD. Explain about pointer variable? POINTER VARIABLES • • A pointer variable is a special type of variable you can use to locate data . What are the maximum level numbers in PL/1? Maximum level number is 255 and the maximum level is 15. Notes: • Level 1 is the Major structure level which does not have attributes. 2 NAME CHAR(20). Structure can store variables/values of different data type. Eg. DCL VALUE2 FLOAT (6). This facilitates Overlay-defining of identifiers that do not have same base. BYNAME: need to move the elementary variable between two structures but in different order in two structures. READ FILE(INFILE) INTO (EMP_ADDRESS). 2 CITY CHAR(20). e. Can you declare a sample structure with the name of “Student”? Refer ans of 55.g. scale and precision. By assignment of the value returned by the ADDR built-in function. 57.Structures DCL EMP_ADDRESS. P=ADDR(VALUE2). 2 STREET CHAR(20). • 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. However other storage qualifiers like BASED(P) are to be specified here. 59. Array is the subset of structure. 58. 60. Before a reference can be made to a based variable . 1. This can be done in one of the following ways. . 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.i. Both the elementary variable should be in same elementary level. 2 STATE CHAR(20). • STRING(structure variable) can also be used as a pseudo variable (on the LHS of an assignment statement.
DCL (P. _/* elementary name */ 3 First char (15). Declare 1 Payroll. In the above structure how can you initialize the value into “Overtime”. 2 Name.2).2). “Regular” and “First” variables? We need to initialize each variable at its elementary level with INIT attribute. LOCATE FILE (OUTPUT) SET(Q). 3 First (10) char (15). Facilitates processing of records in their buffers rather than in storage work areas. 63.g.g. DCL AREA CHAR(100) BASED(P). Facilitates List processing. 4. Facilitates POINTER values for subsequent use by the program. DCL (P. e. By assignment of the value of another pointer. READ FILE(INPUT) SET(P). 3. 2 Hours. 3 First char (15). 3 Last (10) char (20). 64. ALLOCATE(AREA). 2 Name. 3 Regular fixed dec (3.2). What is the difference between the following Declare 1 Payroll (10). 3 Overtime fixed dec (5.Q) POINTER. 3 Last char (20). Can you use array in the structure? Yes. Q=P.2). _/* minor structure name */ 3 Last char (20). With the SET option of a READ or LOCATE statement. In the second one elementary level has one value only but in first it has array.Q) POINTER. e. They are: BIT HIGH MPSTR TRANSLATE . 3 Overtime fixed dec (3. e. _/* major structure name */ 2 Name. P=ADDR(AREA). By an ALLOCATE statement. 3 Regular fixed dec (5. 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. 62. Declare 1 Payroll.g.2. 61. ALLOCATE(AREA) SET(Q). 2 Rates.
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. the SIGN function indicates the sign of an arithmetic value. Determine properties of arithmetic values. 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. mode. 2. For example. They are: ACOS COSD LOG SINH ASIN COSH LOG2 SQRT ATAN ERF LOG10 TAN ATAND ERFC SIN TAND ATANH EXP SIND TANH result. 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.BOOL CHAR GRAPHIC INDEX LENGTH LOW REPEAT STRING SUBSTR UNSPEC VERIFY Arithmetic Built In Functions The arithmetic built-in functions allow you to: 1. . or within an ON-unit for the ERROR or FINISH condition when raised as an implicit action. All other uses are out of context. Control conversion of base. 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. scale. and precision both directly and during basic arithmetic operations.
/* LTH=4 */ NAME=REPEAT(‘PL/1’. NAME = ‘PL/1’. IND=INDEX(NAME.Storage Control Built In Functions The storage-control built in functions allow you to determine the storage requirements and location of variables. VERIFY.2).J) TRANSLATE(s. /* IND=1 */ DCL NAME CHAR(20) VARYING. TRANSLATE And INDEX? What is the use of each function? Function 1. 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. DCL B CHAR(5).n) SUBSTR(NAME.p) Concatenates the given string itself a specified no.4).of times To manipulate smaller part of larger char or bit string Substitutes one char with .I. A=175.1. to assign special values to area and locator variables. B=CHAR(A). Y=SUBSTR(X.CHAR(x. /* Y=‘PL/1’ */ NAME=‘ABCD’. /* B=‘ 175’ */ X=BIT(NUMBER).CHAR 2. LTH=LENGTH(NAME). /* NAME=‘PL/1PL/1’ */ X=‘PL/1 LANGUAGE’. 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 REPEAT(m. /* X=BIT STRING */ NAME=‘PL/1 LANG’.’PL/1’).r. 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. What are the syntaxes of SUBSTR. and to obtain the number of generations of a controlled variable.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). to perform conversion between offset and pointer values.
X=‘01234’. RETURN(I). it is called as recursive procedure.g. Pseudo-variables : • Can appear on the left of the assignment symbol in an assignment. 68.another VERIFY Examines two strings to verify that each char or bit of the first string is represented in the second string NAME=TRANSLATE(NAME . Except when noted in the description.1). Difference between RETURNS and RETURN? . /* NAME=‘XBCD’ */ DIGITS=‘0123456789’. e. Can you write the first statement in PL/1? MYPROG:PROCEDURE OPTIONS(MAIN).’X’. To specify a procedure as RECURSIVE we need to give RECURSIVE option with PROCEDURE statement. ELSE I=N*N_FACTORIAL(K). What is the use of Recursive? RECURSIVE PROCEDURES When a procedure invokes itself . 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. What is Pseudovariable? Pseudo-variables Pseudo-variables represent receiving fields. 69. 71. 70. N-FACTORIAL: PROCEDURE (N) RECURSIVE. END N_FACTORIAL. the • Can appear in a data list of a GET statement or in the STRING option of a PUT statement. Internal and External procedure (Subroutine). RESULT=VERIFY(X. How many types of procedures in PL/1? Two types are there.DIGITS ). /* RESULT = 0 */ 66. IF K = 1 THEN I=N. K=N-1.
Internal proc needs to start with alphabetic and can be length of 44.NOTIFY=USERAA //MYSTEP EXEC PROC=IEL1CLG. 73. . GET DATA (FIELD1.45. It can be invoked by call statement. RETURN Statement The RETURN statement terminates execution of the procedure that contains the RETURN statement. Procedure: • We can pass and get more than one value.REGION. END MYPROG.2). SUM:PROCEDURE (A. RETURN (expression). DCL B FIXED DECIMAL(7.FIELD2).B) RETURNS(FIXED DECIMAL(7. RETURN (A+B). DCL A FIXED DECIMAL(7.FIELD2)). • It may be internal or external • Internal procedure max length is 44. PUT SKIP LIST(SUM(FIELD1.23.PLI=1M //PLI. /* // RETURNS We need to give in the definition RETURN It will return the value. 72 What is the difference between Function and Procedure? Function: • Returns a single value.FIELD1=3. it will be invoked inside the main program itself.2). END SUM. DCL FIELD2 FIXED DECIMAL(7. 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.2).2). The RETURN statement with expression is used to terminate a procedure invoked by a function reference. DCL FIELD1 FIXED DECIMAL(7. • It will be called inside the same program.SYSIN DD * FIELD2=1.//USERAA1 JOB MSGCLASS=A. /* //GO.2)).SYSIN DD * MYPROG: PROCEDURE OPTIONS(MAIN). • External procedure nothing but subroutine needs to declare with entry statement.
77. but it cannot be specified for internal procedures or ENTRY statements. External: . parameters are received by value. How can you declare External procedure? DCL SUM ENTRY(FIXED DEC(3). What is Call by value and Call by reference? Format for PROCEDURE statement entry-constant: PROCEDURE (parameter.FIXED DEC(3)) RETURNS(FIXED DEC(3)) EXTERNAL. BYADDR is the default BYVALUE can be specified for EXTERNAL PROCEDURE statements. Any change to a parameter that is being passed by value is not reflected in the argument passed by the caller. If you specify BYADDR. It is mainly related to performance. What is REORDER? The functionality of REORDER is to avoid dead lock situation in the program execution.…) RETURNS(attribute) OPTIONS (Options-list) Important OPTIONS are BYADDR or BYVALUE Specify how all parameters defined for this procedure entry are passed. P1000_INITIAL_PROCESS: PROC. parameter. 75. 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. Additionally BYVALUE entry points can only have scalar arguments and return values that are either POINTER or REAL FIXED BINARY(31.74. parameter.0) BYADDR is the default. parameters are received by address.…) RETURNS(attribute) OPTIONS (Options-list) Format for ENTRY statement entry-constant: ENTRY (parameter. Maximum length of external proc is 8. ENTRY keyword denotes that it is an External proc. 78. 76. What is the maximum length of procedure name for Internal and External procedures? Maximum length of internal proc is 44. Internal: CALL P1000_INITIAL_PROCESS. If you specify BYVALUE.
FIXED DEC(3)) RETURNS(FIXED DEC(3)). 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. Argument is the values/variables used in the subroutine. What are Signal and Revert conditions? SIGNAL Statement You can raise a condition by means of the SIGNAL statement. 81. PLIRETV is used to capture the return value. returned by PLIRETC function. What is the first executable statement in PL/1? Main statement is the first executable statement. The established action is taken unless the condition is disabled. If the specified condition is disabled. from a sub-program. 80. CALL SUM(Parameter).DCL SUM ENTRY(FIXED DEC(3). 79. 82. 86. the SIGNAL statement becomes equivalent to a null statement. How can you return the return code from PLI to JCL? PLIRETC (value) 83. How can you pass the data from JCL to PL/1? How many methods are there? Two methods. What are PLIRETC and PLIRETV? PLIRETC is a user defined return code that we can pass to the JCL to display after job execution. What is the Call statement? Tho CALL statement only we can invoke any procedures. 85. What is Parameter and Argument? Parameter is the values/variables passed from the main program. REVERT statement . The syntax for the SIGNAL statement is: SIGNAL Condition. How can you access the data from PARM parameter (it is JCL parameter) to PL/1? MYPROG:PROCEDURE (PARM) OPTIONS(MAIN). 84. either through SYSIN parameter or through PARM parameter.
where the error occurred ONFILE – returns the file in which error occurs ONSOURCE – return the field name ONCHAR – ONKEY 87. A) what are the ON-UNIT conditions in PL/1? Can you give some conditions? ONCODE .null on-Unit The effect of a null statement on-unit is to execute normal return from the condition. as a string. ON CONVERSION BEGIN. Example for REVERT:PROC1: PROCEDURE. Once this action is established. (If a null ON-unit is specified. . B) Explain about conditional handling. but not all conditions can be disabled. for two reasons: • A null ON-unit can be specified for any condition. ON CONVERSION BEGIN. if possible. . END PROC1. • Disabling a condition. since a procedure can be called from anywhere where it is visible. END. Dynamic descendency is not known until run time. REVERT CONVERSION. END. END PROC2. can save time by avoiding any checking for this condition. .returns the error code. Note: Dynamic descendency refers to the fact that ON-units are inherited from the calling procedure in all circumstances. Use of the null on-unit is not the same as disabling. binary value. the system must still check for the raising of the condition). /* Overrides ON unit in PROC1 */ /* Now the ON unit in PROC1 is back in control */ 87. 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. The execution of an ON statement establishes an action specification for a condition. for diagnostic purposes ONLOC .returns the procedure/function name. B: PROC2.
If a condition is enabled. expression evaluation. Enabling and disabling can be specified for the eligible conditions by a condition prefix. the raising of the conditions does not execute an action. the raising of the condition executes an action. and computation. Classification of Conditions The conditions are classified as follows: • Computation conditions-those associated with data handling. /* 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. If a condition is disabled. 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 . Example: (SIZE): L1 X=(I**N).Condition Handling Condition Prefixes You can specify whether or not some conditions are enabled or disabled. C) Explain about the ON-UNITS conditions classification. These conditions are: AREA ATTENTION CONDITION ENDFILE ENDPAGE ERROR FINISH KEY NAME RECORD TRANSMIT UNDEFINEDFILE 87. The conditions are: .
no WHEN clause is selected and no OTHERWISE clause is 3 present 4 SIGNAL FINISH.CONVERSION SIZE FIXEDOVERFLOW UNDERFLOW OVERFLOW ZERODIVIDE If a computational conditional (except UNDERFLOW) is raised and the condition is disabled. it usually is used only in programs testing. because the above are normally disabled conditions. It is removed for production programs. • Miscellaneous conditions. • Program-checkout conditions-those conditions that facilitate the debugging of a program. • Input/output conditions-those conditions associated with input and output. CONDITION record 88. ERROR. 89. What is exceptional handling? Exceptional handling is nothing but the error handling using SIGNAL statement and ONUNIT conditions. They are STRINGSIZE STRINGRANGE SUBSCRIPTRANGE If SUBSCRIPTRANGE is raised is disabled. 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 . the program is in error. Because this checking involves a substantial overhead in both storage space and run time. For write of fixed length records it Can occur if buffer is larger than record size. FINISH. the program is in error. which are: AREA. 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. 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.
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. . error while opening a VSAM data set error while opening a data set REUSE specified. 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. but data set is not reusable Alternate index specified for an empty VSAM data set.
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. 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 .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. LINE or SKIP attempted for nonprint file.
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. 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 . 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.1015 1016 1018 1019 event variable for an input/output operation is already in use. mixed.
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 .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.
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. RRDS VSAM FILE INPUT / OUTPUT Action PL/I statement Define the File DECLARE filename FILE … Open the File OPEN FILE(filename). 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.9250 9251 9252 9253 9254 9255 9257 9999 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. 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. ESDS. 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: .
PUT • INPUT OUTPUT UPDATE • SEQUENTIAL DIRECT • ENVIRONMENT • KEYED Input only Output only Valid only for RECORD mode. . the default DDNAME is composed of a compiler generated truncated name (first 4 and last 3 characters). GET. READ. Records accessed in physical sequence Valid in RECORD MODE only. CLOSE. 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)………. Create a DD statement with a data definition name (DDNAME) //STOCK DD DSN=PARTS.INSTOCK. VSAM | CONSECUTIVE F | FB | V | VB. WRITE. Implies KEYED attribute. . LOCATE STREAM Associated verbs OPEN. RECSIZE (N) Only RECORD files. CLOSE. Records accessed in any order by KEY. Ensure that the DDNAME of the DD statement that defines the data set is the same as either the declared PL/I file name.DCL STOCK FILE STREAM INPUT. FILE(file-reference)………. Transmission in either direction Valid in RECORD MODE only. BLKSIZE(N). REWRITE. FILE ATTRIBUTE OF A DATA ITEM Main attributes are GROUP ALTERNATIVES Usage STREAM | RECORD Function INPUT | OUTPUT | UPDATE Access SEQUENTIAL | DIRECT Scope EXTERNAL | INTERNAL DEFAULT STREAM INPUT SEQUENTIAL EXTERNAL Notes on Attributes • RECORD Associated verbs OPEN. . . DELETE. It means records can be accessed using one of KEY. If the file name is longer than 7 characters.
Precision of five digits of which two are decimal fraction Scale Attribute Base attribute Identifier (variable) PL/1 Keyword 93. 94. DCL SYSPRINT FILE STREAM OUTPUT PRINT. /*Record I/O*/ WRITE FILE(file-reference)…… /*Record I/O*/ REWRITE FILE(file-reference)….. What is the syntax of a file declaration? DCL FUNDIN FILE RECORD INPUT. How can you declare a variable? DCL/DECLARE PRICE DECIMAL FIXED(5. DCL EXTRACT FILE RECORD DIRECT UPDATE KEYED ENV (VSAM).READ FILE(file-reference)……. DCL OUTFILE FILE RECORD SEQUENTIAL OUTPUT. What are the attributes in PL/1? Explain about each mode? File Attributes: Group Type Alternative Attributes Default Attribute Usage STREAM or RECORD STREAM Function INPUT or OUTPUT or UPDATE INPUT Access SEQUENTIAL or DIRECT SEQUENTIAL Buffering BUFFERED or UNBUFFERED BUFFERED (for SEQUENTIAL files). . /*Record I/O*/ DELETE FILE(file-reference)…… /*Record I/O*/ CLOSE FILE(file-reference)…… /*Both forms I/O*/ 92.2).
Group Type Alternative Attributes Default Attribute UNBUFFERED (for DIRECT files) Scope EXTERNAL or INTERNAL EXTERNAL Type of transmission Attribute Stream-oriented ENVIRONMENT INPUT and OUTPUT PRINT STREAM Record-oriented BUFFERED and UNBUFFERED DIRECT and SEQUENTIAL ENVIRONMENT INPUT. and UPDATE KEYED RECORD . OUTPUT.
Attributes of PL/I file declarations 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 Data Set Organization 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 I I I I I I INPUT1 D D D D D D FILE OUTPUT O O O O O O FILE ENVIRONMENT O O O O O O FILE STREAM D - - - - .FILE STREAM OUTPUT .Table 33.FILE PRINT1 O - - - - .
Each record is transmitted as an entity to or from a variable.RECORD - I I I I I FILE UPDATE - O O O O O FILE RECORD SEQUENTIAL - D D D - .FILE RECORD KEYED2 - - O O I I FILE RECORD DIRECT - - - - S S FILE RECORD KEYED Notes: • • 1 A file with the INPUT attribute cannot have the PRINT attribute KEYED is required for indexed and relative output 2 RECORD and STREAM attributes The RECORD and STREAM usage attributes specify the kind of data transmission used for the file. . each of which consists of one or more data items in any form. >>-+-+--------+-+---------------------------------------------->< '-RECORD-' Default: STREAM RECORD indicates that the file consists of a collection of physically separate records. .-STREAM-----.
-SEQUENTIAL-. REWRITE. CLOSE. . OUTPUT. >>-+-+--------+-+---------------------------------------------->< '-DIRECT-' Abbreviation: SEQL for SEQUENTIAL Default: SEQUENTIAL The DIRECT attribute specifies that records in a data set are directly accessed. LOCATE. . and UPDATE attributes The INPUT. A declaration of UPDATE for a SEQUENTIAL file indicates the update-in-place mode. OUTPUT. A file with the STREAM attribute can be specified only in the FILE option of the OPEN. in character form. and PUT input/output statements. specifies that the data can be transmitted in either direction. and UPDATE function attributes specify the direction of data transmission allowed for a file.-INPUT------. OUTPUT specifies that data is transmitted from the program to a data set. GET. UPDATE. and DELETE input/output statements. or from expressions into the stream. assigned from the stream to variables.STREAM indicates that the data of the file is a continuous stream of data items. and specify how the records in the file are accessed. A file with the RECORD attribute can be specified only in the FILE option of the OPEN. which applies to RECORD files only. INPUT specifies that data is transmitted from a data set to the program. The location of the record in the data set is determined by a character-string key. Therefore. INPUT. WRITE. >>-+-+--------+-+---------------------------------------------->< | '-OUTPUT-' | '-+--------+-' '-UPDATE-' Default: INPUT SEQUENTIAL and DIRECT attributes The SEQUENTIAL and DIRECT access attributes apply only to RECORD files. the DIRECT . either to create a new data set or to extend an existing one. READ. CLOSE.
The SEQUENTIAL attribute specifies that records in a consecutive or relative data set are accessed in physical sequence. Existing records of a data set in a SEQUENTIAL UPDATE file can be modified. using them in a file declaration can limit the portability of your application program. The associated data set must be on a direct-access storage device.attribute implies the KEYED attribute. The BUFFERED attribute specifies that during transmission to and from a data set. . if the data set is indexed. This allows both move and locate mode processing. and that records in an indexed data set are accessed in key sequence order. and UNBUF for UNBUFFERED Defaults: BUFFERED is the default for SEQUENTIAL files. the file must have the additive attribute KEYED. refer to the Programming Guide. deleted. UNBUFFERED is the default for DIRECT files. 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. In this case. BUFFERED and UNBUFFERED attributes The buffering attributes apply only to RECORD files. each record of a RECORD file must pass through intermediate storage buffers. ignored. a file with the SEQUENTIAL attribute can also be used for direct access or for a mixture of random and sequential access. This allows only move mode processing. >>-+-+----------+---+------------------------------------------>< | '-BUFFERED-' | '-+------------+-' '-UNBUFFERED-' Abbreviations: BUF for BUFFERED. Note: Because the characteristics are not part of the PL/I language. For a full description of the characteristics and their uses. ENVIRONMENT attribute The characteristic list of the ENVIRONMENT attribute specifies various data set characteristics that are not part of PL/I. or. For certain data set organizations.
and must be associated with indexed and relative data sets.FUND || EXT_REC. What are the different opening modes? INPUT Input only OUTPUT Output only UPDATE Valid only for RECORD mode. WRITE FILE (OUTFILE) FROM (OUT_REC). WRITE FILE (EXTRACT) FROM (EXT_REC) KEYFROM (EXT_REC. or KEYFROM) of record I/O statements. Transmission in either direction 96.CUSIP || .MAT_DATE || EXT_REC.FUND || EXT_REC. What are the syntaxes of READ/ WRITE/ REWRITE/ DELETE commands? READ FILE (POSIN) INTO (POSIN_REC). PRINT attribute The PRINT attribute is described in PRINT attribute. BKWD CONSECUTIVE CTLASA GENKEY GRAPHIC KEYLENGTH KEYLOC ORGANIZATION RECSIZE REGIONAL(1) SCALARVARYING VSAM KEYED attribute The KEYED attribute applies only to RECORD files. For descriptions of the characteristics. KEYTO. refer to the Programming Guide.CUSIP || EXT_REC. 95. >>-KEYED------------------------------------------------------->< The KEYED attribute need not be specified unless one of the key options is used. It specifies that records in the file can be accessed using one of the key options (KEY.The following characteristics can be specified on the ENVIRONMENT attribute.CPN_RATE || EXT_REC. READ FILE (EXTRACT) INTO (EXT_REC) KEY (EXT_REC.LT_ST_IND).
PUT 105. 102. READ. How can you declare VSAM files in PL/1? What are the attributes are required? DCL EXTRACT FILE RECORD DIRECT UPDATE KEYED ENV (VSAM). What are the different file access modes? Access modes are SEQUENTIAL and DIRECT. Explain about LOCATE statement? LOCATE based-variable FILE(file-reference) Locate mode sequential write DCL BUFFER CHAR(80) BASED(P). DELETE FILE (EXTRACT) KEY (CURR_KEY). CLOSE.LT_ST_IND). What is the syntax of CLOSE statement? CLOSE FILE (INFILE1).FUND || EXT_REC.CUSIP || EXT_REC. Default is SEQUENTIAL mode. mostly we will use RECORD 106. What is the syntax of OPEN statement? OPEN FILE (INFILE1). 100. What are the advantages and disadvantages of INDEXED files? 103.CPN_RATE || EXT_REC. What is the use of GENKEY? GENKEY is a keyword used as partial string search in indexed file processing.CURR_MAT_DATE || CURR_RATE || 'S'). 101. What is the use of KEYED attribute? 104. 98. 99. 97. GET. CLOSE. WRITE. REWRITE. . What is the use of RECORD/STREAM attribute? • RECORD STREAM Associated verbs OPEN. LOCATE Associated verbs OPEN. LOCATE BUFFER FILE(OUTFILE). DELETE. REWRITE FILE (EXTRACT) FROM (EXT_REC) KEY (EXT_REC. What type of files used in your project? I mean STREAM or RECORD.MAT_DATE || EXT_REC.
/* new page and 100 dashes */ The input stream could contain A=12. 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. 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.A.B.B=570. GET EDIT and PUT EDIT? GET LIST (A. LOCATE BUFFER FILE(OUTFILE) KEYFROM(KEYFLD).Locate mode keyed write DCL BUFFER CHAR(80) BASED(P). DATA = .D.C*D).C. /* ABC prints in next page */ PUT SKIP LIST(123). E is superfluous and is GET DATA(A.5.D). GET DATA. DCL KEYFLD CHAR(5).E). */ .C. PUT DATA. /* note use of an expression C*D */ PUT PAGE LIST ('ABC').C.E). PUT LIST. GET DATA(B.C='SED'.B. /* this raises the NAME condition which can be handled /* by an ON NAME(SYSIN) */ /* all items in stream up to the semicolon are input. /* using locate mode output */ DCL DATA BASED(P). /* Skip one line before print */ PUT SKIP(0) LIST (123). /* Skip to line 10 of new page and print */ PUT PAGE LIST ((100)'-'). Write the syntax of GET LIST. /* Print without spacing */ PUT SKIP(2) LIST (123).. Identifier in input stream but not in ET*/ */ GET DATA.C). GO TO NEXT.13. /* output all variables and values PUT DATA (A.D='1011'B. /* would work just as well GET DATA(A. ignored */ */ /* not an error. /*Reads from SYSIN */ PUT LIST (A.D.D)..D.C.B. 107.. /*ERROR!.C). NEXT: LOCATE DATA FILE(OUTFILE). GET DATA(A.B. /* Skip two lines before print */ PUT PAGE LINE (10) LIST (123).
A(10).PUT STRING (FIELD_1) EDIT (A.A(10). END. GET STRING (FIELD_1) EDIT (A.C) (A(20)./* transfers control to the next statement after this block*/ . . 108.. next statement.F(3)). END.F(3)). 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. IF X(I.C) (A(20).J)=0 THEN LEAVE A. Example A: DO I =1 to 10. Example A: DO.B. statement after group A. /* to statement outside group A */ ELSE. END. DO J = 1 to 10. LEAVE.B. 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 . .
This action might not be possible to undo. Are you sure you want to continue?