110 likes | 425 Views
Micro Focus COBOL Programming. Module 4 Constants Copy Statement Perform Verb Part 1. Two types of Constants. Literals Figurative Constants. Cobol Literals. String / Alphanumeric literals are enclosed in quotes and may consists of alphanumeric characters
E N D
Micro Focus COBOL Programming Module 4 Constants Copy Statement Perform Verb Part 1
Two types of Constants • Literals • Figurative Constants
Cobol Literals • String / Alphanumeric literals are enclosed in quotes and may consists of alphanumeric characters • e.g. “Alan Cheah”, “-123”, “123.45” • Numeric Literals may consist of numerals, the decimal point and the plus & minus sign. Numeric literals are not enclosed in quotes. • e.g. 123, 123.45, -640, • E.g. : 01 WeekAmt 03 WeekAmt1 pic 9(6) value 123456 03 WeekAmt2 pic x(6) value “123456”
Figurative Constants • HIGH-VALUE or HIGH-VALUES • LOW-VALUE or LOW-VALUES • SPACE or SPACES • ZERO or ZEROS or ZEROES • QUOTE or QUOTES
Fig. Constants Examples 01 Paycheck PIC 9(5)V99 VALUE 13.5. MOVE ZEROES TO Paycheck. 01 StudentName PIC X(10) VALUE “ALAN” MOVE ALL “-” TO StudentName
Copy Statement • There are many files used in many programs • Defining all the fields in the records is tedious and fussy. • So, we can keep these record definitions in a directory/file accessible to all. • These files are known as copy books/ copy text • The copy book does not include a 01 level
Copy Statement • Sample of copy book (emp-rec.cpy) 03 emp-id pic x(5). 03 emp-salary pic 9(5). • Sample usage fd emp-file 01 emp-rec. copy emp-rec.
Copy Statement • After compilation fd emp-file 01 emp-rec. 03 emp-id pic x(5). 03 emp-salary pic 9(5).
Perform Verb PROCEDURE DIVISION. TopLevel. Display “Top Level.Start Program” Perform Level_One Display “Back in Top Level.”. STOP RUN. Level_Two Display “Now in Level 2” Level_One Display “Now in Level 1” Perform Level_Two Display “Return to Level 1”
Compulsory Lab Exercise • Using PERFORM paragraph PERFORM X TIMES, create a program that accepts user to enter X times for a paragraph to display “I love COBOL and UNITEN.” • Please try before I show you the answer at the end of the lab.