SlideShare una empresa de Scribd logo
1 de 88
User Manual for COBOL
_______________________________________________________________________________




         COBOL




         Training
         Material




_______________________________________________________________________________
 COBOL                                                                   1
User Manual for COBOL
_______________________________________________________________________________
Table of Contents


1. OBJECTIVES...........................................................................................................9

2. INTRODUCTION TO COBOL................................................................................10

2.1. LANGUAGE CONSTRUCTION..........................................................................10

2.2. COBOL CHARACTER SET................................................................................10

2.3. COBOL WORDS.................................................................................................10

2.4. COBOL CODING FORM.....................................................................................11

2.5. DIVISIONS OF COBOL......................................................................................11

3. IDENTIFICATION DIVISION..................................................................................12

3.1. SYNTAX OF IDENTIFICATION DIVISION.........................................................12

4. ENVIRONMENT DIVISION....................................................................................13

4.1. CONFIGURATION SECTION.............................................................................13

4.1.1. SOURCE-COMPUTER....................................................................................13

4.1.2. OBJECT COMPUTER.....................................................................................13

4.1.3. SPECIAL-NAMES............................................................................................13

4.2. INPUT-OUTPUT SECTION.................................................................................15

4.2.1. FILE-CONTROL...............................................................................................15

4.2.2. I-O CONTROL..................................................................................................15

5. DATA DIVISION.....................................................................................................17

5.1. LITERALS AND FIGURATIVE CONSTANTS....................................................17

5.1.1. NUMERIC LITERAL.........................................................................................18

_______________________________________________________________________________
 COBOL                                                                                                       2
User Manual for COBOL
_______________________________________________________________________________
5.1.2. NON-NUMERIC LITERAL...............................................................................18

5.1.3. LIST OF FIGURATIVE CONSTANTS............................................................18

5.2. DATA DESCRIPTION.........................................................................................19

5.2.1. LEVEL NUMBERS...........................................................................................19

5.2.1.1. SPECIAL LEVEL NUMBERS.......................................................................20

5.2.2. DATA NAMES..................................................................................................20

5.2.2.1. FILLER..........................................................................................................21

5.2.3. CLAUSE...........................................................................................................21

5.2.3.1. PICTURE CLAUSE.......................................................................................22

5.2.3.1.1. EDITED PICTURE CLAUSES...................................................................22

5.2.3.1.2. EDIT TYPES - NUMERIC DATA...............................................................22

5.2.3.1.3. EDIT TYPES - ALPHABETIC....................................................................24

5.2.3.1.4. EDIT TYPES - ALPHANUMERIC..............................................................24

5.2.3.1.5. EDIT COMBINATION................................................................................24

5.2.3.2. VALUE CLAUSE...........................................................................................25

5.2.3.3. USAGE CLAUSE..........................................................................................25

5.2.3.3.1. DISPLAY USAGE......................................................................................25

5.2.3.3.2. COMPUTATIONAL(COMP) USAGE........................................................26

5.2.3.4. SIGN CLAUSE..............................................................................................27

5.2.3.5. OCCURS CLAUSE.......................................................................................28

5.2.3.6. REDEFINES CLAUSE..................................................................................28

5.2.3.6.1. EXPLICIT USE OF REDEFINES...............................................................28
_______________________________________________________________________________
 COBOL                                                                                                         3
User Manual for COBOL
_______________________________________________________________________________
5.2.3.6.2. RESTRICTIONS ON USE OF REDEFINES..............................................29

5.2.3.7. RENAMES.....................................................................................................29

5.2.3.8. JUSTIFIED CLAUSE....................................................................................29

5.2.4. CONDITION NAMES.......................................................................................30

6. PROCEDURE DIVISION........................................................................................31

6.1. STATEMENTS IN PROCEDURE DIVISION.......................................................31

6.2. DATA MOVEMENT.............................................................................................33

6.2.1. MOVE...............................................................................................................33

6.2.1.1. DATA MOVEMENT RULES.........................................................................33

6.2.1.2. NUMERIC DATA TRANSFER RULES.........................................................33

6.2.1.3. ALPHANUMERIC DATA TRANSFER.........................................................34

6.2.1.4. GROUP MOVES............................................................................................34

6.2.1.5. MOVE CORRESPONDING...........................................................................35

6.3. ARITHMETIC VERBS ........................................................................................36

6.3.1. ADD..................................................................................................................36

6.3.2. SUBTRACT......................................................................................................37

6.3.3. MULTIPLY........................................................................................................37

6.3.4. DIVIDE..............................................................................................................37

6.3.5. ROUNDED OPTION.........................................................................................38

6.3.6. ON SIZE ERROR.............................................................................................39

6.3.7. COMPUTE........................................................................................................40

6.3.8. ARITHMETIC OPERATORS............................................................................40
_______________________________________________________________________________
  COBOL                                                                                                           4
User Manual for COBOL
_______________________________________________________________________________
6.4. MISCELLANEOUS..............................................................................................41

6.4.1. ACCEPT...........................................................................................................41

6.4.2. DISPLAY..........................................................................................................42

6.4.3. CONTINUE.......................................................................................................42

6.4.4. STOP RUN.......................................................................................................42

6.4.5. EXIT..................................................................................................................42

6.4.6. INITIALIZE........................................................................................................42

6.5. CONDITIONAL AND UNCONDITIONAL TRANSFER.......................................44

6.5.1. SIMPLE IF STATEMENT.................................................................................44

6.5.2. NESTED IF.......................................................................................................45

6.5.3. EVALUATE STATEMENT...............................................................................45

6.5.4. GO TO STATEMENT.......................................................................................46

6.5.5. GO TO WITH DEPENDING.............................................................................46

6.5.6. ALTER..............................................................................................................47

6.6. PERFORM STATEMENTS.................................................................................47

6.6.1. BASIC PERFORM............................................................................................47

6.6.2. PERFORM WITH TIMES PHRASE.................................................................49

6.6.3. PERFORM WITH UNTIL PHRASE..................................................................49

6.6.4. PERFORM WITH VARYING PHRASE............................................................50

6.7. CONDITIONAL EXPRESSIONS.........................................................................51

6.7.1. RELATIONAL CONDITION.............................................................................51

6.7.2. SIGN CONDITION............................................................................................52
_______________________________________________________________________________
  COBOL                                                                                                            5
User Manual for COBOL
_______________________________________________________________________________
6.7.3. CLASS CONDITION........................................................................................52

6.7.4. CONDITION-NAME CONDITION....................................................................53

6.7.5. NEGATED SIMPLE CONDITION....................................................................53

6.7.6. COMPOUND CONDITION...............................................................................53

7. FILE HANDLING....................................................................................................53

7.1. SEQUENTIAL FILES..........................................................................................54

7.2. INDEXED FILES..................................................................................................54

7.3. DIRECT ACCESS FILES....................................................................................54

7.4. STEPS INVOLVED IN FILE HANDLING............................................................54

7.4.1. EXAMPLE........................................................................................................56

7.5. SELECT STATEMENT.......................................................................................56

7.5.1. ORGANIZATION CLAUSE..............................................................................57

7.5.2. ACCESS MODE CLAUSE..............................................................................58

7.5.3. RECORD KEY PHRASE..................................................................................58

7.5.4. ALTERNATE KEY PHRASE...........................................................................58

7.6. FD ENTRY...........................................................................................................58

7.6.1. BLOCK CONTAINS / RECORD CONTAINS PHRASE..................................59

7.6.2. RECORDING MODE CLAUSE.......................................................................59

7.7. INPUT / OUTPUT STATEMENTS......................................................................61

7.8. VSAM DATA SET...............................................................................................62

7.8.1. VSAM DATASETS AND ACCESS MODES....................................................63

7.8.1.1. ORGANIZATION CLAUSE...........................................................................63
_______________________________________________________________________________
 COBOL                                                                                                        6
User Manual for COBOL
_______________________________________________________________________________
7.8.2. ENVIRONMENT DIVISION ENTRIES FOR VSAM FILES..............................64

7.8.3. COBOL STATEMENTS USABLE WITH SEQUENTIAL FILES.....................65

7.8.4. COBOL STATEMENTS WITH INDEXED FILES (KSDS) AND RELATIVE
(RRDS).......................................................................................................................65

7.8.5. PROCEDURE DIVISION STATEMENTS TO UPDATE VSAM FILES...........66

7.8.6. ERROR PROCESSING FOR VSAM................................................................67

7.8.7. APPLICATIONS BEST SUITED TO VSAM DATASETS................................67

7.8.7.1. ESDS.............................................................................................................67

7.8.7.2. KSDS.............................................................................................................68

7.8.7.3. RRDS.............................................................................................................68

8. SUBPROGRAMS...................................................................................................69

8.1. LINKAGE SECTION............................................................................................69

8.1.1. STATIC / DYNAMIC CALLS............................................................................69

8.1.2. PASSING RETURN CODE INFORMATION...................................................71

9. STRING , UNSTRING AND INSPECT STATEMENTS.........................................72

9.1. STRING STATEMENT........................................................................................72

9.2. UNSTRING STATEMENT...................................................................................73

9.3. INSPECT STATEMENT......................................................................................74

9.4. DECLARATIVES.................................................................................................76

10. SORT AND MERGE STATEMENTS...................................................................77

11. INTRINSIC FUNCTIONS.....................................................................................79

11.1. NUMBER HANDLING......................................................................................79


_______________________________________________________________________________
  COBOL                                                                                                            7
User Manual for COBOL
_______________________________________________________________________________
11.2. DATE / TIME....................................................................................................79

11.3. FINANCE..........................................................................................................80

11.4. MATHEMATICS & STATISTICS.....................................................................80

12. COMPILER OPTIONS........................................................................................81

13. APPENDIX...........................................................................................................83

13.1. ERROR CODES...............................................................................................83

13.2. EXERCISES:....................................................................................................84

13.2.1. BASIC PROBLEM SOLVING........................................................................84

13.2.2. REPORT PREPARATION.............................................................................85

13.2.3. ARRAY HANDLING.......................................................................................86

13.2.4. FILE HANDLING............................................................................................86

13.3. JCL...................................................................................................................87




_______________________________________________________________________________
  COBOL                                                                                                           8
User Manual for COBOL
_______________________________________________________________________________

1. OBJECTIVES


The main objective after the completion of this course, is that the students should be able to:
      ♦   Understand the standard format of the COBOL program.
      ♦   Write COBOL programs which uses VSAM or Non VSAM files.
      ♦   Submit jobs to Compile and Link-edit COBOL source codes.
      ♦   Write programs using modular design techniques.




_______________________________________________________________________________
 COBOL                                                                                            9
User Manual for COBOL
_______________________________________________________________________________

2. INTRODUCTION TO COBOL


COBOL => COMMON BUSINESS ORIENTED LANGUAGE
Cobol can be referred to as :
     1. High-Level Programming language oriented towards business applications.
     2. A procedure oriented language. A Procedure is a module having its own task. A Problem
         may be segmented into several tasks. Each task is written as a Paragraph in Procedure
         Division and executed in a logical sequence as mentioned.
     3. Problem Oriented and Machine independent




2.1. LANGUAGE CONSTRUCTION

     ♦       COBOL is like an English language.
     ♦       Character is the lowest component.
     ♦       Word is made up of one or more characters.
     ♦       Clause consists of word and characters. It specifies an attribute for an entry
     ♦       Statement is syntactically valid combination of words and clauses
     ♦       Sentence is a sequence of one or more statements terminated by period
     ♦       Paragraph consists of one or more sentences
     ♦       Section consists of one or more paragraphs
     ♦       Division consists of one or more paragraphs or sections
     ♦       Program is made up of divisions




2.2. COBOL CHARACTER SET


Set of 52 characters
         0,..9                      DIGITS
         A,..Z                      LETTERS
         b                          SPACE/BLANK CHARACTER
         +,-,*,/,(,),=              SPECIAL SYMBOLS
         $,;,“,>,<,.,:




2.3. COBOL WORDS


User defined words
_______________________________________________________________________________
 COBOL                                                                                        10
User Manual for COBOL
_______________________________________________________________________________
        ♦ Words declared by programmer to coin identifiers, paragraph names, file names and section
          names.
Reserved words
        ♦ Words which are having specific meaning to the compiler.




2.4. COBOL CODING FORM


Columns
1- 6        Sequence numbers identifying pages or lines of a program
7           Continuation, comment or starting of a new page
8-11        Area A
12-72       Area B
73-80       Remarks




2.5. DIVISIONS OF COBOL

        ♦    IDENTIFICATION DIVISION
        ♦    ENVIRONMENT DIVISION
        ♦    DATA DIVISION
        ♦    PROCEDURE DIVISION




_______________________________________________________________________________
    COBOL                                                                                11
User Manual for COBOL
_______________________________________________________________________________

3. IDENTIFICATION DIVISION

The Identification division is:
      ♦ First division of a Cobol program.
      ♦ Paragraph program-id followed by a user-defined name is compulsory. Other paragraphs are
        optional but essential for documentation.
      ♦ Should begin in Area A.
      ♦ Length of PROGRAM-ID differs from compiler to compiler. For example, in the case of
        IBM COBOL, it is 8 characters.




3.1. SYNTAX OF IDENTIFICATION DIVISION


IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM NAME.
AUTHOR.COMMENT ENTRY.
INSTALLATION.COMMENT ENTRY.
DATE-WRITTEN.COMMENT ENTRY.
DATE-COMPILED.COMMENT ENTRY.
SECURITY.COMMENT ENTRY.]

Security here does not pertain to the operating system security, but the information that is passed to
the user of the program about the Security features of the program.




_______________________________________________________________________________
 COBOL                                                                                     12
User Manual for COBOL
_______________________________________________________________________________

4. ENVIRONMENT DIVISION

     ♦   It is a machine dependent division.
     ♦   The Division itself is optional but for file handling it is essential.
     ♦   Should begin in Area A.
     ♦   Division is terminated by a period.
     ♦   Describes the computer used, peripheral devices, etc.
     ♦   Contains two sections namely, CONFIGURATION and INPUT-OUTPUT.




4.1. CONFIGURATION SECTION


Mentions the name of the source-computer, object-computer, special-names, symbolic-names and
classes defined by programmer.
The paragraphs of configuration section are SOURCE-COMPUTER, OBJECT-COMPUTER, and
SPECIAL-NAMES.




4.1.1.         SOURCE-COMPUTER

     ♦ Used to specify the name of the Source Computer compiling the COBOL program.
     ♦ The “With Debugging Mode” option can be mentioned to enable the Compiler to include
       all the lines with ‘D’ in the 7th column as syntax(Otherwise it is taken as comment). It can
       also include the debug Declaratives in PROCEDURE DIVISION.




4.1.2.         OBJECT COMPUTER

     ♦ Used to specify the target system.
     ♦ The program collating sequence can also be specified in this paragraph for SORTING and
       STRING COMPARISON. By default, EBCDIC code is followed in MVS. We can change
       it to ASCII, or any other order if we define SPECIAL-NAMES.



4.1.3.         SPECIAL-NAMES

     ♦ Specifies collating sequence.

_______________________________________________________________________________
 COBOL                                                                                  13
User Manual for COBOL
_______________________________________________________________________________
    ♦    Maps IBM specified environment names to user defined mnemonic names.
    ♦    Substitutes character for currency sign.
    ♦    Indicates that ‘ ; ‘ and ‘ . ‘ are to be interchanged in the PIC clause.
    ♦    We can also specify symbolic characters, such as, PERCENTAGE-SIGN IS 38.
    ♦    Regardless of the number of entries in this paragraph, there should be only one period at the
         end.




_______________________________________________________________________________
 COBOL                                                                                     14
User Manual for COBOL
_______________________________________________________________________________

4.2. INPUT-OUTPUT SECTION

     ♦ Contains information regarding files to be used in the program.
     ♦ Consists of two paragraphs FILE-CONTROL and I-O CONTROL.




4.2.1.          FILE-CONTROL


Associates each file used in a COBOL program with an external ddname.
Physical dataset is assigned in DD statement of JCL at execution time.
Three formats for the FILE-CONTROL paragraph are :
     ♦ Sequential file entries
     ♦ Indexed file entries
     ♦ Relative file entries
Coding rules for FILE-CONTROL paragraph.
     ♦ SELECT clause must appear first
     ♦ Other clauses may appear in any order
     ♦ Each clause must start in Area B




4.2.2.          I-O CONTROL

     ♦   Optional Paragraph.
     ♦   Specifies when check points are to be taken.
     ♦   Specifies the storage areas to be shared by different files.
     ♦   The key word I-O control must begin in Area A.




_______________________________________________________________________________
 COBOL                                                                   15
User Manual for COBOL
_______________________________________________________________________________
Example:
IDENTIFICATION DIVISION.
PROGRAM-ID.        DSQ001.
AUTHOR.            A343.
INSTALLATION.      AT DSQ. MAD.
DATE-WRITTEN.      06-04-94.
DATE-COMPILED. XX-XX-XX.
SECURITY. ONLY FOR         TRAINEES.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.                  ES-9000 WITH DEBUGGING MODE.
OBJECT-COMPUTER.        ES-9000
            PROGRAM COLLATING SEQUENCE IS A01.
SPECIAL-NAMES.        C12 IS BOTTOM OF PAGE.
            ALPHABET A01 IS
                           “A”    ALSO   “a”
                           “B”    ALSO   “b”
      ALPHABET A IS STANDARD-1.
      SYSIN IS PROGIN
      CURRENCY IS @
      DECIMAL POINT IS COMMA
INPUT-OUTPUT SECTION.
FILE-CONTROL
            SELECT OUTFILE ASSIGN TO DD1
            ORGANIZATION IS SEQUENTIAL
            ACCESS MODE SEQUENTIAL
            FILE STATUS IS WS-FST.




_______________________________________________________________________________
 COBOL                                                                  16
User Manual for COBOL
_______________________________________________________________________________

5. DATA DIVISION


Data division is used to define data needed to be accessed by the program. The three sections of this
division are
FILE SECTION
     ♦ Describes Record Structure of Files
WORKING-STORAGE SECTION
     ♦ Succeeds file section
     ♦ Used for intermediate storage
     ♦ Common practice to group related items together.
LINKAGE SECTION
     ♦ Describes data made available from another program.




5.1. LITERALS AND FIGURATIVE CONSTANTS.

     ♦ Literal is a constant representing a number or Non number (Alpha numeric) like 45.3 /
       ‘MANAGER’.
     ♦ Literals are storable in a memory Location having a user defined name called Data Name or
       Identifier or
     ♦ Variable or Field
     ♦ Figurative Constant is a COBOL RESERVED WORD representing frequently used
       constants like
       ♦ ZEROS / SPACES.
     ♦ Figurative constants are used in the program as such for better readability as.
       ♦ MOVE SPACES TO WS-REC.
     ♦ Literals are classified in to NUMERIC and NON-NUMERIC literals.




_______________________________________________________________________________
 COBOL                                                                                    17
User Manual for COBOL
_______________________________________________________________________________

5.1.1.           NUMERIC LITERAL

      ♦    Must contain at least one digit
      ♦    Sign, if used must be the left-most character
      ♦    Not more than one decimal point
      ♦    Decimal may not be the right most character
      ♦    Maximum of 18 digits.
      ♦    TOTAL-MARK           PIC 9(3) VALUE 100..
      ♦    Here 100 is a numeric constant assigned in identifier TOTAL-MARK.




