This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Saturday, 13 August 2011

Cobol Variables

Data Types & Variables  :--
COBOL supports variables which are either alphabetic, numeric, or alphanumeric.
 
Variable declaration
 
    Variables must be declared in a COBOL program prior to their use.  Declarations occur in the DATA DIVISION.  Data items are either "elementary data items" or "record description entries." 








Elementary items
 
An elementary data item is a variable which contains a single value.  For example, one might define a variable HOURS-WORKED to be an integer with up to 2 digits as follows:


        DATA DIVISION.
        WORKING-STORAGE SECTION.
        77      HOURS-WORKED PICTURE 99 IS ZERO.



The 77 above is referred to as a level number.  Level 77 is specific level number used to  describe elementary items in the working storage section of the data division.
        Note that this data item also has included an optional initialization value.  Values may be either literal or figurative.  Literal values are written as follows.

        Numeric      1-18 digits
                                      Option: may be preceeded by + or - sign
                                      Option: may include an embedded decimal point
      Alphabetic   0 or more characters enclosed in quotes (").
                                      Option: to include a quote in a literal string,type two
      Figurative values are:


  • ZERO
  • ZEROES
  • ZEROS
  • SPACE
  • SPACES
  • ALL "string"

    the ALL modifier is used to fill an alphabetic variable with copies of the string.  For
    example,
   
        77      OUTPUT-STRING PICTURE X(21) IS ALL "+-".
           
    would be the same as
   
        77      OUTPUT-STRING PICTURE X(21) IS "+-+-+-+-+-+-+-+-+-+-+".

 Group items         
 
 
A record is a group of items which contain related data values.   For example, we might define a record as follows:

DATA DIVISION.
        WORKING-STORAGE SECTION.
        01      ALBUM.
                05      TITLE                           PICTURE X(30).
                05      GENRE                           PICTURE X(10).
                05      ARTIST.      
                        10           FIRST-NAME         PICTURE X(20).
                        10           LAST-NAME          PICTURE X(20).
                        10           BAND-NAME          PICTURE X(20).
                05      ID-NUMBER                       PICTURE X(10).
                05      YEAR                            PICTURE 9999.

The level numbers above are used to show subordination of groups of values.  Level 01 is    the uppermost level in the hierarchy.  Other numbers can be chosen as the programmers  preference in the range of 02-49.  All items with the same level number are at the same hierarchical level in the record, referenced through the data name that subordinates them.
   
    In other words, this data description shows a group called ALBUM with the five subordinate items, TITLE, GENRE, ID-NUMBER and YEAR (all elementary) and another group called ARTIST with three elementary items, FIRST-NAME, LAST-NAME, and BAND-NAME.

    Note: all user-defined names at the 01-level must be unique; however, it is permissible to use the same subordinate names in other group variables.
   
    Group items can be referenced in a program as an entire unit, for example,
   
        ALBUM
       
    or by the items within the structure.  For example, we may have,
   
        TITLE OF ALBUM
        
    or

        BAND-NAME OF ARTIST OF ALBUM
       
    to refer to specific data items.
   
    Boolean data items

    COBOL does not directly support logical/boolean variables; however, level-88 is used to define condition names which have the same effect.  For example, suppose we have a variable called CLASS-YEAR which is a number in the range 0-5 with the following interpretation:
        0     a student who has been accepted but has not yet registered for courses
        1     a student in the freshman year
        2     sophomore
        3     junior
        4     senior
        5     graduate
           
    77    CLASS-YEAR  PIC  9.
          88    NON-MATRICULATED     VALUE  0.
          88    FROSH                VALUE  1.
          88    SOPH                 VALUE  2.
          88    JUNIOR               VALUE  3.
          88    SENIOR               VALUE  4.
          88    GRADUATE             VALUE  5.
          88    INVALID-CLASS        VALUES 6,7,8,9.
         
    which would allow statements like
   
        IF GRADUATE ...
       
    whose result would be determined by the value currently stored in CLASS-YEAR when  this statement is pocessed.  Note that it is possible to have more than one value associated with a condition. For example, above, if any number outside 0 through 5 is stored in CLASS-YEAR the data name INVALID-CLASS will become true.

COBOL Basics

COBOL programs are entered in predefined formats i.e., formatted acceptable by the COBOL compilers. For this reason, COBOL programs are written on COBOL coding sheets, which use a standard format. There are 80 characters positions on each line of the coding sheet and these positions are grouped into the following 5 fields.

RULES FOR CODING A COBOL PROGRAM OR MARGIN RULES


1-6 Sequence numbers
7 Indicator
8-11 Area A / Margin A
12-72 Area B / Margin B
73-80 Identification
73-81 





Columns 1 – 6
Line Numbers: Reserved for line numbers automatically assigned by the Compiler. These numbers are not used in the actual manipulations within the program.

Column 7
Indicator Area:- Documentation (‘*’ or ‘/’). A ’ * ’ is put in this column so that the Compiler can ignore the sentence. Continuation ( - hyphen) in this column specifies  that the commands continue onto the next line.

Column 8 – 11
Are reserved for programming statements.
Area A:
The following must begin in area A:
 Division and section headers
 Paragraph names
Declaratives and End Declaratives
End Program header
Level indicator (FD or SD)or level-number (01 or 77)

Column 12 – 72
Area B:
The following must begin in area B:
 Entries, sentences, statements, clauses

Column 73 onwards
Is ignored by the Compiler
 

COBOL LANGUAGE ELEMENTS :--

In  COBOL Language There are mainly 7 Elements are there , that are
  1. Cobol Characters
  2. Words
  3. Statements
  4. Sentences
  5. Paragraphs
  6. Sections
  7. Divisions
1. Cobol Characters :--

  • Alphabetic Characters   : A - Z, ‘ - ‘ i.e. hyphen preceded or followed by either a  letter or  a digit.
  • Numeric Characters      :  0 - 9
  • Punctuation Characters : , . ; ‘ (  )
  • Special Characters         : + - / * = > < . $
 The hyphen may NOT appear as the first or last character.Lowercase is equivalent to uppercase (except in non-numeric literals).Non-numeric literals and comments may contain any of the characters from the character set of the computer. 
NOTE: The program-name in PROGRAM-ID paragraph must begin with an alphabetic and hyphen(s) will be changed to zero(s).

2. Words :- 
 
COBOL is based on syntax rules and words derived from the English Language. Any violation of the rules would result in compilation errors. The 2 kinds of words used in COBOL are :
  • Reserved Words
  • User-Defined Words
Reserved words : A reserved word is a character-string with a predefined meaning in a COBOL source program. There are several types of reserved words in COBOL.
User-Defined Words: Unlike the reserved word the user-defined word is constructed and used by the application programmer. The following are the rules to be followed while framing user-defined words.


 Word Naming Rules :--

  • Length may be up to 30 characters
  • Only alphabets, digits and hyphen (-) are allowed
  • Embedded blanks are not allowed
  • At lease one character must be alphabetic
  • Cannot be a Cobol reserved word
  • May not begin or end with a hyphen
Sections and Paragraphs :-

         Each division of a COBOL program is broken down into sections beginning with special line called section header and each section in turn broken down to paragraph.

Section header consists of the name of the section followed by the word “SECTION” and a period. Section name in environment division and data division are a fixed part of COBOL program and cannot be changed. The Identification division has no paragraph.

Paragraph in COBOL may be part of a section or can stand alone with their division. In all cases paragraphs are identified by a paragraph header, which consists of name of the paragraph followed by a period.

Paragraph in the procedure division are made up of sentences. Although COBOL allows a period at the end of every statement.

 7.  Divisions :: -

         A COBOL program always consists of four main parts, called division. They are 
  • Identification Division
  • Environment Division
  • Data Division
  • Procedure Division   
  Identification Division :--
                  The IDENTIFICATION DIVISION is the first division of every COBOL source program. There may be several paragraphs in this division of which the paragraph PROGRAM-ID is essential in most of the machines. The other paragraphs are optional and may be used mainly for documentation purpose. The following shows the structure of this division.

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

The division heading and paragraph names should be coded as area A entries. Each of the paragraph names must end with a period sign followed by at least one blank space. The PROGRAM-ID paragraph contains the program name to be used to identify the object program. The entries in the other paragraphs are normally treated as comments and the programmer is free to write anything for these entries. The author paragraph may include the name of the programmer. The date-compiled paragraph may contain the date of compilation.

Environment Division :-
The ENVIRONMENT DIVISION is the division that must follow the IDENTIFICATION Division in a COBOL source Program. Among all the four divisions this one is the most machine-dependent division. The Computer and all peripheral devices required by the program are described in this division.

This division contains two sections- CONFIGURATION SECTION and INPUT-OUTPUT SECTION. Of these the CONFIGURATION SECTION appears first. The out line of the sections and paragraphs of this division is shown below.

ENVIRONMENT DIVISION
CONFIGURATION SECTION
SOURCE-COMPUTER. Source-Computer-entry.
OBJECT-COMPUTER. Object-Computer-entry
[SPECIAL NAMES. Special-names-entry]
[INPUT-OUTPUT SECTION.
FILE-CONTROL. {File-control-entry}
[I-O-CONTROL. Input-output-control-entry].]
CONFIGURATION SECTION
This section contains an overall] 1 specification of the computer used for the purpose of compilation and execution of the program, There are in all three paragraphs in this section.
SOURCE-COMPUTER

