1. Trang chủ
  2. » Công Nghệ Thông Tin

Record and table handling

59 346 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 59
Dung lượng 795,5 KB

Nội dung

® IBM Software Group © 2006 IBM Corporation Enterprise COBOL Education Using Rational Developer for System Z Enterprise COBOL Education Using Rational Developer for System Z Intermediate COBOL Record and Table Handling Patterns Intermediate COBOL Record and Table Handling Patterns Jon Sayles, IBM Software Group, Rational EcoSystems Team 2 IBM Trademarks and Copyrights  © Copyright IBM Corporation 2007,2008. All rights reserved.  The information contained in these materials is provided for informational purposes only, and is provided AS IS without warranty of any kind, express or implied. IBM shall not be responsible for any damages arising out of the use of, or otherwise related to, these materials. Nothing contained in these materials is intended to, nor shall have the effect of, creating any warranties or representations from IBM or its suppliers or licensors, or altering the terms and conditions of the applicable license agreement governing the use of IBM software. References in these materials to IBM products, programs, or services do not imply that they will be available in all countries in which IBM operates.  This information is based on current IBM product plans and strategy, which are subject to change by IBM without notice. Product release dates and/or capabilities referenced in these materials may change at any time at IBM’s sole discretion based on market opportunities or other factors, and are not intended to be a commitment to future product or feature availability in any way.  IBM, the IBM logo, the on-demand business logo, Rational, the Rational logo, and other IBM Rational products and services are trademarks or registered trademarks of the International Business Machines Corporation, in the United States, other countries or both. Other company, product, or service names may be trademarks or service marks of others. 3 Course Contributing Authors  Thanks to the following individuals, for assisting with this course:  David Myers/IBM 4 Purpose of This Document  Course Name: COBOL Foundation Training - with RDz  Course Description: Learn the COBOL language, RDz and learn z/OS terms, concepts and development skills in this course.  Pre-requisites: Some experience in a 3rd or 4th Generation Language is expected. SQL is also recommended.  Course Length: 10 days  Topics (Agenda)  Getting Started - installing and configuring RDz - and the course materials, and using Eclipse to edit COBOL  COBOL General Language Rules  Basic COBOL Statements  Additional record and table handling Additional record and table handling  Debugging Programs - Note: Deep dive on using RDz for common COBOL programming errors (001, 0C4, 0C7, infinite loops, fall-thru, etc.)  Input/Output and Report Writing Patterns  COBOL Subprograms and the Linkage Section  Structured Programming Concepts, professional COBOL development practices and Coding Patterns  Advanced Character Manipulation, COBOL Intrinsic Functions, Date and Time coding patterns, and Language Environment calls  OS/390 Concepts and JCL - Compile/Link & Run Procs on the mainframe  Indexed file Coding Patterns  Sort/Merge, Sequential File Match/Merge and Master File Update Coding Patterns  Accessing DB2 Data and DB2 Stored Procedures  COBOL in the Real World: – CICS - lecture only – IMS (DL/I and TM) - ditto – Batch processing - ditto – Java calling COBOL – COBOL and XML Statements – SOA and COBOL - creating and calling Web Services – Web 2.0 using Rich UI 5 Course Details  Audience  This course is designed for application developers who have programmed in some language before, and who wish to learn COBOL.  Prerequisites  This course assumes that the student has the basic knowledge of IS technologies, data processing, software and have programmed for at least two or more years in a language such as: Java, VB, RPG, PL/1, Pascal, or some 4 th Generation Language or tool.  Knowledge of SQL (Structured Query Language) for database access is assumed as well.  Basic PC and mouse-driven development skills is also assumed.  Finally, it is assumed that you have been following along in this course, and have successfully completed the learning modules in sequence.  Or have the equivalent COBOL background obtained through some other form of COBOL study or on-the-job work. 6 Unit  Additional Record Concepts Additional Record Concepts  COBOL Tables – Definition and Language Concepts  Multi-Dimension COBOL Tables  Variable Length COBOL Tables  Searching COBOL Tables  Processing COBOL Tables With Intrinsic Functions Topics: Topics: Additional Record and COBOL Additional Record and COBOL Table Handling Facilities Table Handling Facilities 7 COBOL Records – Review  COBOL records are hierarchical structures that allow you to organize ("model") sophisticated real-world complex data  Records have a 01 level number definition  Coded beginning in the "A" margin  Typically with no PIC clause  01 Employee-Data.  And records continue with one-to-many elementary items – some of which may be "group" data items (with no PIC clause)  Here's an example shown in COBOL and graphically (with data) 01 Employee-Data. 01 Employee-Data. 05 Name. 05 Name. 10 Last-Name PIC X(10). 10 Last-Name PIC X(10). 10 Mid-Init PIC X(01). 10 Mid-Init PIC X(01). 10 First-Name PIC X(10). 10 First-Name PIC X(10). 05 Phone. 05 Phone. 10 Area-Code PIC 9(03) 10 Area-Code PIC 9(03) 10 Phone-Number PIC 9(07) 10 Phone-Number PIC 9(07) J J o o n n e e s s b b b b b b b b b b K K R R o o b b e e r r t t b b b b b b b b 2 2 0 0 1 1 4 4 5 5 6 6 3 3 2 2 3 3 1 1 Last-Name Last-Name M M First-Name First-Name Area- Area- Code Code Phone-Number Phone-Number Name Name Phone Phone Employee-Data Employee-Data Data Data 10-level 10-level 05-level 05-level 01-level 01-level 8 REDEFINED Fields  In many of the COBOL applications you will work in, you will encounter situations where fields in records are REDEFINED (the actual COBOL keyword is REDEFINES) – with different PIC clauses.  REDEFINES means that the same area of storage in the DATA DIVISION can be referenced in two or different ways.  Here's an example:  Assume an HR application stores employee mailing addresses  As up-to three lines of street-address, or a P.O. Box  Two records from the employee external file in succession: 01 Employee-Data. 01 Employee-Data. 05 Emp-Street-Addr. 05 Emp-Street-Addr. 10 Street-Line-1 PIC X(10). 10 Street-Line-1 PIC X(10). 10 Street-Line-2 PIC X(10). 10 Street-Line-2 PIC X(10). 10 Street-Line-3 PIC X(11) 10 Street-Line-3 PIC X(11) 05 Emp-Rural-Addr REDEFINES Emp-Street-Addr. 05 Emp-Rural-Addr REDEFINES Emp-Street-Addr. 10 Postal-Box PIC 9(06) 10 Postal-Box PIC 9(06) 10 Filler PIC 9(25) 10 Filler PIC 9(25) 1 1 0 0 0 0 1 1 b b S S O O U U T T H H M M A A I I N N b b S S T T R R E E T T A A P P T T . . b b 5 5 6 6 3 3 2 2 b b b b Street-Line-1 Street-Line-1 Street-Line-1 Street-Line-1 Street-Line-1 Street-Line-1 A A 3 3 4 4 T T 9 9 7 7 b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b Postal-Box Postal-Box Filler Filler Employee-Data Employee-Data Rec Rec #1 #1 Rec Rec #2 #2 Why REDEFINE fields? See Slide Notes. Why REDEFINE fields? See Slide Notes. Why REDEFINE fields? See Slide Notes. Why REDEFINE fields? See Slide Notes. 9 Defining and Using REDEFINED Fields  Language Rules – How to declare or REDEFINE a field:  You redefine a field:  At the same level number  The level numbers can not be: 88, 66, 01 (in the FILE SECTION) – but you can REDEFINE an 01 record in WORKING-STORAGE  Immediately following the field –with no higher level numbers between (higher in the COBOL hierarchy)  The data description entry for other-data-item cannot contain an OCCURS clause  The redefining field should (does not have to, but should) have the same number of characters as the Redefined field  You can have multiple redefinitions of the same field's character positions.  However, they must all refer to other-data-item, the data-name that originally defined the area.  The redefining entries cannot contain VALUE clauses except in condition-name entries. How to tell which field to reference: How to tell which field to reference: (The redefining or the redefined) (The redefining or the redefined)  Typically your record will have a flag or some sort of indicator variable that distinguishes the record types.  Usually this is one-byte "flag" – PIC X field that carries a value which describes the data that follows  See the example on the right  01 DATE-TABLE. 01 DATE-TABLE. 05 DATEVALS PIC X(30) 05 DATEVALS PIC X(30) VALUE "312831303130313130313031". VALUE "312831303130313130313031". 05 Month-Days 05 Month-Days REDEFINES REDEFINES DATEVALS PIC 9(2) OCCURS 12. DATEVALS PIC 9(2) OCCURS 12. 05 Name. 05 Name. 10 FIRST-NAME 10 FIRST-NAME PIC X(10). PIC X(10). 10 MID-INIT 10 MID-INIT PIC X(01). PIC X(01). 10 LAST-NAME 10 LAST-NAME PIC X(10). PIC X(10). 05 Company-Name 05 Company-Name REDEFINES REDEFINES Name PIC X(21). Name PIC X(21). 01 Business-Partner-Record. 01 Business-Partner-Record. 05 Record-Type 05 Record-Type PIC X(01). PIC X(01). 88 Individual-BP Value "I". 88 Individual-BP Value "I". 88 Company-BP Value "C". 88 Company-BP Value "C". 05 Name. 05 Name. 10 FIRST-NAME 10 FIRST-NAME PIC X(10). PIC X(10). 10 MID-INIT 10 MID-INIT PIC X(01). PIC X(01). 10 LAST-NAME 10 LAST-NAME PIC X(10). PIC X(10). 05 Company REDEFINES Name PIC X(21). 05 Company REDEFINES Name PIC X(21). … … PROCEDURE DIVISION. PROCEDURE DIVISION. … … READ INFILE INTO Business-Partner-Record. READ INFILE INTO Business-Partner-Record. If Individual-BP If Individual-BP … … use Name definition use Name definition Else If Company-BP Else If Company-BP … … use Company definition use Company definition 10 REDEFINED Records  In the WORKING-STORAGE SECTION (not in the FILE SECTION) you may redefine at the 01-record level.  This was common practice in older systems that were memory or storage-constrained.  Typically you might have (at least) 3 different records read:  Header-Rec: With Job run-date information, Company Name, etc.  Detail-Rec: With the base information to be processed  Note that within the detail record, you might very well find additional REDEFINE fields  Trailer-Rec: With more balancing total amounts, etc  Here's an example  H01/01/2008|Acme Motor Corporation|…  D…………………………|……|…|…|……|………………|…|……|……  D…………………………|……|…|…|……|………………|…|……|……  …  T0908432|984320432|…………………………………………… And to process: READ IN-FILE INTO HEADER-REC. READ IN-FILE INTO HEADER-REC. … … IF Rec-Type = "H" IF Rec-Type = "H" … Perform Header Record Processing ELSE IF Rec-Type = "D" ELSE IF Rec-Type = "D" … Perform Detail Record Processing Else Else … Perform Trailer Record Processing WORKING-STORAGE SECTION. WORKING-STORAGE SECTION. … … 01 Header-Rec. 01 Header-Rec. 05 Rec-type PIC X(01). 05 Rec-type PIC X(01). 05 Date-In 05 Date-In PIC X(10). PIC X(10). 05 Company-Name-In PIC X(30). 05 Company-Name-In PIC X(30). 05 FILLER PIC X(269). 05 FILLER PIC X(269). 01 Detail-Rec REDEFINES Header-Rec. 01 Detail-Rec REDEFINES Header-Rec. 05 Field-1 PIC X(01). 05 Field-1 PIC X(01). 05 Field-2 05 Field-2 PIC X(10). PIC X(10). 05 Field-3 PIC X(30). 05 Field-3 PIC X(30). 05 Field-4 05 Field-4 PIC X(10). PIC X(10). 05 Field-5 PIC X(30). 05 Field-5 PIC X(30). … … 01 Trailer-Rec REDEFINES Detail-Rec. 01 Trailer-Rec REDEFINES Detail-Rec. 05 Rec-type PIC X(01). 05 Rec-type PIC X(01). 05 In-Rec-Count 05 In-Rec-Count PIC X(10). PIC X(10). 05 In-Rec-Trial-Balance PIC X(30). 05 In-Rec-Trial-Balance PIC X(30). 05 Filler PIC X(269). 05 Filler PIC X(269). … … [...]... do the following labs: 1 Data Representation and assignment (MOVE statement) Lab 2 Open ended workshop 11 Unit Additional Record and COBOL Table Handling Facilities Topics:  Additional Record Concepts  COBOL Tables – Definition and Language Concepts  Multi-Dimension COBOL Tables  Variable Length COBOL Tables  Searching COBOL Tables  Processing COBOL Tables With Intrinsic Functions 12 Topic Objectives... do the following labs: 1 Data Representation and assignment (MOVE statement) Lab 2 Open ended workshop 26 Unit Additional Record and COBOL Table Handling Facilities Topics:  Additional Record Concepts  COBOL Tables – Definition and Language Concepts  Multi-Dimension COBOL Tables  Variable Length COBOL Tables  Searching COBOL Tables  Processing COBOL Tables With Intrinsic Functions 27 Topic Objectives... inside the table (with the appropriate indices) … READ INPUT-FILE AT END MOVE 'Y' TO SW-END-OF-FILE END-PERFORM 33 Lab Assignment From the course workshop documents, do the following labs: 1 Data Representation and assignment (MOVE statement) Lab 2 Open ended workshop 34 Unit Additional Record and COBOL Table Handling Facilities Topics:  Additional Record Concepts  COBOL Tables – Definition and Language... in storage vertically  Table- Item-1 and Table- Item-2 are elementary data fields – that are repeated three times, as they are child variables of Table- Column 14 COBOL Tables – Overview  General information on COBOL tables:  Are one(1)-based in subscripts - not zero-based  The value within the parenthesis must be: > 0 and . Processing COBOL Tables With Intrinsic Functions Topics: Topics: Additional Record and COBOL Additional Record and COBOL Table Handling Facilities Table Handling Facilities 7 COBOL Records – Review. Z Intermediate COBOL Record and Table Handling Patterns Intermediate COBOL Record and Table Handling Patterns Jon Sayles, IBM Software Group, Rational EcoSystems Team 2 IBM Trademarks and Copyrights. installing and configuring RDz - and the course materials, and using Eclipse to edit COBOL  COBOL General Language Rules  Basic COBOL Statements  Additional record and table handling Additional record

Ngày đăng: 23/10/2014, 20:10

TỪ KHÓA LIÊN QUAN