5.1.2.           NON-NUMERIC LITERAL

      ♦    May consist of any character in the character set
      ♦    Must be enclosed in quotes
      ♦    A numeric literal in quotes is non-numeric
      ♦    Maximum length of 120 chars
05 COMPANY-NAME                PIC X(3) VALUE ‘DSQ’.
Here ‘DSQ’ is a Alphanumeric constant assigned in identifier COMPANY-NAME,




5.1.3.            LIST OF FIGURATIVE CONSTANTS

ZERO/ZEROES/ZEROS                 ONE OR MORE ZEROS
QUOTE/QUOTES                      ONE OR MORE“
SPACE/SPACES                      ONE OR MORE SPACE
HIGH VALUE/HIGHEST VALUE HIGHEST VALUE IN COLLATING

          SEQUENCE
LOW VALUE/LOWEST VALUE            LOWEST VALUE IN COLLATING

          SEQUENCE
ALL                      ONE or MORE STRING CHARACTERS




_______________________________________________________________________________
 COBOL                                                                         18
User Manual for COBOL
_______________________________________________________________________________

5.2. Data Description


The general format of the data description is
        ♦ Level-number data-name/FILLER clauses




5.2.1.            LEVEL NUMBERS

        ♦ A Record is a Collection of all the fields pertaining to an Item/person/Transaction.
        ♦ A record structure is a structure of all the fields of a record. It may be available in the FILE
          SECTION/ WORKING-STORAGE SECTION/ LINKAGE SECTION.
        ♦ The level-number specifies the hierarchy of data within a record, and identifies special-
          purpose data entries. A level-number begins a data description entry, a renamed or
          redefined item, or a condition-name entry.
        ♦ A level-number has a value taken from the set of integers between 1 and 49, or from one of
          the special level-numbers, 66, 77, or 88.
01        This level - number specifies the record itself.
        ♦ A level - 01 entry may be either a group item or an elementary item.
        ♦ It must begin in Area A.
02-49     These level numbers specify group and elementary items within a record.
        ♦ They may begin in Area A or B
        ♦ Group Level Data Names Will not have Picture Clause.
                                EMPLOYEE-REC.
                                        EMP-NO                PIC   XXXX.
                                                 EMP-NAME
                       03 FIRST-NAME          PIC    A(30).
                       03 INITIAL-1            PIC    A.
                       03 INITIAL-2            PIC    A.
                       03 INITIAL-3            PIC    A.




_______________________________________________________________________________
 COBOL                                                                                         19
User Manual for COBOL
_______________________________________________________________________________

5.2.1.1.        SPECIAL LEVEL NUMBERS


66      Identifies items that contain the RENAMES clause.
77      Identifies independent elementary data item.
Identifies any condition name that is associated with a particular value of conditional variable
Level Number 01 can appear as a Group Level Number as well as Elementary data item level number.
It can appear only as an elementary Data Item Level Number.
Example
01     TOTAL          PIC 9(5).
77     WS=FLAG PIC XX.




5.2.2.          Data Names

      ♦ Identifier name/ Data name should not exceed 30 Characters.
      ♦ There should be at least one Alphabet anywhere in the name.
      ♦ Only special Character allowed is – ( Hyphen) but should not be at the Beginning or End
Examples of datanames
      ♦ EMPLOYEE-NAME , COMPANY, 0001AB, 999-EMPLOYEE-RECORD
      ♦ Dataname must be unique within a Record
      ♦ If ‘Name’ is duplicated across Records, it has to be qualified as Identifier-name of Record
        Name.
      ♦ Display balance of stock-record
      ♦ Here balance is an identifier declared in Stock-record.




_______________________________________________________________________________
 COBOL                                                                                        20
User Manual for COBOL
_______________________________________________________________________________

5.2.2.1.         FILLER


Whenever there is no need for specific reference to fields in a record structure, we name it as
FILLER Or F . This Data name is used wherever there is fixed information like SPACES Or
Headings
Are stored.
Example        01    Detail-record.


                      05    FILLER       PIC X(10) VALUE SPACES.
     05   NAME      PIC X(30) .
             05              FILLER                    PIC        X(10)           VALUE       SPACES.
 .         05 BASIC         PIC 9(05) .
               05            FILLER                    PIC        X(10)           VALUE       SPACES.
              05 DA          PIC 9(04) .
               05             FILLER                   PIC        X(10)           VALUE       SPACES.
              05 GROSS       PIC 9(6).




5.2.3.           CLAUSE


A Clause specifies certain characteristics of the data item being described.
The detail of each Clause is explained below.




_______________________________________________________________________________
 COBOL                                                                                        21
User Manual for COBOL
_______________________________________________________________________________

5.2.3.1.        PICTURE CLAUSE


Describes the class (numeric, alphabetic, alphanumeric), sign(signed/unsigned), decimal point
location and size characteristics of a data item.
Specified for every elementary item
Format of Picture Clause.
PICTURE character string

 TYPE            CHARACTER STRING                        REMARK

 Numeric                            9                    Used for arithmetic operations

                                    V                    Assumed Decimal Point



                                    S                    Data item is Signed

                                    P                    Position of Assumed decimal point when
                                                         the point lies outside the data item

 Alphabetic                         A                    Data Item contains only a Letter Or Space

                                    B                    Blank insertion character

 Alpha                              X                    Data item contains any allowable character
 Numeric                                                 from the COBOL character set.

EXAMPLES
VAR1    PIC A(04)     (Defines 4 alphabetic characters.)
VA      R2 PIC 9(4)         (Defines 4 Numeric digits)




5.2.3.1.1. EDITED PICTURE CLAUSES


Used to display Numeric and other data in the human readable form.
Displaying the number as 77,419.56 is easier to read instead of 7741958.




5.2.3.1.2. EDIT TYPES - NUMERIC DATA


Z               ZERO SUPPRESSION
_______________________________________________________________________________
    COBOL                                                                                 22
User Manual for COBOL
_______________________________________________________________________________
*            ASTERISK
$            CURRENCY SIGN
-            MINUS SIGN
+            PLUS SIGN
CR DB               CREDIT DEBIT SIGN
PERIOD(.) COMMA(,) BLANK(‘b‘) ZERO(0) SLASH(/)
BLANK WHEN ZERO (Inserts blanks when data value is zero)




_______________________________________________________________________________
    COBOL                                                               23
User Manual for COBOL
_______________________________________________________________________________

5.2.3.1.3. EDIT TYPES - ALPHABETIC


Used To Insert Blank within Alphabetic Characters.
Example:   10     Var1 PIC A(2)BBBA(3) VALUE “xyabc”




5.2.3.1.4. EDIT TYPES - ALPHANUMERIC

                               BLANK, ZERO and SLASH INSERTION
        PIC   OF         THE          NUMERIC VALUE        EDITED VALUE
        FIELD

        ZZZV99                        38^4                 b3840

        * * 999                       00052                * * 052

        $ * *999                      985                  $**985

        -ZZZV99                       -46^52               -b4652

        +999                          -382                 -382

        +999                          382                  +382

        9999+                         -382                 0382-

        ZZ,Z99                        2456                 b2,456

        ZZZZ.ZZ                       5                    bbbb.05

        $$$$9.99                      342                  b$342.00

        99B99B99                      46                   00b00b46

        09990                         456                  04560

        999/999/99                    3254                 000/032/54
                               BLANK WHEN ZERO
        ZZZ.99 BLANK WHEN ZERO                       25    bb2.50

        999.99 BLANK WHEN ZERO                       0     bbbbbb


5.2.3.1.5. EDIT COMBINATION


_______________________________________________________________________________
 COBOL                                                                    24
User Manual for COBOL
_______________________________________________________________________________
+, -, CR, DB     Are Mutually Exclusive
$, +, -, Z, *    Are Mutually Exclusive.
$ can appear at first place and * as Floating($****.**)
V and .          Are Mutually Exclusive




5.2.3.2.         VALUE CLAUSE
Assigns initial value to a data item
VALUE IS literal

Literal can be Numeric, Non-Numeric(in Quotes) or Figurative Constant
Not for items whose size is variable
Value of item should not exceed picture size
Consistent with class of PIC clause
EXAMPLES


01 WS-REC.
          05 WS-NAME     PIC X(30)        VALUE ‘ABC COMPANY ‘.
          05 FILLER      PIC X(20)        VALUE ALL ‘ - ‘.
01        WS-NUM1        PIC 9(5) VALUE ZERO.
01        WS-CHAR2       PIC X(5) VALUE ZERO.




5.2.3.3.         USAGE CLAUSE

Specifies how a data item is represented internally.
      ♦ DISPLAY
      ♦ COMPUTATIONAL
SYNTAX
USAGE IS         [DISPLAY ]
[COMPUTATIONAL]           [COMP-1] [COMP-2] [COMP-3]

5.2.3.3.1. DISPLAY USAGE.


Each character of the data is represented in one byte .
The number of bytes required is equal to the size of the item.
DISPLAY is the default usage

_______________________________________________________________________________
  COBOL                                                                 25
User Manual for COBOL
_______________________________________________________________________________




5.2.3.3.2. COMPUTATIONAL(COMP) USAGE

     ♦    Maintained in binary
     ♦    Only integral numbers
     ♦    Depending on the size of the data item, it can be stored either in half word or full word
     ♦    Should be numeric only
     ♦
          NUMBER OF digits IN PIC                LENGTH OF ITEM IN BYTES

                     1 TO 4                                       2

                     5 TO 9                                       4

                    10 TO 18                                      8


01       WS - NUM        PIC S9(004) USAGE COMP.
COMP-1 USAGE .
     ♦    One word in floating point form
     ♦    The number is represented in hexadecimal
     ♦    The picture clause cannot be specified
     ♦    Suitable for arithmetic operations
WS - NUM           USAGE COMP1 .
COMP-2 USAGE.
     ♦ Same as COMP 1 except that data is represented internally in two words
     ♦ Increases the precision of the data




_______________________________________________________________________________
 COBOL                                                                                       26
User Manual for COBOL
_______________________________________________________________________________
COMP-3 USAGE.
       ♦       Internal Representation In Packed Decimal Form
       ♦       Each digit and sign occupy 1/2 a byte
       ♦       The Hexadecimal number C or F denotes a positive sign
       ♦       The Hexadecimal number D denotes a negative sign
EXAMPLE FOR USAGE COMP - 3
10 A       PIC    S9(3)     USAGE COMP-3 VALUE 123.
Internally stored as
0001       0010      0011   1111
1          2         3      F
10 A       PIC S9(04)       USAGE COMP-3 VALUE 123.
is stored as
0000       0000      0001   0010      0011   1111
(Extra Byte)




5.2.3.4.             SIGN CLAUSE

       ♦       [SIGN IS][LEADING]              [SEPARATE CHAR ]          [TRAILING]
       ♦       Specifies the position and mode of representation of sign
       ♦       Only for numeric elementary items
       ♦       Picture string should contain ‘S’
       ♦       Usage should be DISPLAY
       ♦       Default is TRAILING without separate character
EXAMPLE


                    PIC         VALUE               SIGN       REPRESENTATION

                   S9(3)           -243        LEADING                 K 4 3

                   S9(3)           -243       TRAILING                 2   4 L




_______________________________________________________________________________
    COBOL                                                                             27
User Manual for COBOL
_______________________________________________________________________________

5.2.3.5.        OCCURS CLAUSE


There may be a need to keep a table of values in the memory for calculations. We use OCCURS
clause to allocate physically contiguous memory locations to store the table values and access them
with subscripts.
Example,


01 WS-TABLE.
        10 WS-NAME     OCCURS          10      TIMES PIC X(20).
01 WS-TABLE.
        10 WS-REC      OCCURS          10      TIMES.
                15 X           PIC X(5).
                15 Y           PIC X(8).

WS - REC (1) = 13 BYTES (i.e. X(1) = 5 bytes, Y(1) = 8 bytes)
Hence, 10 such group items (WS-REC) are allocated memory space contiguously.




5.2.3.6.        REDEFINES CLAUSE


This clause allows the same area of memory to be referenced by more than one data-name with
different formats and sizes.
SYNTAX AND RULES
< Lvl.no >   <Data-item-1>     REDEFINES       <Data-item-2>.
Redefines clause must immediately follow <data-item-1>
Level nos of <data-item-1> and <data-item-2> must be identical and not 66 or 88.




5.2.3.6.1. Explicit Use OF REDEFINES


REDEFINES must be used for remapping record areas outside the FILE-SECTION, or within the
FILE-SECTION if a part of a record is to be remapped.




_______________________________________________________________________________
 COBOL                                                                                  28
User Manual for COBOL
_______________________________________________________________________________
Example,
FD CARDIN.
01 D-TYPE-1
        05 CARD-CODE PIC        9.
        05 NAME-ADD.
                10 NAME         PIC       X(20).
                10 ADD-LN-1     PIC       X(40).
        05 NAME-DD      REDEFINES         NAME-ADD.
                10 ADD-LN-2     PIC       X(60).




5.2.3.6.2. RESTRICTIONS ON USE OF REDEFINES


Redefinition ceases whenever a level number is less than or equal to that of <data-item-1 > or <data-
item-2>
Multiple redefinition’s of the same area is possible provided there are no new storage areas
defined in between . < data-item - 1 > and <data-item-2>
Value clauses are allowed only in condition names in a redefined data-item.
At 01 level, OCCURS and REDEFINES cannot be combined
<data-name-2> may not have an OCCURS clause




5.2.3.7.        RENAMES


Regrouping of elementary data items in a Record.


01      W-RESPONSE
        05      W-CHAR-123      PIC XXX.
        05      W-CHAR-4        PIC X.
        05      W-CHAR-56       PIC XX.
        66      ADD-RESPONSE          RENAMES W-CHAR-123.
      66        VIEW-RESPONSES        RENAMES W-CHAR-123         THRU       W-
CHAR-4.
      66        DELETE-RESPONSE RENAMES W-CHAR-123               THRU       W-
CHAR-56.


5.2.3.8.        JUSTIFIED CLAUSE


_______________________________________________________________________________
 COBOL                                                                                    29
User Manual for COBOL
_______________________________________________________________________________
Overrides standard positioning rules for a receiving stem of the alphabetic or alphanumeric
categories.
01       WS-CHAR            PIC   X(05)   JUSTIFIED RIGHT.

Default is left justified
Justified clause does not alter initial settings as determined by the value clause
Justified clause must not be specified with level 66(RENAMES) and level 88(condition-names)
clauses.




5.2.4.            CONDITION NAMES

      ♦ Allow users to assign acceptable values for data names
      ♦ Are used as an abbreviation for condition checking

01       W-PERSON-STATUS PIC 9(02).
         88 C-PER-MINOR       VALUE O THRU 20
         88 C-PER-ADULT       VALUE 21 THRU 99




_______________________________________________________________________________
 COBOL                                                                               30
User Manual for COBOL
_______________________________________________________________________________

6. PROCEDURE DIVISION

     ♦ Last division in a COBOL program
     ♦ Contains statements which specify the operations to be performed
     ♦ Contains the following structure

STRUCTURE
         PROCEDURE DIVISION
                SECTION
                        PARAGRAPHS
                                SENTENCES
                                        STATEMENTS
                                                VERBS

     ♦ Paragraph names and section names should start in Area A
     ♦ Statements and sentences should start in Area B
     ♦ Section names and paragraph names are user-defined
     ♦ Section names must be unique and must be different from paragraph names
     ♦ Section names should be followed by a space and the word SECTION with a period at the
       end
     ♦ Paragraph names must be unique within a section
     ♦ If paragraph name is duplicated across sections, it has to be qualified as paragraph-name
       { of / in } section name




6.1. STATEMENTS IN PROCEDURE DIVISION


Procedure division statements can be broadly classified as
     ♦ Imperative Statements
     ♦ Statement which directs the program to take a specific action during execution
Examples MOVE, ADD, GOTO, EXIT.
     ♦ Conditional Statements
     ♦ A conditional statement specifies that the truth value of a condition is to be determined, and
       that the subsequent action of the object program is dependent on this truth value.
Examples:       IF , EVALUATE , ADD...ON SIZE ERROR, ADD...NOT ON SIZE ERROR
     COMPUTE...ON SIZE ERROR, COMPUTE...NOT ON SIZE ERROR
     ♦ Compiler Directives
A Compiler-Directing Statement is a statement, beginning with a compiler directing verb, that causes
the compiler to take a specific action during compilation.
Example : Use, Copy

_______________________________________________________________________________
 COBOL                                                                                    31
User Manual for COBOL
_______________________________________________________________________________
     ♦ Explicit Scope Terminator
An EXPLICIT SCOPE TERMINATOR terminates the scope of conditional statements. This includes
statements which contain conditional expression (like IF statement) and imperative statements (like
ADD)
Examples
END-ADD, END-IF, END-COMPUTE, END-DELETE, END-SUBTRACT, END-EVALUATE,
END-CALL,
END-MULTIPLY
     ♦ Implicit Scope Terminator
At the end of any sentence, an IMPLICIT SCOPE TERMINATOR is a separator period that
terminates the scope of all previous statements not yet terminated.




_______________________________________________________________________________
 COBOL                                                                                  32
User Manual for COBOL
_______________________________________________________________________________

6.2. Data Movement


6.2.1.          MOVE


To move data into a place in memory.
Format,


MOVE {IDENTIFIER-1/LITERAL-1} TO IDENTIFIER-2[,IDENTIFIER-3],..


6.2.1.1.        DATA MOVEMENT RULES


Only one sending field , One or more receiving fields.
Value of the sending field remains unaltered after the statement execution.

6.2.1.2.        NUMERIC DATA TRANSFER RULES


When sending field is numeric or numeric-edited, the Data Movement is called Numeric.
The dominant factor in the numeric data transfer is the alignment of decimal points of the two fields
If the decimal point is not explicitly indicated, the decimal point is assumed to be at the right of the
rightmost digit
If the receiving field is not large enough to hold the data received, truncation can take place at either
ends or at both ends
If the significant integral positions are likely to be lost, a warning to that effect is issued by the
compiler
If the receiving field is larger than the sending field, the unused positions will be filled with zeros,
which is known as ‘ zero fill ‘




_______________________________________________________________________________
 COBOL                                                                                        33
User Manual for COBOL
_______________________________________________________________________________

6.2.1.3.         ALPHANUMERIC DATA TRANSFER.

When both the sending and receiving fields are alphabetic, alphanumeric or alphanumeric edited, the
Data Movement is called as Alphanumeric.
In the case of alphanumeric data transfer, receiving area is filled from left to right
When the receiving field is smaller, truncation occurs from the right and the compiler gives a warning
to that effect
If the receiving field is larger than the field, the unused positions will be filled with spaces, which is
called as ‘ space fill ‘
Examples
MOVE A TO B
A                         B
PIC 9999         PIC ZZZ9
bb34
MOVE 15 TO A.
If A has picture of 999, after execution A will contain 015
MOVE “DSQ SOFTWARE Ltd.“ TO COMPANY-MNAME.
MOVE A TO B, C, D.




6.2.1.4.         GROUP MOVES

When At Least One Of The Fields is a Group item, it is called A Group Move
EXAMPLE


        01       REC-1.
                 05       A1      PIC      9999.
                 05       A2      PIC      AA.
                 05       A3      PIC      XXXX.
        01       REC-2
                 05       B1      PIC      9999.
                 05       B2      PIC      AA.
                 05       B3      PIC      XXXX.