This Paragraph specifies the name of the computer used to compile the COBOL program. The following is the form of this paragraph.

SOURCE-COMPUTER. computer name.

For example: If ICL 1901 is to be used for compiling the COBOL Source Program, this paragraph should be as follows:
SOURCE- COMPUTER. ICL-1901.

OBJECT-COMPUTER

THE OBJECT-COMPUTER Paragraph describes the computer on which the program is to be executed. The following shows the syntax for this paragraph.

OBJECT-COMPUTER. computer-name
MEMORY SIZE integer-1 CHARACTERS
WORDS
[PROGRAM COLLATING SEQUENCE IS alphabet-name]
[SEGMENT-LIMIT IS integer-2].

The Computer name specifies a particular computer on which the object program is to be executed. The MEMORY SIZE is used to indicate the amount of storage available to the object program. This clause is also used in conjunction with the SORT Verb. The PROGRAM COLLATING SEQUENCE clause specifies the collating sequence that is to be used to compare nonnumeric data items. The alphabet name in this clause should be defined in the SPECIAL-NAMES paragraph to specify a collating sequence.

EX:
OBJECT-COMPUTER. ICL-1900
Memory size 8000 WORDS.

SPECIAL- NAMES

This Paragraph is used to relate some hardware names to user-specified mnemonic names. This Paragraph is optional in all compilers. The following is the format of this paragraph.

