# Welcome To: Introduction To COBOL Programming

2y ago
20 Views
3.31 MB
141 Pages
Last View : 27d ago
Transcription

Welcome to:Introduction to COBOLProgramming

Introduction to COBOLProgramming Class Introductions . Your Trainer – Peter Molchan COB100

Introduction to COBOLProgramming Class Hours Approx 9:00 am. to 4:00 pm. Lunch around 11:30 Morning and afternoon break

Introduction to COBOLProgramming Training Medium Student Workbook Additional Skill-Building Exercises Mainframe Express COBOL Compiler

Introduction to COBOLProgramming High Level Course Overview COBOL Introduction Structure of a COBOL Program Introduction to Mainframe Express Back to COBOL

Introduction to COBOLProgramming Course Methodology Lecture Instructor led hands-on instruction Student exercises Case problems Workshop sessions

Introduction to COBOLProgramming Course Objectives Learn the requirements and syntax of the COBOLlanguage Describe expressions and statements Write File and Data Definition statements Perform Input/Output operations Use arithmetic functions Write basic report programs Use subroutines

Introduction to COBOLProgramming Course Manual (Student Workbook) TOCCourse IntroductionCOBOL OverviewProgram and File DefinitionCOBOL Procedures and StatementsBranchingTesting and DebuggingValidation, Logic, and ArithmeticElements of Structured COBOLCOBOL ReportsDBMS Interface (not covered in public class format)VS COBOL II differences (not typically covered in pubilc class format)

Introduction to COBOLProgramming Mainframe Express Create/Edit Programs Compile Programs Test/Debug Programs Edit Data Files Control Compiler

Introduction to COBOL ProgrammingChapter 1 COBOL OverviewPage 1-1

1.1 ObjectivesAfter completing this chapter, you will understand the capabilities andsyntax of COBOL programs. Specifically, you will be able to:Describe the steps of the Programming Life CycleDescribe the function of the four COBOL divisionsList the advantages and disadvantages of COBOLDescribe the purpose of the COBOL compilerUnderstand the column structure of COBOLPage 1-1

1.2 Topics to be covered:Programming life cycleWhat is COBOL?Advantages of COBOLLimitations of COBOLCOBOL preparationCOBOL structureCOBOL columnsCOBOL linesCOBOL syntaxPage 1-2

1.2.1 Programming life cycleBackground .Page 1-3

1.2.1 Programming life cycleEnterprise LevelBusiness/data modeling* Enterprise modelingNeeds analysis* Feasibility, survey investigation, data gathering & analysisSystem design* Input/output requirements, system controls, databasesProgram Development/Maintenance LevelProgram development* Code, compile, linkTesting* Find the bugs before the bugs find youImplementation/sign-off* Conversion, training, auditing, evaluationMaintenance* Monitoring, adjustments, upgrades, service requestsPage 1-3

1.2.2 What is COBOL? Common Business Oriented Language COBOL Roots - Evolution Developed by the Department of Defense in 1959COnference of DAta SYstem Languages (CODASYL)Under the guidance of Grace HopperConference goals were to develop a language that was: Business OrientedMachine independentEnglish-likeSelf documentingDOD mandated parameters to software developersStandards were/are maintained/updated by the American NationalStandards Institute (ANSI)Page 1-4/5

1.2.3 Advantages of COBOL English-likeSolves Business ProblemsHandles large volumes of dataUniversal and standardizedCompatible and transportableEasy to maintainSupports a variety of file organizationsPage 1-6

1.2.4 Limitations of COBOL Requires a compiler English like means statements can be verylong If unstructured, can be very difficult tomaintain/debug No Relational DBMS verbs - (SQL must beembedded/pre-compiled)Page 1-7

1.2.5 COBOL PreparationCOBOL code must go through a two step process tobecome executable COMPILE Checks for syntax errorsProduces source listing of COBOLProduces diagnostic listingTranslates COBOL statements to machine language instructions,producing an object program LINK Brings COBOL subroutines into program object codeResolves external references of programs external to programobject codeProduces load modulePage 1-8

1.2.6 COBOL StructureProgramming SpecificsPage 1-9

1.2.6 COBOL StructureCOBOL structure - Formal - 4 Divisions Identification Division Identifies the program via program name, author, date written, and otherpertinent information Environment Division Describes computer hardware and external file information Data Division Describes input, output, and work files/items Procedure Division Contains the logical instructionsPage 1-9

1.2.6 COBOL StructureCOBOL structure - Formal - 4 DivisionsPage 1-9

1.2.7 COBOL ColumnsCoding Rules .There are some precise rules governing COBOLcoding.Page 1-10

1.2.7 COBOL ColumnsSequence Numbers Columns 1-6A Margin Columns 8-11 - Division names, Section names, Paragraph names, Filedescriptions, Hi-level data items B Margin Columns 12-72Identification Code Columns 73-80 Comment/Continuation Column 7 Statements are continued in B marginSplitting of literals requires hyphen in column 7 and a leading quote (’) in theB-marginPage 1-10/11

