IDMS Batch COBOL Programming

March 26, 2018 | Author: Anup Saravan | Category: Databases, Programmer, Sql, Relational Database, Software Engineering


Comments



Description

IDMS BATCH COBOL PROGRAMMINGby Neal Walters Amerisoft Inc. © 1998 Last Updated: November 17, 1998 This document is licensed for use by customers of the IDMS Tutorial program from Amerisoft Inc. Intended Audiences: 1) Batch COBOL Programmers 2) Or CICS/PL1 programmers who need an overview of Batch IDMS Programming Major Topics: 1) Details on how to code and maintain Batch COBOL IDMS programs 2) Brief overview of IDMS and DBMSs 3) How to compile programs 4) Testing and debugging techniques 5) Error Handling 6) DML Verbs To be used in conjunction with IDMS FUNDAMENTALS course book by Amerisoft Inc. email: [email protected] web site: http://www.amerisoftinc.com/mainframe.htm Table of Contents Overview of Network Databases ......................................................................................... 1 DBMS Overview ............................................................................................................. 1 Why a DBMS? ................................................................................................................ 1 IDMS and SQL ............................................................................................................... 2 IDMS Overview .............................................................................................................. 3 IDMS Schema or Bachman Diagram................................................................................ 4 DML - Data Manipulation Language ............................................................................... 5 Two useful Tools............................................................................................................. 6 CA/IDMS Manuals Relating to DML and COBOL: ......................................................... 6 The DML Precompiler......................................................................................................... 6 Precompiler Options ........................................................................................................ 7 Precompiler Directives..................................................................................................... 9 ENVIRONMENT DIVISION ..................................................................................... 9 DATA DIVISION: SCHEMA SECTION AND WORKING-STORAGE .................. 11 Figure 8 shows where the SCHEMA SECTION is added to the program, and how to copy IDMS records into the program......................................................................... 11 PROCEDURE DIVISION DECLARATIVES........................................................... 12 ERROR HANDLING........................................................................................................ 14 Autostatus vs Non-Autostatus ....................................................................................... 14 IDMS-STATUS Routine ............................................................................................... 17 MVS JOB LOG............................................................................................................. 19 The Program’s SYSOUT............................................................................................... 20 IDMS Error Status ........................................................................................................ 20 IDMS RETRIEVAL COMMANDS .................................................................................. 21 1) FIND/OBTAIN CALC/DUPLICATE........................................................................ 22 2) FIND/OBTAIN CURRENT and 6) FIND/OBTAIN NEXT WITHIN SET/AREA .... 24 3) FIND/OBTAIN DBKEY........................................................................................... 26 4) FIND/OBTAIN OWNER WITHIN set-name ............................................................ 27 5) FIND/OBTAIN WITHIN SET USING SORT KEY.................................................. 28 IDMS UPDATE COMMANDS ........................................................................................ 29 MODIFY EXAMPLE: .................................................................................................. 30 STORE EXAMPLE: ..................................................................................................... 31 ERASE COMMAND: ................................................................................................... 32 ERASE EXAMPLE ...................................................................................................... 33 CONNECT AND DISCONNECT................................................................................. 34 CONNECT EXAMPLE:............................................................................................ 35 DISCONNECT EXAMPLE: ..................................................................................... 35 OTHER REQUIRED COMMANDS:................................................................................ 36 The READY Command................................................................................................. 37 IDMS COBOL Programming by Neal Walters, Amerisoft Inc. © 1998 page ii Use by license agreement only. The COMMIT Command .............................................................................................. 38 The TWO BIND Commands.......................................................................................... 41 The FINISH and ROLLBACK Commands .................................................................... 42 IDMS Online Programming ............................................................................................... 43 IDMS Online Programming Overview ........................................................................... 43 Sample IDMS/DC Commands ....................................................................................... 44 Overview of ADS .......................................................................................................... 45 Overview of CICS ......................................................................................................... 46 Overview of IDMS/DC.................................................................................................. 46 Overview of Native VSAM............................................................................................ 46 Maintaining IDMS Programs ............................................................................................. 47 Files on CD/ROM.............................................................................................................. 49 IDMS COBOL Programming by Neal Walters, Amerisoft Inc. © 1998 page iii Use by license agreement only. Overview of Network Databases DBMS Overview A DBMS (Database Management System) is an advanced method of maintaining data. Many sites have left sequential and random files behind and develop all new systems under a DBMS. There are three types of DBMS: 1) relational (such as DB2/SQL or Oracle) 2) hierarchical (such as IMS) 3) network (such as IDMS) Relational database deal with “tables” where the COBOL program can issue SQL commands to select and join from various tables. Each table is similar to a flat file, and each “row” in the table is the same as a record in the flat file. A hierarchical database establishes a parent child relationship between records. A netwhork database is similar to a hierarchical database, but is more flexible in that the relationships can be more complex. For example, a child record can have more than one parent. Many companies adopted IDMS as the Database of choice in the 80s. Although in the late 90s, most companies are using relational databases, IDMS still has a strong foothold in major corporations around the world. If often costs millions of dollars to convert a system from one DBMS technology to another, so many companies continue to run older systems until they are obsolete or can be re-written. Other companies still believe that IDMS is a better choice than today’s relational alternatives. IDMS was originally marketed by a company called Cullinet, but is now sold and supported by Computer Associates. Why a DBMS? A DBMS typically has the following benefits over sequential and VSAM files: 1) centralized control often with a data dictionary or repository for the meta-data (i.e. the data about the data) and controlled by the database administration group 2) concurrent batch and online update and retrieval 3) improved recovery (backout or rollback procedures) 4) improved record locking to prevent simultaneous update of same record(s) and to allow programs to wait for a lock to be released - then continue execution. IDMS COBOL Programming by Neal Walters, Amerisoft Inc. © 1998 page 1 Use by license agreement only. IDMS and SQL With release 12.0 of IDMS, an SQL option became available as an extra-cost product. Since SQL is covered in another chapter of this book, IDMS/SQL will not be discussed in this chapter. One of the unique aspects of the IDMS/SQL option is that SQL can be used against either an IDMS/Relational database or an IDMS/Network database. Another advantage of the SQL option is the ODBC capability to download data to PCs or to access IDMS mainframe data on client server platforms. IDMS COBOL Programming by Neal Walters, Amerisoft Inc. © 1998 page 2 Use by license agreement only. IDMS records are stored in IDMS areas. A subschema is a smaller view of the schema that a COBOL program uses to access the database. but in the cases of large areas. Records are connected to each other via SETs. This is sometimes done on weekends to speed up long running batch jobs. usually the dbkey is divided by 256 to get the page number. and a child record is called a MEMBER. It is common to say that the test CV will come down at 9 pm and back up at 6 am. Some sites have different CVs for different applications. is assigned a DBKEY. one area may be mapped to a series of data set names. All online programs always run “under the CV. a maintenance CV. there is usually a Database Administration (DBA) group that is responsible for defining the databases (and for keeping the production databases well organized). IDMS programmer testing may be limited. a parent record is called an OWNER.thus preventing online and other batch jobs from concurrent update. when stored. It is also possible for one physical data set to contain several areas. Segments. In IDMS 12.0 and after. Some sites have one large global subschema. each of which has a physical page range. All database relationships are predefined in a schema. When dealing with IDMS. Usually. Running “under the CV” incurs typical DBMS overhead such as journalling.IDMS Overview In IDMS terminology. and update jobs run “under the CV” to allow for concurrent update and record locking. DBKEYs are referenced as an S9(8) COMP field in COBOL. © 1998 page 3 Use by license agreement only. for the sake of speed. several related areas are grouped together to form a SEGMENT. each area is mapped to one physical file (data set). Amerisoft Inc. and a production CV. Each IDMS record occurrence.” Most sites use the presence of a //SYSCTL JCL statement to indicate that the job is running “under the CV”. retrieval only jobs run in local-mode. which consists of the pagenumber and line-index (usually between 1 and 256). IDMS programs can run in local-mode or “under the CV. To convert this number to a page and line number. buffering. Usually. IDMS COBOL Programming by Neal Walters.” all database I/O is done by by the Central Version (one task running on the computer). a Y2K Conversion CV. or CV for short. this feature is seldom used because the areas must be varied out of update mode . while other sites have many small subschemas. and record-locking. When the IDMS CV is down. The page range and page size of each area determines how much space is available in any given area. buffering. While update jobs can be run in local mode. and journalling all defined in a DMCL (Device Media Control Language) created by the DBA. .) An IDMS system is called a Central Version. for instance a development CV.” When running “under the CV. and the remainder is the line number (see the sample IDMS programs on the CD/ROM for a program that converts DBKEYs from one format to another and gives full details. based on any logical key(s) in the record 2) VIA .records are physically stored near their owner record (this allows for extremely rapid access) 3) DIRECT . Amerisoft Inc. also called “Bachman” diagrams (after Charles Bachman.a randomly assigned “hash” key.IDMS Schema or Bachman Diagram Most IDMS sites publish a book or chart of schema diagrams. (This is the only figure in this document . . IDMS Schema Diagram (Employee Demo Database) **Insert figure here . IDMS records can be stored in three “location modes:” 1) CALC .1. or a specific dbkey can be provided and the record is stored at that location) ???Editor: I have asked Computer Associates for permission to reprint this schema diagram .) ** IDMS COBOL Programming by Neal Walters. A set relationship is shown by connecting two recordstogether. Figure 23. I do not have this diagram in computer format.this storage mode is most commonly used for audit trails (the record can be stored with the highest dbkey in the area.but have not yet received anything from them in writing.I am sending a photocopy of a diagram from a Computer Associates Manual. They should be in contact with Tracy Dunkelberger.all other examples are “listings”. Each IDMS record-type is illustrated by a box. © 1998 page 4 Use by license agreement only. All sets represent a one-to-many relationship (where the point of the arrow indicates the child relationship). one of the pioneers in database technology). PL/1 or even FORTRAN. With relational databases. A triangle symbol on a schema diagram represents an indexed set. IDMS COBOL Programming by Neal Walters. a program cannot issue a JOIN between two record types. the programmer just queries for the desired data. a copy of the IDMSRPTS utility is used with the schema diagram. DML . “STORE” and “ERASE.e.Data Manipulation Language IDMS databases are maintained by executing DML (Data Manipulation Language) commands. along with a full listing of all the elements in each record. There must be a pre-defined set relationship between the two record types (and this set relationship is drawn on the schema diagram). This report contain the same information that is on the diagram. 2) With IDMS. VIA. Variable.” The differences between DML and SQL show that there are two primary differences between an IDMS network database and a relational database: 1) With IDMS. it might be better to walk an index set when there are only 100 records in the database. This is a set that has a pre-defined sort key assigned. © 1998 page 5 Use by license agreement only. Indexes are used 1) as a rapid access entry point into the database based on a logical key value and 2) as a means of quickly displaying sorted data on an online retrieval transaction. a program’s DML navigation may become slower. as the metrics of an IDMS database change. Sometimes. Usually. Fixed Compressed. it might be faster to do an area sweep for the same records. For example. . DL=Duplicates Last) line 4 contains the physical AREA-NAME Some sites add the approximate record occurrence count on the fourth line. or DIRECT) line 3 contains the CALC key or VIA SET-NAME. DF=Duplicates First.FC. Thus. and the DBMS chooses the access logic. Variable Compressed the record length (in bytes) the location mode (CALC. the programmer chooses the his preferred database navigation strategy (which hopefully is the fastest). followed by the duplicates option (DN=Duplicates Not Allowed. The DML commands allow the programmer to “navigate” the database (using “OBTAIN” commmnds) and to make changes by issuing simple commands like “MODIFY”. Amerisoft Inc. the program’s runtime can be improved by changing the DML navigation path. Assembler. The same commands can be used from COBOL. all the set relationships are pre-defined. i.Each bachman record box consist of four lines: line 1 contains the record-name line 2 contains the record-id. F.VC for Fixed. This sometimes helps the programmer to create a faster navigation path. but when there are one million records.V. A sample JCL (Job Control Language) to execute the preprocessor.Two useful Tools Computer Associates (CA) has an additional-cost product called “DMLO” which stands for Data Manipulation Language Online. A competitor product called “DBOL” (Database Online) is sold by Allen Systems Group. Most programmers to do not need to understand the format of the “CALL ‘IDMS’”. also called the DML pre-processor. © 1998 page 6 Use by license agreement only. because the code is maintained in the high-level DML language. Figure 2 and Figure 3 show the DML code before and after expansion by the DML precompiler. These two products allow programmers to issue and practice DML commands online and interactively. . Note two things about this example: IDMS COBOL Programming by Neal Walters. Since “OBTAIN CALC” is not recognized by COBOL. and the linkage editor can be found in file COMPJCL on the CD/ROM that accompanies this book. Amerisoft Inc. the COBOL compiler. converts high-level DML (Data Manipulation Language) statements to standard COBOL calls to the appropriate IDMS subroutine. the DML Precompiler converts this statement to a “CALL ‘IDMS’” statement with the appropriate using parameters. A programmer often uses these products for the following purposes: 1) to test a DML navigation path before writing a COBOL program 2) to help debug a COBOL program by verifying DML navigation or values of fields in a database CA/IDMS Manuals Relating to DML and COBOL: Bookname in IBM/READER CAIDDMLC CAIDNDML CAIDMSG Order Number R005/&F0CBE R005/&F0NPE R005/&F0M1E R005/&F0M2E R005/&F0M3E R005/&F0M4E RC05/&F0PQE Manual Name CA-IDMS DML Reference COBOL CA-IDMS DML Navigational DML Programming CA-IDMS Messages and Codes (Volumes 1 through 4) CAIDQPRG CA-IDMS Programming Quick Reference Figure 1 -Recommended IDMS Manuals for COBOL Programmers The DML Precompiler The DML Precompiler. *RETRIEVAL *DMLIST *NODMLIST NOTE: These three lines are standard COBOL comments (the asterisk should begin in column 7). This DML-SEQUENCE number is displayed in the IDMS ERRORSTATUS routine. Amerisoft Inc. the DML-SEQUENCE number is used to identify which IDMS DML VERB caused the problem. if the program fails with a bad IDMS STATUS.1) The “OBTAIN CALC” statement remains in the program.Code Submitted to DML Preprocessor 000332 000333 000334 000335 000336 000337 000338 000339 000340 000341 000342 000343 000344 000345 000346 000347 1000-OBTAIN-EMPLOYEE. IF DB-REC-NOT-FOUND PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT ELSE PERFORM IDMS-STATUS PERFORM 1200-EMP-FOUND THRU 1200-EXIT END-IF . 028400 028500 028600 028800 028900 029000 029010 029100 029200 029300 029400 1000-OBTAIN-EMPLOYEE. 1000-EXIT. © 1998 page 7 Use by license agreement only. 1000-EXIT. MOVE '123456789' TO EMPLOYEE-NUM * OBTAIN CALC EMPLOYEE-REC MOVE 4 TO DML-SEQUENCE CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (32) SR2001 IDBMSCOM (43). Figure 2 . but is commented out 2) A unique DML-SEQUENCE number is assigned to each CALL to IDMS. IDMS COBOL Programming by Neal Walters. EXIT. Figure 3 . thus.Code as Output from the DML Preprocessor Precompiler Options PRECOMPILER OPTIONS tell the precompiler how to do its work. EXIT. MOVE '123456789' TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT ELSE PERFORM IDMS-STATUS PERFORM 1200-EMP-FOUND THRU 1200-EXIT END-IF . . 14. This can be both a blessing and curse. This information is available within the online task “IDD” or by running a batch IDD job.A feature of the DML PRECOMPILER is that it can update the IDMS Integrated Data Dictionary (IDD) each time the program is compiled. This is often done by your compile PROC which concatenates a one line member IDMS COBOL Programming by Neal Walters. ADD RECORD NAME IS EMPLOYEE-REC VERSION IS 1 RECORD NAME SYNONYM IS EMPLOYEE-REC VERSION 1 *+ COPIED INTO PROGRAM DBATDEMO VERSION 1 . © 1998 page 8 Use by license agreement only. ADD PROGRAM NAME IS DBATDEMO VERSION IS 1 *+ DATE CREATED IS 04/14/98 *+ DATE LAST COMPILED IS 04/14/98 *+ NUMBER OF TIMES COMPILED IS 1 PUBLIC ACCESS IS ALLOWED FOR ALL ESTIMATED LINES ARE 339 PROGRAM CALLED IS IDMS VERSION IS 1 PROGRAM CALLED IS IDMSERR1 VERSION IS 1 PROGRAM CALLED IS ABORT VERSION IS 1 MODULE USED IDMS-STATUS VERSION IS 11 LANGUAGE IS COBOL RECORD COPIED SUBSCHEMA-CTRL VERSION IS 2 RECORD COPIED EMPLOYEE-REC VERSION IS 1 RECORD COPIED DB-STATISTICS VERSION IS 1 SUBSCHEMA IS DBATSS01 OF SCHEMA DBATSC01 VERSION IS 1 AREA DBATEST1-AREA READIED FOR UPDATE RECORD EMPLOYEE-REC BIND RECORD EMPLOYEE-REC OBTAIN MODE IS BATCH LANGUAGE IS COBOL . or a Librarian Scan for Librarian). . Figure 5 . many sites disable the auto-update of the dictionary by including the “*RETRIEVAL” command at the top of each program. The disadvantage is that large programs can create a large number of record locks on the dictionary.IDD “Display Record” Most cross reference information can be also be obtained by scanning the source code (using TSO/ISPF 3. PANSCAN for Panvalet. Figure 4 . Figure 4 shows a sample of program information that is automatically stored in IDD by the precompiler. Therefore. The advantage is that detailed information about the program will be automatically documented in the dictionary. Amerisoft Inc.IDD “Display Program” Figure 5 shows how the IDD can also cross-references records back to programs: DIS REC EMPLOYEE-REC WITH PROGRAMS AS SYN. causing other IDD users and other program precompiles to slow down or to ABEND with deadlocks. DIS PROG DBATDEMO AS SYN. or CICS-AUTOSTATUS. IDMS-CONTROL SECTION. . the precompiler can run for several minutes. FILE-CONTROL.that contains just the line “*RETRIEVAL”. MODE IS BATCH DEBUG IDMS-RECORDS MANUAL. The *DMLIST or *NODMLIST option specifies that the source listing it to be displayed as output from the preprocessor. or DC-BATCH for programs that run in batch but require DC services such as “GET QUEUE”. Figure 6 . specify IDMSDC for online programs (programs that will use IDMS services such as MAPIN/MAPOUT). SELECT INPUT1-FILE ASSIGN TO INPUT1. NOTE: The precompiler runs vary fast for small subschemas. Amerisoft Inc. the errors typically point to the line number of the error. An advantage of running in RETRIEVAL mode is that the program can run in local mode rather than CV mode. The default is “*NODMLIST”.Precompiler/Environment Division In place of the word “BATCH” (in the above figure). and with *NODMLIST is can be difficult to find the error. A listing of error messages is always produced. but when a subschema contains 50 or 100 or 150 records. IDMS COBOL Programming by Neal Walters. However. Precompiler Directives PRECOMPILER DIRECTIVES also affect the way the DML PRECOMPILER works. © 1998 page 9 Use by license agreement only. ENVIRONMENT DIVISION The first required directive is the IDMS-CONTROL SECTION in the ENVIRONMENT DIVISION and is shown in Figure 6. PROTOCOL. 008700 008800 009000 009100 009200 009300 009400 009500 ENVIRONMENT DIVISION. INPUT-OUTPUT SECTION. and causes the DML-SEQUENCE numbers to be generated for each DML VERB. but may be inappropriate for larger subschemas. Amerisoft Inc. Instead. Some sites may also have defined their own customized “modes. This works fine for small subschemas. READ TERMINAL. if “IDMS RECORDS WITHIN WORKING-STORAGE” is specified. © 1998 page 10 Use by license agreement only. .” BATCH BATCH-AUTOSTATUS CICS CICS-AUTOSTATUS DC-BATCH IDMS-DC Typical batch program Typical batch program with AUTOSTATUS on Typical CICS program Typical CICS program with AUTOSTATUS on For batch programs that need some typically online services such as GET QUEUE or PUT QUEUE. The “IDMS RECORDS MANUAL” clause specifies that the program will manually include the required “COPY IDMS” statements in the WORKING-STORAGE or LINKAGE SECTION. then all records in the entire subschema will automatically be copied into the program.There are several common modes listed below. Check with the DBA or reference manual for a complete listing. For online IDMS programs that will use IDMS services such as MAP IN.Common Modes The word DEBUG is optional (but almost always used). or GET QUEUE Figure 7 . IDMS COBOL Programming by Neal Walters. MAP OUT. The AUTOSTATUS protocols are discussed in the next section on ERRORHANDLING. SUBSCHEMASETNAMES. COPY IDMS DB-STATISTICS.Precompiler/Data Division The SCHEMA SECTION simply identifies the name of the schema and subschema. Amerisoft Inc. This information is extremely useful for debugging and/or improving performance of a program. IDMS COBOL Programming by Neal Walters. FD INPUT1-FILE LABEL RECORDS ARE STANDARD BLOCK CONTAINS 0 RECORDS. COPY IDMS RECORD EMPLOYEE-REC. and SUBSCHEMA-AREANAMES. COPY IDMS SUBSCHEMA-CONTROL. . DB DBATSS01 WITHIN DBATSC01. and “COPY IDMS record” statements do not need to be coded. Every program must include these. 01 INPUT1-REC PIC X(80).DATA DIVISION: SCHEMA SECTION AND WORKING-STORAGE Figure 8 shows where the SCHEMA SECTION is added to the program. © 1998 page 11 Use by license agreement only. SCHEMA SECTION. WORKING-STORAGE SECTION. Figure 8 . DB-STATISTICS is a optional record used with the “ACCEPT STATISTICS” command. as they are used in the “CALL ‘IDMS’” statements. The “SUBSCHEMA-CONTROL” is actually a special code word for four record-names: SUBSCHEMA-CTRL. “COPY IDMS” statements are used to build the required record layouts from the data dictionary (IDD). then all subschema records are automatically copied. 010000 010100 010200 010300 010400 010500 010600 010700 011000 011100 011200 011300 011400 011500 011600 DATA DIVISION FILE SECTION. SUBSCHEMA-RECNAMES. and how to copy IDMS records into the program. Many programs ACCEPT and display the IDMS statistics at the end of the program. (If the “IDMS RECORDS WITHIN WORKING-TORAGE” clause was used. In the WORKING-STORAGE section. Each source program can only access one schema (a called subroutine can be used to access data from a different schema). 025800 025900 026000 026100 026200 026300 026400 026700 026710 028000 028100 0500-INITIALIZE. EXIT.PROCEDURE DIVISION DECLARATIVES Figure 9 and Figure 10 show how and where the “COPY IDMS SUBSCHEMA-BINDS” (the first listing is before the DML precompiler. Figure 9 . Amerisoft Inc. ACCEPT TODAYS-DATE FROM DATE. ACCEPT TODAYS-TIME FROM TIME. the second listing is after the expansion by the precompiler). . DISPLAY 'START: DBATDEMO . 0500-EXIT.RELOAD AUDHST-RECS ' DISPLAY 'DATE = ' TODAYS-DATE ' TIME = ' TODAYS-TIME. © 1998 page 12 Use by license agreement only. COPY IDMS SUBSCHEMA-BINDS.Precompiler Directives in the Procedure Division IDMS COBOL Programming by Neal Walters. and much of the database navigation is done by the subschema instead of the COBOL IDMS COBOL Programming by Neal Walters. ACCEPT TODAYS-TIME FROM TIME. © 1998 page 13 Use by license agreement only. NOTE: Some sites make use of Logical Record Facility (LRF) which results in several changes to this information in this section. DISPLAY 'START: DBATDEMO . Amerisoft Inc. Special processing logic is actually coded in the subschema. .Same after Precompiler Expansion The “COPY IDMS SUBSCHEMA-BINDS” accomplishes three things: 1) The program-name from the PROGRAM-ID statement is moved to a field called “PROGRAM-NAME”. * * COPY IDMS SUBSCHEMA-BINDS. ACCEPT TODAYS-DATE FROM DATE. special return-codes can be set.RELOAD AUDHST-RECS ' DISPLAY 'DATE = ' TODAYS-DATE ' TIME = ' TODAYS-TIME. EXIT. BIND JOB-REC MOVE 2 TO DML-SEQUENCE CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (48) SR2003 JOB-REC. 2) The “BIND RUN UNIT” statement is generated 3) A “BIND RECORD” statement is generated for each database record (either each record in the subschema or each record included into the program with “COPY IDMS” statements). MOVE 3 TO DML-SEQUENCE CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (48) SR2001 EMPLOYEE-REC. BIND EMPLOYEE-REC. This is useful to the DBA when monitoring the system.where a logical record consists of one or more physical records. 0500-EXIT. This COPY statement does NOT generate a READY statement for each database area. MOVE 'DBATDEMO' TO PROGRAM-NAME BIND RUN-UNIT MOVE 1 TO DML-SEQUENCE CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (59) SUBSCHEMA-CTRL SUBSCHEMA-SSNAME.0500-INITIALIZE. * * Figure 10 . LRF allows the DBA or programmers to create logical records in the subschema . an ERROR-STATUS of 0326 or DB-REC-NOTFOUND is common when doing an OBTAIN CALC DML command.” This causes the precompiler to automatically generate a “PERFORM IDMS-STATUS” statement after each DML command. The definition of these 88-levels is available in Figure 15. Thus. 028400 028500 028600 028700 028800 028900 029000 029100 029200 1000-OBTAIN-EMPLOYEE. . because if a programmer forgets to check the ERROR-STATUS and the program keeps running.program. ERROR HANDLING Autostatus vs Non-Autostatus Note that some modes (see Figure 7) contain the word “AUTOSTATUS. MOVE '123456789' TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC ON DB-REC-NOT-FOUND PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT .Sample OBTAIN with AUTOSTATUS IDMS COBOL Programming by Neal Walters. Any site using LRF should have special instructions available for its unique implementation. Some people prefer AUTOSTATUS. Figure 11 . and Figure 12 shows the same code after it is expanded by the DML precompiler. Use of AUTOSTATUS requires coding an “ON” statement for any “allowable” errors. then logic errors occur which can be difficult to debug. Some people prefer not using AUTOSTATUS because the code looks cleaner. It is a matter of a site’s coding standards or a programmer’s own personal preference as to whether autostatus is used. There are several COBOL 88-level working-storage variables defined for the most common IDMS error codes. Figure 11 shows a program coded to use AUTOSTATUS. 1000-EXIT. © 1998 page 14 Use by license agreement only. PERFORM 1200-EMP-FOUND THRU 1200-EXIT . Amerisoft Inc. the programmer must code one “ON error” statement for each anticipated status. For instance. EXIT. when using AUTOSTATUS. 1000-EXIT. Figure 14 . The programmer should code the appropriate “PERFORM IDMS-STATUS” after each DML verb (after checking for any normally expected errors . Figure 13 . IF DB-ANY-ERROR PERFORM IDMS-STATUS. PERFORM 1200-EMP-FOUND THRU 1200-EXIT . Figure 12 . PERFORM IDMS-STATUS PERFORM 1200-EMP-FOUND THRU 1200-EXIT . 1000-EXIT.Obtain with NON-AUTOSTATUS Some programmers will CODE a variation of the Figure 13 as shown in Figure 14(note the addition of line 28910). . 028400 028500 028600 028700 028800 028900 028950 029000 029100 029200 1000-OBTAIN-EMPLOYEE. Amerisoft Inc. This avoids performing the IDMS-STATUS paragraph unless needed but results in two lines of code error-checking code instead of one. 028400 028500 028600 028700 028800 028900 028910 028950 029000 029100 029200 1000-OBTAIN-EMPLOYEE. EXIT. EXIT. MOVE '123456789' TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT . © 1998 page 15 Use by license agreement only. MOVE '123456789' TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT . ELSE PERFORM 1100-EMP-NOT-FOUND THRU 1100-EXIT . PERFORM 1200-EMP-FOUND THRU 1200-EXIT . Note the addition of line 28950.Same after precompiler expansion Figure 13 shows the same code as Figure 12 when not using AUTOSTATUS.The above code gets translated to the following 000336 000337 000338 000339 000340 000341 000342 000343 000344 000345 000346 000347 000348 000349 000350 000351 1000-OBTAIN-EMPLOYEE.Alternative Coding IDMS COBOL Programming by Neal Walters. EXIT. 1000-EXIT.such as the DB-REC-NOT-FOUND condition). MOVE '123456789' TO EMPLOYEE-NUM * OBTAIN CALC EMPLOYEE-REC * ON DB-REC-NOT-FOUND MOVE 4 TO DML-SEQUENCE CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (32) SR2001 IDBMSCOM (43) IF NOT DB-REC-NOT-FOUND PERFORM IDMS-STATUS. Amerisoft Inc. ANY-STATUS VALUE ' ' THRU '9999'. © 1998 page 16 Use by license agreement only. ANY-ERROR-STATUS VALUE '0001' THRU '9999'. 01 SUBSCHEMA-CTRL. 03 PROGRAM-NAME 03 ERROR-STATUS 88 88 88 88 88 03 DBKEY PIC X(8) VALUE SPACES. PIC S9(8) COMP SYNC. . DB-STATUS-OK VALUE '0000'. Figure 15 . DB-END-OF-SET VALUE '0307'.*COPY IDMS SUBSCHEMA-CONTROL. DB-REC-NOT-FOUND VALUE '0326'.Error-Status and 88-levels IDMS COBOL Programming by Neal Walters. PIC X(4) VALUE '1400'. This occurs IDMS COBOL Programming by Neal Walters. ****************************************************************** IDMS-STATUS.' ERROR-RECORD DISPLAY 'ERROR SET --------. An example of an anticipated error is 0326 or DB-REC-NOT-FOUND. * ROLLBACK CALL 'IDMS' USING SUBSCHEMA-CTRL IDBMSCOM (67) IF ANY-ERROR-STATUS DISPLAY 'ROLLBACK FAILED WITH STATUS=' ERROR-STATUS DISPLAY 'ROLLBACK FAILED WITH STATUS=' ERROR-STATUS UPON CONSOLE END-IF CALL 'ABORT' . *COPY IDMS IDMS-STATUS. The IDMS-STATUS routine should be performed after each DML Verb after checking for anticipated errors.' ERROR-AREA DISPLAY 'LAST GOOD RECORD -. © 1998 page 17 Use by license agreement only.IDMS-STATUS Routine Figure 16 shows the common code that is copied into all batch IDMS programs. A site may have custom tailored this routine to provide additional functionality. The code itself is stored on the data dictionary (IDD) as a module with source code. ' ERROR-RECORD ' **** RECOVER IDMS ****' UPON CONSOLE DISPLAY 'PROGRAM NAME -----. . ' ERROR-STATUS '.CHANGED "ROLLBACK" * TO A HARD-CODED CALL . EXIT. Amerisoft Inc. IDMS-ABORT-EXIT.' ERROR-STATUS DISPLAY 'ERROR RECORD -----. The CALL ‘ABORT’ statement results in the U2222 Abend as shown in Figure 16.TO AVOID "AUTOSTATUS" * ADDING A "PERFORM IDMS-STATUS" AFTER THE ROLLBACK COMMAND * AND THUS CREATING AN ENDLESS LOOP IN THIS PARAGRAPH * (WHICH WOULD NOW FLOOD THE CONSOLE WITH THE IDMSERR1 MESSAGES. IF NOT DB-STATUS-OK PERFORM IDMS-ABORT DISPLAY '**************************' ' ABORTING .' PROGRAM-NAME '.' ERROR-SET DISPLAY 'ERROR AREA -------. Your site may have made minor modifications to this code. IDMS-ABORT SECTION. ************************ V 33 BATCH-AUTOSTATUS ******************* *IDMS-STATUS-PARAGRAPH.' PROGRAM-NAME DISPLAY 'ERROR STATUS -----.' AREA-NAME DISPLAY 'DML SEQUENCE--------' DML-SEQUENCE * IN-HOUSE CUSTOMIZATION . Figure 16 .' RRECORD-NAME DISPLAY 'LAST GOOD AREA ---. and the appropriate one is copied from the IDD based on the “MODE IS” clause of the PROTOCOL statement.IDMS-STATUS Paragraph There are several versions of the IDMS-STATUS routine. Amerisoft Inc. In the case of an U2222 ABEND. © 1998 page 18 Use by license agreement only. the program will ABORT with a U2222 (also called a USER 2222 ABEND). the programmer must look at the DISPLAY statements found in the //SYSOUT and the job log.which means that the IDMS/Central Version went down . If there is an unexpected error. . IDMS COBOL Programming by Neal Walters.frequently and the program should handle such an error.and thus the program cannot continue. An example of an unexpected error might be an 0069 or 1469 . 45 SEQ=04261 CPU=0000 ASID=0031 PSW AT TIME OF ERROR 078D1000 851000DE ILC 2 INTC 0D ACTIVE LOAD MODULE ADDRESS=05100080 OFFSET=0000 NAME=IDMSCANC DATA AT PSW 051000D8 .46 JOB05801 + It is described by a corresponding IEA995I message.46 JOB05801 + incomplete.TIME=10.15. JULY $HASP373 NRWDTSTE STARTED .TESTERR1.Errors in MVS Job Log IDMS COBOL Programming by Neal Walters.16.16.TIME=10.16.00181610 0A0D1814 0A0D0700 GPR 0-3 80000000 800008AE 0000CB08 00006D60 GPR 4-7 000008AE 0004B298 051000B4 851000A4 GPR 8-11 80012BE0 0000A6A0 0004ACC0 851000A4 GPR 12-15 80012662 0004AFE8 80012BDE 00000000 END OF SYMPTOM DUMP 10.16.16.JES2 JOB STATISTICS -----31 JUL 1996 JOB EXECUTION DATE 379 CARDS READ Figure 17 .16.38 10. The job log on MVS would look something like this: J E S 2 J O B L O G -.16.002 75085AA 8000XXXA TIM 10.15. 10.CLASS N .46 JOB05801 +IGZ043I A 'SYSABOUT' error occurred.46 JOB05801 *END STEP STEP01 OF NRWDTSTE TIME 10:16 **** ABEND U2222 10.16.46 10.16.46 JOB05801 IEF450I NRWDTSTE STEP01 .46 JOB05801 JOB05801 JOB05801 JOB05801 JOB05801 JOB05801 JOB05801 JOB05801 -N O D IRR010I USERID USERID1 IS ASSIGNED TO THIS JOB.38 10.16.46 JOB05801 +IGZ057I An ABEND was intercepted by the COBOL run-time ABEN 10.ENDED .38 +IDMS DB347011 dbname XXXXXXXX invalid . The ABEND information 10.16. 10.16.46 10. +IDMS RUN-UNIT CANCELLED DUE TO PROGRAM REQUEST IEA995I SYMPTOM DUMP OUTPUT USER COMPLETION CODE=2222 TIME=10.16. .16.15.STARTED .38 10. © 1998 page 19 Use by license agreement only.16.46 10. Amerisoft Inc. The key error messages are highlighted in bold.15.ABEND=S000 U2222 REASON=00000000 TIME=10.16.46 JOB05801 JOB NRWDTSTE END DATE 96.46 JOB05801 IEF404I NRWDTSTE .16.45 10.INIT 12 .46 JOB05801 $HASP395 NRWDTSTE ENDED -----.SYS ABCD IEF403I NRWDTSTE .46 JOB05801 IEC130I SYSABOUT DD STATEMENT MISSING 10. 1477.37 10.15.46 10.S Y S T E M G S L P 10. ICH70001I USERID1 LAST ACCESS AT 10:13:47 ON WEDNESDAY.binding subschema is +************************** ABORTING .MVS JOB LOG Figure 17 shows the MVS output of a batch job with a U2222 ABEND.213 CPU 0. Figure 18 . 09=READY).0301 ERROR RECORD -----. Amerisoft Inc.EMPLOYEE-REC ERROR SET --------ERROR AREA -------.TESTERR1 ERROR STATUS -----.The Program’s SYSOUT A sample listing of the //SYSOUT appears in Figure 18. such as 26=RECORD NOT FOUND. 66=AREA NOT AVAILABLE). IDMS COBOL Programming by Neal Walters. PROGRAM NAME -----. The minor code indicates the problem. . The IDMS manuals (seeFigure 1) should be consulted for a full explanation of each error code. The first two bytes are the major code and the last two bytes are the minor code. . © 1998 page 20 Use by license agreement only. The major code always indicates the verb number (for example 03=OBTAIN.Errors in Program’s //SYSOUT IDMS Error Status The IDMS Error-Status is a four byte code.USER-AREA-NAME LAST GOOD RECORD -LAST GOOD AREA ---DML SEQUENCE--------0000000008 . IDMS RETRIEVAL COMMANDS There are three retrieval commands: FIND. 95% of programmers use only the OBTAIN command. A FIND command sets database currency and retrieves the data. Amerisoft Inc. but does not put the data into the COBOL’s working-storage records. There are six formats of the FIND/OBTAIN command: 1) 2) 3) 4) 5) 6) FIND/OBTAIN FIND/OBTAIN FIND/OBTAIN FIND/OBTAIN FIND/OBTAIN FIND/OBTAIN CALC/DUPLICATE CURRENT DBKEY OWNER WITHIN set-name WITHIN SET USING SORT KEY WITHIN SET/AREA Database currency refers to the where the program is positioned in the database. GET. and simply moves the data from the IDMS buffer space to the designated record-name in the COBOL’s workingstorage. © 1998 page 21 Use by license agreement only. There are four types of currency: 1) 2) 3) 4) Database Currency (one only) Area Currency (one for each area) Record Currency (one for each record) Set Currency (one for each set) When a command like “OBTAIN NEXT WITHIN ABC-AREA” is issued. IDMS COBOL Programming by Neal Walters. Likewise. the set currency for the “XYZ-SET” is used to obtain the next record in the set. a programmer will just do a FIND in order to save small amount of computer time. . A GET presumes that a FIND command has already been done. Unfortunately. and OBTAIN. this topic deserves an entire chapter to itself. A completed sample IDMS retrieval program can be found in file EMPDEMO1 on the CD/ROM that accompanies this book. because an OBTAIN does a FIND plus a GET. the area currency for area “ABC-AREA” is used to obtain the next record in the area. when a command like “OBTAIN NEXT WITHIN XYZ-SET” is issued. Occasionally. Beginning programmers can easily get lost when navigating a database if they lack a good understanding of database currency. A typical scenario would be an EMPLOYEE-RECORD where the CALC KEY might be EMPLOYEE-NUM or EMP-SOCIAL-SECURITY-NUM. © 1998 page 22 Use by license agreement only.OBTAIN CALC Example Duplicates are rare on CALC KEYS. OBTAIN CALC EMPLOYEE-REC DUPLICATE. Amerisoft Inc. . 1000-GET-EMPLOYEE. but if the CALC record was defined as “DUPLICATES FIRST” or “DUPLICATES LAST” the program can continue to get the remaining records with the same CALC KEY by performing a loop. EXIT. EXIT. 2100-EXIT. EXIT.but it might consists of several noncontiguous field-names. IF NOT DB-REC-NOT-FOUND PERFORM IDMS-STATUS PERFORM 2100-DISPLAY-RESULT THRU 2100-EXIT . A record can have only one CALC KEY . Figure 20 .OBTAIN CALC DUPLICATE Example IDMS COBOL Programming by Neal Walters. MOVE '123456789' TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC PERFORM IDMS-STATUS PERFORM 2100-DISPLAY-RESULT THRU 2100-EXIT PERFORM 2000-GET-DUP-EMPLOYEES THRU 2000-EXIT UNTIL DB-REC-NOT-FOUND. 1000-EXIT. 2100-DISPLAY-NAME. 2000-EXIT. MOVE ‘123456789’ TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND DISPLAY ‘ EMPLOYEE-NUM=’ EMPLOYEE-NUM ‘ WAS NOT FOUND’ ELSE PERFORM IDMS-STATUS DISPLAY ‘ EMPLOYEE-NUM=’ EMPLOYEE-NUM ‘ EMPLOYEE-NAME=’ EMPLOYEE-NAME END-IF Figure 19 . Figure 19 shows a code fragment that demonstrates this command. the fastest way to retrieve that record is to OBTAIN it by using its CALC key. 2000-GET-DUP-EMPLOYEES. Figure 20 shows a code fragment that demonstrates this command.1) FIND/OBTAIN CALC/DUPLICATE If a record is stored with location-mode of CALC. IF DB-REC-NOT-FOUND DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘WAS NOT FOUND’ ELSE DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ EMPLOYEE-NAME=‘ EMPLOYEE-NAME END-IF. IDMS COBOL Programming by Neal Walters. © 1998 page 23 Use by license agreement only. . Amerisoft Inc. The FIND/OBTAIN CURRENT is used to reposition database currency back to a prior location.” This process might also be called an extract job. If the program is not careful. the fastest way to retrieve all of a certain record type from the database is to do an “AREA SWEEP. this could cause the program to omit records in an extract. © 1998 page 24 Use by license agreement only. . or to go into a loop re-reading the same series of records over-and-over. the program is obtains the owner record and then processes each member of the set. and then performing the “OBTAIN NEXT” command until the DB-END-OF-SET condition is reached. looking for the next EMPLOYEE-REC. This is very common when sweeping a database for record-1 while then walking a set for record-2. Amerisoft Inc. the “OBTAIN NEXT EMPLOYEE-REC WITHIN AREA” statement will start from the currency of area. and go forward in the area.2) FIND/OBTAIN CURRENT and 6) FIND/OBTAIN NEXT WITHIN SET/AREA The FIND/OBTAIN NEXT command is used to get the first or next record in the area or set. If the current database position is not on the last EMPLOYEE-REC. it can “lose currency”. For example. If the database area is over 50% full.” Usually. This involves getting the FIRST record in the area. The FIND/OBTAIN NEXT WITHIN SET is used to “walk a set. The following code fragment demonstrates the following: 2) FIND/OBTAIN CURRENT 6) FIND/OBTAIN NEXT WITHIN SET and AREA IDMS COBOL Programming by Neal Walters. Figure 21 shows a code fragment that demonstrates these commands. Notes: options: 1) 2) 3) 4) 5) desired Figure 21 . Amerisoft Inc. 1000-GET-EMPLOYEE. IF RECORD-COUNT = 0 OBTAIN FIRST EMPLOYEE-REC WITHIN EMPLOYEE-AREA ELSE OBTAIN NEXT EMPLOYEE-REC WITHIN EMPLOYEE-AREA END-IF IF DB-END-OF-SET GO TO 2000-EXIT END-IF PERFORM IDMS-STATUS PERFORM 3000-GET-NEXT-JOBHIST THRU 3000-EXIT UNTIL DB-ANY-ERROR. © 1998 page 25 Use by license agreement only.OBTAIN CURRENT & OBTAIN NEXT Example With the OBTAIN WITHIN SET/AREA command. OBTAIN NEXT JOBHIST WITHIN EMP-JOBHIST IF NOT DB-END-OF-SET PERFORM 4000-WRITE-OUT-DATA THRU 4000-EXIT END-IF . 2000-GET-NEXT-EMPLOYEE. . 3000-GET-NEXT-JOBHIST. MOVE ZERO TO RECORD-COUNT PERFORM 2000-GET-NEXT-EMPLOYEE THRU 2000-EXIT UNTIL DB-END-OF-SET. FIND CURRENT EMPLOYEE-REC PERFORM IDMS-STATUS . EXIT. there are five OBTAIN FIRST OBTAIN NEXT OBTAIN LAST OBTAIN PRIOR OBTAIN ws-number where ws-number is the Nth record (this option is rarely used) IDMS COBOL Programming by Neal Walters. *SET CURRENCY BACK TO LAST EMPLOYEE-REC *THE “FIND” IS USED INSTEAD OF THE “OBTAIN” BECAUSE THE PROGRAM *IS NO LONGER INTERESTED IN THE DATA FROM THAT RECORD. 3000-EXIT. 2000-EXIT. EXIT. 1000-EXIT. EXIT. 3) FIND/OBTAIN DBKEY The FIND/OBTAIN DBKEY command is used to retrieve a record based on a dbkey that was saved from a prior retrieval of that record. and occasionally a different computation must be used. and require special processing to convert to page/line number 2) 99% of all databases are defined to allow 255 records per page. © 1998 page 26 Use by license agreement only. and thus can be used in a MOVE statement in lieu of an “ACCEPT” command.123:49 2) cobol number 50. IDMS COBOL Programming by Neal Walters. and thus the number 256 is used in converting dbkeys to page-line numbers. because IDMS will only have to do one I/O.for example: 50. Therefore it is unwise to save dbkeys in sequential files for processing that will occur more than a few hours later in the same day.123 and X’31’ converts to 49).123 * 256 + 49) for example: 12831537 (which equals In 3) hex . Amerisoft Inc. ADVANCED NOTES on DBKEYs: 1) large dbkeys over 8.388. . This field always contains the value of the dbkey of the last database record accessed. WARNING: If the database administrator reorgs or re-sizes the physical database. then all the dbkeys will change. DBKEYs can be displayed three different ways: 1) page:line-number . TIP: A DBKEY consists of a page-number and a line-number.608 will appear as negative numbers in an S9(8) COMP field. COBOL it is defined as an S9(8) COMP field. This is the fastest possible way to retrieve a record.for example: 00C3CB31 (where X’00C3CB’ converts to 50. 3) There is a field called DBKEY in the SUBSCHEMA-CTRL record. The database administrator has the power to change the radix of the dbkey. this can cause bad program logic and make debugging difficult.IF setname MEMBER Example IDMS COBOL Programming by Neal Walters. Figure 23 shows a code fragment that demonstrates this command.) (or MOVE DBKEY TO WS-SAVE-DBKEY) . which saves the current DBKEY into a working-storage variable. this gives a site the flexibility to change the set options without having to worry about having to re-code programs. Thus. NOTE: The dbkey can also be saved by doing a move of the field “DBKEY” in the SUBSCHEMA-CTRL to a working-storage variable. . Technically. but by always coding the “IF MEMBER”. * * * ACCEPT WS-SAVE-DBKEY FROM CURRENCY. IF EMPLOYEE-JOBHIST MEMBER OBTAIN OWNER WITHIN EMPLOYEE-JOBHIST DISPLAY ‘OWNER-EMPLOYEE-NUM=‘ EMPLOYEE-NUM ELSE DISPLAY ‘WARNING: JOBHIST IS NOT A MEMBER OF EMPLOYEE-JOBHIST’ END-IF Figure 23 . Figure 22 . .The FIND/OBTAIN DBKEY is almost useless without the ACCEPT DBKEY statement.OBTAIN DBKEY Example 4) FIND/OBTAIN OWNER WITHIN set-name The FIND/OBTAIN OWNER command allows the programmer to navigate up a hierarchy by moving from a member (child) record to its owner (or parent). © 1998 page 27 Use by license agreement only. Although an OBTAIN OWNER statement may be coded with checking for ownership first. PERFORM IDMS-STATUS (or ACCEPT WS-SAVE-DBKEY FROM EMPLOYEE-REC CURRENCY. . this is only needed for OPTIONAL sets. OBTAIN EMPLOYEE-REC DBKEY IS WS-SAVE-DBKEY. Figure 22 shows a code fragment that demonstrates this command. it should be a standard procedure to always use the “IF MEMBER” statement first. 77 WS-SAVE-DBKEY PIC S9(8) COMP. . the program has already obtained a JOBHIST record and needs to OBTAIN the owner EMPLOYEE-REC within the EMPLOYEE-JOBHIST set. For the following example. . misc other processing here . Amerisoft Inc. PERFORM IDMS-STATUS. MOVE ‘123456789’ TO WS-SEARCH-EMP-NUM * NOTE: THE EMPLOYEE DEMO-DATABASE IS NOT Y2K COMPLIANT MOVE ‘970501’ TO WS-SEARCH-DATE MOVE WS-SEARCH-EMP-NUM TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ WAS NOT FOUND’ ELSE PERFORM IDMS-STATUS DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ EMPLOYEE-NAME=‘ EMPLOYEE-NAME MOVE WS-SEARCH-DATE TO START-DATE OBTAIN JOBHIST WITHIN EMPLOYEE-JOBHIST USING START-DATE IF DB-REC-NOT-FOUND DISPLAY ‘NO JOBHIST FOUND FOR DATE=‘ START-DATE ELSE DISPLAY ‘START DATE=‘ START-DATE ‘ JOB-TITLE=‘ JOB-TITLE END-IF END-IF Figure 24 . the START-DATE is the day that the employee began working on a certain job.OBTAIN USING sortkey Example IDMS COBOL Programming by Neal Walters. Amerisoft Inc. For example.5) FIND/OBTAIN WITHIN SET USING SORT KEY The FIND/OBTAIN WITHIN SET USING SORT KEY is used when a sortedset is available. In other words. suppose EMPLOYEE-JOBHIST set is sorted by START-DATE. and the program is aware of the value of the sort-key of a desired member-record. © 1998 page 28 Use by license agreement only. . Suppose the query is: “What job did employee 123456789 start on the date of 19970501? Figure 24 shows a code fragment that demonstrates this command. the program can change the values of the fields in the record. the program can use this command to ERASE (delete) the record from the database Used to connect a database record to an optional set Used to disconnect a database record from an optional set Figure 25 . MODIFY After OBTAINING a record. the program can use this command to STORE (add) a new record to the database After OBTAINING a record. and then use this command to MODIFY (replace) the record in the database After setting the working-storage values for a record. Amerisoft Inc.IDMS Update Commands STORE ERASE CONNECT DISCONNECT IDMS COBOL Programming by Neal Walters. . © 1998 page 29 Use by license agreement only.IDMS UPDATE COMMANDS Figure 25 shows the five simple commands used to update an IDMS database. © 1998 page 30 Use by license agreement only.MODIFY Example IDMS COBOL Programming by Neal Walters.MODIFY EXAMPLE: Figure 26 shows a code fragment that demonstrates the MODIFY command. Amerisoft Inc. . MOVE ‘123456789’ TO WS-SEARCH-EMP-NUM MOVE ‘JONES’ TO WS-NEW-LAST-NAME MOVE WS-SEARCH-EMP-NUM TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ WAS NOT FOUND’ ELSE PERFORM IDMS-STATUS MOVE EMPLOYEE-LAST-NAME TO WS-OLD-LAST-NAME MOVE WS-NEW-LAST-NAME TO EMPLOYEE-LAST-NAME MODIFY EMPLOYEE-REC PERFORM IDMS-STATUS DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ LAST-NAME CHANGED FROM: ‘ ‘ TO: ‘ EMPLOYEE-LAST-NAME END-IF Figure 26 . STORE EXAMPLE: Figure 27 shows a code fragment that demonstrates the STORE command. see Figure 30 and Figure 31). © 1998 page 31 Use by license agreement only. then you must be current on the owner record in that set.STORE Example Note: If you attempt to store a child record (into a Mandatory Automatic set. IDMS COBOL Programming by Neal Walters. . If no record is current. Amerisoft Inc. you will get error-status 1225. INITIALIZE EMPLOYEE-REC MOVE ‘1231231234’ TO EMPLOYEE-NUM MOVE ‘JONES’ TO EMPLOYEE-LAST-NAME MOVE ‘JOHN’ TO EMPLOYEE-FIRST-NAME STORE EMPLOYEE-REC PERFORM IDMS-STATUS Figure 27 . IDMS will automatically connect the member record to the current owner record. ERASE will fail). 1) ERASE record-name Erases only the specified record (but if record has children. The “IF MEMBER” statement and the ERASE command are illustrated in Figure 29. Erases the specified record and all mandatory member records Erases the specified record and all optional member records Erases the specified record and all mandatory and optional member records 2) ERASE record-name PERMANENT MEMBERS 3) ERASE record-name SELECTIVE MEMBERS 4) ERASE record-name ALL MEMBERS Figure 28 . Amerisoft Inc. © 1998 page 32 Use by license agreement only. before attempting an ERASE.Erase Sub-Options NOTE: When dealing with a database that has a hierarchical structure (Record A owns B owns C owns D). When dealing with a record that is not the owner of any set. This can be done with the “IF MEMBER” command. It is often practical to check for members. and the EMPLOYEEJOBHIST set is not empty. all members records below (including C and D) might also be erased. . These options provide flexibility and safety for deleting OWNER records.ERASE COMMAND: The ERASE command has four options (shown in Figure 28). the simplest option (#1 below) may be used. If the “ERASE EMPLOYEE-REC” command is used. when the top record in the hierarchy is erased. the program get an IDMS ERRORSTATUS=0230 (an attempt has been made to erase the owner record of a non-empty set). depending on the ERASE options specified. IDMS COBOL Programming by Neal Walters. . © 1998 page 33 Use by license agreement only. Amerisoft Inc.ERASE EXAMPLE MOVE WS-SEARCH-EMP-NUM TO EMPLOYEE-NUM OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM ‘ WAS NOT FOUND’ ELSE PERFORM IDMS-STATUS DISPLAY ‘ EMPLOYEE-NUM=‘ EMPLOYEE-NUM IF EMPLOYEE-JOBHIST NOT EMPTY DISPLAY ‘CANNOT ERASE UNTIL MEMBERS ARE DELETED’ ELSE ERASE EMPLOYEE-REC PERFORM IDMS-STATUS END-IF END-IF Figure 29 .ERASE Example IDMS COBOL Programming by Neal Walters. © 1998 page 34 Use by license agreement only. An example of the CONNECT verb is shown in Figure 32. OPTIONAL Figure 30 .Second Set Option The CONNECT command can be executed on any record that is not connected to its owner by the set relationship. A program may never do a CONNECT or DISCONNECT on when the set options are MandatoryAutomatic (MA).First Set Option AUTOMATIC The member record will automatically be connected to the set when the member record is stored. IDMS COBOL Programming by Neal Walters. These options always come in a pair. . This can either be a record that was STORED and never connected (OM or MM set options). MM. or a record that had been disconnected by the DISCONNECT command (OA or OM) set options. and two possible values for the second part of the pair. Amerisoft Inc. OM. MANUAL Figure 31 . It is important to understand the meaning of these set options. where there are two possible values for the first of the pair. The member record will not be connected to the set when the member record is stored. The four combinations of set options are usually abbreviated by their initials (MA. The member record can be disconnected from the set. These sets option are explained in the following in figures (Figure 30 and Figure 31).CONNECT AND DISCONNECT The CONNECT and DISCONNECT commands are used less frequently than the other IDMS update commands. MANDATORY The member record cannot be disconnect from the set and therefore the DISCONNECT command NOT allowed. The majority of IDMS sets are “MANDATORY AUTOMATIC”. OA). CONNECT Example It is common for a member record to be disconnect from one owner and then reconnected immediately to another owner. A record that is disconnected from one owner but not reconnected to another owner is sometimes called an ORPHAN record.DISCONNECT Example IDMS COBOL Programming by Neal Walters.CONNECT EXAMPLE: IF NOT EMPLOYEE-JOBHIST MEMBER CONNECT JOBHIST TO EMPLOYEE-JOBHIST PERFORM IDMS-STATUS END-IF Figure 32 . An example of the DISCONNECT verb is shown in Figure 33. Amerisoft Inc. © 1998 page 35 Use by license agreement only. DISCONNECT EXAMPLE: DISCONNECT JOBHIST FROM EMPLOYEE-JOBHIST PERFORM IDMS-STATUS Figure 33 . . Indicates that all database updates are final and releases all update (exclusive) locks.Other Required Commands IDMS COBOL Programming by Neal Walters.OTHER REQUIRED COMMANDS: A few other commands are important to COBOL programmers.specifies an area of working storage to be used for retrieving and updating each database record FINISH ROLLBACK Indicates that all database updates are final and ends the run-unit Indicates that all database updates since the start of the program or the last commit (which ever is most recent) should be reversed or rolled-out and the rununit is ended. They are the READY. Two formats: 1) BIND RUN-UNIT . but does NOT end the run-unit. FINISH. . Amerisoft Inc. COMMIT Figure 34 . although they neither retrieve data or store data. ROLLBACK and COMMIT commands.establishes a run-unit with IDMS 2) BIND RECORD . © 1998 page 36 Use by license agreement only. BIND. A brief summary of each command is shown in Figure 34. READY BIND Used to READY IDMS-AREAs in retrieval or update mode. Amerisoft Inc. © 1998 page 37 Use by license agreement only. . Once the program starts. If area is readied in RETRIEVAL mode. IDMS COBOL Programming by Neal Walters. The READY AREA statement is extremely useful in production job scheduling. IDMS will return the ‘xx29’ errorstatus causing one of the two programs to ABEND. because they limit the ability of other programs to run concurrently against the same IDMS AREAs. This lock is released when the program does a COMMIT or when the run unit terminates (via either a ROLLBACK or FINISH). any updates against that area will fail. This reduces locking and contention. The format of the READY statement is: READY area-name USAGE-MODE IS PROTECTED/EXCLUSIVE RETRIEVAL/UPDATE.The READY Command The READY command deals with the program’s intentions as to how an IDMS AREA is to be used. a SCAN utility is often run against the COBOL source code to identify the how each program readies each IDMS-AREA. But. When an IDMS program readies an area in update mode. PROTECTED UPDATE has one main advantage. any other program that attempts to READY the same AREA in UPDATE mode will fail with an IDMS ERROR-STATUS = 0966. the job schedulers needs to know if two programs can run at the same time. This lock is released when another record of the same record-name is retrieved. Usually the PROTECTED and EXCLUSIVE options are omitted. program-B will go into a DBKEY WAIT. To understand deadlocks. it avoids deadlocks. when two programs tend to use the same data records. When the condition arises that program-A needs a record locked by program-B. If two programs access different data in the same area there is no problem. It is wise to READY each area in the lowest possible READY mode. Typically. Any record that is updated has an UPDATE lock (also called EXCLUSIVE lock) turned on. every record retrieved has a SELECT lock (also called INQUIRE lock)turned on. and program-B needs a record that is locked by program-A a DEADLOCK occurs. IDMS locking must be understood. Thus. “PROTECTED UPDATE” indicates that this program will be the only program allowed to update the AREA. performance usually decreases because one program will go into WAIT until the lock is freed by the other program. or if the Database Administrator can run a re-org job against AREA-X while program B is running on a weekend. When program-B requests a record that program-A has locked. © 1998 page 38 Use by license agreement only. 1000-EXIT. then 300 records have been written to the database. PIC S9(4) COMP VALUE ZERO. Figure 35 . A program typically has a record-update counter. 8000-EXIT. PIC S9(4) COMP VALUE +100. MOVE ZERO TO WS-COMMIT-COUNTER. the program could be restarted and could simply IDMS COBOL Programming by Neal Walters. Amerisoft Inc. . PERFORM 1000-UPDATE-LOOP THRU 1000-EXIT UNTIL WS-YN-INPUT1-EOF = ‘Y’ DISPLAY ‘NUMBER OF UPDATES=‘ WS-UPDATE-COUNTER. VALUE ZERO. 8000-COMMIT. EXIT. and when that counter reaches a certain point. EXIT. the program performs a commit.The COMMIT Command Deadlocks can often be avoided by increasing the COMMIT frequency. READ INPUT1-FILE AT END MOVE ‘Y’ TO WS-YN-INPUT1-EOF GO TO 1000-EXIT END-READ MOVE INPUT1-EMP-ID TO EMPLOYEE-EMP-ID OBTAIN CALC EMPLOYEE-REC IF DB-REC-NOT-FOUND DISPLAY ‘RECORD NOT FOUND EMP-ID=‘ INPUT1-EMP-ID GO TO 1000-EXIT END-IF PERFORM IDMS-STATUS MOVE INPUT1-LAST-NAME TO EMPLOYEE-LAST-NAME MODIFY EMPLOYEE-REC PERFORM IDMS-STATUS ADD 1 TO WS-UPDATE-COUNTER ADD 1 TO WS-COMMIT-COUNTER IF WS-COMMIT-COUNTER NOT < WS-COMMIT-FREQ PERFORM 8000-COMMIT THRU 8000-EXIT END-IF . the above program is incomplete because it does not handle the case of an ABEND and restart logic. Figure 35 shows how to code COMMIT frequency logic in an update program: *THIS PROGRAM READS A SEQUENTIAL FILE CONTAINING *AN EMPLOYEE-ID AND A CHANGE TO THE EMPLOYEE’S LAST-NAME. 03 03 03 WS-UPDATE-COUNTER WS-COMMIT-COUNTER WS-COMMIT-FREQ PIC S9(4) COMP. COMMIT. What happens? Since the commit counter is set for every 100 records. In the case of a simple MODIFY-only program as shown above.COMMIT Frequency Example However. 1000-UPDATE-LOOP. PERFORM IDMS-STATUS. Suppose there are 500 records on the input file and that the program ABENDs when processing record #325. This could be done by adding logic as shown in Figure 36. COMMIT. This means that the program must save the current record counter each time it does a commit. The second approach is more elegant . However. A complete sample IDMS update program with commit and restart logic can be found in file EMPDEMO2 on the CD/ROM that accompanies this book. EXIT. OPEN OUTPUT COMMIT1-FILE. 8000-COMMIT. © 1998 page 39 Use by license agreement only. 8000-EXIT. Figure 36 . MOVE WS-UPDATE-COUNTER TO COMMIT1-UPDATE-COUNTER. and begin it’s STORE logic right where it left off. then the restart logic becomes more difficult. WRITE COMMIT1-REC CLOSE COMMIT1-FILE. Amerisoft Inc. .reprocess all 500 records. MOVE ZERO TO WS-COMMIT-COUNTER. *THIS TECHNIQUE ASSUMES THAT THE COMMIT1-FILE EXISTS *AND THAT DISP=SHR IS SPECIFIED IN THE MAINFRAME MVS *JCL (JOB CONTROL LANGUAGE). if the program was storing records instead of modifying them. The program could be changed in two ways: 1) The program could check to see if each record existed and only STORE new records 2) The program could “spin past” the first 300 records. at record #301 (realizing that records #301 thru #325 were rolled-out when the program ABENDed). PERFORM IDMS-STATUS.COMMIT Example (UPDATE-COUNTER is saved) IDMS COBOL Programming by Neal Walters.but also is more difficult to code. 8500-EXIT. By opening and closing the file each time. Figure 37 . which is shown in Figure 37. 8510-SKIP-INPUT1-REC. EXIT. Amerisoft Inc. 8510-EXIT. CLOSE COMMIT1-FILE. READ INPUT1-FILE AT END MOVE ‘Y’ TO WS-YN-INPUT1-EOF DISPLAY ‘8510: ERROR //INPUT1 EOF ON RESTART’ MOVE 16 TO RETURN-CODE STOP RUN END-READ. it also needs restart logic. Now that the program saves this counter.The program now writes the update-counter to a sequential file. . 8500-CHECK-RESTART. OPEN INPUT COMMIT1-FILE. OPEN INPUT INPUT1-FILE PERFORM 8500-CHECK-RESTART THRU 8500-EXIT. 0000-INIT.COMMIT/Restart Example IDMS COBOL Programming by Neal Walters. © 1998 page 40 Use by license agreement only. the last record written is overlaid. PERFORM 1000-UPDATE-LOOP THRU 1000-EXIT UNTIL WS-YN-INPUT1-EOF = ‘Y’ DISPLAY ‘NUMBER OF UPDATES=‘ WS-UPDATE-COUNTER. READ COMMIT1-FILE AT END MOVE ‘Y’ TO WS-YN-COMMIT1-EOF END-READ IF WS-YN-COMMIT1-EOF = ‘Y’ DISPLAY ‘8500 NO RESTART REQUIRED’ ELSE DISPLAY ‘8500 RESTARTING AT UPDATE-COUNTER=’ COMMIT1-UPDATE-COUNTER PERFORM 8510-SKIP-INPUT1-REC THRU 8510-EXIT COMMIT1-UPDATE-COUNTER TIMES MOVE COMMIT1-UPDATE-COUNTER TO WS-UPDATE-COUNTER END-IF. EXIT. PERFORM IDMS-STATUS. The following precompiler directive builds the ‘BIND RUN-UNIT’ statement and a BIND for each record-type. READY ORG-DEMO-REGION USAGE-MODE RETRIEVAL. IDMS COBOL Programming by Neal Walters. © 1998 page 41 Use by license agreement only. But with 12. Amerisoft Inc. (DBNAMEs allow the same program to run against different copies of the same database.0. This is often called segmentation or segmented databases. This ensures that you get the proper error as soon as possible.) There must be one BIND record statement issued for each record that the program will access. A run-unit is an IDMS term that describes a program that has issued a BIND but has not yet issued a FINISH or ROLLBACK. the DBNAME is usually specified external to the program in the //SYSIDMS file.0 of IDMS. If the precompiler directive “COPY SUBSCHEMA BINDS” (Figure 8) is not used. .The TWO BIND Commands The BIND RUN-UNIT statement is used to establish a run-unit. although the data in each database would be entirely different. your BINDs AND READYs could be coded as shown in Figure 38. A run-unit establishes communication with the IDMS database server and creates all necessary control blocks to communicate with IDMS. Prior to release 12. Each BIND record statement provides addressability to the COBOL working-storage section for each record-layout. COPY IDMS SUBSCHEMA-BINDS. This statement was previously discussed in the precompiler directives section (seeFigure 9). sites using multiple DBNAMEs would code the DBNAME on the BIND RUN-UNIT statement. rather than getting a misleading error later. PERFORM IDMS-STATUS. BIND RUN-UNIT PERFORM IDMS-STATUS BIND JOB PERFORM IDMS-STATUS BIND EMPOSITION PERFORM IDMS-STATUS BIND EMPLOYEE PERFORM IDMS-STATUS READY EMP-DEMO-REGION USAGE-MODE RETRIEVAL. For example.BIND Example NOTE: It is always wise to do the “PERFORM IDMS-STATUS” after each statement. a USA Payroll database and a CANADA Payroll database could be maintained by the same programs. Figure 38 . before and after images are also written to the IDMS journal files. and it cannot do any further DML commands (resulting in a bad error-status such as nn77). IDMS COBOL Programming by Neal Walters. If the program ABENDs or issues the ROLLBACK command. it is likely that the program did not include the FINISH statement. . After the program does a FINISH or ROLLBACK. As IDMS updates are written to the actual database files. these journal images are used to reverse the changes made to the actual database.The FINISH and ROLLBACK Commands The FINISH command is used to complete the IDMS RUN-UNIT and to make permanent all the changes to the database (since the last COMMIT). a ROLLBACK is assumed (however. © 1998 page 42 Use by license agreement only. Thus if a programmer runs a test program and then discovers that the updates did not happen. If the program fails to include either a FINISH or ROLLBACK. the run-unit is terminated. Amerisoft Inc. the DML Precompiler will issue a warning). IBM’s Customer Information System 3) IDMS/DC . Amerisoft Inc. Literals and database variables are presented on the terminal and the application end-users use function keys.IDMS Online Programming IDMS Online Programming Overview Online programming involves creating screens (called maps) that allow COBOL programs to communicate with mainframe 3270 terminals (or PC programs that emulate 3270 terminals). but also can be done in line mode. Online programming is usually done in full-screen (mapping) mode. transaction codes. Online programming involves skills above and beyond batch COBOL programming. . IDMS COBOL Programming by Neal Walters. The four most common means of writing online programs for IDMS databases are: 1) ADS . IDMS full-screen maps are created in an IDMS task called MAPC (Mapping Compiler for IDMS 12.for IDMS pre 12.IDMS TP Commands 4) TSO/ISPF Panels IDMS also includes DC (Data Communications) or Teleprocessing capabilities (sometimes called a TP/Monitor). This allows IDMS online programs using interactive screens to access or update an IDMS database. © 1998 page 43 Use by license agreement only. and/or menus to access the desired programs and data.0 releases).IDMS Application Development System 2) CICS . CICS Maps are created with a language called BMS Basic Mapping Support.0 and after) or OLM (Online Mapping . Amerisoft Inc. IDMS software called Universal Communication Facility (UCF) allows IDMS/DC programs to run under CICS. © 1998 page 44 Use by license agreement only. . IDMS COBOL Programming by Neal Walters. READ LINE FROM TERMINAL READ TERMINAL OTHER DC Commands: SET TIMER SEND MESSAGE SNAP STARTPAGE WAIT ENQUEUE/DEQUEUE POST GET QUEUE/PUT QUEUE GET SCRATCH/PUT SCRATCH These DC commands allows IDMS/DC programs to do most anything that CICS programs can do.Sample IDMS/DC Commands Sample IDMS DC commands include: FULL-SCREEN: MAP IN MAP OUT MAP OUTIN INQUIRE MAP LINE-MODE: WRITE LINE TO TERMINAL. or a site might run IDMS/DC and not use CICS at all. ADS is rarely used for batch reporting. © 1998 page 45 Use by license agreement only. An ADSO program is called a dialog. Amerisoft Inc. ADSO programs are typically built online using the Application Generation and Application Compiler. ADS programs are written as module text and stored on the IDMS Integrated Data Dictionary (IDD). IDMS COBOL Programming by Neal Walters. which usually consists of a map. Online Query (OLQ/BATCH). ADSO programmers usually have access to create work records and elements on the IDD. or fourth generation language (4GL) report-writers such as FOCUS. or Easytrieve-Plus. most sites choose COBOL. a subschema. and several response processes.Overview of ADS ADS is a separate product and an entire programming language but one that is totally integrated with IDMS. . one premap process. Many sites have adopted it as their primary online development system. Data-Analyzer. but ADS also has batch capabilities (ADS/Batch). SAS. CULPRIT. ADS is often referred to as ADSO (ADS/Online). PROTOCOL. IDMS-CONTROL SECTION. as shown in Figure 39. and the end-users want a consistent method of accessing data. Figure 40 . An online IDMS/DC program is designated by specifying a proper mode statement in the ENVIRONMENT DIVISION as shown in Figure 40. Amerisoft Inc. Figure 39 . IDMS-CONTROL SECTION. IDMS COBOL Programming by Neal Walters. MODE IS CICS-AUTOSTATUS IDMS-RECORDS MANUAL. MODE IS IDMS-DC IDMS-RECORDS MANUAL. 009200 009300 009400 009500 ENVIRONMENT DIVISION. A CICS/IDMS program is designed by specifying a proper mode statement in the ENVIRONMENT DIVISION. 009200 009300 009400 009500 ENVIRONMENT DIVISION.CICS “MODE IS” Example Some sites use only CICS to create online programs (instead of IDMS/DC or ADS) for the following reasons: 1) CICS programmers might be easier to find and/or the company has a larger base of CICS experience 2) Other in-house programs use CICS/VSAM or sophisticated CICS menuing systems. . PROTOCOL.IDMS/DC “MODE IS” Example Overview of Native VSAM Native VSAM files can be defined to IDMS schemas so that an IDMS/DC or IDMS/Batch program can read or update a VSAM file using DML commands. © 1998 page 46 Use by license agreement only.Overview of CICS CICS programs using CICS command level language and go through a CICS precompiler in addition to the DML precompiler. Overview of IDMS/DC IDMS/DC programs use the same DML precompiler as batch programs. 1) Management Issues Management usually works with the customer to determine what changes must be made. . Often there is a large list of changes which the customer must prioritize.Maintaining IDMS Programs Once an IDMS system is implemented. Suppose the change is to add a PIC X(2) STATUS-CODE to the EMPLOYEE-REC. or if the program code must be changed. the programmer/analysts do research to identify the amount of effort and the number of programs that must be changed. 3) Coordinating Record Structure Changes and Schema Changes with the DBA Typically. Some sites require change control paperwork or the approval of a Quality Control group. months before such a change is made. when a database record must be changed. Someone must create a list of all the effected programs and determine if they need a simple recompile. © 1998 page 47 Use by license agreement only. IDMS has some unique aspects for maintaining the programs. getting the paperwork signed-off can be more challenging than the COBOL program changes. Usually senior programmers work with the DBA to migrate programs from a test system to the production system immediately after these changes are made. 2) Program migration Usually each site has a unique set of procedures for migrating programs from the test environment to the production environment (often using an intermediate staging or quality assurance environment). it is the job of the DBA (database administrator) to run the appropriate restructure utilities. Amerisoft Inc. It is not unusual to have a one to three year backlog of changes. Usually. IDMS COBOL Programming by Neal Walters. In some cases. Most sites recompile the program at some point in this process. but now it runs in four hours. Index sets also need to be reorganized frequently.4) Program Documentation If a report or an online screen is changed. Amerisoft Inc. This is commonly done when database areas approach 70% full. © 1998 page 48 Use by license agreement only. the DBA will reorganize database for the sake of efficiency. he usually performs them late nights or weekends. Perhaps a batch program ran in one hour the first six months in the life of the system. Since the DBA must take the databases offline when making his changes. with the coordination of the production job schedulers. which no longer satisfactory for the nightly batch window. IDMS COBOL Programming by Neal Walters. Perhaps the DML navigation path of program can be changed to make the program run faster. . 6) Preventative Maintenance Frequently. Perhaps an index can be added to the database to make the program run faster. The DBA will also install maintenance and new releases of IDMS software and coordinate the implementation with the programming staff. is there a manual that must be changed? Are there any changes to the customer procedures that will be required before the program is migrated? Is it appropriate to hold a training class before implementing the change? 5) Performance and Tuning Many program changes are made in an effort to make programs run faster. or upon areas where there are abnormally high number of changes. This is used to clean up the database so that EMPDEMO2 can be run again without getting duplicates. those employees added by program EMPDEMO2).Sample update program that deletes all employees with EMP-ID between 1000 and 2000 (i. so the restart logic can be demonstrated in the next step. 4) XMPDEMO1 .JCL demonstrate delete program EMPDEMO3 7) COMPJCL . 6) XMPDEMO3 .Sample JCL for DML Preprocessor and COBOL Compile and link.JCL and INPUT data to demonstrate EMPDEMO2. 3) EMPDEMO3 .PRINTOUT OF EXECUTION . reads sequential file containing OFFICE-CODE.EXECUTION JCL . 8) PMPDEMO1 .Sample update program.from EMPDEMO1 9) PMPDEMO2 . DEPT-ID.Files on CD/ROM 1) EMPDEMO1 . This program has complete COMMIT and restart logic.PRINTOUT OF EXECUTION .Sample report program that reads sequential file and creates detailed employee/job-history report for each employee-id specified 2) EMPDEMO2 . JCL comments explain what each step does.EXECUTION JCL . EMPLAST-NAME.e.Job Control Language (JCL) and INPUT data to demonstrate report program EMPDEMO1 5) XMPDEMO2 . and EMP-FIRST-NAME and stores on database. .EXECUTION JCL .from EMPDEMO2 IDMS COBOL Programming by Neal Walters.EXECUTION JCL . EMP-ID. JCL is set up to cause an ABEND after x records are processed. This program also write a zero counter to the COMMIT file. Amerisoft Inc.COBOL SOURCE . Check with your site for actual COBOL JCL or compile PROC to be used.COBOL SOURCE . © 1998 page 49 Use by license agreement only.COBOL SOURCE .
Copyright © 2024 DOKUMEN.SITE Inc.