SPECIAL NAMES [CURRENCY SIGN IS literal-1]
[DECIMAL-POINT IS COMMA]
[CHANNEL integer is mnemonic-names]…..
[ALPHABET alphabet-name IS STANDARD
NATIVE
Implementer -name
[ , implementer-name IS mnemonic-name ].

The CHANNEL clause is used to control the line spacing of the line printers.
The ALPHABET clause specifies a user-defined alphabet name that can be used to indicate a collating sequence in a PROGRAM COLLATING SEQUENCE clause. NATIVE – computer’s own collating sequence. STANDARD – ASCII collating sequence. The alphabet name is also used to define the external character set in which the data is recorded on a file.

EX: SPECIAL-NAMES. CHANNEL 1 IS PAGE-TOP.

INPUT-OUTPUT SECTION

This section contains information regarding files to be used in the program. There are two paragraphs in this section- FILE CONTROL and I-O-CONTROL. Of these, the first one is used in almost every program. In the following some of the entries of the FILE- CONTROL Paragraph will be discussed.

FILE –CONTROL

The FILE-CONTROL Paragraph names each file and identifies the file medium through file control entries. The Simplified format of a file control entry is given below.

SELECT [OPTIONAL] file–name ASSIGN TO hardware-name.

For each of the file that we are using in program must have a FILE-CONTROL entry. This entry names the file and assigns a peripheral device which holds that particular file. The file names that appear in SELECT clause must be unique and all these files must be described in DATA DIVISION.The word OPTIONAL may be used only for input files. The ASSIGN clause assigns a particular physical peripheral device name ( READER, PRINTER, TAPE and DISK) to a file.

EX:
FILE-CONTROL.
SELECT FILE1 ASSIGN TO READER.

Data Division :--

The DATA DIVISION is that part of a COBOL Program where every data item processed by the program is described. It is important to note that unless a data item is described in the DATA DIVISION, it cannot be used in the procedure division. The DATA DIVISION is divided into a number of sections and depending on the use of a data item, it should be defined in the appropriate section. For the time being only two of the sections of the DATA DIVISION will be considered. These are as follows:

(a) FILE SECTION
The FILE SECTION includes the descriptions of all data items that should be read from or written on to some external file.

(b) WORKING-STORAGE SECTION
The data items which are developed internally as intermediate results as well as the constants are described in this section of the DATA DIVISION,.
The Format of the DATA DIVISION is as follows:
DATA DIVISION
[FILE SECTION
File Section entries.
………..
……….. ]
[WORKING –STORAGE SECTION
Working-Storage entries
……….. ]
5.2 LEVEL STRUCTURE
The data to be processed are internally stored in a specific area in the memory of a computer. The area corresponding to a Particular data item is referenced by the data name used in the description of the said item. Data names are user-created words. The rules for forming such names or words in COBAL have been discussed earlier. However, it is important to note that while the data name actually stands for a particular area in the memory, it is the content of the area that takes part in the operation when referred to by the said data name in the PROCEDURE DIVISION Statements.
In COBOL a distinction is made between elementary and group data items. A few elementary data may be combined to form a group. For example, Day, MONTH and YEAR may be three elementary data items. These may be combined to form a group data named DATE. The organization may be shown pictorially as follows:

DATE

DAY MONTH
YEAR

Example 1
01 DATE
05 DAY
05 MONTH
05 YEAR

5.3. DATA DESCRIPTION ENTRIES
A data description entry describes a data item. It consists of a level number, data name (or FILLER) followed by a number of optional clauses terminated by a period. The purpose of an individual Clause is to specify certain characteristics of the data item being described.
5.3.1 PICTURE Clause
The picture clause describes the general characteristics of an elementary data item.
a.) Class : In COBOL a data item may be one of the 3 classes – numeric(0 – 9), alphabet(A-Z, space) or alphanumeric( digits, letters & special characters).
b.) Sign : A numeric data item can be signed or unsigned.
c.) Point location : It is specified for numeric data items. If it is not specified, the item is considered to be an integer which means that the decimal point is positioned immediately after the right most digits.
d.) Size : Specifies the number of characters or digits required to store the data item in a memory.