1.2.8 COBOL Lines Blank lines are OK* used in Column 7 for comment linesKeywords can be used to control the appearance of your‘post compile’ listingLine Skips SKIP1SKIP2SKIP3Paper Eject - Start New Page for your listing EJECTPage 1-12

1.2.9 COBOL SyntaxNaming conventions apply to:Data-namesParagraph-namesPage 1-13

1.2.9 COBOL SyntaxRules for forming data-names/paragraph-namesNot permitted May NOT be COBOL reserved word (refer to Appendix A in your Manual)May NOT contain spacesMay NOT contain special characters other than hyphenMay NOT begin or end with hyphenPermitted May contain 1-30 charactersMay consist of alphabet (A-Z), integers (0-9), and hyphensParagraph names may consist entirely of integers, but all other names MUST contain at least onealphabetic characterSHOULD be different from all other names in THIS program (qualification is possible but notrecommended)Page 1-13

1.3 WorkshopDO 1.3.1. Review QuestionsSkip 1.3.2 ExerciseTake a BreakPage 1-14/15

1.3 Workshop1.d. DATA DIVISIONc. IDENTIFICATION DIVISIONb. ENVIRONMENT DIVISIONa. PROCEDURE DIVISION2.c. A Margind. B Margine. Identification codeb. Comments/continuationa. Sequence numbers3.X OUTPUT RECORDX RATE/5QUANTITY-ON-HANDX TOTAL#RECORDSINPUT-RECX PAY 52-PICKUPX SUPER*GROSS-PROFITSX PAY TABLEPage 1-14/15

1.3 Workshop4. COBOL Compiler Checks for syntax errorsProduces source listing of COBOLProduces diagnostic listingTranslates COBOL statements to machine language instructions, producing an object program5. COBOL Advantages English-likeSolves Business ProblemsHandles large volumes of dataUniversal and standardizedCompatible and transportableEasy to maintainSupports a variety of file organizations6. COBOL Disadvantages Requires a compilerEnglish like means statements can be very longIf unstructured, can be very difficult to maintain/debugNo Relational DBMS verbs - (SQL must be embedded/pre-compiled)Page 1-14/15

Review .At this point we should be able to:Describe the steps of the Programming Life CycleDescribe the function of the four COBOL divisionsList the advantages and disadvantages of COBOLDescribe the purpose of the COBOL compilerUnderstand the column structure of COBOL

Introduction to COBOL ProgrammingUsing the Micro FocusMainframe Express

What is the Mainframe Express?An integrated , graphical COBOLapplication development toolset whichallows you to create, maintain andsupport: Production mainframe applications PC-based and GUI-Client/Server applications

COBOL Compiler-Language Dialects OSVS VSCII COBOL370 SAA-COBOL Object COBOL

COBOL Development Tools Edit Editor Check Compiler Animate TestingEnvironment

Project OrganizationWorkgroups are used to group programs,data and related files together for easyaccess to the testing environment

Shall we try it out?Let’s Edit, Check and Animate aprogram Start the MFE Open our COB100 Project(C:\COBOL\COBOL100.MVP) Expand Source Folder and highlight COBOL Start our Edit Right Click on TICTAC.CBLClick EditAfter the program loads, click Check/Compile Shut Down the Workbench

Shall we try it out?Let’s Edit, Check and Animate aprogram Select Run from the Debug Menu Select the TSO Tab Enter CALL TICTAC

Now its your turn .Repeat the test of TICTAC.CBL on yourown .

Let’s code something new . In the COBOL100 Project From the File Menu select NewSelect Source File You should be in an Edit Session - Code the following . When you finish coding, click Save as ,under the File MenuRight mouse button in the edit area and SelectAdd to ProjectCheckClean-up any errors ask for Help if needed .

Let’s debug a program . Start the MFE Load COBOL100 Project Start our Edit/Compile Session Double Click on TACKY.CBL to editClick Check/Compile When you encounter the first compiler error, clickZoom to finish the Compile Fix the Program Bug Recheck the Program

Quiz time .When using Mainframe Express, the cycle of Edit, CompileTest is referred to as: Edit, Compile, DebugName a few of the existing COBOL compiler dialects. OSVS, VSCII, ANSI85, SAA-COBOL, Object COBOLThe program VERYTAKI.CBL has several errors in it. See ifyou can rise to the challenge and get a clean compile .

Review .At this point we should be able to: Describe the steps of the Programming Life CycleDescribe the function of the four COBOL divisionsList the advantages and disadvantages of COBOLDescribe the purpose of the COBOL compilerUnderstand the column structure of COBOLUse the Micro Focus Workbench to Edit, Syntax Check and Animate aprogram

