IBM Mainframes PLI Training Class4 Syntax to declare
IBM Mainframes PLI Training Class-4
Syntax to declare a DATA NAME DCL DATA-NAME MODE SCALE BASE PRECISION; § § DCL is used to specify the attributes to the variable. § § § SCALE is either fixed or float. MODE of an arithmetic item is either real or complex. default is real. BASE is either decimal or binary. PRECISION means number of figures that a fixed point data item can hold or in case of floating point, the minimum number of valid digits to be regarded as significant.
DECLARE Statement § DCLARE (DCL) is used to reserve storage area for data to a variable and this statement should be with in Procedure. § Declare statement specifies the attributes of a variable. Ex : DECLARE DATA-NAME Attributes; Attributes are data type, its size and data format in it. § Required files in the program are also declared using DECLARE statement
Rules to Name a Data Item § The variable name(data name) should not exceed more than 31 characters. § The allowable characters are A-Z, 0 -9, and _, @, #, $. § First character must be alphabet. § We can give any reserved words. § E. g. : #_of_lines § Basix_pay § Rate_of_income § Sum
Data types in PLI Data Type PICTURE DATA FORMAT Zoned decimal STORAGE 1 byte/digit CHARACTERS Character 1 byte/Char BIT Bit FIXED BINARY Binary One byte Half/full word FIXED DECIMAL Packed decimal 1 Nibble FLOAT DECIMAL FLOATBINARY Floating point 32/64/128 bits Basic Usage Numeric character Alphanumeric character Logical Data Arithmetic Operation
Data Type § § PICTURE Variables which are to hold both types of data must be declared using picture attribute or PIC. § 9 §V §S §X §A Indicates Numeric Indicates Decimal Point Indicates Sign Position May Hold Any Character. Position May Hold Alphabetic Character Or Blank. § $, *, Cr… Picture Edit Characters Must be enclosed in quotation marks. minus and decimal point use storage spaces. if the number is non-negative, it is replaced by a blank.
Examples PICTURE DCL number PIC 'S 999 V. 99‘ INIT(123. 45); In storage, the number will be stored as +123. 45 § Syntax: PICTURE ‘PICTURE SPECIFICATION CHARACTERS’ Picture Specification Characters: 9 ---- decimal V ---- ASSUMED DECIAML POINT DIGIT S ---- SIGN Z ---- ZERO SURPRESSIONS B ---- BLANK ----- CR, DB, + , -, /, $. . DCL A PIC ‘ 9999’; ‘ 9999 V 99’; ‘(4)9’; ’ 99 V. 99’; ‘ZZZV 99’; ‘ZZZZVZ 9’; /* INVALID */ ’$ZZ, 999 V 99’; ‘****9’;
Data Type § CHARACTER Character string variable can hold data that may contain A-Z, 0 -9, and Blank space E. G. : - DCL ENAME CHAR(30); § To vary not only the context but also the length of a character variable we can use the attribute VARYING or VAR. E. G. : - DCL ENAME CHAR(30) VARYING; § The length can vary from 1 to 30 and no padding of spaces is done, if the length is less than 30. Default length Max. length None 1000 characters for constants 32767 characters for variables
Data Type BIT § Bit strings are like char strings except that the digits represent one bit (0 and 1). bit strings must be enclosed in quotation marks. bit strings may have VARYING attributes. § § Bit string constants '1011101001‘B '111‘B Bit string variables BIT : Default length Max. length Example: DCL YES NO None 8000 bits for constants 32767 bits for variables BIT(1) INIT(‘ 1’B); INIT(‘ 0’B);
Data Type FXIED DECIMAL The data format is packed decimal and occupies 1 Nibble for each digit. Default precision 5 digits Ex: 99, 999 Max precision 15 decimal digits Syntax: DCL SALARY FIXED DECIAML(M, N); M total number of digits including fractional digits N number of fractional digits. Example : DCL SALARY FIXED DECIAML(5, 2); DCL is a PLI keyword. SALARY FIXED DECIAML (5 , 2) precision of 5 digit of which 2 are decimal fractions
Data Type FXIED BINARY The data stored as binary format and occupies bits as half word and full word. Used for faster calculation on integers. Default precision Max precision Syntax: 15 bits + sign 31 bits + sign Max : 32, 767 Max : 2**31 DCL MIN FIXED BINARY(15); DCL MIN FIXED BINARY(31);
INITIAL & Constants § To assign value to a variable at the start of the program execution use the attribute INITIAL or INIT. DCL SWITCH DCL WHOLE DCL TITLE § BIT 1 FIXED DEC(5) CHAR(10) INIT('1'B); INIT(0); INIT('Welcome'); CONSTANTS are used along with the INITIAL to assign initial value to the data items. Types of Constants we have: 1. 2. 3. 4. Decimal Fixed Point Decimal Float Point Character String Constant Bit String Constant
Constants Decimal Fixed /Float Decimal Fixed Point Constant : these consists of one or more decimal and optional a decimal point. if no decimal point appears then the data items is an integer. Example: 125, 2. 154 , +34. 56 Decimal Floating Point Constant: written using exponential notation. 12. E+05 OR 12 E 5 1200000 3141593 E-6 3. 141593. 1 E-7. 00000007 85 E 85
Constants Character String/Bit String Character String Constant : Any thing between single quotes. ‘welcome all ‘ ‘ welcome 1 and 2’ Bit String Constant : series of binary digits (0’s and 1’s ) enclosed in single quote marks and follow by a letter B. used for a indicator or flag’s. they can be set to 0 or 1. E. g. : ‘ 1’B, ‘ 101010’B
Addition Program ADDPGM: PROCEDURE OPTIONS(MAIN); DCL A PIC '999‘ INIT(200); DCL B PIC '999‘ INIT(300); DCL C PIC '999‘ INIT(0); C = A + B; PUT SKIP LIST(C); END ADDPGM;
Run JCL for Add program //FSS 197 EX JOB NOTIFY=&SYSUID //STEP 1 EXEC PGM=ADDPGM //STEPLIB DD DSN=FSS 197. MF. LOAD, DISP=SHR //SYSPRINT DD SYSOUT=* //SYSOUT DD SYSOUT=* //
Structures A structures is a collection of data items whose data types can be same or different and are inter related to one another. When a data structure is declared the level of each data name is indicated by level number. Structures are three types: Major Structures: Declared using Level Number 1. Minor Structures: Declared using Level Number 2 - 255. Elementary Items: Declared using Level Number 2 – 255 The only difference between elementary and minor structures is the minor structures are structures with the major structures just like sub group.
Structures To declare structures we use level numbers these level numbers starts with 1 and can go maximum up to 255. Level number 1 is used to indicate the major structures and remaining from 2 – 255 are used for both minor and elementary data names The elementary data names are the actual data name having a particular data type. Each name of the deeper level is given a greater number to indicate the level depth. Level number must be followed by a space.
Example DCL 1 2 2 EMPDETAILS, EMPID PIC ‘ 99999’. EMPNAME CHAR(15), EMPLOC, 5 STREET CHAR(15), 5 CITY CHAR(15), 5 STATE CHAR(15), 5 PINCODE CHAR(15), EMPSAL BINARY FIXED(15);
Thank You
- Slides: 20