Syntax: PICTURE IS character-string
PIC

The character string can consist of 1 to 30 code characters.
Code characters meaning
9 Data item is numeral
X Data item is of any character from COBOL character set.
A Data item contains letter or space
V Position of the decimal point
P Assumed when point lies outside the data item
S Data item is signed

The allowable combinations are governed by the following rules:
(i) In the case of an alphabetic item the picture may contain only the symbol A.
(ii) In the case of a numeric item the picture may contain only the symbols 9, v, p and S. these are called operational characters. It must contains at least one 9. The symbol is V and S can appear only once and S, if t included, must be the leftmost character or on left (but not on the left of S) as may times as is required to indicate the position of the assumed decimal point.
(iii) In the Case of an alphanumeric item, the picture may Contain all XS or a combination of 9, A and X (Except all 9 or all A). In the latter case the item is considered as if the string consists of all XS.
Example:
PICTURE IS S999V99.

5.3.2 VALUE Clause
The Value Clause defines the initial value of a data item. Normally the initialization is done just before the first statement in the PROCEDURE DIVISION is executed. The syntax of the VALUE Clause in its most simple form is
VALUE IS literal

Examples
VALUE IS 3.5
VALUE IS “ MY DATA ”
VALUE ZERO.



5.4 FILE SECTION

The FILE SECTION must contain a file description entry followed by one or more record description entries for each of the files used in a program. The file description entry must begin with the level indicator FD followed to by the file name. This file name must be identical with the file name specified in the select clause of the ENVIRONMENT DIVISION.

FD file –name LABEL RECORDS ARE STANDARD
RECORD IS OMITTED

FD CARD-FILE
01 CARD-RECORDS
02 SALESMAN-NO PIC 9(5)
02 FILLER PIC X (5)
03 QUANTITY PIC 9 (5)
02 FILLER PIC X (5)
02 UNIT-PRICE PIC 9 (8) v99.
02 AMOUNT PIC 9(8) v 99
02 FILLER PI X (40)

5.5 WORKING-STORAGE Section

The data in the working storage can be a group item containing all its subdivisions as in the case of record description. There may also be elementary data items which do not belong to a group. Such data items should be defined at a special level number 77 and must begin in area A.

EX:
WORKING-STORAGE SECTION.
77 A PIC X(20).
77 DATA-N PIC 9(2) VALUE ZERO.
01 DATE.
03 DAY PIC 99.
03 F PIC X VALUE “/”.
03 MONTH PIC 99.
03 FILLER PIC X VALUE “/”.
03 YEAR PIC 99.

5.6.EDITING

The data to be printed in a report requires some editing before it can be printed. For example: It is desirable to print a numeric data item but suppressing the leading zeros. If necessary, the sing and decimal point can also be inserted in numeric data.. Editing the normally performed by moving a numeric data item to a field containing special editing characters in its PICTURE Clause.



5.6.1 EDIT CHARACTERS FOR NUMERIC DATA

The following characters can be used in the PICTURE clause to indicate editing.

Z * $ - + CR DB . , B O /

Example:
The following examples illustrate the use of Z editing characters. The character is used to indicate a space character and the character is used to indicate the position of the decimal point.

• Z (Zero suppression) : The edit character Z has the same meaning as that of a 9 in the picture except that the leading zeros in the source data, if any, in the digit position indicated by Z will be suppressed.
• * (Asterisk) : The edit character * (asterisk) is identical to Z except that the leading zeros are replaced by asterisks instead of space characters.
• $ (currency Sign) : A single currency sign can appear at the leftmost position of a picture. In that case the $ is inserted.
• - (minus sign) : A minus sign can appear either at the leftmost or right most position of a picture. If the value is negative, a minus sign will be inserted in the said position. On the other hand, if the item is positive, a space character will be inserted.

Examples
Picture of the Field Numeric value moved to the Edited value
To the Field
ZZ999 04226 b4226
** 999 04678 * 4678
** 999 00052 **052
**999 1 ^ 68 **001
$99999 788 $00788
- 9999 - 454 - 0454

BLANK WHEN ZERO

BLANK WHEN ZERO is an editing clause, which may be used along with a picture. This will set the entire data item to blanks if its value is equal to zero. However, the edit character asterisk (*) may not be used if BLANK WHEN ZERO is specified. When this clause is used to describe a field whose picture contains an asterisk, the compiler ignores it. The syntax of this clause is follows.

BLANK WHEN ZERO
Examples
Picture of the Field Numeric value Moved Edited value
To the Field

ZZZ.99 BLANK WHEN ZERO 2^5 bb2.50
ZZZ.99 BLANK WHEN ZERO 0 bbbbbb
999.99 BLANK WHEN ZERO 0 bbbbbb

