ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Writing Variable File In Cobol
    카테고리 없음 2020. 2. 29. 20:08
    1. Comp Variables In Cobol

    In addition to reading filesprograms often write records to a file.For our sample program,we want to write records to produce a report.As you can see in this program,on line 7, I declare a file calledEmployee File.That will be my inputand on line eleven, I have a fileSelect Output File which will be my output.My output file will have the nameempreport.lptI have my NotePad in split screen modeso you can see the input file.In order to write records to a file,first format the record in working storage.In this program, I've already definedthe heading line, the detail line andtwo total lines. Let's scroll downand take a look.The heading line starts on line 64notice the heading line each variablejust says filler but on the right-hand sidethe value specifies what will get printed.employee ID, employee name, start date,and salary.On line 76 is the detail line that matches upwith the headings.In the detail line I define variablesfor each of the items listed above.If you have a printer spacing chart available. COBOL is an endangered language. But it once ran 80% of the world's business systems: thousands of mission-critical applications that still exist today.

    Writing variable file in cobol cCobol

    Some companies want to upgrade and transition their COBOL applications to more modern frameworks; others want to stick with COBOL's relatively stable platform. In either case, hiring managers are willing to pay a premium for candidates who know how to take on COBOL's challenges. For this reason, programmers are learning COBOL again.This course is designed to help new and experienced programmers alike add COBOL (or add COBOL back) to their skill set. Peggy Fisher shows how to get a COBOL development environment up and running and how to start programming. She reviews COBOL's data types and constants, control structures, file storage and processing methods, tables, and strings. Challenges issued along the way will help you practice what you've learned.

    Data Division is used to define the variables used in a program. To describe data in COBOL, one must understand the following terms −. Data Name. Level Number. Picture Clause. Value Clause01 TOTAL-STUDENTS PIC9(5) VALUE '125'.

    Level Number Data Name Picture Clause Value ClauseData NameData names must be defined in the Data Division before using them in the Procedure Division. They must have a user-defined name; reserved words cannot be used. Data names give reference to the memory locations where actual data is stored. They can be elementary or group type. ExampleThe following example shows valid and invalid data names −Valid:WS-NAMETOTAL-STUDENTSA100100BInvalid:MOVE (Reserved Words)COMPUTE (Reserved Words)100 (No Alphabet)100+B (+ is not allowed)Level NumberLevel number is used to specify the level of data in a record. They are used to differentiate between elementary items and group items. Elementary items can be grouped together to create group items.

    Sr.No.Level Number & Description101Record description entry202 to 49Group and Elementary items366Rename Clause items477Items which cannot be sub-divided588Condition name entry.Elementary items cannot be divided further. Level number, Data name, Picture clause, and Value clause (optional) are used to describe an elementary item.Group items consist of one or more elementary items. Level number, Data name, and Value clause (optional) are used to describe a group item. Group level number is always 01.ExampleThe following example shows Group and Elementary items −DATA DIVISION.WORKING-STORAGE SECTION.01 WS-NAME PIC X(25). ELEMENTARY ITEM01 WS-CLASS PIC 9(2) VALUE '10'.

    Comp Variables In Cobol

    ELEMENTARY ITEM01 WS-ADDRESS. GROUP ITEM05 WS-HOUSE-NUMBER PIC 9(3). ELEMENTARY ITEM05 WS-STREET PIC X(15).

    File

    ELEMENTARY ITEM05 WS-CITY PIC X(15). ELEMENTARY ITEM05 WS-COUNTRY PIC X(15) VALUE 'INDIA'. ELEMENTARY ITEMPicture ClausePicture clause is used to define the following items −.Data type can be numeric, alphabetic, or alphanumeric.

    Numeric type consists of only digits 0 to 9. Alphabetic type consists of letters A to Z and spaces. Alphanumeric type consists of digits, letters, and special characters.Sign can be used with numeric data. It can be either + or –.Decimal point position can be used with numeric data. Assumed position is the position of decimal point and not included in the data.Length defines the number of bytes used by the data item.Symbols used in a Picture clause − Sr.No.Symbol & Description19Numeric2AAlphabetic3XAlphanumeric4VImplicit Decimal5SSign6PAssumed DecimalExampleThe following example shows the use of PIC clause −. IDENTIFICATION DIVISION.PROGRAM-ID. IDENTIFICATION DIVISION.PROGRAM-ID.

    HELLO.DATA DIVISION.WORKING-STORAGE SECTION.01 WS-NUM1 PIC 99V9 VALUE IS 3.5.01 WS-NAME PIC A(6) VALUE 'ABCD'.01 WS-ID PIC 99 VALUE ZERO.PROCEDURE DIVISION.DISPLAY 'WS-NUM1: 'WS-NUM1.DISPLAY 'WS-NAME: 'WS-NAME.DISPLAY 'WS-ID: 'WS-ID.STOP RUN.JCL to execute the above COBOL program −//SAMPLE JOB(TESTJCL,XXXXXX),CLASS = A,MSGCLASS = C//STEP1 EXEC PGM = HELLOWhen you compile and execute the above program, it produces the following result −WS-NUM1: 03.5WS-NAME: ABCDWS-ID: 00.

Designed by Tistory.