Introduction to COBOL ProgrammingChapter 2 Program and FileDefinitionsPage 2-1

2.1 ObjectivesAfter completing this chapter, you will understand the three COBOLdivisions used to identify the program and its files (Identification,Environment, and Data Division). Specifically, you will be able to: Code an identification division Code an environment division Code a data division Tell whether statements belong in the A-margin or B-margin Write a record description for a file Process literals and figurative constants Describe the mainframe COBOL compilerPage 2-1

2.2 Topics to be covered: Identification division Environment division Data division File description PICTURE clause USAGE clause VALUE clause Literals and figurative constants Copy statementCOBOL compiler and optionsPage 2-2

2.2.1 Identification DivisionDocuments program name and origin PROGRAM-ID Required 1-30 characters Only first 8 used to uniquely identify SECURITYPage 2-3

2.2.1 Identification DivisionExample:000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID. HL2COB1.000300 AUTHOR. ALFRED E NEWMAN SALES X-9876.000400 INSTALLATION. COMPANY B.000500 DATE-WRITTEN. JANUARY, 1990.000600 DATE-COMPILED.000700 SECURITY. UNCLASSIFIED.Note the use of periodsPage 2-3

2.2.1 Work AssignmentUse Maineframe Express to create a new filecalled PROGRAM1.CBLCode the example (in your book). Use applicablenotations for Program-Id, etc.000100 IDENTIFICATION DIVISION.000200 PROGRAM-ID. PROGRAM1.000300 AUTHOR. ALFRED E NEWMAN SALES X-9876.000400 INSTALLATION. COMPANY B.000500 DATE-WRITTEN. JANUARY, 1990.000600 DATE-COMPILED.000700 SECURITY. UNCLASSIFIED.Check your program for syntax errorsPage 2-3

2.2.2 Environment Divisionmade up of 2 sectionsCONFIGURATION SECTIONDescribes computer on which program is compiled and executedSOURCE-COMPUTEROBJECT-COMPUTERINPUT-OUTPUT SECTIONRelates each program file with external hardware device viaFILE-CONTROL statementSELECT program-file ASSIGN TO jcl-external-namejcl-external-name– class indicator (2)– organization indicator (1)– external name (1-8)Page 2-4

2.2.2 Environment DivisionExample:000800 ENVIRONMENT DIVISION.000900 CONFIGURATION SECTION.00l000 SOURCE-COMPUTER. IBM-370.001100 OBJECT-COMPUTER. IBM-370.001200 INPUT-OUTPUT SECTION.001300 FILE-CONTROL.001400 SELECT SALES-FILE-IN ASSIGN TO UT-S-SALESIN.001500 SELECT REPORT-FILE-OUT ASSIGN TO UT-S-RPTOUT.UT - Unit TapeS - SequentialPage 2-4

2.2.2 Work AssignmentAdd the following code to PROGRAM1.CBL000800 ENVIRONMENT DIVISION.000900 CONFIGURATION SECTION.00l000 SOURCE-COMPUTER. IBM-370.001100 OBJECT-COMPUTER. IBM-370.001200 INPUT-OUTPUT SECTION.001300 FILE-CONTROL.001400 SELECT SALES-FILE-IN ASSIGN TO UT-S-SYSUT1.Check your program for syntax errors**** Syntax errors for missing FD’s are OK for nowPage 2-4

2.2.3 Data DivisionContains detailed information about all data used byyour programFILE SECTION describes external dataWORKING-STORAGE SECTION describes internal dataPage 2-5