5.6.2 Editing of Alphabetic and Alphanumeric Data
Although editing is primarily required for numeric data, limited editing is also possible for alphabetic and alphanumeric data. An alphabetic data item may contain only the B edit character. An alphanumeric data item may contain only o, B and / edit characters.




5.6.4 SPECIAL-NAMES Paragraph
If a currency symbol other than $ required for editing , a one character symbol may be specified in the SPECIAL-NAMES paragraph. This character may not be a digit or letters A to D, L, P, R, S, V, X, Z or special characters blank * - , . ; ( ) + ‘ ‘ / = . the syntax is as follows:



SPECIAL-NAMES.

CURRENCY SIGN IS “character”
DECIMAL POINT IS COMMA.

5.7. CLASSES AND CATEGORIES OF DATA
In order that the class attribute of any data item in COBOL can be determined conclusively, all elementary data items are classified into the following five categories- alphabetic, numeric, numeric edited, alphanumeric and alphanumeric edited. The characters in the picture string determines the category of an elementary data item.
Category Symbols in PICTURE Character string

Alphabetic A B

Numeric 9 p s v

Numeric Edited 9 P V and at least one of the
Editing symbols
B / z O + - * , . CR DB $

Alphanumeric X 9 A
(Must contain at least one X
or a combination of 9 and A)

Alphanumeric Edited X 9 A B O /
(Must contain (i) at least one X
with at least one of B O / or
(ii) at least one A with at least one
O or / )

Procedure Division :- 


STRUCTURE OF THE PROCEDURE DIVISION
The Procedure Division Contains statements, which specify the operations to be performed by the computer. Each of these statements is formed with COBOL words and literals. A Statement always starts with a COBOL verb. The following are examples of COBOL statements.
ADD ALLOWANCE TO BASIC – PAY
IF TOTAL – PAY IS GREATER THAN 1000 GO TO PARA TAX- CALCULATION.

PROCEDURE DIVISION
{ Section- name SECTION.
[ Paragraph-name. [Sentence} …… ] … } …

The following format shows the simplified structure of the PROCEDURE DIVISION when it does not contain sections.
PROCEDURE DIVISION
[Paragraph- name. [Sentence] … ]…

A section can consist of zero, one or more paragraphs constituting its body. All section names must unique and must be different from paragraph names, data names and any other names. All paragraphs within a section must have unique names. In order to make a reference to a non unique paragraph name, it should be qualified as shown below.
Paragraph-name OF Section-name
IN

6.2. DATA MOVEMENT VERB: MOVE
It frequently becomes necessary to move data form one place in the memory to another place. This is done with the help of the MOVE verb. The COBOL statement MOVE A to B means that the value contained in the fieldname A should be transferred to the data field named B. Another example of a MOVE statement may be MOVE 3 to COUNT. In this case the value 3 itself is moved to the field named COUNT. The general form of the MOVE Verb is as follows:
MOVE identifier-1
Literal-1 TO identifier-2 [identifier–3]

6.3. ARITHMETIC VERBS
Most of the problems require some computations to be performed on the input or intermediate data, which are numeric in nature. Arithmetic verbs are used to perform these computations. All these verbs can contain either identifiers or numeric literals or both. In the case of identifiers, they must be elementary numeric fields, and identifiers used after GIVING option can be edited or inedited numeric fields. Some arithmetic verbs in their most elementary forms are discussed below.

6.3.1 ADD
This verb an be used to find the sum of two or mote numbers and to store the sum. The ADD verb takes any note of the following two forms

ADD identifier-1 identifier-2 ……. TO identifier-3 [, identifier-4].....
Literal-1 literal-2

ADD identifier-1 identifier-2 identifier-3 . [GIVING identifier-4 [, identifier-5]…].
Literal-1 literal-2 literal-3

Example
ADD A TO B.
ADD A, B giving C, D, E.




6.3.2 SUBTRACT
This verb is used to subtract one, or the sum of two or more numbers from one or more numbers and to store the result.
The form of the SUBTRACT verb is as follows:

SUBTRACT identifier-1 identifier-2
Numeric- numeric- … FROM identifier-3[ , identifier-4] …
literal-1 literal-2
[ , GIVING identifier-5 [ , identifier-6] …]

Example
a) SUBTRACT A FROM B.
This statement means that the value of A will be subtracted from the value of B and the subtracted result will be stored in B. The decimal point alignment will be done automatically.

6.3.3 MULTIPLY
This statement causes one or more multiplicands to be multiplied by a multiplier and to store the products. The form of the MULTIPLY verb is as follows.

MULTIPLY identifier-1 BY identifier-2 [ , identifier-3] …
numeric-literial-1

[ , GIVING identifier-4 [ , identifer-5] … ]

Example
MULTIPLY A by B.
In this case the value of A and B will be multiplied and the Product will be stored in B. The decimal point position will automatically be taken care of. The old value of B will be lost.




6.3.4 DIVIDE
The Purpose of this verb is to divide one number by another and to store the result. There are several forms of this verb,. One of its forms is as follows.