MOVE REC-1 TO REC-2




_______________________________________________________________________________
 COBOL                                                                                         34
User Manual for COBOL
_______________________________________________________________________________
6.2.1.5.        MOVE CORRESPONDING


When the names of the corresponding data item of two groups are the same, this statement can be
used to substitute for a set of move statements
MOVE CORRESPONDING IDENTIFIER-1 TO IDENTIFIER-2.
Source and destination groups can include data names that are not common
Only the fields having identical names in the two records will take part in the data movements
The remaining data items in the destination group will remain unchanged
EXAMPLE


01      PAY-REC.
        05      EMP-NO.                 PIC     9(5)
        05      EMP-NAME                PIC     X(30).
        05      EMP-BASIC               PIC     9(5)V99.
01      PRINT-REC.
        05      FILLER          PIC     X(5).
        05      EMP-NO                  PIC     9(5).
        05      FILLER          PIC     X(5).
        05      EMP-NAME                PIC     X(30).
        05      FILLER          PIC     X(5).
        05      EMP-SAL                 PIC     9(6).99.
MOVE CORRESPONDING PAY-REC TO PRINT-REC.




_______________________________________________________________________________
 COBOL                                                                                     35
User Manual for COBOL
_______________________________________________________________________________

6.3. ARITHMETIC VERBS


6.3.1.          ADD


This verb is used to find the sum of two or more numbers and to store the resultant sum


ADD [CORRESPONDING]             [IDENTIFIER-1 / LITERAL-1] [IDENTIFIER-2 / LITERAL-2]
   [TO / GIVING]        IDENTIFIER-3, IDENTIFIER-4, ...

Example:-


ADD A TO B
ADD A B GIVING C.
ADD CORR OLD-REC TO NEW-REC.

In the case of TO option, the previous value of the last named operand takes part in the summation
and then this value is replaced by the result.
Whereas in the case of GIVING option, the value of the last named operand does not take part in the
summation and only the result is stored there.
In the group add, numeric elementary items in the group referred to by first identifier are added to
and stored in the corresponding elementary items of the second group.
Data items in identifier-1 and identifier-2 take part in the summation, only if they have the Same data
name and same qualifiers
Corresponding items can have different locations within the group and the field sizes Can also be
different




_______________________________________________________________________________
 COBOL                                                                                      36
User Manual for COBOL
_______________________________________________________________________________

6.3.2.          SUBTRACT


This verb is used to subtract one or the sum of two or more numbers from one or more numbers.


Subtract [CORR] [IDENTIFIER-1 / LITERAL-1] [IDENTIFIER-2 / LITERAL-2]
   [FROM / GIVING]       IDENTIFIER-3, IDENTIFIER-4, ...

If GIVING option is used literals can be used in place of identifier-4.
Example:-


SUBTRACT A      FROM B.
SUBTRACT A B FROM C.
SUBTRACT A B FROM C D.
SUBTRACT 10     FROM A.




6.3.3.          MULTIPLY


Multiply verb is used to multiply one or more multiplicands by multiplier .


MULTIPLY        {IDENTIFIER-1 BY IDENTIFIER-2 [ , IDENTIFIER-3]...
                LITERAL - 1}
                [GIVING IDENTIFIER-4 [ , IDENTIFIER-5]...]

If giving option is used, LITERALS can be used in place of identifier-2 and identifier-3.
Example:-


MULTIPLY A               BY B.
MULTIPLY A               BY B C D.
MULTIPLY A               BY B GIVING C.
MULTIPLY 0.5     BY B.




6.3.4.          DIVIDE


Divide verb is used to divide one number by another.


_______________________________________________________________________________
 COBOL                                                                                      37
User Manual for COBOL
_______________________________________________________________________________
DIVIDE {Identifier-1 / Literal-1}
         INTO[BY] identifier-2 { ,identifier-3}....
         [GIVING            identifier-4 [ ,identifier-5]...]
         [REMAINDER identifier-6].

Example


DIVIDE     5   INTO A ..
DIVIDE     A   INTO B      GIVING C.
DIVIDE     A   BY    B GIVING C D.
DIVIDE     A   BY    B GIVING C REMAINDER D.




6.3.5.            ROUNDED OPTION


This can be used with any arithmetic verb. It will round the number to the picture clause.


ADD A B GIVING C ROUNDED.

This phrase cannot be specified for the identifier that receives the remainder in a divide operation.




_______________________________________________________________________________
 COBOL                                                                                        38
User Manual for COBOL
_______________________________________________________________________________

6.3.6.           ON SIZE ERROR


If after an arithmetic operation, the result exceeds the largest value that can be accommodated in the
result field, the error is called a “size error”.
Can be used with any arithmetic verb
When a size error occurs, the contents of the resultant field after the operation is unpredictable.
When a size error occurs, the processing is not terminated and the next statement will be taken up for
further execution.
When this phrase is used, the statement becomes a conditional statement.
Example:-


ADD A TO B ON SIZE ERROR GO TO ERROR-PARA.




_______________________________________________________________________________
 COBOL                                                                                         39
User Manual for COBOL
_______________________________________________________________________________

6.3.7.          COMPUTE


This verb is very powerful and is used as a substitute for any of the other arithmetic verbs like add,
subtract, multiply, divide.


COMPUTE         IDENTIFIER-1    [ROUNDED]
                [ , IDENTIFIER-2 [ ROUNDED ] ]
                = ARITHMETIC-EXPRESSION          [ : ON SIZE ERROR]
                IMPERATIVE STATEMENT.




6.3.8.          ARITHMETIC OPERATORS


Arithmetic expression is formed with numeric operands, numeric LITERALS and numeric operators..
Arithmetic expression always assumes a numeric value.
Arithmetic operators permitted in COBOL are


                **      =>      EXPONENTIATION.
                /       =>      DIVISION.
                *       =>      MULTIPLICATION..
                -       =>      SUBTRACTION.
                +       =>      ADDITION.




_______________________________________________________________________________
 COBOL                                                                                     40
User Manual for COBOL
_______________________________________________________________________________

6.4. Miscellaneous


6.4.1.          ACCEPT


Accept statement can transfer data from an input/output device, or system information contained in
the specified conceptual data items DATE, DAY, DAY-OF-WEEK, or TIME
Format


ACCEPT IDENTIFIER [ FROM mnemonic name
                        DATE
                        DAY
                        TIME
                        DAY-OF-WEEK}]

When ‘FROM’ is omitted, the data is read from the operator’s terminal.
At the time of execution, program is suspended until the operator enters the data.
Mnemonic name option is implementation dependent and has to be defined in SPECIAL-NAMES
paragraph.
The date option returns six digit [9(6)] current date in YYMMDD format.
The day option returns five digit [9(5)] current date in YYDDD format.
The time option returns eight digit [9(8)] time in HHMMSSTT format
The day-of-week option returns a single digit [9(1)] value as follows:
1 - Monday,     2 - Tuesday, 3 - Wednesday and so on.


ACCEPT THIS-DATE FROM DATE.




_______________________________________________________________________________
 COBOL                                                                                 41
User Manual for COBOL
_______________________________________________________________________________

6.4.2.          DISPLAY


Display statement is used to display data on the terminal.
Format


DISPLAY         {identifier-1    identifier-2
                 literal-1}      , literal - 2
                [upon mnemonic-name]

Example

DISPLAY “RESULT b IS “,THE-RESULT




6.4.3.          CONTINUE


The CONTINUE statement allows you to specify a no operation statement. CONTINUE indicates
that no executable instruction is present.




6.4.4.          STOP RUN


This verb is used to terminate the execution of the program.




6.4.5.          EXIT


The EXIT statement provides a common end point for a series of paragraphs.
This statement indicates a no operation and when executed, no action takes place




6.4.6.          INITIALIZE


This statement is used to initialize value of either an elementary or group item.

_______________________________________________________________________________
 COBOL                                                                              42
User Manual for COBOL
_______________________________________________________________________________



       INITIALIZE {identifier-1 } . . .
       REPLACING {        ALPHABETIC
                                   ALPHANUMERIC
                                   NUMERIC
                                   ALPHA-NUMERIC-EDITED.
                                   NUMERIC-EDITED }
       DATA BY { identifier-2
                     literal-2 }



Example:-


INITIALIZE WS - REC.
       01 WS - REC.
                05        A        PIC    9(4).
                05        B        PIC    A(4).
                05        C        PIC    X(4).
       DATAITEM           PIC      BEFORE         AFTER
                                   EXECUTION EXECUTION
       A                  9(4)     1000           0000
       B                  A(4)     LIFE           bbbb
       C                  X(4)     A2BC           bbbb
INITIALIZE B
                REPLACING NUMERIC             DATA BY 105
                REPLACING ALPHANUMERIC            DATA BY “ LOVE “
                REPLACING NUMERIC-EDITED DATA BY 1500.23.




_______________________________________________________________________________
 COBOL                                                                  43
User Manual for COBOL
_______________________________________________________________________________

6.5. CONDITIONAL AND UNCONDITIONAL TRANSFER


6.5.1.            SIMPLE IF STATEMENT.

IF condition [THEN]
          statement-1
ELSE
          statement-2
END-IF.

The condition can be any one of the conditions mentioned before.
Statement-1 represents one or more COBOL statements If the condition is found to be true, the
statements represented in the THEN part will be executed. Statement-1 and Statement-2 represents
one or more COBOL statements
If the condition is found to be FALSE, the statements represented in the ELSE part will be executed
After execution of this statement control will be implicitly transferred to the next sentence following
the IF statement.
Period (.) is placed only at the end of the IF structure. i.e. after the connective END-IF.
Example:-


IF        AMOUNT > 5000 THEN
          ADD AMOUNT TO TOTAL-1
ELSE
          ADD AMOUNT TO TOTAL-2
END-IF.

NEXT SENTENCE will be used to make either the THEN or ELSE part dummy.




_______________________________________________________________________________
 COBOL                                                                                        44
User Manual for COBOL
_______________________________________________________________________________

6.5.2.            NESTED IF


Inclusion of one or more IF statements within its scope is called as Nesting.
The most inclusive IF statement must have terminating period.


        IF condition-1 [THEN]
                  IF condition-2 [THEN ]
                           statement-1
                  ELSE
                           statement-2
                  END-IF
        END-IF.

Indent nested ‘if‘ s properly to improve readability and maintainability.

6.5.3.            EVALUATE STATEMENT


Used for decisions and can be used when many branches are there
Can be used as a substitute for nested if “s


EVALUATE          SUBJECT-1        [ALSO SUBJECT-2]...

        {WHEN OBJECT-1             [ALSO OBJECT-2}...}
        [WHEN OTHER {IMPERATIVE-STATEMENT-2}...]
[END-EVALUATE]

A list of subjects and several lists of objects are associated with an Evaluate.
A list of subjects is specified between the word EVALUATE and the first appearance of WHEN
Subject can be an Identifier / Literal /Expression or key words True / False
Each WHEN specifies a list of objects
Number of subjects and number of objects should tally
Subjects and their corresponding objects should be comparable
WHEN phrases are taken up for a “ match “ in the order they appear.
Imperative statements corresponding to the matching WHEN will be executed.
WHEN OTHER phrase is selected only if none of the previous WHEN phrases are selected.
Objects can be Numeric value , Non-numeric value,          Range of Numeric values, Range of non-
numeric values, Conditional Values, keywords
Example:-

_______________________________________________________________________________
 COBOL                                                                                  45
User Manual for COBOL
_______________________________________________________________________________

EVALUATE TRUE
         WHEN MONTH = 4 OR 6 OR 9 OR 11
                 MOVE 30 TO NO - OF - DAYS
         WHEN MONTH = 2
                 MOVE 28 TO NO - OF - DAYS
         WHEN OTHER
                 MOVE 31 TO NO - OF - DAYS
 END-EVALUATE.

Example:-


EVALUATE PRODUCT - TYPE ALSO
         CUSTOMER - TYPE
                 WHEN 1 ALSO ANY
                         MOVE 0 TO COMMISSION
                 WHEN 2 ALSO 1 THRU 5
                         MOVE 10 TO COMMISSION
                 WHEN OTHER
                         MOVE 20 TO COMMISSION
END-EVALUATE.




6.5.4.           GO TO STATEMENT.


It is an unconditional transferring control to the specified paragraph .
There is no any comparison being made by the system before branching off .
Example GOTO DISPLAY-PARA.
Note:-    It is advised to avoid GOTO Statements as the structured programming
Technique does not support unconditional transfer statements.




6.5.5.           GO TO WITH DEPENDING


This verb is used to conditionally transfer the control to elsewhere in the program.
Depending on whether the value of the identifier is 1,2 . . . n , the control is transferred to procedure-
name-1, procedure-name-2, . . . procedure-name-n respectively.
If the value of the identifier is anything other than the specified range of 1, 2 . n, the said go to is
ineffective and the control is transferred to the next statement.
_______________________________________________________________________________
 COBOL                                                                                         46
User Manual for COBOL
_______________________________________________________________________________

GO TO PROCEDURE-NAME-1 [ , PROCEDURE-NAME-2 ]...
        PROCEDURE-NAME-N
DEPENDING ON identifier

The statement transfers control to one of the procedures named in the statement depending on the
value of the identifier
The identifier specified in the statement must be a numeric, integral, elementary item.
Example:-
GO TO RECEIPT-PARA, ISSUE-PARA, ADJUSTMENT-PARA
DEPENDING ON TRANSACTION - TYPE.




6.5.6.          ALTER


The alter statement can be used to modify the targets of goto statements written elsewhere in the
procedure division.


        ALTER PROCEDURE-NAME-1 TO
                [PROCEED TO ] PROCEDURE-NAME-2
                [PROCEDURE-NAME-3 TO {PROCEED TO }
                 PROCEDURE-NAME-4 ]....

Each of the PROCEDURE-NAME-1, PROCEDURE-NAME-3 is the name of the paragraph that
contains only one sentence.
This sentence must consist of a single goto statement without the depending clause.
During the execution each of the PROCEDURE-NAME-1 , PROCEDURE-NAME-3, . . . will be
replaced by PROCEDURE-NAME-2, PROCEDURE-NAME-4 ...respectively.

6.6. PERFORM STATEMENTS


A PERFORM statement is used to execute a group of consecutive statements specified elsewhere in
the program, under a paragraph.




6.6.1.          Basic Perform


PERFORM PARA-name-1.
Para-name-1 specifies the range , which contains statements to be executed

_______________________________________________________________________________
 COBOL                                                                                    47
User Manual for COBOL
_______________________________________________________________________________
Upon execution of this statement the control is transferred to the beginning of the paragraph and
executes all the statements in that paragraph till the last statement.
After executing the said range, the control is implicitly , transferred to the next line after the
PERFORM statement
Example:-


        100-MAIN-PARA.
                PERFORM 1000-ACCEPT-PARA.
                PERFORM 2000-COMPUTE-PARA.

PERFORM para-name-1 thru para-name-2.
This statement executes all the statements beginning in the para-name-1 till the last statement in the
para-name-2
If there are any other paragraphs placed in between these two paragraphs, those are also executed
After executing the said range, the control is implicitly , transferred to the next line after the
PERFORM statement
Example:-


PERFORM BEGIN-PARA THRU END-PARA.




_______________________________________________________________________________
 COBOL                                                                                     48
User Manual for COBOL
_______________________________________________________________________________

6.6.2.           PERFORM with TIMES phrase


PERFORM para-name-1 [THRU para-name-2] {identifier-1/ integer} TIMES.
This is a looping statement which executes the specified range of statements a fixed no. of times.
Example:-


         PERFORM READ-RTN 10 TIMES.

This statement executes all the stmts. in READ-RTN 10 times without testing any condition.




6.6.3.           PERFORM with UNTIL phrase


PERFORM para-name-1 [THRU para-name-2] UNTIL condition.
This statement executes a series of instructions in para-name-1 repeatedly till the condition becomes
TRUE.
Initially the condition is expected to be false.
The condition should be made true, within the paragraph being performed.
If the condition is true initially, the range is not executed at all
Example:-


         MOVE 0 TO I.
         PERFORM 000-CALC-PARA UNTIL I>10
000-CALC-PARA.
         --
         ADD 1 TO I.

Here 000-CALC-PARA is performed 10 TIMES.




_______________________________________________________________________________
 COBOL                                                                                      49
User Manual for COBOL
_______________________________________________________________________________

6.6.4.             PERFORM with VARYING phrase.