2.2.3 Data Division/File SectionFILE SECTIONFD File Descriptors (Logical File Definitions) - one for each file in the programFD SALES-FILE-IN(Describes the Data file named in the SELECTstatement)LABEL RECORDS ARE STANDARD (Throwback to tape storage - records wereeither labeled or unlabeled - STANDARDfor disk storage)RECORDING MODE IS F(fixed/variable record length)RECORD CONTAINS 80 CHARACTERS (# of bytes in the record)BLOCK CONTAINS 0 RECORDS(# of records in a block of records)DATA RECORD IS SALES-RECORD.(data name of the record)01 SALES-RECORD PICTURE X(80). (refers back to the DATA-RECORD data-nameand defines the record layout)Page 2-5

2.2.3 Data DivisionExample:001600 DATADIVISION.001700 FILE SECTION.001800 FD SALES-FILE-IN001900 LABEL RECORDS ARE STANDARD002000 RECORDING MODE IS F002100 RECORD CONTAINS 80 CHARACTERS002200 BLOCK CONTAINS 0 RECORDS002300 DATA RECORD IS SALES-RECORD.002400 01 SALES-RECORDPICTURE X(80).002500 WORKING-STORAGE SECTION.002600 77 END-OF-FILE-SWITCH PICTURE X VALUE 'N’.002700 01 PRINT-CONTROL.002800 05 LINE-COUNTRPICTURE 9(2) VALUE 99.002900 05 PAGE-COUNTRPICTURE 9(4) VALUE 0.003000 05 LINES-PER-PAGEPICTURE 9(2) VALUE 60.Page 2-5

2.2.3 Work AssignmentAdd the following code to PROGRAM1.CBL001600 DATA DIVISION.001700 FILE SECTION.001800 FD SALES-FILE-IN001900 LABEL RECORDS ARE STANDARD002000 RECORDING MODE IS F002100 RECORD CONTAINS 78 CHARACTERS002200 BLOCK CONTAINS 0 RECORDS002300 DATA RECORD IS SALES-RECORD.002400 01 SALES-RECORDPICTURE X(78).002500 WORKING-STORAGE SECTION.002600 77 END-OF-FILE-SWITCH PICTURE X VALUE 'N’.002700 01 PRINT-CONTROL.002800 05 LINE-COUNTRPICTURE 9(2) VALUE 99.002900 05 PAGE-COUNTRPICTURE 9(4) VALUE 0.003000 05 LINES-PER-PAGEPICTURE 9(2) VALUE 60.Page 2-5

2.2.4 Variable Length RecordsRECORDING MODE IS VRECORD CONTAINS largest #DATA RECORDS AREExample:DATA DIVISION.FILE SECTION.FD SALES-FILE-INLABEL RECORDS ARE STANDARDRECORDING MODE IS VRECORD CONTAINS 90 CHARACTERSBLOCK CONTAINS 0 RECORDSDATA RECORDS 1 REGION-1-RECORD PICTURE X(80).01 REGION-2-RECORD PICTURE X(40)01 REGION-3-RECORD PICTURE X(90).Page 2-6

2.2.5 Describing Data File: group of related records File description area (FD) Code an FD for each file referenced by the programFD coded in the A marginFile name coded in the B marginFile Parameters coded in the B marginFile name must match SELECT statement in Environment Division Record: group of related fields Record name Follow each FD (external record description)Also appear in Working-Storage (internal to the program)Described as an 01 levelCode in A margin Field: item used for one piece of data Field within record Elementary item 02-49 levelData Name or FILLER may be usedCode in B marginOne fieldCode in A margin01 LINE-COUNTRPICTURE 9(2) VALUE 99.Group item Higher level item composed of one or more lower level elementary items01 PRINT-CONTROL.05 LINE-COUNTRPICTURE 9(2) VALUE 99.05 PAGE-COUNTRPICTURE 9(4) VALUE 0.Page 2-7

2.2.5 Describing Data - Example18 12A B001600 DATA DIVISION.001700 FILE SECTION.001800 FD SALES-FILE-IN001900LABEL RECORDS ARE STANDARD002000RECORDING MODE IS F002100RECORD CONTAINS 80 CHARACTERS002200BLOCK CONTAINS 0 RECORDS002300DATA RECORD IS SALES-RECORD.002400 01 SALES-RECORDPICTURE X(80).002500 WORKING-STORAGE SECTION.002600 77 END-OF-FILE-SWITCH PICTURE X VALUE 'N’.002700 01 PRINT-CONTROL.002800 05 LINE-COUNTRPICTURE 9(2) VALUE 99.002900 05 PAGE-COUNTRPICTURE 9(4) VALUE 0.003000 05 LINES-PER-PAGEPICTURE 9(2) VALUE 60.Page 2-7

2.2.5 Data Representation A discussion about how data is represented binary hex bits and bytes halfwords and words 2bytes, 4 bytes etc .Page 2-7

2.2.5 Data RepresentationPage 2-7

2.2.6 Picture Clause PICTURE (PIC) describes data TYPE and LENGTH A - alphabetic 9 - numeric X- alphanumeric V- implied decimal S - sign (optional) used to capture ,- valuesExamples:Ol CUSTOMER-RECORD.05 LAST-NAME05 FIRST-NAME05 PHONE.10 AREA10 EXCHANGE10 EXTENSN05 BILL-AMOUNT05 FILLERPIC X(20).PIC X(15).PIC 9(3).PIC 9(3).PIC 9(4).PIC S9(3)V99.PIC X(30).Page 2-8

2.2.7 Usage Clause USAGE (optional) describes how data is stored INDEX Used in table handling DISPLAY One character per byte ("print format”) - default COMPUTATIONAL (COMP) - binary 1st position contains operational sign 1-4 digits 2 bytes (halfword) 5-9 digits 4 bytes (fullword) 10-18 digits 8 bytes (2 fullwords)Page 2-9

2.2.7 Usage Clause USAGE (optional) describes how data is stored COMPUTATIONAL-1 (COMP-1) - short precision floating point 4 bytes (fullword) COMPUTATIONAL-2 (COMP-2) - long precision floating point 8 bytes (doubleword) COMPUTATIONAL-3 (COMP-3) - packed decimal format 2 digits per byte NOTE: COMP-1, COMP-2, COMP-3 are IBM extensions of ANS 74Page 2-9

2.2.8 Display DataPIC X(3) VALUE ‘ABC’ USAGE DISPLAY.PIC X(3) VALUE ‘ABC’. C1 C2 C3 PIC 9(4) VALUE 1234 USAGE DISPLAY.PIC 9(4) VALUE 1234. F1 F2 F3 F4 PIC S9(4) VALUE 1234 USAGE DISPLAY.PIC S9(4) VALUE 1234. F1 F2 F3 C4 PIC S9(4) VALUE -1234 USAGE DISPLAY.PIC S9(4) VALUE -1234. F1 F2 F3 D4 Page 2-10

2.2.9 Packed dataPIC 9(3) VALUE 123 USAGE COMP-3.PIC 9(3) VALUE 123 COMP-3. 12 3F PIC S9(4) VALUE 123 USAGE COMP-3.PIC S9(4) VALUE 123 COMP-3. 00 12 3C PIC S9(4) VALUE -123 USAGE COMP-3.PIC S9(4) VALUE -123 COMP-3. 00 12 3D Page 2-11

2.2.10 Binary DataPIC 9(4) VALUE 10 USAGE COMP.PIC 9(4) VALUE 10 COMP. 00 0A PIC 9(4) VALUE 123 USAGE COMP.PIC 9(4) VALUE 123 COMP. 00 7B Page 2-12

2.2.11 VALUE ClauseOptional initializes memory Can't be used in file section Only used with elementary itemsEXAMPLES01 PRINT-CONTROL.05 LINE-COUNTEROS PAGE-COUNTER05 LINES-PER-PAGE01 HEADlNG-l.05 FILLEROS FILLER05 FILLER05 PAGE-NUMBERPIC 9(2) VALUE 99.PIC 9(4) VALUE ZERO.PIC 9(2) VALUE 60.PIC X(30) VALUE SPACES.PIC X(16) VALUE 'CUSTOMER LISTING'.PIC X(30) VALUE SPACES.PIC 9(4).Page 2-13

2.2.12 Numeric Literals Syntax 1-8 digits Optional decimal (any position except last) Optional sign ( or -) - must be first* if sign not used, compiler assumes value is positive Cannot enclose in quotes Storage05 PAGE-COUNTER PIC 9(4) VALUE 10. F0 F0 F1 F0 05 BILL-AMOUNTPIC 9(3)V99 VALUE 10. F0 F1 F0 F0 F0 05 CASH-VALUE PIC S9(3)V99 VALUE 14.32. F0 F1 F4 F3 C2 05 DEBIT-AMOUNT PIC S9(3)V99 VALUE -394.13 F3 F9 F4 F1 D3 Page 2-14

2.2.13 Alphanumeric Literals Syntax 1-120 characters enclosed in quotes may contain any character (except quotes) Storage05 HEADING-3 PIC X(8) VALUE 'PAGE'. P A G E D7 C1 C7 C5 40 40 40 40 05 HEADING-NUMBER PIC X(7) VALUE '898'. 8 9 8 F8 F9 F8 40 40 40 40 Page 2-15

2.2.14 Figurative Constants Compiler generated - refer to course manual do not enclose in ESPACESQUOTEQUOTESZEROZEROSZEROESA L 'x'Page 2-16

2.2.15 COPY statement. Brings in externally stored COBOL code at compile time Usually Data Division Saves time Reduces errors Pulled in at compile time from COBOL libraries Must use ‘LIB' compiler option and //SYSLIB DD statement COPY module-nameCOPY SALEREC.Page 2-17

2.2.16 Compiling procs for JCL Purpose - check syntax of COBOL statements COBUC Compile using standard COBOL compiler COB2UC Compile using VS COBOL 11 compilerPage 2-18

2.2.17 Compiler files STEPLIB Points to location of compiler program SYSIN Compiler input - points to data set containing COBOL source SYSUT1 Compiler workspace needed by compiler SYSPRINT Compiler report output - storage map, listings, messages SYSLIN Object data set as output from compiler SYSPUNCH Object data set as output from compiler SYSLIB Optional user COBOL source libraries (for COPY command)Page 2-19

2.2.18 Compiling your program - mainframe ISPF Option 5 (BATCH) Choose which COBOL compiler you want Fill in a valid job card Fill in options (remembered from session to session) Press ENTER or PF3, as instructed to submit batch compile Browse the output using Option S (SDSF)Page 2-20

2.2.19 Compiler Options Controls the outputs of the compiler Specified in the PARM field of your JCL In Micro Focus, right click on the programto access check/compile options Note: for animating (testing) a program in this classyou will have to add the following compiler directive(option) to access data files ASSIGN ‘EXTERNAL’Page 2-21

2.2.20 Compiler JCL Refer to text for samples .Page 2-22

2.3 WorkshopDO ALL 2.3 Review QuestionsExtra Fun Debug Chap2bug.cblPage 2-23/26

2.3 Review Questions1A DIVISIONA Level 01 entryB SELECTB BLOCK CONTAINSA SECTIONB Level 05 entryA FDB PICTURE205 LAST-NAME05 FIRST-NAME05 STREET-ADDRESS05 CITY05 STATE05 ZIP-CODE05 AMOUNT-PAIDPIC X(30).PIC X(20).PIC X(30).PIC X(20).PIC A(2).PIC 9(5).PIC 9(7)V99.Page 2-23

2.3 Review Questions3A ‘HSRP’B 29.95B -2036330359D SPACESB 898.6E -1/2D ZEROE LOW VALUESC FILLERD HIGH-VALUESA/E ‘999V99’A ‘DECEMBER 7, 1941’4E SELECTB DATA DIVISIOND PICTUREA ASSIGNC PROGRAM-IDF FIGURATIVE CONSTANTPage 2-24

2.3 Review Questions5 E7 E8 E9 40 F3 F8 D4 95 30 0F 00 03 7C 00 64 C3 D6 C2 D6 D3 40 40 40 Page 2-25

2.3 Review QuestionsPROGRAM-ID. PROGRAM1.AUTHOR. PETER MOLCHAN.INSTALLATION. CLASSROOM.DATE-COMPILED.SECURITY. UNCLASSIFIED.ENVIRONMENT DIVISION.CONFIGURATION SECTION.SOURCE-COMPUTER. IBM-370.OBJECT-COMPUTER. IBM-370.INPUT-OUTPUT SECTION.FILE-CONTROL.SELECT SALES-FILE-IN ASSIGN TO UT-S-SALESIN.DATA DIVISION.FILE SECTION.FD SALES-FILE-INLABEL RECORDS ARE STANDARDRECORDING MODE IS FRECORD CONTAINS 80 CHARACTERSBLOCK CONTAINS 0 RECORDSDATA RECORD IS SALES-RECORD.01 SALES-RECORD.05 ITEM-SOLDPIC 9(1).05 LAST-NAMEPIC X(20).05 FIRST-NAMEPIC X(10).05 STREET-ADDRESSPIC X(20).05 CITYPIC X(10).05 STATEPIC A(2).05 ZIP-CODEPIC 9(5).05 AMOUNT-PAIDPIC 9(5)V99.05 SALESPERSON-CODEPIC 9(3).05 FILLERPIC X(2).WORKING-STORAGE SECTION.77 END-OF-FILE-SWITCHPICTURE X VALUE 'N'.01 PRINT-CONTROL.05 LINE-COUNTRPICTURE 9(2) VALUE 99.05 PAGE-COUNTRPICTURE 9(4) VALUE 0.05 LINES-PER-PAGEPICTURE 9(2) VALUE 60.Page 2-26

2.3 Debug Chap2bug.cblProblemsFILE-SECTION.FD SALES-FILE-INLABEL RECORDS ARE STANDARDRECORDING MODE IS FRECORD CONTAINS 80 CHARACTERSBLOCK CONTAINS 0 RECORDSDATA RECORD IS SALES-RECORD.01 SALES-RECORDPIC X(80).05 ITEM-SOLDPIC 9(1).05 LAST-NAMEPIC X(20).05 FIRST-NAMEPIC X(10).05 STREET-ADDRESSPIC X(20).05 CITYPIC X(10).05 STATEPIC A(2).05 ZIP CODEPIC 9(5).05 AMOUNT-PAIDPIC '9(5)V99'.Should be FILE SECTION.No picture clause on a group itemInvalid data-nameInvalid picture clausePage 2-26

Review .At this point we should be able to: Describe the steps of the Programming Life CycleDescribe the function of the four COBOL divisionsList the advantages and disadvantages of COBOLDescribe the purpose of the COBOL compilerUnderstand the column structure of COBOLUse the Micro Focus Workbench to Edit, Syntax Check and Animate aprogramCode an identification divisionCode an environment divisionCode a data divisionTell whether statements belong in the A-margin or B-marginWrite a record description for a fileProcess literals and figurative constantsDescribe the mainframe COBOL compiler

2.1 ObjectivesAfter completing this chapter, you will be able to code basic COBOLstatements in the Procedure Division. Specifically, you will be able to: Code file I/O statements (OPEN,CLOSE,READ,WRITE) Code special I/O statements (ACCEPT,DISPLAY) Perform basic data transfer (MOVE) Detect when an end of file condition is reached Create a simple COBOL program using Mainframe Express End the program as needed (GOBACK, STOP RUN) Compile, link, and test a simple COBOL program Understand the function of an optimizerPage 3-1

3.2 Topics to be covered: Procedure Division Paragraphs I/O Statements MOVE statements Allowable moves GOBACK and STOP RUN Compiling and Linking Code OptimizationPage 3-2

3.2.1 Procedure Division Statements Combination of Words & Symbolscausing ActionMOVE INPUT-RECORD TO WORK-RECORD SentencesADD 1 TO TOTAL-COUNTERS.IF MONTH ‘JANUARY’THENPERFORM JANUARY-ROUTINGELSEPERFORM OTHER-ROUTINE.Page 3-3

3.2.1 Paragraphs One or more logically related statements Begins with Paragraph Name Ends with next Paragraph NameTOP-LEVEL.PERFORM INIT-ROUTINE.PERFORM PROCESS-EACH-RECORD UNTIL END-OF-DATA.PERFORM WRAP-UP.STOP RUN.PROCESS-EACH-RECORDPage 3-4

3.2.2 Input/Output Statements OPEN CLOSE READ WRITE ACCEPT DISPLAYPage 3-5

3.2.3 OPEN Statement Prepares File for processing Must be executed for all I/O Designate file as Input or Output Example:OPEN INPUT IN-EMP-FILE.OPEN OUTPUT OUT-FILE.Page 3-6

3.2.4 CLOSE Statement Terminates processing of files Should be executed for all files Residue data in file are can be written Example:CLOSE EMP-FILE.CLOSE OUT-FILE.CLOSE EMP-FILEOUT-FILE.Page 3-7

3.2.5 READ Statement Retrieves next record from file Allows detection of End of File Can Transfer external file data to internalarea (INTO) File must be opened before READPage 3-8

3.2.6 WRITE Statement Sends record to file Requires Record Name File must be open Can transfer data from other part ofprogramPage 3-9

3.2.6 WRITE Statement ExamplesWRITE NEW-MASTER-RECORD.WRITE NEW-MASTER-RECORD FROM WORK-MASTER-RECORDWRITE REPORT-RECORD AFTER ADVANCING 2 LINESPage 3-9

3.2.7 ACCEPT Statement Retrieves special low-volume data fromexternal source DATE, DAY, TIME System Input Device (SYSIN) ExampleACCEPT RUN-DATE FROM DATEPage 3-10

3.2.8 DISPLAY Statement Sends special low volume data to externalsource Good for Debugging purposes Sent to SYSOUT or CONCOLE Display Elementary or group items andconstants and literalsDISPLAY ‘TOTAL RECORDS ‘ WS-TOTAL-RECORDSPage 3-11

3.2.9 MOVE Statement Copies contents of input are to output area Literal may be specified Data conversion is done, if necessary, tomeet description of output area Truncation and padding may occur Can move to more than one output areaPage 3-12

3.2.9 MOVE Statement Examples01 INPUT-FIRST-NAMEPIC X(9).01 OUTPUT-FIRST-NAMEPIC X(15)MOVE INPUT-FIRST-NAME TO OUTPUT-FIRST-NAME A R I S T O T L E A R I S T O T L E Page 3-12

3.2.9 MOVE Statement Examples01 INPUT-FIRST-NAMEPIC X(9).01 OUTPUT-FIRST-NAMEPIC X(5)MOVE INPUT-FIRST-NAME TO OUTPUT-FIRST-NAME A R I S T O T L E A R I S T Page 3-13

3.2.9 MOVE Statement Examples01 INPUT-FIRST-NAMEPIC X(4).01 OUTPUT-FIRST-NAMEPIC X(8)MOVE INPUT-FIRST-NAME TO OUTPUT-FIRST-NAMEJUSTIFIED RIGHT A R I S J A C K Page 3-13

3.2.10 Numeric MOVE Statement Examples01 MONTHLY-CHARGEPIC 9(3).01 AMOUNT-OWEDPIC 9(5)MOVE MONTHLY-CHARGE TO AMOUNT-OWED 5 6 7 8 9 7 8 9 Page 3-4

3.2.10 Numeric MOVE Statement Examples01 MONTHLY-CHARGEPIC 9(3)V99.01 AMOUNT-OWEDPIC 9(2)V9.MOVE MONTHLY-CHARGE TO AMOUNT-OWED 5 6 7 8 9 6 7 8 Page 3-14

3.2.10 Numeric MOVE Statement Examples01 MONTHLY-CHARGEPIC 9(3)V99.01 AMOUNT-OWEDPIC 9(2)V99.01 SALARY-AMOUNTPIC 9(3)V99 COMP-3.MOVE ZERO TO MONTHLY-CHARGEAMOUNT-OWED 0 0 0 0 0 SALARY-AMOUNT. 0 0 0 00 0 0 00 0 C Page 3-14

3.2.12 GOBACK Statement Terminate Execution of program No further statements executed Files should be closed Control returns to calling programPage 3-16

3.2.13 STOP RUN Statement Terminate Execution of program No further statements executed Files should be closed Control does not return to calling programPage 3-17

3.3 Workshop DO Pages 25 AND 26Review page 27Using the Micro Focus Workbench: (Page 28) Edit the program PROGRAM1.CBL. Your SELECT ASSIGN must be coded as follows:SELECT SALES-FILE-IN ASSIGN TO UT-S-SYSUT1ORGANIZATION IS LINE SEQUENTIAL. Code a simple Procedure Division that will: read the first record in the SALES file.Print the record to the screen using the DISPLAY verbClose the SALES file.Check and Animate the program be sure to use the ASSIGN ‘EXTERNAL’ compiler directive On-line Quiz . Edit Prog02.cblFill in the required blanks - Indicated at Exercise # pointsGet a clean check (compile) If you wish, AnimateChange PROGRAM1.CBL so it reads/writes the entire filePage 3-25-28

3.3 Workshop1OPEN INPUT CUSTOMER-ORDER-FILE.CLOSE CUSTOMER-ORDER-FILE.OPEN OUTPUT CUSTOMER-ORDER-REPORT.CLOSE CUSTOMER-ORDER-REPORT.OPEN OUTPUT CUSTOMER ERROR REPORT.CLOSE CUSTOMER ERROR REPORT.Page 3-25-28

3.3 Workshop2PROCEDURE DIVISION.OPEN INPUT SALES-FILE-IN.READ SALES-FILE-IN.OPEN OUTPUT SALES-FILE-OUT.WRITE SALES-REPORT.3 C6 C9 C5 D3 C4 40 40 40 40 40 40 4 F0 F2 F3 F8 F7 Page 3-25-28

3.3 WorkshopPROGRAM-ID. PROGRAM1.AUTHOR. PETER MOLCHAN.INSTALLATION. CLASSROOM.DATE-COM

Introduction to COBOL Programming Course Manual (Student Workbook) TOC Course Introduction COBOL Overview Program and File Definition COBOL Procedures and StatementsCOBOL Procedures and Statements Branching Testing and Debugging Validation, Logic, and Arithmetic Elements of Structured COBOL COBOL Reports DBMS Interface (not covered in public class format)

Related Documents:

cation of the COBOL standard (COBOL o20021) is pending as of this writing. It follows COBOL 68, COBOL 74, and COBOL 85. If you consider the Intrinsic Func-tions Addendum published in o1989, the new COBOL o2002 actually marks the ﬁfth ofﬁcial release of standard COBOL. The disrespect for the COBOL programming language, which is encouraged in

The VSI COBOL for OpenVMS DBMS Database Programming Manual is a component of the VSI COBOL for OpenVMS documentation set. Complete information about VSI COBOL for OpenVMS can be found in the VSI COBOL for OpenVMS User Manual and VSI COBOL for OpenVMS Reference Guide. VSI COBOL for OpenVMS is a VSI implementation of COBOL (COmmon Business-Oriented

the COBOL language, and who will use COBOL facilities for applications under GCOS 7. It is assumed that the reader is familiar with the COBOL language and with COBOL terminology. Section 1: Describes COBOL calls for Job Management. Section 2: Describes COBOL calls for File Management. Section 3: Describes COBOL calls for Time Management.

COBOL-74 and COBOL-85 respectively. In 2002, Object-Oriented COBOL was released, which could use encapsulated objects as a normal part of COBOL programming. Importance of COBOL COBOL was the first widely used high-level programming language. It is an English-like language

Jun 05, 2018 · §Enterprise COBOL for z/OS, V5 and Enterprise COBOL for z/OS, V6 §COBOL compilers with new generation code generator and optimizer When §COBOL V5.1: 2013, V5.2: 2015 –COBOL V5 EOM Sept 11, 2017 (announced Dec 6, 2016) §COBOL V6.1: 2016, V6.2: 2017 –Migrating to V6 is the same

of COBOL programs from use with compilers developed in accordance with the 1968 COBOL Standard (FIPS PUB 21) to compilers developed in accordance with the 1974 COBOL Standard (FIPS PUB 21-1). Key Words: COBOL; COBOL program conversion; Federal Standard COBOL; pro gram conversion; programming aids; programming languages. Nat. Bur. Stand.

COBOL FOR MVS is the official application system language supported at the State of Hawaii Executive Branch's central computer site. Since 2001, COBOL FOR OS/390, COBOL FOR MVS AND VM became IBM'S current COBOL language products, and they replace both COBOL/370 and VS COBOL II which will not be supported.

Waves API 550 User Manual - 3 - 1.2 Product Overview . The Waves API 550 consists of the API 550A, a 3-Band parametric equalizer with 5 fixed cutoff points per band and the API 550B, a 4-Band parametric equalizer with 7 fixed cutoff points per band. Modeled on the late 1960’s legend, the API 550A EQ delivers a sound that has been a hallmark of high end studios for decades. It provides .