DIVIDE identifier-1 INTO identifier-2 { , identifier-3} …
numeric-literal-1

[ , GIVING identifier-4 [ , identifier-5] …. ].

Examples
a) DIVIDE 5 INTO A.
If the value of A is 20, then after the execution of this statement the value of A will be 4. The old value of A will be lost.

The Second form of this verb is as follows:

DIVIDE identifier-1 By identifier-2
numeric-literal-1 numeric-literal-2

[ GIVING identifier-3 [ , identifier-4] …]
Examples
DIVIDE A BY 3 GIVING C.

6.4. SEQUENCE CONTROL VERBS
Usually, the statements are executed sequentially one after another. This sequence can be altered with the help of a sequence control verb. There are several sequence control verbs in COBOL. In the present chapter we will discuss only two of these sequence control verbs.

6.4.1 GO TO
This verb is used to unconditionally transfer the control to elsewhere in the program. Its form is as follows
GO To Procedure-name

Example: GO TO ERROR- ROUTINE

6.4.2 STOP
This verb causes the termination of the execution of the object program, its form is STOP RUN

6.5 INPUT AND OUTPUT VERBS
Reading the data into the memory form some input medium (such as punched cards) and writing the results from the memory onto some output medium. (Such as continuous stationary) are of basic importance. The verbs OPEN, READ, WRITE and close are available for such input- Output operations.

6.5.1 OPEN
When a READ or a WRITE operation is performed in a file it must be open. The opening of a file may be done with the help of the OPEN Verb.

OPEN INPUT file name-1 [ , file-name-2] …..
OUT PUT file-name-3 [ , file-name-4] ….

Example-1
OPEN INPUT TRANSACTION, OLD-MASTER OUT PUT NEW-MASTER.

6.5.2 READ
The Purpose of this verb is to make available the next logical record from an input file. It is important to note the meaning of “ Next ” logical record in the above statement.

READ file –name RECORD [ INTO identifier-1 ]
AT END imperative- Statement
Example-1
READ OLD-MASTER AT END MOVE ZERO TO END – OF-RECORDS.



6.5.3 WRITE
The WRITE verb releases a record onto an output file. The syntax of the WRITE statement can be different depending on the output device and medium used.

WRITE record-name [ FROM-identifier-1]

BEFORE ADVANCING INTEGER-1 LINES
AFTER IDENTIFIER-2 LINES

MNEMONIC-NAME
HARDWARE-NAME

6.5.5 ACCEPT
The ACCEPT Statement is used to read low-volume data from the operator’s console, some other hardware device or from the operating system. The general format of the ACCEPT statement is as follows: -

ACCEPT identifier FROM mnemonic-name
DATE
DAY
TIME

Example: ACCEPT FLAG-A FROM CONTROL-DATA.

6.5.6 DISPLAY
The function of the DISPLAY statement is Opposite to that of the ACCEPT Statement. It is used to display low-volume results on the Operator’s Console or some other hardware device. The general format of the DISPLAY Statement is

DISPLAY identifier-1 , identifier-2 ….. [UPON mnemonic-name] literal-1 , literal-2


Example : DISPLAY “RESULT IS ”, THE-RESULT.

Cobol Introduction

Introduction to COBOL ?

COBOL Stands for Common Business Oriented Language. It was specifically developed to suit business applications in which large volumes of data are used. The COBOL language has its own set of rules, which must be strictly followed.

                    COBOL is non-mathematical in contrast to other programming language like FORTRAN and BASIC, which are based upon algebric, symbolic or algorithmic notations. One of COBOL’s important features is that it is largely self-documenting a programmer can understand most of a COBOL program simply be reading the program itself .

  • COBOL is a third-generation high-level language, procedure-oriented and machine-independent.
  • COBOL is a Business-Oriented language
  • COBOL is a standard language
  • COBOL is an English like language
  • COBOL is a user friendly language
  • COBOL was initially developed with an objective to provide for the handling of mass storage of data  and simple processing on magnetic tapes. 

History of COBOL:
            
  • In 1959 several large business organization government, computer manufactures, and other interested parties formed a committee to develop the language. The committee [ named CODASYL for Conference on Data Systems Languages] developed the specifications for a language called COBOL. 
  • COBOL was developed and is maintained by CODASYL, it has established it as a standard language by American National Standard Institute (ANSI).    
  • The suppliers of COBOL compilers generally base them on the American National standard COBOL an initial standard issued in 1968 was revised in 1974 and again in the mid 1980s.
  • The American national standard COBOL recognizes different levels of COBOL implementation and provides standards for each.              
 The COBOL language closely resembles the English Language. A COBOL program is written using an English-like syntax that looks and reads like ordinary Business English. However,  COBOL is a structured programming language and thus requires that a program be written in a specific format. Thus, a COBOL program is a lengthy one consisting of COBOL words, clauses, sentences and paragraphs.

Mainframe Commands

