Chapter 2

336 views

Published on

This chapter deals with the various divisions and editing characters

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
336
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Brackets [ ] mean item is optional, braces { } mean one of enclosed items required Ellipses (. . .) mean entry may be repeated
  • The ENVIRONMENT DIVISION consists of two separate sections - CONFIGURATION SECTION The CONFIGURATION SECTION consists of two paragraphs namely SOURCE-COMPUTER paragraph and OBJECT-COMPUTER paragraph. The SOURCE-COMPUTER paragraph specifies the computer on which the source program is to be compiled and the OBJECT-COMPUTER paragraph specifies the computer for which the object program is designated. INPUT-OUTPUT SECTION The INPUT-OUTPUT SECTION consists of two paragraphs namely FILE CONTROL paragraph and I-O CONTROL paragraph. In the FILE CONTROL paragraph a file name is selected for each file to be used in the program and assigned to a device.
  • DATA DIVISION The DATA DIVISION is used to declare the data items that will be processed in the PROCEDURE DIVISION of the source program. Though there are seven different SECTIONs in DATA DIVISION, which appear in the order – FILE SECTION The FILE SECTION is used to declare the FD (File descriptor) and SD (Sort descriptor) entries for files and sort files used in the program. WORKING-STORAGE SECTION The WORKING-STORAGE SECTION is used to declare all the temporary variables and record structures used in the program. LOCAL STORAGE SECTION The LOCAL-STORAGE SECTION defines storage that is allocated and freed on a per-invocation basis. On each invocation, data items defined in the Local-Storage Section are reallocated and initialized to the value assigned in their VALUE clauses. LINKAGE SECTION The LINKAGE SECTION is used to describe data items made available from another program. It is important to note that storage is not allocated to the data structures defined in the LINKAGE SECTION as the data exists elsewhere. COMMUNICATION SECTION The COMMUNICATION SECTION is used to create a control block required for communication, which is release dependent. REPORT SECTION The REPORT SECTION is used to describe RD (Report Descriptor) entries, which will be required for Report Writer Module. SCREEN SECTION The SCREEN SECTION is used to describe labels and data items, which will be required for formatted input/output in case of application programs developed for Personal computers. Of these the sections which are most commonly used are – WORKING-STORAGE SECTION FILE SECTION
  • PROCEDURE DIVISION The PROCEDURE DIVISION consists of the following – a) Sections b) Paragraphs c) Sentences d) Statements
  • PROCEDURE DIVISION The PROCEDURE DIVISION is the most significant DIVISION of a COBOL program. It includes statements and sentences necessary for reading input, processing it and writing the output.
  • Description of DATA NAMES a) All the data names used in the PROCEDURE DIVISION must be described in the DATA DIVISION. b) The description of a data name is done with the aid of the following – (1) Level number (2) PICTURE clause (3) VALUE clause
  • LEVEL NUMBER Level numbers specify the hierarchy of data within a record and identify special-purpose data entries. A level number begins a data description entry and 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. The following are the significance of the various level numbers that can be used with data items. a) 01 - For record descriptions. b) 02 to 49 - For fields within records. c) 01 / 77 - For independent items (use 01, as 77 will be removed in future releases) d) 66 - For RENAMES clause. e) 88 - For condition names.
  • PICTURE clause The following are the general picture characters and their meaning. a) A for alphabetic b) X for alphanumeric c) 9 for numeric d) S for sign e) V for implied decimal point.
  • Group and Elementary items In COBOL the term “group item” is used to describe a data item which has been further subdivided. Some properties of a Group item are – a) A Group item is declared using a level number and a data name. b) It cannot have a picture clause. c) Where a group item is the highest item in a data hierarchy it is referred to as a record and uses the level number 01.
  • LEVEL Numbers & DATA hierarchy In COBOL, Level numbers are used to express data hierarchy. The higher the level number, the lower the item is in the hierarchy. So Group items contain sets of elementary items with lower level numbers. At the lowest level the data is completely atomic (i.e. at the lowest level we would always have an elementary item).
  • Edited picture symbols There are two general methods of editing in a PICTURE clause. Insertion - There are four types of Insertion editing namely 1) Simple insertion 2) Special insertion 3) Fixed insertion 4) Floating insertion Suppression and Replacement - This is of two kinds 1) Zero suppression and replacement with asterisk 2) Zero suppression and replacement with spaces
  • BASIC DATA TYPES There are five basic data types in COBOL. They are a) Alphabetic - (Made up of only upper and lower case letters) b) Numeric - (Made up of the digits 0, 1, 2, . . . ,9) c) Alphanumeric - (Made of both letters and digits), d) Edited Numeric - (Made up of digits and special characters) e) Edited Alphanumeric - (Made up of letters, digits and special characters)
  • Chapter 2

    1. 1. COBOLCOMMON BUSINESS ORIENTED LANGUAGE
    2. 2. Contents Divisions—General Formats. Level structure. Data Description Entries.—PITURE andVALUE Clause. Editing Characters. Special–names Paragraph, Classes andcategories of Data.
    3. 3. IDENTIFICATION DIVISION Provides identifying information about program. Divided into paragraphs. PROGRAM-ID is only required paragraph . The entry inthe PROGRAM-ID paragraph contains the program nameto be used to identify the object program. Other paragraphs are optional. Used mainly for documentation purpose. The division heading and paragraph names should becoded as area A entries.
    4. 4. IDENTIFICATION DIVISIONFormatIDENTIFICATION DIVISION.PROGRAM-ID. entry.[AUTHOR. entry.][INSTALLATION. entry.][DATE-WRITTEN. entry.][DATE-COMPILED. entry.][SECURITY. entry.]
    5. 5. IDENTIFICATION DIVISION.PROGRAM-ID. PROG1.AUTHOR. R.R. BHATT.INSTALLATION. ABC CORP.DATE-WRITTEN. 01-JAN-2005.DATE-COMPILED. 01-JAN-2005.SECURITY. HIGH.IDENTIFICATION DIVISION.PROGRAM-ID. PROG1.AUTHOR. R.R. BHATT.INSTALLATION. ABC CORP.DATE-WRITTEN. 01-JAN-2005.DATE-COMPILED. 01-JAN-2005.SECURITY. HIGH.OPTIONALCompiler takes this asProgram Identifier.PROGRAM-ID comesimmediately after IDDivision.IDENTIFICATION DIVISION …
    6. 6. ENVIRONMENT DIVISION The computer and all peripheral devices required by theprogram are described in this division. This division is machine-dependent since devices differ fromcomputer to computer. It consists of 2 sections. ENVIRONMENT DIVISION.CONFIGURATION SECTION.SOURCE-COMPUTER. entry.OBJECT-COMPUTER. entry.[SPECIAL NAMES. Entry].[INPUT-OUTPUT SECTION.FILE-CONTROL. {entry}.[I-O-CONTROL. entry].]
    7. 7. ENVIRONMENT DIVISIONCONFIGURATION SECTION INPUT-OUTPUT SECTIONIdentifies thecomputer used forcompiling of programsIdentifies theresources used forexecuting the programENVIRONMENT DIVISION
    8. 8. 1.CONFIGURATION SECTIONThis section contains an overall specification of the computer usedfor the purpose of compilation and execution of the program. The SOURCE-COMPUTER paragraph specifies the name of thecomputer used to compile the COBOL program. The OBJECT-COMPUTER paragraph describes the computeron which the program is to be executed. It consist of MEMORYSIZE, SEGMENT LIMIT etc. The SPECIAL_NAMES is used to relate some hardware namesto user-specified mnemonic names. This is optional in allcomputers.SOURCE-COMPUTER. ICL-1901.OBJECT-COMPUTER. ICL-1900.
    9. 9. 2.INPUT-OUTPUT SECTION INPUT-OUTPUT SECTIONThis section contains information regarding files to be usedin the program. The INPUT-OUTPUT SECTION consists of two paragraphsnamely FILE CONTROL paragraph and I-O CONTROLparagraph. In the FILE CONTROL paragraph a file name is selectedfor each file to be used in the program and assigned to adevice. The simplified format of a file control entry is givenbelow:SELECT file-name ASSIGN TO hardware-name.This section as a whole is optional in many computers.
    10. 10.  The DATA DIVISION is used to describe the data structuresused in the program. There are sections in the DATA DIVISION1. FILE SECTION2. WORKING-STORAGE SECTION3. LOCAL STORAGE SECTION4. LINKAGE SECTION5. COMMUNICATION SECTION6. REPORT SECTION7. SCREEN SECTIONDATA DIVISION
    11. 11. The two most commonly used components (sections) area) WORKING-STORAGE SECTIONInternal data structures are defined here.b) FILE SECTIONFile I/O buffer areas are defined here. General FormatDATA DIVISION.[ FILE SECTION.file section entries. ………….. ][ WORKING-STORAGE SECTION.working-storage entries. ……….. ]
    12. 12. DATA DIVISION The DATA DIVISION is used to declare the data itemsthat will be processed in the PROCEDURE DIVISIONof the source program. Though there are sevendifferent SECTIONs in DATA DIVISION, which appearin the order :1) FILE SECTIONThe FILE SECTION is used to declare the FD (Filedescriptor) and SD (Sort descriptor) entries for files andsort files used in the program.1) WORKING-STORAGE SECTIONThe WORKING-STORAGE SECTION is used to declareall the temporary variables and record structures used inthe program.
    13. 13. 3) LOCAL STORAGE SECTION1) The LOCAL-STORAGE SECTION defines storage thatis allocated and freed on a per requirement basis.2) On each requirement, data items defined in the Local-Storage Section are reallocated and initialized to thevalue assigned in their VALUE clauses.4) LINKAGE SECTION1) The LINKAGE SECTION is used to describe dataitems made available from another program.2) Storage is not allocated to the data structuresdefined in the LINKAGE SECTION as the data existselsewhere.
    14. 14. 5) COMMUNICATION SECTION1) The COMMUNICATION SECTION is used to createa control block required for communication, which isrelease dependent.6) REPORT SECTION1) The REPORT SECTION is used to describe RD(Report Descriptor) entries, which will be required forReport Writer Module.
    15. 15. 7) SCREEN SECTION1) The SCREEN SECTION is used to describe labelsand data items, which will be required for formattedinput/output in case of application programs developedfor Personal computers.Of these the sections which are most commonly used are –a) WORKING-STORAGE SECTIONb) FILE SECTION
    16. 16. The PROCEDURE DIVISION consists of the following1. Sections2. Paragraphs3. Sentences4. StatementsGeneral FormatPROCEDURE DIVISION.[ section-name SECTION.[paragraph-name. [sentence] …. ] …. ]PROCEDURE DIVISION
    17. 17. PROCEDURE DIVISIONPROCEDURE DIVISION.0001-ACCOUNT SECTION.001-ACCOUNT-READ-PARA.READ ACC-FILE AT ENDMOVE ‘Y’ TO EOF.MOVE TAX-REDUCT TO TAX-AMOUNT001-ACCOUNT-VALIDATE-PARA.ADD AMOUNT TO TOT-AMOUNT.IF AMOUNT IS GREATER THAN 1000GO-TO ACCOUNT-READ-PARA.ACCEPT EMPLOYEE-SALARY.DISPLAY “Current Employee Salary “EMPLOYEE-SALARY.001-EXIT-PARA.STOP RUN.SectionParagraphSentencesstatementSection contain one ormore Paragraphs.A PARAGRAPHcomprises of one ormore sentencesA SENTENCE is acombination of one ormore statements and isterminated by a full stop.A STATEMENT is acombination of aCOBOL verb and one ormore operands.
    18. 18. IDENTIFICATION DIVISION.PROGRAM-ID. FIRSTPG.PROCEDURE DIVISION.MAIN-PARA.DISPLAY ‘-------------------------------’.DISPLAY ‘ WELCOME TO COBOL’.DISPLAY ‘--------------------------------’.STOP RUN.IDENTIFICATION DIVISION.PROGRAM-ID. FIRSTPG.PROCEDURE DIVISION.MAIN-PARA.DISPLAY ‘-------------------------------’.DISPLAY ‘ WELCOME TO COBOL’.DISPLAY ‘--------------------------------’.STOP RUN.First COBOL program
    19. 19. DATA Description Entries A data description entry describes a data item. A component in this context is a level number, a dataname or a clause. Except for the level number, no other component canappear in area A. There must be at least one space between any twoconsecutive components of an entry.
    20. 20.  All the data names used in the PROCEDURE DIVISION mustbe described in the DATA DIVISION. The description of a data name is done with the aid of thefollowing –(1) Level number(2) PICTURE clause(3) VALUE clauseDescription of data namesDATA DIVISION.01 EMP-NO PIC X(10) VALUE 1001.LEVEL NO Data Name Picture Clause VALUE Clause
    21. 21.  It is a two-digit number starting from 01. Is used tospecify the data hierarchy.Level numberLevel Number Purpose01 Record description and independent items02 to 49 Fields within records and sub items66 RENAMES clause77 Independent items88 Condition namesDATA NAME  LEVEL NO
    22. 22. Picture Clause The PICTURE Clause describes the general characteristics ofan elementary data item. The characteristics are1. CLASS—A data item may be one of the 3 classes.NUMERIC---Digits 0 to 9.ALPHABETIC---A to Z & Space (Blank) Character.ALPHANUMERIC---Digits, Letters, Special Characters.2. SIGN---A numeric data item can be signed or unsigned.Implicitly, unsigned, ie Positive.Sign can be specified in the PICTURE clause to describe asigned data item.
    23. 23. Picture Clause3.POINT LOCATION---The position of the decimal point isanother characteristic that can be specified in the case ofnumeric data items.4.SIZE---Which specify the number of characters or digitsrequired to store the data item in the memory.General format for PICTURE clausePICTURE [PIC] IS character-string. The PICTURE clause is only to be specified for elementaryitems. It can’t be used for a group item. The size of a group item is equal to the total of the sizes of allsubordinate elementary items. The class of a group item is alphanumeric.
    24. 24. Code Characters Meaning9 NumericA AlphabeticX AlphanumericS (Signed) Sign bitV position of Assumed Decimal pointP position of Assumed Decimal pointwhen the point lies outside the data itemPicture Clause
    25. 25. Rules1. In Alphabetic item the picture may contain only A.2. In Numeric item the picture may contain only9,V,P,S.These are called operational characters. Itmust contain at least one 9 and V & S can appear onlyonce.S, if it is included, must be the leftmost character ofthe picture string.The Symbol P can be repeated as many times asis required to indicate the position of the assumeddecimal point.3. In Alphanumeric item, the picture may contain all Xs ora combination of 9, A and X (except all 9 or all A).
    26. 26. Example1.PIC IS S999V99Means data is signed numeric with size 5 characters. The positionof decimal point is before 2 places from the rightmost end.2. PIC IS PPP999Means data is of 3 characters in size & 6 positions after theassumed decimal point.Data is 234, the value will be taken as .000234.3. PIC IS 999PPData is 234, the value will be taken as 23400.
    27. 27. COBOL ‘PICTURE’ Clauses Some examples PICTURE 999 a three digit (+ive only) integer PICTURE S999 a three digit (+ive/-ive) integer PICTURE XXXX a four character text item or string PICTURE 99V99 a +ive ‘real’ in the range 0 to 99.99 PICTURE S9V9 a +ive/-ive ‘real’ in the range ? If you wish you can use the abbreviation PIC. Numeric values can have a maximum of 18 (eighteen) digits(i.e. 9’s). The limit on string values is usually system-dependent.
    28. 28. Abbreviating recurring symbols Instead of repeating 9, X, A or P in the picture string, it ispossible to write the number of occurrences of a characterenclosed within parentheses immediately after the saidcharacter. Recurring symbols can be specified using a ‘repeat’ factorinside round brackets PIC A(6) is equivalent to PICTURE AAAAAA. PIC 9(6)V99 is equivalent to PIC 999999V99 PICTURE X(10) is equivalent to PIC XXXXXXXXXX PIC S9(4)V9(4) is equivalent to PIC S9999V9999 PIC 9(18) is equivalent to PIC 999999999999999999
    29. 29. Declaring DATA in COBOL In COBOL a variable declaration consists of a line containing thefollowing items;ŒA level number.A data-name or identifier.ŽA PICTURE clause.DATA DIVISION.WORKING-STORAGE SECTION.01 Num1 PIC 999 VALUE ZEROS.01 VatRate PIC V99 VALUE .18.01 StudentName PIC X(10) VALUE SPACES.Num1 VatRate StudentNameNum1 VatRate StudentName000000.18.18DDATAATA
    30. 30. VALUE clause Is used to assign an initial value to a elementary data item.Syntax: VALUE IS literal. The initial value can be numeric literal, non- numeric literalor figurative constant. We can give a starting value to variables by means of anextension to the picture clause called the value clause. It is an optional clause. Examples: 1)VALUE IS 23.5.2)VALUE IS “ Apples”. Or VALUE IS “My Data”.3) VALUE ZERO.
    31. 31. VALUE clause If a VALUE clause is used at a group level , it should not beused for any item within the group. Only nonnumeric literalsand figurative constants can be used to specify the value of agroup item.Example—1) 03 num1 PIC S9(3)V99 VALUE -2.34.Here data item is level 3 elementary item belonging to a group.2) 01 num2 VALUE IS “234567”.02 data-1 PIC 9(2). ----- 2302 data-2 PIC 9(3). ----- 456 Values Stored02 data-3 PIC 9(1). ----- 7
    32. 32.  In COBOL the term “group item” isused to describe a data item which hasbeen further subdivided. A Group item is declared using alevel number and a data name.It cannot have a picture clause. Where a group item is thehighest item in a data hierarchy itis referred to as a record anduses the level number 01. Picture clauses are NOTspecified for ‘group’ data itemsbecause the size of a group itemis the sum of the sizes of itssubordinate, elementary itemsand its type is always assumedto be PIC X.Group and elementary itemsWORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).
    33. 33. WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(20).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(20).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).Group itemSub-ItemsGroup Items/Records - Example
    34. 34. 123456789012345678901234567890 (cols)1234JyothiS E&R Bangalore2234Archana E&R Marathi9999Bhushan E&R C++Data in input fileWORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).1234JyothiS E&R Bangalore1234JyothiS E&R BangaloreVariable for file read ValueGroup Items/Records - Example
    35. 35. WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).WORKING-STORAGE SECTION.01 EMPLOYEE-DETAILS PIC X(30).01 EMPLOYEE-DETAILS.05 EMP-NUM PIC 9(4).05 EMP-NAME PIC X(10).05 EMP-DEPT PIC X(4).05 EMP-LOC PIC X(12).1234JyothiS E&R Bangalore1234JyothiSE&RBangalore1234JyothiS E&R Bangalore1234JyothiSE&RBangaloreVariable for file read Value123456789012345678901234567890 (cols)1234JyothiS E&R Bangalore2234Archana E&R Mysore9999Bhushan E&R ChennaiData in input fileGroup Items/Records - Example
    36. 36.  In COBOL, Level numbersare used to express datahierarchy. The higher thelevel number, the lowerthe item is in thehierarchy. So Group items containsets of elementary itemswith lower level numbers.At the lowest level thedata is completely atomic.LEVEL Numbers & DATA hierarchyWORKING-STORAGE SECTION.01 POLICY-DETAILS.05 POLICY-NO.10 POLICY-TYP PIC X(4).10 POLICY-LOC PIC X(2).10 POLICY-ID PIC X(5).05 POLICY-TYPE PIC X(10).05 POLICY-EXPDT PIC X(10).WORKING-STORAGE SECTION.01 POLICY-DETAILS.05 POLICY-NO.10 POLICY-TYP PIC X(4).10 POLICY-LOC PIC X(2).10 POLICY-ID PIC X(5).05 POLICY-TYPE PIC X(10).05 POLICY-EXPDT PIC X(10).
    37. 37. DATA DIVISION.WORKING-STORAGE SECTION.01 REGNO PIC X(5).01 NAME.05 FIRST-NAME PIC A(15).05 MID-NAME PIC A(15).05 LAST-NAME PIC A(10).01 AGE PIC 99V99.01 SCHOLARSHIP PIC 9(4) VALUE 1000.DATA DIVISION.WORKING-STORAGE SECTION.01 REGNO PIC X(5).01 NAME.05 FIRST-NAME PIC A(15).05 MID-NAME PIC A(15).05 LAST-NAME PIC A(10).01 AGE PIC 99V99.01 SCHOLARSHIP PIC 9(4) VALUE 1000.Description of data names
    38. 38. H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 FGroupItems/RecordsStudentDetailsWORKING-STORAGE SECTION.01 StudentDetails PIC X(26).WORKING-STORAGE SECTION.01 StudentDetails PIC X(26).
    39. 39. H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 FStudentDetailsStudentName StudentId CourseCode Grant GenderGroupItems/RecordsWORKING-STORAGE SECTION.01 StudentDetails.0202 StudentNameStudentName PIC X(10).PIC X(10).0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.WORKING-STORAGE SECTION.01 StudentDetails.0202 StudentNameStudentName PIC X(10).PIC X(10).0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.
    40. 40. H E N N E S S Y R M 9 2 3 0 1 6 5 L M 5 1 0 5 5 0 FStudentDetailsSurname InitialsWORKING-STORAGE SECTION.01 StudentDetails.0202 StudentName.StudentName.03 Surname03 Surname PIC X(8).PIC X(8).03 Initials03 Initials PIC XX.PIC XX.0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.WORKING-STORAGE SECTION.01 StudentDetails.0202 StudentName.StudentName.03 Surname03 Surname PIC X(8).PIC X(8).03 Initials03 Initials PIC XX.PIC XX.0202 StudentIdStudentId PIC 9(7).PIC 9(7).0202 CourseCodeCourseCode PIC X(4).PIC X(4).0202 GrantGrant PIC 9(4).PIC 9(4).0202 GenderGender PIC X.PIC X.StudentName StudentId CourseCode Grant GenderGroupItems/Records
    41. 41. FILE SECTION This contain a file description entry followed by one or morerecord description entries for each of the files used in aprogram. Format for file description entry isFD file-name LABEL RECORDS ARE STANDARDRECORD IS OMITTED The label indicator FD must begin in Area A and rest of the filedescription entry must appear only in Area B. The file-name must be identical with the file name specified inthe select clause of the ENVIRONMENT section. STANDARD option should be specified for disk files, OMITTEDoption should be specified for card reader and printer files. LABEL RECORD clause---it is mandatory in ANSI 74. Manycompilers treat it as optional.
    42. 42. FILE SECTION The coding rule for an FD entry is similar to that of level 01entry. The description entries that follow the file description entry,should describe the record types in the file. There should be onerecord description entry for each type of record. A record description entry is a 01 level group item along with allits subdivisions. ExampleFD card-file.01 card-records.02 num pic 9(3).02 price pic 9(2)v9(2)02 amount pic 9(2)v9(2)
    43. 43. WORKING-STORAGE SECTION The data in the working storage can be group item, containingall its subdivisions same as record description. There may also be elementary data item which do not belong toa group. Such data items should be defined at a special levelnumber 77. Level number 77 must begin in Area A. Elementary item in this section need not always be defined atthe level 77. It can as well be defined at the level 01.Example---- WORKING-STIRAGE SECTION.77 num PIC X(7).01 date.05 day pic 99.05 month pic 99.05 year pic 9999.01 address pic x(10).
    44. 44. EDITING PICTURECLAUSE
    45. 45. EDITING The data to be printed in a report requires some editing. Example—To print a numeric data item ,by suppressing theleading zeros. Editing is normally performed by moving a numeric data itemto a field containing special editing characters in its pictureclause. Following characters can be used in the PICTURE clause toindicate editingZ * $ - + CR DB . , B 0 /
    46. 46. Edit symbol MeaningZ Zero suppression* Check protection, Comma insertion- Minus sign insertion+ Plus or minus sign insertionEdited picture symbols
    47. 47. Edited picture symbolsEdit symbol Meaning$ Dollar sign insertionCR Credit symbolDB Debit symbolB Blank insertion/ Slash insertion. Decimal point insertionBLANK WHENZEROBlank insertion when the value iszero
    48. 48. Z-Zero suppression The Z has the same meaning as that of 9 in the picture exceptthat the leading zeros in the source data. If any, in the digit positions indicated by Z will be suppressed—Replaced by space characters. It is obvious that Z cannot appear to the right of any 9. After the decimal point either the digit positions are indicated byall Z or none at all. In the below examplesThe character b ---is used to indicate a space character.The character ^ ---is used to indicate the position of the decimalpoint.
    49. 49. ZZ999 01234 b1234ZZ999 00034 bb034ZZ999 1^23 bb001ZZZV99 12^3 b1230ZZZV99 0^12 bbb12ZZZZVZZ 0^01 bbbb01ZZZZVZZ 0 bbbbbbEdit symbol Value Edited valueZ (Zero Suppression)---Example
    50. 50. *(Asterisk) Example This is same as Z except that the leading zeros are replacedby * instead of space.Edit symbol Value Edited value**999 01234 *1234**999 00012 **012**999 1^23 **001
    51. 51. $(Currency Sign) Example A single currency sign can appear at the leftmost position of apicture. In that case the $ character is inserted.Edit symbol Value Edited value$99999 123 $00123$99999 12345 $12345$ZZ999 123 $bb123$ZZ999 12345 $12345$**999 123 $**123
    52. 52. -(Minus Sign) Example It can appear at leftmost or rightmost position of the picture. If thevalue of an item is –ve, a - sign will be inserted, If value is +ve, aspace character will be inserted.Edit symbol Value Edited value-9999 -123 -0123-9999 123 b01239999- -123 0123-9999- 123 0123b-ZZZV99 -12^34 -b1234-ZZZV99 12^34 bb1234
    53. 53. +(Plus Sign) Example It is same as minus sign except that when the item is +ve, + signwill be inserted. If value is –ve, - sign will be inserted,.Edit symbol Value Edited value+9999 -123 -0123+9999 123 +01239999+ -123 0123-9999+ 123 0123++ZZZV99 -12^34 -b1234+ZZZV99 12^34 +b1234
    54. 54. CR and DB (Credit and Debit Sign)Example CR or DB symbol appear only at the rightmost position of thepicture. These symbols appear in the rightmost position only if theitem is negative, otherwise they will be replaced by 2 spaces.Edit symbol Value Edited value9999CR -1234 1234CR9999CR 1234 1234bbZZZCR -12 b12CRZZZ9V99DB -123^45 b12345DBZZZ9V99DB 123^45 b12345bb
    55. 55. Period or Decimal Point-Example It is used to insert a decimal point and may not appear more thanonce. Both period & V cannot appear in the same picture. A period must not also appear as the rightmost character in thepicture. If all the digits before and after the period happen to be zeros, theperiod does not stop zero suppression and the entire fieldincluding the period is space-filled (the period is not filled withspace when an asterisk(*) is used as a zero-suppressioncharacter.
    56. 56. Period or Decimal Point-ExampleEdit symbol Value Edited value9999.99 123^45 0123.45ZZ99.99 12^34 bb12.34ZZ99.99 123 b123.00ZZZZ.ZZ 0^01 bbbb.01ZZZZ.ZZ 0 bbbbbbb****.** 0 ****.**$ZZZ9.99 0123 $b123.00
    57. 57. , (Comma)-- Example It is treated as an insertion character and inserted wherever itappears. If zero suppression takes place to the right of any comma, thesaid comma will also be suppressed and a space character willtake its position . It cannot appear either as the rightmost or leftmost character in apicture. There can be more than one comma in a picture.
    58. 58. , (Comma)-- ExampleEdit symbol Value Edited value99,999 1234 01,23499,999 12 00,012ZZ,Z99 1234 b1,234**,*** 12 ****12*,***,** 123 ****1,23*,***,** 123456 1,234,56ZZ,Z9.99 123^45 b1,23.45
    59. 59. B (Blank Insertion)-- Example The appearance of a B anywhere in the picture will insert a spacecharacter in the edited data. There can be more than one B in apicture.Edit symbol Value Edited value99B99B99 123456 12b34b5699B99B99 12 00b00b12
    60. 60. Z (Zero Insertion)-- Example It is same as B except that 0 will be inserted instead of a spacecharacter.Edit symbol Value Edited value9900 12 120009990 123 01230
    61. 61. / (Slash Insertion)-- Example It may appear anywhere in the picture. If used, it will be inserted. Itis also called as stroke.Edit symbol Value Edited value99/99/99 123456 12/34/56999/999/99 1234 000/012/34
    62. 62. BLANK WHEN ZERO-- Example BLANK WHEN ZERO is an editing clause which may be used alongwith a picture. This will set the entire data item to blanks if its value is equal to 0.Edit symbol Value Edited valueZZZ.99 BLANK WHEN ZERO 1^2 bb1.20ZZZ.99 BLANK WHEN ZERO 0 bbbbbb999.99 BLANK WHEN ZERO 0 bbbbbb
    63. 63. SPECIAL-NAMES Paragraph If a currency symbol other than $ is required for editing, a onecharacter symbol may be specified in the SPECIAL-NAMESparagraph of the ENVIRONMENT DIVISION. This character may not be a digit or letters A to D, L, P, R, S,V, X, Z or special characters blank * - , . ; ( ) + ‘ ‘ / =. SyntaxSPECIAL-NAMES.CURRENCY SIGN IS “ character”.Specifies a substitute character for the currency signDECIMAL-POINT IS COMMA.
    64. 64. CLASSES AND CATEGORIES OFDATA All elementary data items are classified into the following 5categories.1.Alphabetic ( A)2.Numeric( 9)3.Alphanumeric (X)4.Edited numeric ( Z, $)5.Edited alphanumeric(/,-) The characters in the picture string determines the categoryof an elementary data item.
    65. 65. Categories and the corresponding symbolsused in the PICTURE character string1.Alphabetic A2.Numeric 9 P S V3.Edited Numeric 9 P V and at least one of theediting symbols B / Z 0 + - * , . CR DB4.Alphanumeric X 9 A (at least one X or acombination of 9 and A)5.Edited Alphanumeric X 9 A B 0 / ( must contain at leastone X with at least one of B 0 / or at least one A with at least one 0or /)
    66. 66. CLASS & CATEGORY These five categories of data are grouped into 3 classes. Theclass of a data item indicates how the data is treated duringexecution.Level of Data Item Class categoryElementary Alphabetic AlphabeticNumeric NumericAlphanumeric Numeric editedAlphanumericAlphanumeric EditedGroup Alphanumeric Elementary datawithin the group may
    67. 67. Questions ?

    ×