PERFORM VARYING{identifier-1 FROM {identifier-2 /integer-1}
          BY       {identifier-3 / integer-2}   UNTIL Condition-1
          AFTER identifier-1          FROM {identifier-2/integer-1}
          BY       {identifier-3/integer-2} UNTIL Condition-2
               [imperative statement]
END-PERFORM.

This is also a looping statement which executes imperative statement for all possible values of
identifier-1 and identifier-3 until Condition-1 and Condition-2 are TRUE.
Example
PERFORM VARYING I FROM 1                        BY 1 UNTIL I > 3
AFTER              J FROM 1           BY 1 UNTIL J > 4
Display        SALE ( I , J )
END-PERFORM.
 The above example will take I and j vales as
1,1 1,2     1,3 1,4 2,1 2,2          2,3 2,4 3,1 3,2       3,3 3,4




_______________________________________________________________________________
 COBOL                                                                               50
User Manual for COBOL
_______________________________________________________________________________

6.7. Conditional expressions


In COBOL there are various types of conditions as follows :


RELATIONAL CONDITION
SIGN CONDITION
CLASS CONDITION.
CONDITION - NAME CONDITION
NEGATED SIMPLE CONDITION.
COMPOUND CONDITION




6.7.1.             RELATIONAL CONDITION


A relation condition compares two operands, either of which can be an identifier, literal, arithmetic
expression, or index-name. A non-numeric literal can be enclosed in parentheses within a relation
condition.
The relational operators are <      <=        >              >=
        NOT GREATER THAN / LESSER THAN / EQUAL TO


        IF A > B
                   DISPLAY “ A IS GREATER THAN B “
        ELSE
                   DISPLAY “ A IS LESS THAN OR EQUAL TO B “
        END-IF .




_______________________________________________________________________________
 COBOL                                                                                    51
User Manual for COBOL
_______________________________________________________________________________

6.7.2.            SIGN CONDITION


The sign condition determines whether or not the algebraic value of a numeric operand is greater
than, less than, or equal to zero. The Possible SIGN conditions are POSITIVE / NEGATIVE /
ZERO.


        IF CURR-STOCK-ISS-QTY IS NEGATIVE
                  DISPLAY “ ISSUE CANNOT BE MADE”
                  GO TO NO-STOCK-PARA
        END-IF.




6.7.3.            CLASS CONDITION


The class condition determines whether the content of a data item is alphabetic,
alphabetic-lower, alphabetic-upper, numeric, or contains only the characters in the set of characters
specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the Environment
Division.
The possible CLASS Conditions are ALPHABETIC / NUMERIC / ALPHANUMERIC


        IF A IS NUMERIC
                  ADD 1 TO A
        ELSE
                  DISPLAY “ NON - NUMERIC DATA FOR A “
                  GO TO ERROR-PARA
        END-IF.




_______________________________________________________________________________
 COBOL                                                                                    52
User Manual for COBOL
_______________________________________________________________________________

6.7.4.            CONDITION-NAME CONDITION


A condition-name condition tests a conditional variable to determine whether its value is equal to any
value(s) associated with the condition-name.
Condition names are not memory locations but names assigned to data ranges .
Comparisons can be simplified .


        01        WS-MARITAL-STATUS
                  88    SINGLE          VALUE IS 0.
                  88    MARRIED                 VALUE IS 1.
        IF SINGLE
                  ADD 1 TO SINGLE-COUNT.




6.7.5.            NEGATED SIMPLE CONDITION


A simple condition is negated through the use of the logical operator NOT.

        IF NOT MARRIED
        DISPLAY “ELIGIBLE FOR RS 1000 ONLY “
        END-IF.




6.7.6.            COMPOUND CONDITION


Two or more conditions can be logically connected to form a compound condition.
The possible Compound Conditions are AND         OR    NOT .


        IF AGE IS LESS THAN 18 AND MARRIED
        DISPLAY “EARLY MARRIAGE “
        END-IF.




7. FILE HANDLING


_______________________________________________________________________________
 COBOL                                                                                     53
User Manual for COBOL
_______________________________________________________________________________
A data file is a collection of relevant records of an application.
A record is a collection of relevant fields pertaining to an item/case/ account/transaction .
File is organized in storage media in one of the following ways
      ♦ SEQUENTIAL
      ♦ INDEXED
      ♦ RELATIVE




7.1. Sequential Files


If a file organization is Sequential then
      ♦ Records can be accessed in the order in which they appear in the file
      ♦ Records can be appended at the end of the file but can not be inserted.
      ♦ Records cannot be deleted




7.2. Indexed Files


Indexed File Organization is to do random Processing or sequential processing.
In this Organization
      ♦ Record can be accessed in any order by key called Primary Key.
      ♦ There can be more than one key called Alternate Keys to access records
      ♦ Records can be inserted added and deleted.




7.3. Direct Access Files

This record is best suited if there are records which can be accessed on record number basis rather
than based on a field of the record.
Each record has a unique address and is identified by a relative record number.

7.4. STEPS INVOLVED IN FILE HANDLING


To handle a file the following operations are to done.
Step 1.




_______________________________________________________________________________
 COBOL                                                                                          54
User Manual for COBOL
_______________________________________________________________________________
     ♦ All files handled in a program should be assigned a logical name chosen by the programmer
       as per the syntax similar to Cobol identifier. The organization of the file ,DDNAME
       assigned for the dataset and its primary and alternate key, if any, have to be specified in the
       File-Control para of Environment Division. This is specified using SELECT statement of
       File-Control para.
Step2.
     ♦ Describe the File with detail like record name ,record structure in the File Section of
       DATA DIVISION .Also specify as how many records are grouped as a BLOCK for Input
       Output Operation.
Step3.
     ♦ All files described as explained above should be first opened      to do read/write
         operations. Open statement is used to connect dataset to the Cobol program. This
         statements are coded in procedure division .
     Files can be opened for reading, writing ,appending .
Step4.
  If we have to read a file READ statement is used in procedure Division.
  SYNTAX
         Read File -name.
  If we have to write in to a file WRITE command is used in procedure Division.
  The record attached to the concerned file alone can be used to write into the file.
         SYNTAX
               WRITE Record -name.
Step5.
  After read / write operations are over the file must be closed to disconnect the file from the
Cobol program.
   SYNTAX
         CLOSE     File-name.




_______________________________________________________________________________
 COBOL                                                                                     55
User Manual for COBOL
_______________________________________________________________________________

7.4.1.          EXAMPLE

IDENTIFICATION DIVISION.
PROGRAM-ID. F1.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE -CONTROL.
      SELECT CUSTOMER-FILE ASSIGN TO DD1.
      ORGANIZATION IS INDEXED.
      ACCESS MODE IS SEQUENTIAL.
      RECORD KEY      IS CUST-NO.
      FILE STATUS    KEY IS WS-FST1.
FILE SECTION.
FD CUSTOMER - FILE
      RECORDING MODE IS F
      RECORD CONTAINS 80 CHARACTERS
      DATA RECORD IS CUSTOMER - RECORD.
01 CUSTOMER RECORD.
      05        CUSTOMER - NAME      PIC   X(13).
      05        CUSTOMER - UNITS     PIC   9(3).
      05        ADDRESS              PIC   X(64).
WORKING-STORAGE SECTION..
01    WS-FST1         PIC X(2).
PROCEDURE DIVISION.
000-MAIN-PARA.
       OPEN OUTPUT CUSTOMER-FILE.
      DIASPLAY WS-FST1.
100-WRITE-PARA.
      ACCEPT CUSTOMER-NAME
      ACCEPT CUSTOMER-UNITS
      ACCEPT ADDRESS
      WRITE       CUSTOMER-RECORD.
      Display WS-FST1.
200-CLOSE -PARA.
      CLOSE CUSTOMER-FILE.
         STOP RUN.


7.5. SELECT Statement


_______________________________________________________________________________
 COBOL                                                                  56
User Manual for COBOL
_______________________________________________________________________________
  Syntax :
  SELECT file-name ASSIGN TO           DD Name
             ORGANIZATION IS [ SEQUENTIAL/INDEXED/RELATIVE]
  ACESS MODE IS [SEQUENTIAL/DYNAMIC/RELATIVE]
   [RECORD KEY data-name-1 ]
   [ALTERNATE KEY IS data-name-2. WITH DUPLICATE]
             FILE-STATUS IS data-name-2.




7.5.1.            ORGANIZATION CLAUSE


This clause should appear in    Environment division.
We can choose File Organization
SEQUENTIAL           This Option is to handle a       PS data set or VSAM ESDS .
Once the file is Organised as Sequential records can be placed as first come first served basis.
INDEXED              This Option is to handle a       VSAM KSDS .
         There should be a key field to choose this operating. This is called primary key
         And is to be unique like ROLLNO, EMPLYEE NO.
RELATIVE                 This Option is to   handle    a     VSAM RRDS . Record Numbers are
identifying the records to access..




_______________________________________________________________________________
 COBOL                                                                                      57
User Manual for COBOL
_______________________________________________________________________________

7.5.2.              ACCESS MODE CLAUSE


This clause should appear in the access mode statement of Environment division.
Files can be accessed in different modes based on the type of Organization.
We can choose access mode depending on the order in which we like it to be accessed.
Sequential Access Mode will facilitate to access any file records in sequential order.
Random      Access Mode will facilitate to access a particular record of an Indexed File / Relative
File
provided the Record key must be set before read / write operation.
Dynamic Access Mode will facilitate to access a particular record or in sequential order from
an Indexed File / Relative File
We give below all possible access modes on organization.

                            Seq. access                Random access          Dynamic access

         Organization

         Sequential         Order of write             Invalid                Invalid

         Relative           Ascending rel rec. no      Value of rel key       Seq. or random

         Indexed            Ascending key value        Value of rel key       Seq. or random




7.5.3.              RECORD KEY PHRASE


This Phrase is to be defined in the Environment Division and essential when the file is an Indexed
File.
This key is to be Unique and is to be a part of the Indexed record.




7.5.4.              ALTERNATE KEY PHRASE


This Phrase is to be defined in the Environment Division when we want to access record in the order
of some other Key apart from primary key.
This key need not be unique but to be a part of the record.

7.6. FD entry

_______________________________________________________________________________
 COBOL                                                                                         58
User Manual for COBOL
_______________________________________________________________________________

Syntax


 FD FILENAME
[BLOCK CONTAINS [int-1 TO ] int-2 RECORDS[CHARACTERS]
[RECORD CONTAINS [int-3 TO } int-4 CHARACTERS
[LABEL RECORD/RECORDS IS/ARE STANDARD/OMITTED
RECORDING MODE IS [ F/ V]
[; DATA RECORD/RECORDS IS/ARE data-name-2]]
record-name
     field1   Pic ..




7.6.1.                 BLOCK CONTAINS / RECORD CONTAINS PHRASE


We can specify the length of the file record in this Clause in terms of Characters this is to be specified
in Data Division. We can specify the number of characters / records contains in a Block.




7.6.2.                 RECORDING MODE CLAUSE


This Phrase is to be defined in the File section Data division. When the file is with Fixed length
record is chosen as F.
This key represent s only the record Number.

RECORDING MODE               [F] [V].

F => Fixed which Indicates that every record of same length
          FD           BLOCK       CONTAINS 500 CHARACTERS.
                       RECORD CONTAINS 50 CHARACTERS.
                       DATA-RECORD IS EMP-RECORD.
EMP-RECORD
01 EMPNO               PIC X(6).
02        EMP-NAME             PIC X(30).
02        BASIC PIC 9(5).
02            HRA              PIC 9(5).
02            DA               PIC 9(4).
The above record is of length 50 characters.

_______________________________________________________________________________
 COBOL                                                                                         59
User Manual for COBOL
_______________________________________________________________________________
V => Variable   which Indicates that record length may vary from I1 to I2.
Example
FD   BLOCK CONTAINS 320 THRU 640 CHARACTERS.
       RECORD CONTAINS 32 THRU 64 CHARACTERS.
DATA RECORD IS MARK-RECORD.
01 MARK-RECORD
02 P1 PIC 99.
02 MARKS OCCURS 10 THRU 20 Depending P1
       03 SCORE PIC 999.
The above record length is based on P1.




_______________________________________________________________________________
 COBOL                                                                       60
User Manual for COBOL
_______________________________________________________________________________

7.7. INPUT / OUTPUT STATEMENTS


Open statement can be used for opening the file with different mode.
OPEN OUTPUT file-name :-                   connects       data set      to   your   COBOL        program
to write records when the file is even with out a single record..
OPEN INPUT             file-name     :-       connects     data   set   to   your   COBOL        program
to records from the first .
OPEN EXTEND file-name :- connects data set to your COBOL program for writing new records
in an existing non empty file.
OPEN I-O file-name         :-      connects     data set to your COBOL program for processing
to do read/write /Rewrite.
WRITE :- Add records to a file or load a file . When this command is used in an Indexed file
key must be newer one always.
START Establish the current location in the cluster for a READ NEXT statement
START does not retrieve a record , it only sorts the current record pointer described under File
Position indicator
READ statement is used to read a record from a file. If it is used to read a sequential file it will
read the next record always . If it used to read from an Indexed/Relative file it will read the
corresponding key record, The key field must have value before read.
If we have read sequentially from an Indexed file        READ NEXT RECORD will retrieve records
from a file in sequence
     REWRITE            Update records.
     DELETE             Logically remove records from indexed and relative files only
     CLOSE              Disconnect the VSAM data set from your program




_______________________________________________________________________________
 COBOL                                                                                      61
User Manual for COBOL
_______________________________________________________________________________

7.8. VSAM DATA SET


COMPARISON ON VSAM DATASETS
   Entry - sequenced                  Key - sequenced                    Relative - Record

   Records are in order in which      Records are in collating           Records are in relative record
   they are written                   sequence by key field              number order

   Access is sequential               Access is by key through an        Access is by relative record
                                      index                              number , which is treated like a
                                                                         key

   May have one           or   more   May have one         or    more    May not have alternate indexes
   alternate indexes                  alternate indexes.

   A record’s RBA cannot change       A record RBA can change            A record relative record
                                                                         number cannot change

   Space at the end of the data set   Distributed free space is used     for fixed length RRDS empty
   is used for adding records         for inserting record and           slots in the data set are used
                                      changing their lengths in place    for adding records. For
                                                                         variable - length RRDS,
                                                                         distributed free space is used
                                                                         for adding records and
                                                                         changing their lengths in place

   A record cannot be deleted but     Space given up by a deleted or     Space given up by a deleted
   you can reuse its space for a      shortened        record      is    record can be reused
   record of the same length          automatically reclaimed within
                                      a control interval

   Can have spanned records           can have spanned records           Can be reused as a word file

   Can be reused as a word file       can be reused as a work file       can be reused as work file
   unless it has an alternate index   unless it has an alternate index
   associated with key ranges or      associated with key ranges or
   exceeds 123 extents per volume     exceeds 123 extents per volume




_______________________________________________________________________________
 COBOL                                                                                                62
User Manual for COBOL
_______________________________________________________________________________

7.8.1.         VSAM DATASETS AND ACCESS MODES



   File Organization       Seq.         Ran.         Dyna.        Fixed    Variable
                          Access       Access        Access       Length   Length

   VSAM      sequential   Yes         No           No             Yes      Yes
   (ESDS)

   VSAM        indexed    Yes         Yes          Yes            Yes      Yes
   (KSDS)

   VSAM        Relative   Yes         Yes          Yes            Yes      NO
   (RRDS)


7.8.1.1.       ORGANIZATION CLAUSE
ORGANIZATION IS SEQUENTIAL - for VSAM sequential files (ESDS)
ORGANIZATION IS INDEXED            - for VSAM indexed files (KSDS)
ORGANIZATION IS RELATIVE           - for VSAM relative files (RRDS).




_______________________________________________________________________________
 COBOL                                                                           63
User Manual for COBOL
_______________________________________________________________________________

7.8.2.        ENVIRONMENT DIVISION ENTRIES FOR VSAM
FILES
Example :VSAM Sequential File


              SELECT S -FILE
              ASSIGN TO SEQUENTIAL - FILE
              ORGANIZATION IS SEQUENTIAL
              ACCESS IS SEQUENTIAL
              FILE STATUS KEY IS FSTAT - CODE VSAT - CODE

Example :VSAM Indexed File


              SELECT I - FILE
              ASSIGN TO INDEXED - FILE
              ORGANIZATION IS INDEXED
              ACCESS IS DYNAMIC
              RECORD KEY IS IFILE - RECORD - KEY
              ALTERNATE RECORD KEY IS IFILE - ALTREC - KEY
              FILE STATUS KEY IS FSTAT - CODE VSAM - CODE

Example:- VSAM Relative File
              SELECT R - FILE
              ASSIGN TO RELATIVE - FILE
              ORGANIZATION IS RELATIVE
              ACCESS IS RANDOM
              RELATIVE KEY IS RFILE - RELATIVE - KEY
              FILE STATUS KEY IS FSTAT - CODE VSAM - CODE




_______________________________________________________________________________
 COBOL                                                                  64
User Manual for COBOL
_______________________________________________________________________________

7.8.3.          COBOL STATEMENTS USABLE WITH SEQUENTIAL
FILES

Access Mode     COBOL /       OPEN        OPEN     OPEN       OPEN
                370           INPUT       OUTPUT   I-O        EXTEND
                Statement
Sequential      OPEN          X           X        X          X
                WRITE                     X                   X
                START
                READ          X                    X
                REWRITE                            X
                DELETE
                CLOSE         X           X        X          X




7.8.4.  COBOL STATEMENTS WITH INDEXED FILES
(KSDS) AND RELATIVE (RRDS)


   Access         COBOL/370       OPEN    OPEN     OPEN        OPEN
   Mode           Statement
                                  INPUT   OUTPUT   I-O         EXTEND

   Sequential     OPEN            X       X        X           X

                  WRITE                   X                    X

                  START           x                x

                  READ            X                X

                  REWRITE                          X

                  DELETE                           x

                  CLOSE           X       X        X           X




   Random         OPEN            X       X        X

                  WRITE                   X        X

                  START

                  READ            X                X

                  REWRITE                          X

                  DELETE                           X

                  CLOSE           X       X        X




_______________________________________________________________________________
 COBOL                                                                  65
User Manual for COBOL
_______________________________________________________________________________
   Dynamic        OPEN             X            X               X

                  WRITE                         X               X

                  START            X                            X

                  READ             X                            X

                  REWRITE                                       X

                  DELETE                                        X

                  CLOSE            X            X               X




7.8.5.  PROCEDURE DIVISION STATEMENTS TO UPDATE
VSAM FILES


ESDS                             KSDS                            RRDS
ACCESS IS SEQUENTIAL                     ACCESS IS SEQUENTIAL                   ACCESS        IS
SEQUENTIAL
OPEN EXTEND                              OPEN EXTEND                            OPEN EXTEND
WRITE                            WRITE                           WRITE
CLOSE                            CLOSE                           CLOSE
OPEN I - O                       OPEN I - O                      OPEN I - O
READ                             READ                            READ
REWRITE                          REWRITE                         REWRITE
                         DELETE                                  DELETE
CLOSE                            CLOSE                           CLOSE
ACCESS IS RANDOM                 ACCESS IS RANDOM                ACCESS IS RANDOM
                         OPEN I - O                      OPEN I - O
                         READ                            READ
Not Applicable                   WRITE                           WRITE
                         REWRITE                         REWRITE
                         DELETE                                  DELETE
                         CLOSE                           CLOSE
ACCESS IS DYNAMIC                        ACCESS IS DYNAMIC                      ACCESS        IS
DYNAMIC
Sequential processing            Sequential processing           Sequential processing
                         OPEN I - O                      OPEN I - O

_______________________________________________________________________________
 COBOL                                                                                   66
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol
User manual for cobol

Más contenido relacionado

Destacado

SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...
SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...
SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...JHONATAN CHAFLA
 
Analista-programador Cobol - Módulo 1.1
Analista-programador Cobol - Módulo 1.1Analista-programador Cobol - Módulo 1.1
Analista-programador Cobol - Módulo 1.1natachaceleste
 
Analista-programador Cobol - Módulo 1.8
Analista-programador Cobol - Módulo 1.8Analista-programador Cobol - Módulo 1.8
Analista-programador Cobol - Módulo 1.8natachaceleste
 
Analista-programador Cobol - Módulo 1.6
Analista-programador Cobol - Módulo 1.6Analista-programador Cobol - Módulo 1.6
Analista-programador Cobol - Módulo 1.6natachaceleste
 
Resolución de problemas de algoritmo.
Resolución de problemas de algoritmo.Resolución de problemas de algoritmo.
Resolución de problemas de algoritmo.francisco dixon
 
Analista-programador Cobol - Módulo 1.3
Analista-programador Cobol - Módulo 1.3Analista-programador Cobol - Módulo 1.3
Analista-programador Cobol - Módulo 1.3natachaceleste
 
Programación
 Programación Programación
Programaciónrehoscript
 
Manual para numerar páginas desde un número de página diferente
Manual para numerar páginas desde un número de página diferenteManual para numerar páginas desde un número de página diferente
Manual para numerar páginas desde un número de página diferenteHinata Akashiya
 
Como generar un índice en word
Como generar un índice en wordComo generar un índice en word
Como generar un índice en wordisaiasrl
 
Como enumerar páginas en word 2010
Como enumerar páginas en word 2010Como enumerar páginas en word 2010
Como enumerar páginas en word 2010Alejandra Gomez
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheLeslie Samuel
 

Destacado (12)

SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...
SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...
SECCIONES, TABLA DE CONTENIDOS, TABLA DE ILUSTRACIONES, REFERENCIAS BIBLIOGRÁ...
 
Analista-programador Cobol - Módulo 1.1
Analista-programador Cobol - Módulo 1.1Analista-programador Cobol - Módulo 1.1
Analista-programador Cobol - Módulo 1.1
 
Analista-programador Cobol - Módulo 1.8
Analista-programador Cobol - Módulo 1.8Analista-programador Cobol - Módulo 1.8
Analista-programador Cobol - Módulo 1.8
 
Analista-programador Cobol - Módulo 1.6
Analista-programador Cobol - Módulo 1.6Analista-programador Cobol - Módulo 1.6
Analista-programador Cobol - Módulo 1.6
 
Resolución de problemas de algoritmo.
Resolución de problemas de algoritmo.Resolución de problemas de algoritmo.
Resolución de problemas de algoritmo.
 
Analista-programador Cobol - Módulo 1.3
Analista-programador Cobol - Módulo 1.3Analista-programador Cobol - Módulo 1.3
Analista-programador Cobol - Módulo 1.3
 
Programación
 Programación Programación
Programación
 
Manual para numerar páginas desde un número de página diferente
Manual para numerar páginas desde un número de página diferenteManual para numerar páginas desde un número de página diferente
Manual para numerar páginas desde un número de página diferente
 
Como generar un índice en word
Como generar un índice en wordComo generar un índice en word
Como generar un índice en word
 
Como enumerar páginas en word 2010
Como enumerar páginas en word 2010Como enumerar páginas en word 2010
Como enumerar páginas en word 2010
 
Libro basico de arduino
Libro basico de arduinoLibro basico de arduino
Libro basico de arduino
 
How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 

Similar a User manual for cobol

Usfos verification manual
Usfos verification manualUsfos verification manual
Usfos verification manualFerit Fazliu
 
Ibis ver5 0_guidelines
Ibis ver5 0_guidelinesIbis ver5 0_guidelines
Ibis ver5 0_guidelinespefkush
 
Completeficomanual 120711232834-phpapp02
Completeficomanual 120711232834-phpapp02Completeficomanual 120711232834-phpapp02
Completeficomanual 120711232834-phpapp02Jaime Torres R
 
1660 S M Operator S Handbook Rel4
1660 S M  Operator S  Handbook  Rel41660 S M  Operator S  Handbook  Rel4
1660 S M Operator S Handbook Rel4Fxx
 
Spring Reference
Spring ReferenceSpring Reference
Spring ReferenceSyed Shahul
 
1660 S M Oper R4
1660 S M  Oper  R41660 S M  Oper  R4
1660 S M Oper R4Fxx
 
Sop ddu gky_ver_2.0.0(2)
Sop ddu gky_ver_2.0.0(2)Sop ddu gky_ver_2.0.0(2)
Sop ddu gky_ver_2.0.0(2)sanjaya sahoo
 
S Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+GuideS Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+Guideguestd2fe1e
 
S Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+GuideS Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+Guideguestd2fe1e
 
Chapter 00-table ofcontents
Chapter 00-table ofcontentsChapter 00-table ofcontents
Chapter 00-table ofcontentsjps619
 
Spring Reference
Spring ReferenceSpring Reference
Spring Referenceasas
 
Manual tutorial-spring-java
Manual tutorial-spring-javaManual tutorial-spring-java
Manual tutorial-spring-javasagicar
 
Rails Cookbook
Rails CookbookRails Cookbook
Rails Cookbookjonkinney
 
ABE fermentation products recovery methods A review.pdf
ABE fermentation products recovery methods A review.pdfABE fermentation products recovery methods A review.pdf
ABE fermentation products recovery methods A review.pdfYolanda Ivey
 

Similar a User manual for cobol (20)

Vmoduser
VmoduserVmoduser
Vmoduser
 
Usfos verification manual
Usfos verification manualUsfos verification manual
Usfos verification manual
 
Ibis ver5 0_guidelines
Ibis ver5 0_guidelinesIbis ver5 0_guidelines
Ibis ver5 0_guidelines
 
Complete fico manual
Complete fico manualComplete fico manual
Complete fico manual
 
Completeficomanual 120711232834-phpapp02
Completeficomanual 120711232834-phpapp02Completeficomanual 120711232834-phpapp02
Completeficomanual 120711232834-phpapp02
 
1660 S M Operator S Handbook Rel4
1660 S M  Operator S  Handbook  Rel41660 S M  Operator S  Handbook  Rel4
1660 S M Operator S Handbook Rel4
 
Spring Reference
Spring ReferenceSpring Reference
Spring Reference
 
1660 S M Oper R4
1660 S M  Oper  R41660 S M  Oper  R4
1660 S M Oper R4
 
Sop ddu gky_ver_2.0.0(2)
Sop ddu gky_ver_2.0.0(2)Sop ddu gky_ver_2.0.0(2)
Sop ddu gky_ver_2.0.0(2)
 
Gdbint
GdbintGdbint
Gdbint
 
S Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+GuideS Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+Guide
 
S Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+GuideS Pii Plus+C+Library+Programmer+Guide
S Pii Plus+C+Library+Programmer+Guide
 
Chapter 00-table ofcontents
Chapter 00-table ofcontentsChapter 00-table ofcontents
Chapter 00-table ofcontents
 
Spring Reference
Spring ReferenceSpring Reference
Spring Reference
 
Manual tutorial-spring-java
Manual tutorial-spring-javaManual tutorial-spring-java
Manual tutorial-spring-java
 
Rails Cookbook
Rails CookbookRails Cookbook
Rails Cookbook
 
Juki rs 1 specifications
Juki rs 1 specificationsJuki rs 1 specifications
Juki rs 1 specifications
 
Drools expert-docs
Drools expert-docsDrools expert-docs
Drools expert-docs
 
ABE fermentation products recovery methods A review.pdf
ABE fermentation products recovery methods A review.pdfABE fermentation products recovery methods A review.pdf
ABE fermentation products recovery methods A review.pdf
 
24319102
2431910224319102
24319102
 

Más de Nirmal Pati

100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPSNirmal Pati
 
JCL BEYOND DFSORT
JCL BEYOND DFSORTJCL BEYOND DFSORT
JCL BEYOND DFSORTNirmal Pati
 
COMMON ABEND CODES
COMMON ABEND CODESCOMMON ABEND CODES
COMMON ABEND CODESNirmal Pati
 
JCL FOR FRESHERS
JCL FOR FRESHERSJCL FOR FRESHERS
JCL FOR FRESHERSNirmal Pati
 
COBOL FOR FRESHER
COBOL FOR FRESHERCOBOL FOR FRESHER
COBOL FOR FRESHERNirmal Pati
 
A beginner's guide to cobol programming
A beginner's guide to cobol programmingA beginner's guide to cobol programming
A beginner's guide to cobol programmingNirmal Pati
 
Windows keyboard shortcuts
Windows keyboard shortcutsWindows keyboard shortcuts
Windows keyboard shortcutsNirmal Pati
 
COBOL COMPILATION
COBOL COMPILATIONCOBOL COMPILATION
COBOL COMPILATIONNirmal Pati
 

Más de Nirmal Pati (13)

100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS100 COOL MAINFRAME TIPS
100 COOL MAINFRAME TIPS
 
DB2 DOCUMENT
DB2 DOCUMENTDB2 DOCUMENT
DB2 DOCUMENT
 
JCL BEYOND DFSORT
JCL BEYOND DFSORTJCL BEYOND DFSORT
JCL BEYOND DFSORT
 
JCL ICETOOL
JCL ICETOOLJCL ICETOOL
JCL ICETOOL
 
MVS ABEND CODES
MVS ABEND CODESMVS ABEND CODES
MVS ABEND CODES
 
JCL DFSORT
JCL DFSORTJCL DFSORT
JCL DFSORT
 
COMMON ABEND CODES
COMMON ABEND CODESCOMMON ABEND CODES
COMMON ABEND CODES
 
JCL SORT TOOL
JCL SORT TOOLJCL SORT TOOL
JCL SORT TOOL
 
JCL FOR FRESHERS
JCL FOR FRESHERSJCL FOR FRESHERS
JCL FOR FRESHERS
 
COBOL FOR FRESHER
COBOL FOR FRESHERCOBOL FOR FRESHER
COBOL FOR FRESHER
 
A beginner's guide to cobol programming
A beginner's guide to cobol programmingA beginner's guide to cobol programming
A beginner's guide to cobol programming
 
Windows keyboard shortcuts
Windows keyboard shortcutsWindows keyboard shortcuts
Windows keyboard shortcuts
 
COBOL COMPILATION
COBOL COMPILATIONCOBOL COMPILATION
COBOL COMPILATION
 

Último

Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxCarlos105
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 

Último (20)

Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptxBarangay Council for the Protection of Children (BCPC) Orientation.pptx
Barangay Council for the Protection of Children (BCPC) Orientation.pptx
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 

User manual for cobol

  • 1. User Manual for COBOL _______________________________________________________________________________ COBOL Training Material _______________________________________________________________________________ COBOL 1
  • 2. User Manual for COBOL _______________________________________________________________________________ Table of Contents 1. OBJECTIVES...........................................................................................................9 2. INTRODUCTION TO COBOL................................................................................10 2.1. LANGUAGE CONSTRUCTION..........................................................................10 2.2. COBOL CHARACTER SET................................................................................10 2.3. COBOL WORDS.................................................................................................10 2.4. COBOL CODING FORM.....................................................................................11 2.5. DIVISIONS OF COBOL......................................................................................11 3. IDENTIFICATION DIVISION..................................................................................12 3.1. SYNTAX OF IDENTIFICATION DIVISION.........................................................12 4. ENVIRONMENT DIVISION....................................................................................13 4.1. CONFIGURATION SECTION.............................................................................13 4.1.1. SOURCE-COMPUTER....................................................................................13 4.1.2. OBJECT COMPUTER.....................................................................................13 4.1.3. SPECIAL-NAMES............................................................................................13 4.2. INPUT-OUTPUT SECTION.................................................................................15 4.2.1. FILE-CONTROL...............................................................................................15 4.2.2. I-O CONTROL..................................................................................................15 5. DATA DIVISION.....................................................................................................17 5.1. LITERALS AND FIGURATIVE CONSTANTS....................................................17 5.1.1. NUMERIC LITERAL.........................................................................................18 _______________________________________________________________________________ COBOL 2
  • 3. User Manual for COBOL _______________________________________________________________________________ 5.1.2. NON-NUMERIC LITERAL...............................................................................18 5.1.3. LIST OF FIGURATIVE CONSTANTS............................................................18 5.2. DATA DESCRIPTION.........................................................................................19 5.2.1. LEVEL NUMBERS...........................................................................................19 5.2.1.1. SPECIAL LEVEL NUMBERS.......................................................................20 5.2.2. DATA NAMES..................................................................................................20 5.2.2.1. FILLER..........................................................................................................21 5.2.3. CLAUSE...........................................................................................................21 5.2.3.1. PICTURE CLAUSE.......................................................................................22 5.2.3.1.1. EDITED PICTURE CLAUSES...................................................................22 5.2.3.1.2. EDIT TYPES - NUMERIC DATA...............................................................22 5.2.3.1.3. EDIT TYPES - ALPHABETIC....................................................................24 5.2.3.1.4. EDIT TYPES - ALPHANUMERIC..............................................................24 5.2.3.1.5. EDIT COMBINATION................................................................................24 5.2.3.2. VALUE CLAUSE...........................................................................................25 5.2.3.3. USAGE CLAUSE..........................................................................................25 5.2.3.3.1. DISPLAY USAGE......................................................................................25 5.2.3.3.2. COMPUTATIONAL(COMP) USAGE........................................................26 5.2.3.4. SIGN CLAUSE..............................................................................................27 5.2.3.5. OCCURS CLAUSE.......................................................................................28 5.2.3.6. REDEFINES CLAUSE..................................................................................28 5.2.3.6.1. EXPLICIT USE OF REDEFINES...............................................................28 _______________________________________________________________________________ COBOL 3
  • 4. User Manual for COBOL _______________________________________________________________________________ 5.2.3.6.2. RESTRICTIONS ON USE OF REDEFINES..............................................29 5.2.3.7. RENAMES.....................................................................................................29 5.2.3.8. JUSTIFIED CLAUSE....................................................................................29 5.2.4. CONDITION NAMES.......................................................................................30 6. PROCEDURE DIVISION........................................................................................31 6.1. STATEMENTS IN PROCEDURE DIVISION.......................................................31 6.2. DATA MOVEMENT.............................................................................................33 6.2.1. MOVE...............................................................................................................33 6.2.1.1. DATA MOVEMENT RULES.........................................................................33 6.2.1.2. NUMERIC DATA TRANSFER RULES.........................................................33 6.2.1.3. ALPHANUMERIC DATA TRANSFER.........................................................34 6.2.1.4. GROUP MOVES............................................................................................34 6.2.1.5. MOVE CORRESPONDING...........................................................................35 6.3. ARITHMETIC VERBS ........................................................................................36 6.3.1. ADD..................................................................................................................36 6.3.2. SUBTRACT......................................................................................................37 6.3.3. MULTIPLY........................................................................................................37 6.3.4. DIVIDE..............................................................................................................37 6.3.5. ROUNDED OPTION.........................................................................................38 6.3.6. ON SIZE ERROR.............................................................................................39 6.3.7. COMPUTE........................................................................................................40 6.3.8. ARITHMETIC OPERATORS............................................................................40 _______________________________________________________________________________ COBOL 4
  • 5. User Manual for COBOL _______________________________________________________________________________ 6.4. MISCELLANEOUS..............................................................................................41 6.4.1. ACCEPT...........................................................................................................41 6.4.2. DISPLAY..........................................................................................................42 6.4.3. CONTINUE.......................................................................................................42 6.4.4. STOP RUN.......................................................................................................42 6.4.5. EXIT..................................................................................................................42 6.4.6. INITIALIZE........................................................................................................42 6.5. CONDITIONAL AND UNCONDITIONAL TRANSFER.......................................44 6.5.1. SIMPLE IF STATEMENT.................................................................................44 6.5.2. NESTED IF.......................................................................................................45 6.5.3. EVALUATE STATEMENT...............................................................................45 6.5.4. GO TO STATEMENT.......................................................................................46 6.5.5. GO TO WITH DEPENDING.............................................................................46 6.5.6. ALTER..............................................................................................................47 6.6. PERFORM STATEMENTS.................................................................................47 6.6.1. BASIC PERFORM............................................................................................47 6.6.2. PERFORM WITH TIMES PHRASE.................................................................49 6.6.3. PERFORM WITH UNTIL PHRASE..................................................................49 6.6.4. PERFORM WITH VARYING PHRASE............................................................50 6.7. CONDITIONAL EXPRESSIONS.........................................................................51 6.7.1. RELATIONAL CONDITION.............................................................................51 6.7.2. SIGN CONDITION............................................................................................52 _______________________________________________________________________________ COBOL 5
  • 6. User Manual for COBOL _______________________________________________________________________________ 6.7.3. CLASS CONDITION........................................................................................52 6.7.4. CONDITION-NAME CONDITION....................................................................53 6.7.5. NEGATED SIMPLE CONDITION....................................................................53 6.7.6. COMPOUND CONDITION...............................................................................53 7. FILE HANDLING....................................................................................................53 7.1. SEQUENTIAL FILES..........................................................................................54 7.2. INDEXED FILES..................................................................................................54 7.3. DIRECT ACCESS FILES....................................................................................54 7.4. STEPS INVOLVED IN FILE HANDLING............................................................54 7.4.1. EXAMPLE........................................................................................................56 7.5. SELECT STATEMENT.......................................................................................56 7.5.1. ORGANIZATION CLAUSE..............................................................................57 7.5.2. ACCESS MODE CLAUSE..............................................................................58 7.5.3. RECORD KEY PHRASE..................................................................................58 7.5.4. ALTERNATE KEY PHRASE...........................................................................58 7.6. FD ENTRY...........................................................................................................58 7.6.1. BLOCK CONTAINS / RECORD CONTAINS PHRASE..................................59 7.6.2. RECORDING MODE CLAUSE.......................................................................59 7.7. INPUT / OUTPUT STATEMENTS......................................................................61 7.8. VSAM DATA SET...............................................................................................62 7.8.1. VSAM DATASETS AND ACCESS MODES....................................................63 7.8.1.1. ORGANIZATION CLAUSE...........................................................................63 _______________________________________________________________________________ COBOL 6
  • 7. User Manual for COBOL _______________________________________________________________________________ 7.8.2. ENVIRONMENT DIVISION ENTRIES FOR VSAM FILES..............................64 7.8.3. COBOL STATEMENTS USABLE WITH SEQUENTIAL FILES.....................65 7.8.4. COBOL STATEMENTS WITH INDEXED FILES (KSDS) AND RELATIVE (RRDS).......................................................................................................................65 7.8.5. PROCEDURE DIVISION STATEMENTS TO UPDATE VSAM FILES...........66 7.8.6. ERROR PROCESSING FOR VSAM................................................................67 7.8.7. APPLICATIONS BEST SUITED TO VSAM DATASETS................................67 7.8.7.1. ESDS.............................................................................................................67 7.8.7.2. KSDS.............................................................................................................68 7.8.7.3. RRDS.............................................................................................................68 8. SUBPROGRAMS...................................................................................................69 8.1. LINKAGE SECTION............................................................................................69 8.1.1. STATIC / DYNAMIC CALLS............................................................................69 8.1.2. PASSING RETURN CODE INFORMATION...................................................71 9. STRING , UNSTRING AND INSPECT STATEMENTS.........................................72 9.1. STRING STATEMENT........................................................................................72 9.2. UNSTRING STATEMENT...................................................................................73 9.3. INSPECT STATEMENT......................................................................................74 9.4. DECLARATIVES.................................................................................................76 10. SORT AND MERGE STATEMENTS...................................................................77 11. INTRINSIC FUNCTIONS.....................................................................................79 11.1. NUMBER HANDLING......................................................................................79 _______________________________________________________________________________ COBOL 7
  • 8. User Manual for COBOL _______________________________________________________________________________ 11.2. DATE / TIME....................................................................................................79 11.3. FINANCE..........................................................................................................80 11.4. MATHEMATICS & STATISTICS.....................................................................80 12. COMPILER OPTIONS........................................................................................81 13. APPENDIX...........................................................................................................83 13.1. ERROR CODES...............................................................................................83 13.2. EXERCISES:....................................................................................................84 13.2.1. BASIC PROBLEM SOLVING........................................................................84 13.2.2. REPORT PREPARATION.............................................................................85 13.2.3. ARRAY HANDLING.......................................................................................86 13.2.4. FILE HANDLING............................................................................................86 13.3. JCL...................................................................................................................87 _______________________________________________________________________________ COBOL 8
  • 9. User Manual for COBOL _______________________________________________________________________________ 1. OBJECTIVES The main objective after the completion of this course, is that the students should be able to: ♦ Understand the standard format of the COBOL program. ♦ Write COBOL programs which uses VSAM or Non VSAM files. ♦ Submit jobs to Compile and Link-edit COBOL source codes. ♦ Write programs using modular design techniques. _______________________________________________________________________________ COBOL 9
  • 10. User Manual for COBOL _______________________________________________________________________________ 2. INTRODUCTION TO COBOL COBOL => COMMON BUSINESS ORIENTED LANGUAGE Cobol can be referred to as : 1. High-Level Programming language oriented towards business applications. 2. A procedure oriented language. A Procedure is a module having its own task. A Problem may be segmented into several tasks. Each task is written as a Paragraph in Procedure Division and executed in a logical sequence as mentioned. 3. Problem Oriented and Machine independent 2.1. LANGUAGE CONSTRUCTION ♦ COBOL is like an English language. ♦ Character is the lowest component. ♦ Word is made up of one or more characters. ♦ Clause consists of word and characters. It specifies an attribute for an entry ♦ Statement is syntactically valid combination of words and clauses ♦ Sentence is a sequence of one or more statements terminated by period ♦ Paragraph consists of one or more sentences ♦ Section consists of one or more paragraphs ♦ Division consists of one or more paragraphs or sections ♦ Program is made up of divisions 2.2. COBOL CHARACTER SET Set of 52 characters 0,..9 DIGITS A,..Z LETTERS b SPACE/BLANK CHARACTER +,-,*,/,(,),= SPECIAL SYMBOLS $,;,“,>,<,.,: 2.3. COBOL WORDS User defined words _______________________________________________________________________________ COBOL 10
  • 11. User Manual for COBOL _______________________________________________________________________________ ♦ Words declared by programmer to coin identifiers, paragraph names, file names and section names. Reserved words ♦ Words which are having specific meaning to the compiler. 2.4. COBOL CODING FORM Columns 1- 6 Sequence numbers identifying pages or lines of a program 7 Continuation, comment or starting of a new page 8-11 Area A 12-72 Area B 73-80 Remarks 2.5. DIVISIONS OF COBOL ♦ IDENTIFICATION DIVISION ♦ ENVIRONMENT DIVISION ♦ DATA DIVISION ♦ PROCEDURE DIVISION _______________________________________________________________________________ COBOL 11
  • 12. User Manual for COBOL _______________________________________________________________________________ 3. IDENTIFICATION DIVISION The Identification division is: ♦ First division of a Cobol program. ♦ Paragraph program-id followed by a user-defined name is compulsory. Other paragraphs are optional but essential for documentation. ♦ Should begin in Area A. ♦ Length of PROGRAM-ID differs from compiler to compiler. For example, in the case of IBM COBOL, it is 8 characters. 3.1. SYNTAX OF IDENTIFICATION DIVISION IDENTIFICATION DIVISION. PROGRAM-ID. PROGRAM NAME. AUTHOR.COMMENT ENTRY. INSTALLATION.COMMENT ENTRY. DATE-WRITTEN.COMMENT ENTRY. DATE-COMPILED.COMMENT ENTRY. SECURITY.COMMENT ENTRY.] Security here does not pertain to the operating system security, but the information that is passed to the user of the program about the Security features of the program. _______________________________________________________________________________ COBOL 12
  • 13. User Manual for COBOL _______________________________________________________________________________ 4. ENVIRONMENT DIVISION ♦ It is a machine dependent division. ♦ The Division itself is optional but for file handling it is essential. ♦ Should begin in Area A. ♦ Division is terminated by a period. ♦ Describes the computer used, peripheral devices, etc. ♦ Contains two sections namely, CONFIGURATION and INPUT-OUTPUT. 4.1. CONFIGURATION SECTION Mentions the name of the source-computer, object-computer, special-names, symbolic-names and classes defined by programmer. The paragraphs of configuration section are SOURCE-COMPUTER, OBJECT-COMPUTER, and SPECIAL-NAMES. 4.1.1. SOURCE-COMPUTER ♦ Used to specify the name of the Source Computer compiling the COBOL program. ♦ The “With Debugging Mode” option can be mentioned to enable the Compiler to include all the lines with ‘D’ in the 7th column as syntax(Otherwise it is taken as comment). It can also include the debug Declaratives in PROCEDURE DIVISION. 4.1.2. OBJECT COMPUTER ♦ Used to specify the target system. ♦ The program collating sequence can also be specified in this paragraph for SORTING and STRING COMPARISON. By default, EBCDIC code is followed in MVS. We can change it to ASCII, or any other order if we define SPECIAL-NAMES. 4.1.3. SPECIAL-NAMES ♦ Specifies collating sequence. _______________________________________________________________________________ COBOL 13
  • 14. User Manual for COBOL _______________________________________________________________________________ ♦ Maps IBM specified environment names to user defined mnemonic names. ♦ Substitutes character for currency sign. ♦ Indicates that ‘ ; ‘ and ‘ . ‘ are to be interchanged in the PIC clause. ♦ We can also specify symbolic characters, such as, PERCENTAGE-SIGN IS 38. ♦ Regardless of the number of entries in this paragraph, there should be only one period at the end. _______________________________________________________________________________ COBOL 14
  • 15. User Manual for COBOL _______________________________________________________________________________ 4.2. INPUT-OUTPUT SECTION ♦ Contains information regarding files to be used in the program. ♦ Consists of two paragraphs FILE-CONTROL and I-O CONTROL. 4.2.1. FILE-CONTROL Associates each file used in a COBOL program with an external ddname. Physical dataset is assigned in DD statement of JCL at execution time. Three formats for the FILE-CONTROL paragraph are : ♦ Sequential file entries ♦ Indexed file entries ♦ Relative file entries Coding rules for FILE-CONTROL paragraph. ♦ SELECT clause must appear first ♦ Other clauses may appear in any order ♦ Each clause must start in Area B 4.2.2. I-O CONTROL ♦ Optional Paragraph. ♦ Specifies when check points are to be taken. ♦ Specifies the storage areas to be shared by different files. ♦ The key word I-O control must begin in Area A. _______________________________________________________________________________ COBOL 15
  • 16. User Manual for COBOL _______________________________________________________________________________ Example: IDENTIFICATION DIVISION. PROGRAM-ID. DSQ001. AUTHOR. A343. INSTALLATION. AT DSQ. MAD. DATE-WRITTEN. 06-04-94. DATE-COMPILED. XX-XX-XX. SECURITY. ONLY FOR TRAINEES. ENVIRONMENT DIVISION. CONFIGURATION SECTION. SOURCE-COMPUTER. ES-9000 WITH DEBUGGING MODE. OBJECT-COMPUTER. ES-9000 PROGRAM COLLATING SEQUENCE IS A01. SPECIAL-NAMES. C12 IS BOTTOM OF PAGE. ALPHABET A01 IS “A” ALSO “a” “B” ALSO “b” ALPHABET A IS STANDARD-1. SYSIN IS PROGIN CURRENCY IS @ DECIMAL POINT IS COMMA INPUT-OUTPUT SECTION. FILE-CONTROL SELECT OUTFILE ASSIGN TO DD1 ORGANIZATION IS SEQUENTIAL ACCESS MODE SEQUENTIAL FILE STATUS IS WS-FST. _______________________________________________________________________________ COBOL 16
  • 17. User Manual for COBOL _______________________________________________________________________________ 5. DATA DIVISION Data division is used to define data needed to be accessed by the program. The three sections of this division are FILE SECTION ♦ Describes Record Structure of Files WORKING-STORAGE SECTION ♦ Succeeds file section ♦ Used for intermediate storage ♦ Common practice to group related items together. LINKAGE SECTION ♦ Describes data made available from another program. 5.1. LITERALS AND FIGURATIVE CONSTANTS. ♦ Literal is a constant representing a number or Non number (Alpha numeric) like 45.3 / ‘MANAGER’. ♦ Literals are storable in a memory Location having a user defined name called Data Name or Identifier or ♦ Variable or Field ♦ Figurative Constant is a COBOL RESERVED WORD representing frequently used constants like ♦ ZEROS / SPACES. ♦ Figurative constants are used in the program as such for better readability as. ♦ MOVE SPACES TO WS-REC. ♦ Literals are classified in to NUMERIC and NON-NUMERIC literals. _______________________________________________________________________________ COBOL 17
  • 18. User Manual for COBOL _______________________________________________________________________________ 5.1.1. NUMERIC LITERAL ♦ Must contain at least one digit ♦ Sign, if used must be the left-most character ♦ Not more than one decimal point ♦ Decimal may not be the right most character ♦ Maximum of 18 digits. ♦ TOTAL-MARK PIC 9(3) VALUE 100.. ♦ Here 100 is a numeric constant assigned in identifier TOTAL-MARK. 5.1.2. NON-NUMERIC LITERAL ♦ May consist of any character in the character set ♦ Must be enclosed in quotes ♦ A numeric literal in quotes is non-numeric ♦ Maximum length of 120 chars 05 COMPANY-NAME PIC X(3) VALUE ‘DSQ’. Here ‘DSQ’ is a Alphanumeric constant assigned in identifier COMPANY-NAME, 5.1.3. LIST OF FIGURATIVE CONSTANTS ZERO/ZEROES/ZEROS ONE OR MORE ZEROS QUOTE/QUOTES ONE OR MORE“ SPACE/SPACES ONE OR MORE SPACE HIGH VALUE/HIGHEST VALUE HIGHEST VALUE IN COLLATING SEQUENCE LOW VALUE/LOWEST VALUE LOWEST VALUE IN COLLATING SEQUENCE ALL ONE or MORE STRING CHARACTERS _______________________________________________________________________________ COBOL 18
  • 19. User Manual for COBOL _______________________________________________________________________________ 5.2. Data Description The general format of the data description is ♦ Level-number data-name/FILLER clauses 5.2.1. LEVEL NUMBERS ♦ A Record is a Collection of all the fields pertaining to an Item/person/Transaction. ♦ A record structure is a structure of all the fields of a record. It may be available in the FILE SECTION/ WORKING-STORAGE SECTION/ LINKAGE SECTION. ♦ The level-number specifies the hierarchy of data within a record, and identifies special- purpose data entries. A level-number begins a data description entry, a renamed or redefined item, or a condition-name entry. ♦ A level-number has a value taken from the set of integers between 1 and 49, or from one of the special level-numbers, 66, 77, or 88. 01 This level - number specifies the record itself. ♦ A level - 01 entry may be either a group item or an elementary item. ♦ It must begin in Area A. 02-49 These level numbers specify group and elementary items within a record. ♦ They may begin in Area A or B ♦ Group Level Data Names Will not have Picture Clause. EMPLOYEE-REC. EMP-NO PIC XXXX. EMP-NAME 03 FIRST-NAME PIC A(30). 03 INITIAL-1 PIC A. 03 INITIAL-2 PIC A. 03 INITIAL-3 PIC A. _______________________________________________________________________________ COBOL 19
  • 20. User Manual for COBOL _______________________________________________________________________________ 5.2.1.1. SPECIAL LEVEL NUMBERS 66 Identifies items that contain the RENAMES clause. 77 Identifies independent elementary data item. Identifies any condition name that is associated with a particular value of conditional variable Level Number 01 can appear as a Group Level Number as well as Elementary data item level number. It can appear only as an elementary Data Item Level Number. Example 01 TOTAL PIC 9(5). 77 WS=FLAG PIC XX. 5.2.2. Data Names ♦ Identifier name/ Data name should not exceed 30 Characters. ♦ There should be at least one Alphabet anywhere in the name. ♦ Only special Character allowed is – ( Hyphen) but should not be at the Beginning or End Examples of datanames ♦ EMPLOYEE-NAME , COMPANY, 0001AB, 999-EMPLOYEE-RECORD ♦ Dataname must be unique within a Record ♦ If ‘Name’ is duplicated across Records, it has to be qualified as Identifier-name of Record Name. ♦ Display balance of stock-record ♦ Here balance is an identifier declared in Stock-record. _______________________________________________________________________________ COBOL 20
  • 21. User Manual for COBOL _______________________________________________________________________________ 5.2.2.1. FILLER Whenever there is no need for specific reference to fields in a record structure, we name it as FILLER Or F . This Data name is used wherever there is fixed information like SPACES Or Headings Are stored. Example 01 Detail-record. 05 FILLER PIC X(10) VALUE SPACES. 05 NAME PIC X(30) . 05 FILLER PIC X(10) VALUE SPACES. . 05 BASIC PIC 9(05) . 05 FILLER PIC X(10) VALUE SPACES. 05 DA PIC 9(04) . 05 FILLER PIC X(10) VALUE SPACES. 05 GROSS PIC 9(6). 5.2.3. CLAUSE A Clause specifies certain characteristics of the data item being described. The detail of each Clause is explained below. _______________________________________________________________________________ COBOL 21
  • 22. User Manual for COBOL _______________________________________________________________________________ 5.2.3.1. PICTURE CLAUSE Describes the class (numeric, alphabetic, alphanumeric), sign(signed/unsigned), decimal point location and size characteristics of a data item. Specified for every elementary item Format of Picture Clause. PICTURE character string TYPE CHARACTER STRING REMARK Numeric 9 Used for arithmetic operations V Assumed Decimal Point S Data item is Signed P Position of Assumed decimal point when the point lies outside the data item Alphabetic A Data Item contains only a Letter Or Space B Blank insertion character Alpha X Data item contains any allowable character Numeric from the COBOL character set. EXAMPLES VAR1 PIC A(04) (Defines 4 alphabetic characters.) VA R2 PIC 9(4) (Defines 4 Numeric digits) 5.2.3.1.1. EDITED PICTURE CLAUSES Used to display Numeric and other data in the human readable form. Displaying the number as 77,419.56 is easier to read instead of 7741958. 5.2.3.1.2. EDIT TYPES - NUMERIC DATA Z ZERO SUPPRESSION _______________________________________________________________________________ COBOL 22
  • 23. User Manual for COBOL _______________________________________________________________________________ * ASTERISK $ CURRENCY SIGN - MINUS SIGN + PLUS SIGN CR DB CREDIT DEBIT SIGN PERIOD(.) COMMA(,) BLANK(‘b‘) ZERO(0) SLASH(/) BLANK WHEN ZERO (Inserts blanks when data value is zero) _______________________________________________________________________________ COBOL 23
  • 24. User Manual for COBOL _______________________________________________________________________________ 5.2.3.1.3. EDIT TYPES - ALPHABETIC Used To Insert Blank within Alphabetic Characters. Example: 10 Var1 PIC A(2)BBBA(3) VALUE “xyabc” 5.2.3.1.4. EDIT TYPES - ALPHANUMERIC BLANK, ZERO and SLASH INSERTION PIC OF THE NUMERIC VALUE EDITED VALUE FIELD ZZZV99 38^4 b3840 * * 999 00052 * * 052 $ * *999 985 $**985 -ZZZV99 -46^52 -b4652 +999 -382 -382 +999 382 +382 9999+ -382 0382- ZZ,Z99 2456 b2,456 ZZZZ.ZZ 5 bbbb.05 $$$$9.99 342 b$342.00 99B99B99 46 00b00b46 09990 456 04560 999/999/99 3254 000/032/54 BLANK WHEN ZERO ZZZ.99 BLANK WHEN ZERO 25 bb2.50 999.99 BLANK WHEN ZERO 0 bbbbbb 5.2.3.1.5. EDIT COMBINATION _______________________________________________________________________________ COBOL 24
  • 25. User Manual for COBOL _______________________________________________________________________________ +, -, CR, DB Are Mutually Exclusive $, +, -, Z, * Are Mutually Exclusive. $ can appear at first place and * as Floating($****.**) V and . Are Mutually Exclusive 5.2.3.2. VALUE CLAUSE Assigns initial value to a data item VALUE IS literal Literal can be Numeric, Non-Numeric(in Quotes) or Figurative Constant Not for items whose size is variable Value of item should not exceed picture size Consistent with class of PIC clause EXAMPLES 01 WS-REC. 05 WS-NAME PIC X(30) VALUE ‘ABC COMPANY ‘. 05 FILLER PIC X(20) VALUE ALL ‘ - ‘. 01 WS-NUM1 PIC 9(5) VALUE ZERO. 01 WS-CHAR2 PIC X(5) VALUE ZERO. 5.2.3.3. USAGE CLAUSE Specifies how a data item is represented internally. ♦ DISPLAY ♦ COMPUTATIONAL SYNTAX USAGE IS [DISPLAY ] [COMPUTATIONAL] [COMP-1] [COMP-2] [COMP-3] 5.2.3.3.1. DISPLAY USAGE. Each character of the data is represented in one byte . The number of bytes required is equal to the size of the item. DISPLAY is the default usage _______________________________________________________________________________ COBOL 25
  • 26. User Manual for COBOL _______________________________________________________________________________ 5.2.3.3.2. COMPUTATIONAL(COMP) USAGE ♦ Maintained in binary ♦ Only integral numbers ♦ Depending on the size of the data item, it can be stored either in half word or full word ♦ Should be numeric only ♦ NUMBER OF digits IN PIC LENGTH OF ITEM IN BYTES 1 TO 4 2 5 TO 9 4 10 TO 18 8 01 WS - NUM PIC S9(004) USAGE COMP. COMP-1 USAGE . ♦ One word in floating point form ♦ The number is represented in hexadecimal ♦ The picture clause cannot be specified ♦ Suitable for arithmetic operations WS - NUM USAGE COMP1 . COMP-2 USAGE. ♦ Same as COMP 1 except that data is represented internally in two words ♦ Increases the precision of the data _______________________________________________________________________________ COBOL 26
  • 27. User Manual for COBOL _______________________________________________________________________________ COMP-3 USAGE. ♦ Internal Representation In Packed Decimal Form ♦ Each digit and sign occupy 1/2 a byte ♦ The Hexadecimal number C or F denotes a positive sign ♦ The Hexadecimal number D denotes a negative sign EXAMPLE FOR USAGE COMP - 3 10 A PIC S9(3) USAGE COMP-3 VALUE 123. Internally stored as 0001 0010 0011 1111 1 2 3 F 10 A PIC S9(04) USAGE COMP-3 VALUE 123. is stored as 0000 0000 0001 0010 0011 1111 (Extra Byte) 5.2.3.4. SIGN CLAUSE ♦ [SIGN IS][LEADING] [SEPARATE CHAR ] [TRAILING] ♦ Specifies the position and mode of representation of sign ♦ Only for numeric elementary items ♦ Picture string should contain ‘S’ ♦ Usage should be DISPLAY ♦ Default is TRAILING without separate character EXAMPLE PIC VALUE SIGN REPRESENTATION S9(3) -243 LEADING K 4 3 S9(3) -243 TRAILING 2 4 L _______________________________________________________________________________ COBOL 27
  • 28. User Manual for COBOL _______________________________________________________________________________ 5.2.3.5. OCCURS CLAUSE There may be a need to keep a table of values in the memory for calculations. We use OCCURS clause to allocate physically contiguous memory locations to store the table values and access them with subscripts. Example, 01 WS-TABLE. 10 WS-NAME OCCURS 10 TIMES PIC X(20). 01 WS-TABLE. 10 WS-REC OCCURS 10 TIMES. 15 X PIC X(5). 15 Y PIC X(8). WS - REC (1) = 13 BYTES (i.e. X(1) = 5 bytes, Y(1) = 8 bytes) Hence, 10 such group items (WS-REC) are allocated memory space contiguously. 5.2.3.6. REDEFINES CLAUSE This clause allows the same area of memory to be referenced by more than one data-name with different formats and sizes. SYNTAX AND RULES < Lvl.no > <Data-item-1> REDEFINES <Data-item-2>. Redefines clause must immediately follow <data-item-1> Level nos of <data-item-1> and <data-item-2> must be identical and not 66 or 88. 5.2.3.6.1. Explicit Use OF REDEFINES REDEFINES must be used for remapping record areas outside the FILE-SECTION, or within the FILE-SECTION if a part of a record is to be remapped. _______________________________________________________________________________ COBOL 28
  • 29. User Manual for COBOL _______________________________________________________________________________ Example, FD CARDIN. 01 D-TYPE-1 05 CARD-CODE PIC 9. 05 NAME-ADD. 10 NAME PIC X(20). 10 ADD-LN-1 PIC X(40). 05 NAME-DD REDEFINES NAME-ADD. 10 ADD-LN-2 PIC X(60). 5.2.3.6.2. RESTRICTIONS ON USE OF REDEFINES Redefinition ceases whenever a level number is less than or equal to that of <data-item-1 > or <data- item-2> Multiple redefinition’s of the same area is possible provided there are no new storage areas defined in between . < data-item - 1 > and <data-item-2> Value clauses are allowed only in condition names in a redefined data-item. At 01 level, OCCURS and REDEFINES cannot be combined <data-name-2> may not have an OCCURS clause 5.2.3.7. RENAMES Regrouping of elementary data items in a Record. 01 W-RESPONSE 05 W-CHAR-123 PIC XXX. 05 W-CHAR-4 PIC X. 05 W-CHAR-56 PIC XX. 66 ADD-RESPONSE RENAMES W-CHAR-123. 66 VIEW-RESPONSES RENAMES W-CHAR-123 THRU W- CHAR-4. 66 DELETE-RESPONSE RENAMES W-CHAR-123 THRU W- CHAR-56. 5.2.3.8. JUSTIFIED CLAUSE _______________________________________________________________________________ COBOL 29
  • 30. User Manual for COBOL _______________________________________________________________________________ Overrides standard positioning rules for a receiving stem of the alphabetic or alphanumeric categories. 01 WS-CHAR PIC X(05) JUSTIFIED RIGHT. Default is left justified Justified clause does not alter initial settings as determined by the value clause Justified clause must not be specified with level 66(RENAMES) and level 88(condition-names) clauses. 5.2.4. CONDITION NAMES ♦ Allow users to assign acceptable values for data names ♦ Are used as an abbreviation for condition checking 01 W-PERSON-STATUS PIC 9(02). 88 C-PER-MINOR VALUE O THRU 20 88 C-PER-ADULT VALUE 21 THRU 99 _______________________________________________________________________________ COBOL 30
  • 31. User Manual for COBOL _______________________________________________________________________________ 6. PROCEDURE DIVISION ♦ Last division in a COBOL program ♦ Contains statements which specify the operations to be performed ♦ Contains the following structure STRUCTURE PROCEDURE DIVISION SECTION PARAGRAPHS SENTENCES STATEMENTS VERBS ♦ Paragraph names and section names should start in Area A ♦ Statements and sentences should start in Area B ♦ Section names and paragraph names are user-defined ♦ Section names must be unique and must be different from paragraph names ♦ Section names should be followed by a space and the word SECTION with a period at the end ♦ Paragraph names must be unique within a section ♦ If paragraph name is duplicated across sections, it has to be qualified as paragraph-name { of / in } section name 6.1. STATEMENTS IN PROCEDURE DIVISION Procedure division statements can be broadly classified as ♦ Imperative Statements ♦ Statement which directs the program to take a specific action during execution Examples MOVE, ADD, GOTO, EXIT. ♦ Conditional Statements ♦ A conditional statement specifies that the truth value of a condition is to be determined, and that the subsequent action of the object program is dependent on this truth value. Examples: IF , EVALUATE , ADD...ON SIZE ERROR, ADD...NOT ON SIZE ERROR COMPUTE...ON SIZE ERROR, COMPUTE...NOT ON SIZE ERROR ♦ Compiler Directives A Compiler-Directing Statement is a statement, beginning with a compiler directing verb, that causes the compiler to take a specific action during compilation. Example : Use, Copy _______________________________________________________________________________ COBOL 31
  • 32. User Manual for COBOL _______________________________________________________________________________ ♦ Explicit Scope Terminator An EXPLICIT SCOPE TERMINATOR terminates the scope of conditional statements. This includes statements which contain conditional expression (like IF statement) and imperative statements (like ADD) Examples END-ADD, END-IF, END-COMPUTE, END-DELETE, END-SUBTRACT, END-EVALUATE, END-CALL, END-MULTIPLY ♦ Implicit Scope Terminator At the end of any sentence, an IMPLICIT SCOPE TERMINATOR is a separator period that terminates the scope of all previous statements not yet terminated. _______________________________________________________________________________ COBOL 32
  • 33. User Manual for COBOL _______________________________________________________________________________ 6.2. Data Movement 6.2.1. MOVE To move data into a place in memory. Format, MOVE {IDENTIFIER-1/LITERAL-1} TO IDENTIFIER-2[,IDENTIFIER-3],.. 6.2.1.1. DATA MOVEMENT RULES Only one sending field , One or more receiving fields. Value of the sending field remains unaltered after the statement execution. 6.2.1.2. NUMERIC DATA TRANSFER RULES When sending field is numeric or numeric-edited, the Data Movement is called Numeric. The dominant factor in the numeric data transfer is the alignment of decimal points of the two fields If the decimal point is not explicitly indicated, the decimal point is assumed to be at the right of the rightmost digit If the receiving field is not large enough to hold the data received, truncation can take place at either ends or at both ends If the significant integral positions are likely to be lost, a warning to that effect is issued by the compiler If the receiving field is larger than the sending field, the unused positions will be filled with zeros, which is known as ‘ zero fill ‘ _______________________________________________________________________________ COBOL 33
  • 34. User Manual for COBOL _______________________________________________________________________________ 6.2.1.3. ALPHANUMERIC DATA TRANSFER. When both the sending and receiving fields are alphabetic, alphanumeric or alphanumeric edited, the Data Movement is called as Alphanumeric. In the case of alphanumeric data transfer, receiving area is filled from left to right When the receiving field is smaller, truncation occurs from the right and the compiler gives a warning to that effect If the receiving field is larger than the field, the unused positions will be filled with spaces, which is called as ‘ space fill ‘ Examples MOVE A TO B A B PIC 9999 PIC ZZZ9 bb34 MOVE 15 TO A. If A has picture of 999, after execution A will contain 015 MOVE “DSQ SOFTWARE Ltd.“ TO COMPANY-MNAME. MOVE A TO B, C, D. 6.2.1.4. GROUP MOVES When At Least One Of The Fields is a Group item, it is called A Group Move EXAMPLE 01 REC-1. 05 A1 PIC 9999. 05 A2 PIC AA. 05 A3 PIC XXXX. 01 REC-2 05 B1 PIC 9999. 05 B2 PIC AA. 05 B3 PIC XXXX. MOVE REC-1 TO REC-2 _______________________________________________________________________________ COBOL 34
  • 35. User Manual for COBOL _______________________________________________________________________________ 6.2.1.5. MOVE CORRESPONDING When the names of the corresponding data item of two groups are the same, this statement can be used to substitute for a set of move statements MOVE CORRESPONDING IDENTIFIER-1 TO IDENTIFIER-2. Source and destination groups can include data names that are not common Only the fields having identical names in the two records will take part in the data movements The remaining data items in the destination group will remain unchanged EXAMPLE 01 PAY-REC. 05 EMP-NO. PIC 9(5) 05 EMP-NAME PIC X(30). 05 EMP-BASIC PIC 9(5)V99. 01 PRINT-REC. 05 FILLER PIC X(5). 05 EMP-NO PIC 9(5). 05 FILLER PIC X(5). 05 EMP-NAME PIC X(30). 05 FILLER PIC X(5). 05 EMP-SAL PIC 9(6).99. MOVE CORRESPONDING PAY-REC TO PRINT-REC. _______________________________________________________________________________ COBOL 35
  • 36. User Manual for COBOL _______________________________________________________________________________ 6.3. ARITHMETIC VERBS 6.3.1. ADD This verb is used to find the sum of two or more numbers and to store the resultant sum ADD [CORRESPONDING] [IDENTIFIER-1 / LITERAL-1] [IDENTIFIER-2 / LITERAL-2] [TO / GIVING] IDENTIFIER-3, IDENTIFIER-4, ... Example:- ADD A TO B ADD A B GIVING C. ADD CORR OLD-REC TO NEW-REC. In the case of TO option, the previous value of the last named operand takes part in the summation and then this value is replaced by the result. Whereas in the case of GIVING option, the value of the last named operand does not take part in the summation and only the result is stored there. In the group add, numeric elementary items in the group referred to by first identifier are added to and stored in the corresponding elementary items of the second group. Data items in identifier-1 and identifier-2 take part in the summation, only if they have the Same data name and same qualifiers Corresponding items can have different locations within the group and the field sizes Can also be different _______________________________________________________________________________ COBOL 36
  • 37. User Manual for COBOL _______________________________________________________________________________ 6.3.2. SUBTRACT This verb is used to subtract one or the sum of two or more numbers from one or more numbers. Subtract [CORR] [IDENTIFIER-1 / LITERAL-1] [IDENTIFIER-2 / LITERAL-2] [FROM / GIVING] IDENTIFIER-3, IDENTIFIER-4, ... If GIVING option is used literals can be used in place of identifier-4. Example:- SUBTRACT A FROM B. SUBTRACT A B FROM C. SUBTRACT A B FROM C D. SUBTRACT 10 FROM A. 6.3.3. MULTIPLY Multiply verb is used to multiply one or more multiplicands by multiplier . MULTIPLY {IDENTIFIER-1 BY IDENTIFIER-2 [ , IDENTIFIER-3]... LITERAL - 1} [GIVING IDENTIFIER-4 [ , IDENTIFIER-5]...] If giving option is used, LITERALS can be used in place of identifier-2 and identifier-3. Example:- MULTIPLY A BY B. MULTIPLY A BY B C D. MULTIPLY A BY B GIVING C. MULTIPLY 0.5 BY B. 6.3.4. DIVIDE Divide verb is used to divide one number by another. _______________________________________________________________________________ COBOL 37
  • 38. User Manual for COBOL _______________________________________________________________________________ DIVIDE {Identifier-1 / Literal-1} INTO[BY] identifier-2 { ,identifier-3}.... [GIVING identifier-4 [ ,identifier-5]...] [REMAINDER identifier-6]. Example DIVIDE 5 INTO A .. DIVIDE A INTO B GIVING C. DIVIDE A BY B GIVING C D. DIVIDE A BY B GIVING C REMAINDER D. 6.3.5. ROUNDED OPTION This can be used with any arithmetic verb. It will round the number to the picture clause. ADD A B GIVING C ROUNDED. This phrase cannot be specified for the identifier that receives the remainder in a divide operation. _______________________________________________________________________________ COBOL 38
  • 39. User Manual for COBOL _______________________________________________________________________________ 6.3.6. ON SIZE ERROR If after an arithmetic operation, the result exceeds the largest value that can be accommodated in the result field, the error is called a “size error”. Can be used with any arithmetic verb When a size error occurs, the contents of the resultant field after the operation is unpredictable. When a size error occurs, the processing is not terminated and the next statement will be taken up for further execution. When this phrase is used, the statement becomes a conditional statement. Example:- ADD A TO B ON SIZE ERROR GO TO ERROR-PARA. _______________________________________________________________________________ COBOL 39
  • 40. User Manual for COBOL _______________________________________________________________________________ 6.3.7. COMPUTE This verb is very powerful and is used as a substitute for any of the other arithmetic verbs like add, subtract, multiply, divide. COMPUTE IDENTIFIER-1 [ROUNDED] [ , IDENTIFIER-2 [ ROUNDED ] ] = ARITHMETIC-EXPRESSION [ : ON SIZE ERROR] IMPERATIVE STATEMENT. 6.3.8. ARITHMETIC OPERATORS Arithmetic expression is formed with numeric operands, numeric LITERALS and numeric operators.. Arithmetic expression always assumes a numeric value. Arithmetic operators permitted in COBOL are ** => EXPONENTIATION. / => DIVISION. * => MULTIPLICATION.. - => SUBTRACTION. + => ADDITION. _______________________________________________________________________________ COBOL 40
  • 41. User Manual for COBOL _______________________________________________________________________________ 6.4. Miscellaneous 6.4.1. ACCEPT Accept statement can transfer data from an input/output device, or system information contained in the specified conceptual data items DATE, DAY, DAY-OF-WEEK, or TIME Format ACCEPT IDENTIFIER [ FROM mnemonic name DATE DAY TIME DAY-OF-WEEK}] When ‘FROM’ is omitted, the data is read from the operator’s terminal. At the time of execution, program is suspended until the operator enters the data. Mnemonic name option is implementation dependent and has to be defined in SPECIAL-NAMES paragraph. The date option returns six digit [9(6)] current date in YYMMDD format. The day option returns five digit [9(5)] current date in YYDDD format. The time option returns eight digit [9(8)] time in HHMMSSTT format The day-of-week option returns a single digit [9(1)] value as follows: 1 - Monday, 2 - Tuesday, 3 - Wednesday and so on. ACCEPT THIS-DATE FROM DATE. _______________________________________________________________________________ COBOL 41
  • 42. User Manual for COBOL _______________________________________________________________________________ 6.4.2. DISPLAY Display statement is used to display data on the terminal. Format DISPLAY {identifier-1 identifier-2 literal-1} , literal - 2 [upon mnemonic-name] Example DISPLAY “RESULT b IS “,THE-RESULT 6.4.3. CONTINUE The CONTINUE statement allows you to specify a no operation statement. CONTINUE indicates that no executable instruction is present. 6.4.4. STOP RUN This verb is used to terminate the execution of the program. 6.4.5. EXIT The EXIT statement provides a common end point for a series of paragraphs. This statement indicates a no operation and when executed, no action takes place 6.4.6. INITIALIZE This statement is used to initialize value of either an elementary or group item. _______________________________________________________________________________ COBOL 42
  • 43. User Manual for COBOL _______________________________________________________________________________ INITIALIZE {identifier-1 } . . . REPLACING { ALPHABETIC ALPHANUMERIC NUMERIC ALPHA-NUMERIC-EDITED. NUMERIC-EDITED } DATA BY { identifier-2 literal-2 } Example:- INITIALIZE WS - REC. 01 WS - REC. 05 A PIC 9(4). 05 B PIC A(4). 05 C PIC X(4). DATAITEM PIC BEFORE AFTER EXECUTION EXECUTION A 9(4) 1000 0000 B A(4) LIFE bbbb C X(4) A2BC bbbb INITIALIZE B REPLACING NUMERIC DATA BY 105 REPLACING ALPHANUMERIC DATA BY “ LOVE “ REPLACING NUMERIC-EDITED DATA BY 1500.23. _______________________________________________________________________________ COBOL 43
  • 44. User Manual for COBOL _______________________________________________________________________________ 6.5. CONDITIONAL AND UNCONDITIONAL TRANSFER 6.5.1. SIMPLE IF STATEMENT. IF condition [THEN] statement-1 ELSE statement-2 END-IF. The condition can be any one of the conditions mentioned before. Statement-1 represents one or more COBOL statements If the condition is found to be true, the statements represented in the THEN part will be executed. Statement-1 and Statement-2 represents one or more COBOL statements If the condition is found to be FALSE, the statements represented in the ELSE part will be executed After execution of this statement control will be implicitly transferred to the next sentence following the IF statement. Period (.) is placed only at the end of the IF structure. i.e. after the connective END-IF. Example:- IF AMOUNT > 5000 THEN ADD AMOUNT TO TOTAL-1 ELSE ADD AMOUNT TO TOTAL-2 END-IF. NEXT SENTENCE will be used to make either the THEN or ELSE part dummy. _______________________________________________________________________________ COBOL 44
  • 45. User Manual for COBOL _______________________________________________________________________________ 6.5.2. NESTED IF Inclusion of one or more IF statements within its scope is called as Nesting. The most inclusive IF statement must have terminating period. IF condition-1 [THEN] IF condition-2 [THEN ] statement-1 ELSE statement-2 END-IF END-IF. Indent nested ‘if‘ s properly to improve readability and maintainability. 6.5.3. EVALUATE STATEMENT Used for decisions and can be used when many branches are there Can be used as a substitute for nested if “s EVALUATE SUBJECT-1 [ALSO SUBJECT-2]... {WHEN OBJECT-1 [ALSO OBJECT-2}...} [WHEN OTHER {IMPERATIVE-STATEMENT-2}...] [END-EVALUATE] A list of subjects and several lists of objects are associated with an Evaluate. A list of subjects is specified between the word EVALUATE and the first appearance of WHEN Subject can be an Identifier / Literal /Expression or key words True / False Each WHEN specifies a list of objects Number of subjects and number of objects should tally Subjects and their corresponding objects should be comparable WHEN phrases are taken up for a “ match “ in the order they appear. Imperative statements corresponding to the matching WHEN will be executed. WHEN OTHER phrase is selected only if none of the previous WHEN phrases are selected. Objects can be Numeric value , Non-numeric value, Range of Numeric values, Range of non- numeric values, Conditional Values, keywords Example:- _______________________________________________________________________________ COBOL 45
  • 46. User Manual for COBOL _______________________________________________________________________________ EVALUATE TRUE WHEN MONTH = 4 OR 6 OR 9 OR 11 MOVE 30 TO NO - OF - DAYS WHEN MONTH = 2 MOVE 28 TO NO - OF - DAYS WHEN OTHER MOVE 31 TO NO - OF - DAYS END-EVALUATE. Example:- EVALUATE PRODUCT - TYPE ALSO CUSTOMER - TYPE WHEN 1 ALSO ANY MOVE 0 TO COMMISSION WHEN 2 ALSO 1 THRU 5 MOVE 10 TO COMMISSION WHEN OTHER MOVE 20 TO COMMISSION END-EVALUATE. 6.5.4. GO TO STATEMENT. It is an unconditional transferring control to the specified paragraph . There is no any comparison being made by the system before branching off . Example GOTO DISPLAY-PARA. Note:- It is advised to avoid GOTO Statements as the structured programming Technique does not support unconditional transfer statements. 6.5.5. GO TO WITH DEPENDING This verb is used to conditionally transfer the control to elsewhere in the program. Depending on whether the value of the identifier is 1,2 . . . n , the control is transferred to procedure- name-1, procedure-name-2, . . . procedure-name-n respectively. If the value of the identifier is anything other than the specified range of 1, 2 . n, the said go to is ineffective and the control is transferred to the next statement. _______________________________________________________________________________ COBOL 46
  • 47. User Manual for COBOL _______________________________________________________________________________ GO TO PROCEDURE-NAME-1 [ , PROCEDURE-NAME-2 ]... PROCEDURE-NAME-N DEPENDING ON identifier The statement transfers control to one of the procedures named in the statement depending on the value of the identifier The identifier specified in the statement must be a numeric, integral, elementary item. Example:- GO TO RECEIPT-PARA, ISSUE-PARA, ADJUSTMENT-PARA DEPENDING ON TRANSACTION - TYPE. 6.5.6. ALTER The alter statement can be used to modify the targets of goto statements written elsewhere in the procedure division. ALTER PROCEDURE-NAME-1 TO [PROCEED TO ] PROCEDURE-NAME-2 [PROCEDURE-NAME-3 TO {PROCEED TO } PROCEDURE-NAME-4 ].... Each of the PROCEDURE-NAME-1, PROCEDURE-NAME-3 is the name of the paragraph that contains only one sentence. This sentence must consist of a single goto statement without the depending clause. During the execution each of the PROCEDURE-NAME-1 , PROCEDURE-NAME-3, . . . will be replaced by PROCEDURE-NAME-2, PROCEDURE-NAME-4 ...respectively. 6.6. PERFORM STATEMENTS A PERFORM statement is used to execute a group of consecutive statements specified elsewhere in the program, under a paragraph. 6.6.1. Basic Perform PERFORM PARA-name-1. Para-name-1 specifies the range , which contains statements to be executed _______________________________________________________________________________ COBOL 47
  • 48. User Manual for COBOL _______________________________________________________________________________ Upon execution of this statement the control is transferred to the beginning of the paragraph and executes all the statements in that paragraph till the last statement. After executing the said range, the control is implicitly , transferred to the next line after the PERFORM statement Example:- 100-MAIN-PARA. PERFORM 1000-ACCEPT-PARA. PERFORM 2000-COMPUTE-PARA. PERFORM para-name-1 thru para-name-2. This statement executes all the statements beginning in the para-name-1 till the last statement in the para-name-2 If there are any other paragraphs placed in between these two paragraphs, those are also executed After executing the said range, the control is implicitly , transferred to the next line after the PERFORM statement Example:- PERFORM BEGIN-PARA THRU END-PARA. _______________________________________________________________________________ COBOL 48
  • 49. User Manual for COBOL _______________________________________________________________________________ 6.6.2. PERFORM with TIMES phrase PERFORM para-name-1 [THRU para-name-2] {identifier-1/ integer} TIMES. This is a looping statement which executes the specified range of statements a fixed no. of times. Example:- PERFORM READ-RTN 10 TIMES. This statement executes all the stmts. in READ-RTN 10 times without testing any condition. 6.6.3. PERFORM with UNTIL phrase PERFORM para-name-1 [THRU para-name-2] UNTIL condition. This statement executes a series of instructions in para-name-1 repeatedly till the condition becomes TRUE. Initially the condition is expected to be false. The condition should be made true, within the paragraph being performed. If the condition is true initially, the range is not executed at all Example:- MOVE 0 TO I. PERFORM 000-CALC-PARA UNTIL I>10 000-CALC-PARA. -- ADD 1 TO I. Here 000-CALC-PARA is performed 10 TIMES. _______________________________________________________________________________ COBOL 49
  • 50. User Manual for COBOL _______________________________________________________________________________ 6.6.4. PERFORM with VARYING phrase. PERFORM VARYING{identifier-1 FROM {identifier-2 /integer-1} BY {identifier-3 / integer-2} UNTIL Condition-1 AFTER identifier-1 FROM {identifier-2/integer-1} BY {identifier-3/integer-2} UNTIL Condition-2 [imperative statement] END-PERFORM. This is also a looping statement which executes imperative statement for all possible values of identifier-1 and identifier-3 until Condition-1 and Condition-2 are TRUE. Example PERFORM VARYING I FROM 1 BY 1 UNTIL I > 3 AFTER J FROM 1 BY 1 UNTIL J > 4 Display SALE ( I , J ) END-PERFORM. The above example will take I and j vales as 1,1 1,2 1,3 1,4 2,1 2,2 2,3 2,4 3,1 3,2 3,3 3,4 _______________________________________________________________________________ COBOL 50
  • 51. User Manual for COBOL _______________________________________________________________________________ 6.7. Conditional expressions In COBOL there are various types of conditions as follows : RELATIONAL CONDITION SIGN CONDITION CLASS CONDITION. CONDITION - NAME CONDITION NEGATED SIMPLE CONDITION. COMPOUND CONDITION 6.7.1. RELATIONAL CONDITION A relation condition compares two operands, either of which can be an identifier, literal, arithmetic expression, or index-name. A non-numeric literal can be enclosed in parentheses within a relation condition. The relational operators are < <= > >= NOT GREATER THAN / LESSER THAN / EQUAL TO IF A > B DISPLAY “ A IS GREATER THAN B “ ELSE DISPLAY “ A IS LESS THAN OR EQUAL TO B “ END-IF . _______________________________________________________________________________ COBOL 51
  • 52. User Manual for COBOL _______________________________________________________________________________ 6.7.2. SIGN CONDITION The sign condition determines whether or not the algebraic value of a numeric operand is greater than, less than, or equal to zero. The Possible SIGN conditions are POSITIVE / NEGATIVE / ZERO. IF CURR-STOCK-ISS-QTY IS NEGATIVE DISPLAY “ ISSUE CANNOT BE MADE” GO TO NO-STOCK-PARA END-IF. 6.7.3. CLASS CONDITION The class condition determines whether the content of a data item is alphabetic, alphabetic-lower, alphabetic-upper, numeric, or contains only the characters in the set of characters specified by the CLASS clause as defined in the SPECIAL-NAMES paragraph of the Environment Division. The possible CLASS Conditions are ALPHABETIC / NUMERIC / ALPHANUMERIC IF A IS NUMERIC ADD 1 TO A ELSE DISPLAY “ NON - NUMERIC DATA FOR A “ GO TO ERROR-PARA END-IF. _______________________________________________________________________________ COBOL 52
  • 53. User Manual for COBOL _______________________________________________________________________________ 6.7.4. CONDITION-NAME CONDITION A condition-name condition tests a conditional variable to determine whether its value is equal to any value(s) associated with the condition-name. Condition names are not memory locations but names assigned to data ranges . Comparisons can be simplified . 01 WS-MARITAL-STATUS 88 SINGLE VALUE IS 0. 88 MARRIED VALUE IS 1. IF SINGLE ADD 1 TO SINGLE-COUNT. 6.7.5. NEGATED SIMPLE CONDITION A simple condition is negated through the use of the logical operator NOT. IF NOT MARRIED DISPLAY “ELIGIBLE FOR RS 1000 ONLY “ END-IF. 6.7.6. COMPOUND CONDITION Two or more conditions can be logically connected to form a compound condition. The possible Compound Conditions are AND OR NOT . IF AGE IS LESS THAN 18 AND MARRIED DISPLAY “EARLY MARRIAGE “ END-IF. 7. FILE HANDLING _______________________________________________________________________________ COBOL 53
  • 54. User Manual for COBOL _______________________________________________________________________________ A data file is a collection of relevant records of an application. A record is a collection of relevant fields pertaining to an item/case/ account/transaction . File is organized in storage media in one of the following ways ♦ SEQUENTIAL ♦ INDEXED ♦ RELATIVE 7.1. Sequential Files If a file organization is Sequential then ♦ Records can be accessed in the order in which they appear in the file ♦ Records can be appended at the end of the file but can not be inserted. ♦ Records cannot be deleted 7.2. Indexed Files Indexed File Organization is to do random Processing or sequential processing. In this Organization ♦ Record can be accessed in any order by key called Primary Key. ♦ There can be more than one key called Alternate Keys to access records ♦ Records can be inserted added and deleted. 7.3. Direct Access Files This record is best suited if there are records which can be accessed on record number basis rather than based on a field of the record. Each record has a unique address and is identified by a relative record number. 7.4. STEPS INVOLVED IN FILE HANDLING To handle a file the following operations are to done. Step 1. _______________________________________________________________________________ COBOL 54
  • 55. User Manual for COBOL _______________________________________________________________________________ ♦ All files handled in a program should be assigned a logical name chosen by the programmer as per the syntax similar to Cobol identifier. The organization of the file ,DDNAME assigned for the dataset and its primary and alternate key, if any, have to be specified in the File-Control para of Environment Division. This is specified using SELECT statement of File-Control para. Step2. ♦ Describe the File with detail like record name ,record structure in the File Section of DATA DIVISION .Also specify as how many records are grouped as a BLOCK for Input Output Operation. Step3. ♦ All files described as explained above should be first opened to do read/write operations. Open statement is used to connect dataset to the Cobol program. This statements are coded in procedure division . Files can be opened for reading, writing ,appending . Step4. If we have to read a file READ statement is used in procedure Division. SYNTAX Read File -name. If we have to write in to a file WRITE command is used in procedure Division. The record attached to the concerned file alone can be used to write into the file. SYNTAX WRITE Record -name. Step5. After read / write operations are over the file must be closed to disconnect the file from the Cobol program. SYNTAX CLOSE File-name. _______________________________________________________________________________ COBOL 55
  • 56. User Manual for COBOL _______________________________________________________________________________ 7.4.1. EXAMPLE IDENTIFICATION DIVISION. PROGRAM-ID. F1. ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. FILE -CONTROL. SELECT CUSTOMER-FILE ASSIGN TO DD1. ORGANIZATION IS INDEXED. ACCESS MODE IS SEQUENTIAL. RECORD KEY IS CUST-NO. FILE STATUS KEY IS WS-FST1. FILE SECTION. FD CUSTOMER - FILE RECORDING MODE IS F RECORD CONTAINS 80 CHARACTERS DATA RECORD IS CUSTOMER - RECORD. 01 CUSTOMER RECORD. 05 CUSTOMER - NAME PIC X(13). 05 CUSTOMER - UNITS PIC 9(3). 05 ADDRESS PIC X(64). WORKING-STORAGE SECTION.. 01 WS-FST1 PIC X(2). PROCEDURE DIVISION. 000-MAIN-PARA. OPEN OUTPUT CUSTOMER-FILE. DIASPLAY WS-FST1. 100-WRITE-PARA. ACCEPT CUSTOMER-NAME ACCEPT CUSTOMER-UNITS ACCEPT ADDRESS WRITE CUSTOMER-RECORD. Display WS-FST1. 200-CLOSE -PARA. CLOSE CUSTOMER-FILE. STOP RUN. 7.5. SELECT Statement _______________________________________________________________________________ COBOL 56
  • 57. User Manual for COBOL _______________________________________________________________________________ Syntax : SELECT file-name ASSIGN TO DD Name ORGANIZATION IS [ SEQUENTIAL/INDEXED/RELATIVE] ACESS MODE IS [SEQUENTIAL/DYNAMIC/RELATIVE] [RECORD KEY data-name-1 ] [ALTERNATE KEY IS data-name-2. WITH DUPLICATE] FILE-STATUS IS data-name-2. 7.5.1. ORGANIZATION CLAUSE This clause should appear in Environment division. We can choose File Organization SEQUENTIAL This Option is to handle a PS data set or VSAM ESDS . Once the file is Organised as Sequential records can be placed as first come first served basis. INDEXED This Option is to handle a VSAM KSDS . There should be a key field to choose this operating. This is called primary key And is to be unique like ROLLNO, EMPLYEE NO. RELATIVE This Option is to handle a VSAM RRDS . Record Numbers are identifying the records to access.. _______________________________________________________________________________ COBOL 57
  • 58. User Manual for COBOL _______________________________________________________________________________ 7.5.2. ACCESS MODE CLAUSE This clause should appear in the access mode statement of Environment division. Files can be accessed in different modes based on the type of Organization. We can choose access mode depending on the order in which we like it to be accessed. Sequential Access Mode will facilitate to access any file records in sequential order. Random Access Mode will facilitate to access a particular record of an Indexed File / Relative File provided the Record key must be set before read / write operation. Dynamic Access Mode will facilitate to access a particular record or in sequential order from an Indexed File / Relative File We give below all possible access modes on organization. Seq. access Random access Dynamic access Organization Sequential Order of write Invalid Invalid Relative Ascending rel rec. no Value of rel key Seq. or random Indexed Ascending key value Value of rel key Seq. or random 7.5.3. RECORD KEY PHRASE This Phrase is to be defined in the Environment Division and essential when the file is an Indexed File. This key is to be Unique and is to be a part of the Indexed record. 7.5.4. ALTERNATE KEY PHRASE This Phrase is to be defined in the Environment Division when we want to access record in the order of some other Key apart from primary key. This key need not be unique but to be a part of the record. 7.6. FD entry _______________________________________________________________________________ COBOL 58
  • 59. User Manual for COBOL _______________________________________________________________________________ Syntax FD FILENAME [BLOCK CONTAINS [int-1 TO ] int-2 RECORDS[CHARACTERS] [RECORD CONTAINS [int-3 TO } int-4 CHARACTERS [LABEL RECORD/RECORDS IS/ARE STANDARD/OMITTED RECORDING MODE IS [ F/ V] [; DATA RECORD/RECORDS IS/ARE data-name-2]] record-name field1 Pic .. 7.6.1. BLOCK CONTAINS / RECORD CONTAINS PHRASE We can specify the length of the file record in this Clause in terms of Characters this is to be specified in Data Division. We can specify the number of characters / records contains in a Block. 7.6.2. RECORDING MODE CLAUSE This Phrase is to be defined in the File section Data division. When the file is with Fixed length record is chosen as F. This key represent s only the record Number. RECORDING MODE [F] [V]. F => Fixed which Indicates that every record of same length FD BLOCK CONTAINS 500 CHARACTERS. RECORD CONTAINS 50 CHARACTERS. DATA-RECORD IS EMP-RECORD. EMP-RECORD 01 EMPNO PIC X(6). 02 EMP-NAME PIC X(30). 02 BASIC PIC 9(5). 02 HRA PIC 9(5). 02 DA PIC 9(4). The above record is of length 50 characters. _______________________________________________________________________________ COBOL 59
  • 60. User Manual for COBOL _______________________________________________________________________________ V => Variable which Indicates that record length may vary from I1 to I2. Example FD BLOCK CONTAINS 320 THRU 640 CHARACTERS. RECORD CONTAINS 32 THRU 64 CHARACTERS. DATA RECORD IS MARK-RECORD. 01 MARK-RECORD 02 P1 PIC 99. 02 MARKS OCCURS 10 THRU 20 Depending P1 03 SCORE PIC 999. The above record length is based on P1. _______________________________________________________________________________ COBOL 60
  • 61. User Manual for COBOL _______________________________________________________________________________ 7.7. INPUT / OUTPUT STATEMENTS Open statement can be used for opening the file with different mode. OPEN OUTPUT file-name :- connects data set to your COBOL program to write records when the file is even with out a single record.. OPEN INPUT file-name :- connects data set to your COBOL program to records from the first . OPEN EXTEND file-name :- connects data set to your COBOL program for writing new records in an existing non empty file. OPEN I-O file-name :- connects data set to your COBOL program for processing to do read/write /Rewrite. WRITE :- Add records to a file or load a file . When this command is used in an Indexed file key must be newer one always. START Establish the current location in the cluster for a READ NEXT statement START does not retrieve a record , it only sorts the current record pointer described under File Position indicator READ statement is used to read a record from a file. If it is used to read a sequential file it will read the next record always . If it used to read from an Indexed/Relative file it will read the corresponding key record, The key field must have value before read. If we have read sequentially from an Indexed file READ NEXT RECORD will retrieve records from a file in sequence REWRITE Update records. DELETE Logically remove records from indexed and relative files only CLOSE Disconnect the VSAM data set from your program _______________________________________________________________________________ COBOL 61
  • 62. User Manual for COBOL _______________________________________________________________________________ 7.8. VSAM DATA SET COMPARISON ON VSAM DATASETS Entry - sequenced Key - sequenced Relative - Record Records are in order in which Records are in collating Records are in relative record they are written sequence by key field number order Access is sequential Access is by key through an Access is by relative record index number , which is treated like a key May have one or more May have one or more May not have alternate indexes alternate indexes alternate indexes. A record’s RBA cannot change A record RBA can change A record relative record number cannot change Space at the end of the data set Distributed free space is used for fixed length RRDS empty is used for adding records for inserting record and slots in the data set are used changing their lengths in place for adding records. For variable - length RRDS, distributed free space is used for adding records and changing their lengths in place A record cannot be deleted but Space given up by a deleted or Space given up by a deleted you can reuse its space for a shortened record is record can be reused record of the same length automatically reclaimed within a control interval Can have spanned records can have spanned records Can be reused as a word file Can be reused as a word file can be reused as a work file can be reused as work file unless it has an alternate index unless it has an alternate index associated with key ranges or associated with key ranges or exceeds 123 extents per volume exceeds 123 extents per volume _______________________________________________________________________________ COBOL 62
  • 63. User Manual for COBOL _______________________________________________________________________________ 7.8.1. VSAM DATASETS AND ACCESS MODES File Organization Seq. Ran. Dyna. Fixed Variable Access Access Access Length Length VSAM sequential Yes No No Yes Yes (ESDS) VSAM indexed Yes Yes Yes Yes Yes (KSDS) VSAM Relative Yes Yes Yes Yes NO (RRDS) 7.8.1.1. ORGANIZATION CLAUSE ORGANIZATION IS SEQUENTIAL - for VSAM sequential files (ESDS) ORGANIZATION IS INDEXED - for VSAM indexed files (KSDS) ORGANIZATION IS RELATIVE - for VSAM relative files (RRDS). _______________________________________________________________________________ COBOL 63
  • 64. User Manual for COBOL _______________________________________________________________________________ 7.8.2. ENVIRONMENT DIVISION ENTRIES FOR VSAM FILES Example :VSAM Sequential File SELECT S -FILE ASSIGN TO SEQUENTIAL - FILE ORGANIZATION IS SEQUENTIAL ACCESS IS SEQUENTIAL FILE STATUS KEY IS FSTAT - CODE VSAT - CODE Example :VSAM Indexed File SELECT I - FILE ASSIGN TO INDEXED - FILE ORGANIZATION IS INDEXED ACCESS IS DYNAMIC RECORD KEY IS IFILE - RECORD - KEY ALTERNATE RECORD KEY IS IFILE - ALTREC - KEY FILE STATUS KEY IS FSTAT - CODE VSAM - CODE Example:- VSAM Relative File SELECT R - FILE ASSIGN TO RELATIVE - FILE ORGANIZATION IS RELATIVE ACCESS IS RANDOM RELATIVE KEY IS RFILE - RELATIVE - KEY FILE STATUS KEY IS FSTAT - CODE VSAM - CODE _______________________________________________________________________________ COBOL 64
  • 65. User Manual for COBOL _______________________________________________________________________________ 7.8.3. COBOL STATEMENTS USABLE WITH SEQUENTIAL FILES Access Mode COBOL / OPEN OPEN OPEN OPEN 370 INPUT OUTPUT I-O EXTEND Statement Sequential OPEN X X X X WRITE X X START READ X X REWRITE X DELETE CLOSE X X X X 7.8.4. COBOL STATEMENTS WITH INDEXED FILES (KSDS) AND RELATIVE (RRDS) Access COBOL/370 OPEN OPEN OPEN OPEN Mode Statement INPUT OUTPUT I-O EXTEND Sequential OPEN X X X X WRITE X X START x x READ X X REWRITE X DELETE x CLOSE X X X X Random OPEN X X X WRITE X X START READ X X REWRITE X DELETE X CLOSE X X X _______________________________________________________________________________ COBOL 65
  • 66. User Manual for COBOL _______________________________________________________________________________ Dynamic OPEN X X X WRITE X X START X X READ X X REWRITE X DELETE X CLOSE X X X 7.8.5. PROCEDURE DIVISION STATEMENTS TO UPDATE VSAM FILES ESDS KSDS RRDS ACCESS IS SEQUENTIAL ACCESS IS SEQUENTIAL ACCESS IS SEQUENTIAL OPEN EXTEND OPEN EXTEND OPEN EXTEND WRITE WRITE WRITE CLOSE CLOSE CLOSE OPEN I - O OPEN I - O OPEN I - O READ READ READ REWRITE REWRITE REWRITE DELETE DELETE CLOSE CLOSE CLOSE ACCESS IS RANDOM ACCESS IS RANDOM ACCESS IS RANDOM OPEN I - O OPEN I - O READ READ Not Applicable WRITE WRITE REWRITE REWRITE DELETE DELETE CLOSE CLOSE ACCESS IS DYNAMIC ACCESS IS DYNAMIC ACCESS IS DYNAMIC Sequential processing Sequential processing Sequential processing OPEN I - O OPEN I - O _______________________________________________________________________________ COBOL 66