ISPF panel & Commands
Before Discuss About Mainframe Commands Lets Took a Look About  Ispf panel, Its a Good looking GUI Screen on which the user types the Input and sees the outputs. Thus, the GUI-Screens allow the the User to work with and use the Software-Tools interactively. GUI-Screens of an Application are called ISPF Panels. 

ISPF Panel is Looks like a web pages which have an Menu or Action Bar in The Top Portion.When U Click the on Or Select u Got More Options and Below the action bar panel title is present.
            The Body Of the Panel has the main Contents of the Panel and thats is input & output fileds.

Mainframe Commands :--

There are so many types of commands in mainframe but we r going to discuss some of them 
  • Primary Commands  
  • Line Commands
  • Block Commands                    
Primary Commands :--

The following commands can be used from the primary command field of the ISPF editor. This field is found either at the top left or bottom left of the screen depending on how you have your ISPF screens configured.

Place For Type Primary Commands

[ ] indicate optional parameters, [ | ] indicates a choice of one of the options listed (or none), { | } indicates you must specify one of the options. Where no optional parameter is specified the underlined value will be assumed.

  • AUTONUM [ON | OFF] :- Determine whether line numbers are maintained automatically.
  • AUTOSAVE [ON | OFF PROMPT | OFF NOPROMPT] :- Determine whether data is automatically saved when you leave the editor.
  • BOUNDS [left-column right-column] :- Controls left and right boundaries for edit commands.
  • CANCEL :- End the edit session without saving.
  • CHANGE :-  This command works exactly the same as the Find command except that there is an extra parameter that contains the value that is to be substituted for the found string.
  • COPY :- refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • CREATE :-  refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • CUT  :-  refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • DELETE [ALL] [range] [X | NX] :-  Delete the specified lines.
  • EDIT [membername] :- Invoke another edit session.
  • EXCLUDE :-  This command works exactly the same as the Find command except that the lines on which the searched for string is found are excluded from the displayed output.
  • FIND :- refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • HEX [ON DATA | ON VERT | OFF] :- Controls whether the hexadecimal values are displayed and if so how.
  • IMACRO {macro-name | NONE} :- Replaces the initial macro in the edit profile.
  • LOCATE {line-number | label} :- Locate the specified line.
  • LOCATE [NEXT | PREV | FIRST | LAST] [CHANGE | LABEL | EXCLUDED | ERROR | COMMAND | SPECIAL] [range]  :- Locate the specified type of line.
  • MOVE :- refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • NONUMBER :- Turn number mode off.
  • NOTES [ON | OFF] :- Determine whether or not notes are displayed.
  • NULLS [ON STD | ON ALL | OFF] :- Controls how trailing blanks are handled.
  • NUMBER [ON | OFF] [STD | COBOL | STD COBOL] :-  Determine how line numbers are stored.
  • PACK [ON | OFF] :- Determine whether data is stored in a compressed format.
  • PASTE :- refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • PROFILE [profile-name] :- Display the specified profile.
  • PROFILE [LOCK | UNLOCK] :- Determine whether or not profile changes will be saved.
  • RECOVERY [ON | OFF] :- Determines whether changes are saved in a recovery dataset
  • RENUM [ON | OFF] [STD | COBOL | STD COBOL] [DISPLAY] :- Resequence line numbers automatically.
  • REPLACE :- refer to Moving Lines of Data for full details of the parameters available with this command and how to use it.
  • RESET [LABEL] [COMMAND] [ERROR] [CHANGE] [SPECIAL] [EXCLUDED] [range] :- Resets the specified settings to their default.
  • SAVE :- Save the current member.
  • STATS [ON | OFF] :- Determine whether member statistics are maintained.
  • SUBMIT [range] :- Submit the content of the member for background processing.
  • TABS [ON | OFF] [STD | ALL] [tab-character] :- Control logical and hardware tabbing.
  • UNDO :- Undo the last change stored in the recovery dataset.
  • UNNUM :- Replace line numbers with blanks and turn number mode off.
Line Commands :-- 

This is a list of the various commands that can be entered into the field alongside the individual lines of the file that you are editing using the ISPF editor. The field usually contains either '******' or line numbers. These commands usually act on the data line that is alongside and may also affect adjacent lines if a number is typed alongside. With block commands the command needs to be entered on both the first and last lines to define a block of lines.


CommandFunction
<Data shift left
shifts a single line of program source code to the left without affecting the program labels or comment ie. data from column one to the first blank and data following several blanks are not moved. May be specified with a number identifying the distance to move (default 2).
<<Block data shift left
All of the lines in the block are affected as if you typed individual data shift left commands. May be specified with a number identifying the distance to move (default 2).
>Data shift right
As for data shift left but the opposite direction. May be specified with a number identifying the distance to move (default 2).
>>Block data shift right
(Column shift left
Works similarly to data shift left but moves everything within the bounds, nothing stays fixed in place. May be specified with a number identifying the distance to move (default 2).
((Block column shift left
)Column shift right
))Block column shift right
aAfter
used with copy, move, or paste to specify the line after which the copied/moved lines are to be inserted.
bBefore
used with copy, move, or paste to specify the line before which the copied/moved lines are to be inserted.
bndsDisplay bounds above this line
Displays the current boundary positions which can be changed by tying < and > in the new boundary positions that you require.
cCopy
Copies this line either to another place within the current file (using a, b, or o to identify destination) or to another file (using the create, replace, or cut commands). Can be specified with a number to indicate that multiple lines are to be copied.
ccBlock copy
colsDisplay the column ruler above this line
dDelete
Deletes this line from the file. Can be specified with a number to indicate that following lines are also to be deleted.
ddBlock delete
fDisplay the first excluded line
Can be specified with a number to display more than one excluded lines. This command is only valid on excluded lines.
iInsert a new line after this one
Can be specified with a number to insert multiple lines.
lDisplay the last excluded line
Can be specified with a number to display more than one excluded lines. This command is only valid on excluded lines.
lcConvert all text on this line to lower case
Can be specified with a number to convert more than one line to lower case.
lccBlock convert to lower case
mMove
Works the same as copy except that the lines are removed from their current location.
mmBlock move
maskDisplay the mask line above this one
The mask defines the default content for inserted lines.
oOverlay (used with copy and move to specify the line into which the copied/moved line is to be inserted - only spaces are replaced). Can be specified with a number to indicate that following lines are also to be overlaid.
ooBlock overlay (the lines to be copied/moved are inserted into the block as many times as they will fit)
rRepeat - create a duplicate of this line
Can be specified with a number to indicate that additional duplicate lines are to be produced.
rrBlock repeat
Can be specified with a number to indicate that multiple duplicates of the block are to be produced.
sShow the excluded line that has the least indentation
Can be specified with a number to display more than one excluded lines. When multiple lines are displayed they may not be together. This command is only valid on excluded lines.
tabsShow the tab settings above this line
Hardware tabs positions are indicated by asterisks (*) and software tabs by hyphens (-) or underscores (_).
teText Entry mode - allows bulk insert following this line
You can start entering data without paying any attention to lines as the text will wrap automatically. Press the enter key to exit from text entry mode.
tfText flow - flows the text between the margins for this line and following lines until a blank line is found, the indentation changes, or a special character (period, colon, ampersand, less than, or form feed) is found in the first column.
tjText Join - merges this line with the following one
tsText split - splits this line in two
You need to position the cursor at the position on the line where you want the split to occur.
ucConvert all text on this line to upper case
Can be specified with a number to convert multiple lines.
uccBlock convert to upper case
xExclude this line from the display
Can be specified with a number to exclude multiple lines. This command is useful when you need to view two blocks of data that are in different locations within the file, just exclude the intervening data from the display.
xxBlock exclude
.label assignment
You can assign a label to any non-excluded line by typing a period followed by the label name. The label can then be used to identify the line in primary commands. You cannot start labels with "z" as these labels are reserved for system use.

    Full Forms Of Frequently Used Words On Mainframe

    Mainframe Architecture



    • MVS                  :-  Multiple Virtual System
    • JCL                   :-  Job Control Language
    • CICS                 :- Customer Information Control System
    • ISPF                  :- Interactive System Productivity Facility
    • PDF                   :- Program Development Facility
    • APPLID             :- Application  Identifier
    • TSO/E                :- Time Sharing Option Extended
    • IMS                    :- Information Management System
    • MVS/XA            :- Extended Architecture
    • MVS/ESA          :- Enterprise System Architecture
    • PDS                    :- Portioned Data Set
    • PSDS                  :- Physical Sequential Data Set
    • DASD                 :- Direct Access Storage Device
    • DSORG              :- Data set Organization 
    • PS                       :- Physical Sequential 
    • RECFM              :- Record Format
    • F                         :- Fixed
    • V                         :- Variable
    • FB                       :- Fixed Blocked
    • U                         :- Undefined
    • FBS                     :- Fixed Blocked Size
    • VBS                    :- Variable Block Size
    • LRECL               :- Logical Record length
    • DCB                   :- Data Control Block
    • DISP                  :- Disposition
    • DSN                   :- Data Set Name
    • IDCAMS           :- Integrated Data Cluster Access Method Service
    • IDC                   :- Integrated Data Cluster  
    • AMS                  :- Access Method Service
    • ESDS                 :- Entry Sequenced Data Set
    • KSDS                :-  Key Sequenced Data Set 
    • RRDS                :- Relative Record Data Set
    • DDNAME         :- Data Definition name   
    • ICF                    :- Integrated Cat-lg Facility
    • CISZ                  :- Control Interval Size
    • VSAM               :- Virtual Storage  Access Method
    • Cobol                 :- Common Business Oriented Language
    • Rrn                     :- Relative Record Number

    Share

    Twitter Delicious Facebook Digg Stumbleupon Favorites More