62
What are the differences between JES2 & JES3 ? JES3 allocates datasets for all the steps before the job is scheduled. In JES2, allocation of datasets required by a step are done only just before the step executes. JES3 = Job Entry Subsystem 3 An MVS subsystem that receives jobs into the system,converts them to internal format, selects them for execution, processes their output, and purges them from the system. In complexes that have several loosely coupled processing units, the JES3 program manages processors so that the global processor exercises centralized control over the local processors and distributes jobs to them via a common job queue. JES2 = Job Entry Subsystem 2 An MVS subsystem that receives jobs into the system, converts them to internal format, selects them for execution, processes their output, and purges them from the system. In an installation with more than one processor, each processor's JES2 subsystem independently controls job input, scheduling, and output processing. Some principle differences between the two JES systems include: In a mainframe installation that has only one processor, JES3 provides tape setup, dependent job control, and deadline scheduling for users of the system, while JES2 in the same system would require its users to manage these activities through other means. In an installation with a multiprocessor configuration, there are noticeable differences between the two, mainly in how JES2 exercises independent control over its job processing functions. That is, within the configuration, each JES2 processor controls its own job input, job scheduling, and job output processing. In cases where multiple z/OS® systems are clustered (a sysplex), it is possible to configure JES2 to share spool and checkpoint data sets with other JES2 systems in the same sysplex. This configuration is called Multi-Access Spool (MAS). In contrast, JES3 exercises centralized control over its processing 1

Imp Mainframe Question

Embed Size (px)

Citation preview

Page 1: Imp Mainframe Question

What are the differences between JES2 & JES3 ?

JES3 allocates datasets for all the steps before the job is scheduled. In JES2, allocation of datasets required by a step are done only just before the step executes.

JES3 = Job Entry Subsystem 3

An MVS subsystem that receives jobs into the system,converts them to internal format, selects them for execution, processes their output, and purges them from the system. In complexes that have several loosely coupled processing units, the JES3 program manages processors so that the global processor exercises centralized control over the local processors and distributes jobs to them via a common job queue.

JES2 = Job Entry Subsystem 2

An MVS subsystem that receives jobs into the system, converts them to internal format, selects them for

execution, processes their output, and purges them from the system. In an installation with more than one processor, each processor's JES2 subsystem independently controls job input, scheduling, and output processing.

Some principle differences between the two JES systems include:

In a mainframe installation that has only one processor, JES3 provides tape setup, dependent job control, and deadline scheduling for users of the system, while JES2 in the same system would require its users to manage these activities through other means. In an installation with a multiprocessor configuration, there are noticeable differences between the two, mainly in how JES2 exercises independent control over its job processing functions. That is, within the configuration, each JES2 processor controls its own job input, job scheduling, and job output processing. In cases where multiple z/OS® systems are clustered (a sysplex), it is possible to configure JES2 to share spool and checkpoint data sets with other JES2 systems in the same sysplex. This configuration is called Multi-Access Spool (MAS). In contrast, JES3 exercises centralized control over its processing functions through a single global JES3 processor. This global processor provides all job selection, scheduling, and device allocation functions for all of the other JES3 systems. With JES3, installations may decide whether the global JES3 or z/OS base control program will handle device allocation. With JES2, only the z/OS base control program handles device allocation.

what is the difference between plan and package? why package is not a executable?

what is the advantages of the paln and disadvantages of the packages?

1

Page 2: Imp Mainframe Question

package cantains one r more DBRMs.packages are obtained by passing DBRMs through bindpackage.package ia not executable because it does not contain any acess path. plan is obtained by binding DBRMs r packages.plan is executable as it contains the acess path.

it is advantageous to use packages because

it reduces the cost of bind

it reduces rebound time

if there r modifications in the sub program its just enough to crete a package 4 that sub pgm.

lock options and various bind options can b controlled even in the subpgm level itself.

If you've 5 programs, you create 5 distinct PACKAGEs and then club them together using a PLAN. So, in your case, you will have to update (re-bind) the PACKAGE that represents the changed program and your PLAN will automatically take the latest one.

You don't have to rebind the other unchanged programs.

Creating a package versionIf you want to run different versions of a program without needing to make changes to the associated application plan, use package versions. This technique is useful if you need to make changes to your program without causing an interruption to the availability of the program.

You can create a different package version for each version of the program. Each package has the same package name and collection name, but a different version number is associated with each package. The plan that includes that package includes all versions of that package. Thus, you can run a program that is associated with any one of the package versions without having to rebind the application plan, rename the plan, or change any RUN subcommands that use it.

To create a package version:

1. Precompile your program with the option VERSION( version-identifier). 2. Bind the resulting DBRM with the same collection name and package name as any

existing versions of that package. When you run the program, DB2® uses the package version that you specified when you precompiled it.

Example: Suppose that you bound a plan with the following statement: BIND PLAN (PLAN1) PKLIST (COLLECT.*)The following steps show how to create two versions of a package, one for each of two programs.

2

Page 3: Imp Mainframe Question

Step number For package version 1 For package version 2

1 Precompile program 1. Specify VERSION(1).

Precompile program version 2. Specify VERSION(2).

2 Bind the DBRM with the collection name COLLECT and the package name PACKA.

Bind the DBRM with the collection name COLLECT and package name PACKA.

3 Link-edit program 1 into your application.

Link-edit program 2 into your application.

4 Run the application; it uses program 1 and PACKA, VERSION 1.

Run the application; it uses program 2 and PACKA, VERSION 2.

How DB2 identifies packages at run timeThe DB2® precompiler or DB2 coprocessor identifies each call to DB2 with a consistency token. The same consistency token identifies the DBRM that the SQL statement processor produces and the plan or package to which you bound the DBRM.

When you run the program, DB2 uses the consistency token in matching the call to DB2 to the correct DBRM. Usually, the consistency token is in an internal DB2 format. You can override that token if you want.

You also need other identifiers. The consistency token alone uniquely identifies a DBRM that is bound directly to a plan, but it does not necessarily identify a unique package. When you bind DBRMs directly to a particular plan, you bind each one only once. But you can bind the same DBRM to many packages, at different locations and in different collections, and then you can include all those packages in the package list of the same plan. All those packages will have the same consistency token. You can specify a particular location or a particular collection at run time.

what is the purpose of //systsin dd *

3

Page 4: Imp Mainframe Question

It's the DD name used by TSO to enter in-stream TSO commands. The reason you see it in DB2 jobs is that IBM uses TSO as one of the techniques for running DB2 jobs in batch mode.

in the IKTEF01 utility (terminal monitor program) for bind,run a COBOL-DB2 Program,we use this card

//BIND EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(4,LT) //STEPLIB DD DSN=DSN710.SDSNLOAD,DISP=SHR //DBRMLIB DD DSN=E02619.DBRMLIB,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSPRINT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DSNY) BIND PLAN(DB2PROG)- MEMBER(PROG1) - ACT(REP) - LIB('E02619.DBRMLIB') - ISOLATION(CS) /*

The SYSTSIN DD statement is used to specify that the data to follow consists of executable commands and/or subcommands. For example, to indicate to the system that all data following this statement is to be used as input, until the system encounters an input delimiter, such as the characters /* or the DLM operand, specify:

//SYSTSIN DD *

If any of the input statements start with the characters //, use the DD DATA statement instead.

To indicate to the system that all data following this statement is to be used as input, including statements that start with the characters //, until an input delimiter (/* or DLM) is found, specify:

//SYSTSIN DD DATA

To indicate to the system that all the input data can be found in data set PREFIX.INPUT.DATA, specify:

//SYSTSIN DD DSNAME=PREFIX.INPUT.DATA

4

Page 5: Imp Mainframe Question

SYSTSIN DD StatementThe SYSTSIN and SYSTSPRT DD statements can refer to a sequential data set or a member of a partitioned data set. It is recommended that the SYSTSIN DD be defined as a fixed block format data set, with an LRECL of 80.If SYSTSIN is a fixed length data set (FB), the last 8 bytes of the record will be treated as a sequence number and ignored.If SYSTSIN is a fixed length data set with ASA control characters (FBA), the first byte of the record will be treated as a carriage control character and ignored.If SYSTSIN is a variable length data set (VB), the first 8 bytes of the record will be treated as a sequence number and ignored.If SYSTSIN is a variable length data set with ASA control characters (VBA), the first 9 bytes of the record will be treated as a sequence number, followed by a carriage control character and ignored.You cannot refer to concatenated data sets on the SYSTSIN DD statement. Each command or subcommand must begin on a separate statement.

What is check pending and copy pending status in DB2, how do you resolve it?

If the table is loaded with ENFORCE NO option then the table space get into check pending status. That means table space is loaded without enforcing constraints. CHECK utility needs to be run on table space.

If table is loaded with LOG NO option then it get's into cpoy pending status. The meaning is image copy is needed on table space.

Following utilities set the CHECK-pending status

LOAD with ENFORCE NO

RECOVER to a point in time

CHECK LOB

1. Check and correct referential integrity constraints using the CHECK DATA utility.

If a table space is in both REORG-pending and CHECK-pending status (or auxiliary CHECK-pending status) run REORG first and then use CHECK DATA to clear the respective states.

2. COPY-pending (COPY) restrictive status indicates that the affected object must be copied

3. Take an image copy of the affected object.

In Copy pending status the table is available only for query processing. The solution of copy pending status is take an image copy or use repair utility.

5

Page 6: Imp Mainframe Question

Check pending status happens only when the table is loading with ENFORCE NO option.It means the load utility didn't perform constraint checking.

COPY PENDING A state in which, an Image Copy on a table needs to be taken, In this status, the table is available only for queries. You cannot update this table. To remove the COPY PENDING status, you take an image copy or use REPAIR utility. In copypend status... you cannot edit a table.....only u can run queries on that table..not update

If the tablespace is in Copy pending status and you dont want to take image copy , then you can use REPAIR utility or execute following db2 command to bring the status of tablespace to RW

Code:

-START DATABASE(dbname) SPACE(tablespace-name) ACESS(FORCE) .

This command will reset all the pending states and change the status of the tablespace to RW .

CHECK PENDING When a table is LOADed with ENFORCE NO option, then the table is left in CHECK PENDING status. It means that the LOAD utility did not perform constraint checking.

while in Check pending status. you can edit or load table by giving ENFORCE NO option...

The following option will overcome the problem, 1) Copy Pending status - Run the Dummy image copy job and the Tablespace status changes from copy pending to RW

2) Check Pending staus - Run the Check data for those tablespace and the Tablespace status changes from chkp to RW.

The Status RW (READ/WRITE) means that the database is ready to do database processing.

6

Page 7: Imp Mainframe Question

-805 shows Bind problem, Please rebind your program in the correct instance and make sure you give the correct DBRM library name so that your bind JCL picks up DBRM from there

SQLCODE Overview

If SQLCODE = 0, execution was successful.

If SQLCODE > 0, execution was successful with a warning.

If SQLCODE < 0, execution was not successful.

If SQLCODE = 100, "no data" was found. For example, a FETCH statement returned no data because the cursor was positioned after the last row of the result table.

New with DB2 V8, when DB2 processes a multiple row FETCH statement, the contents of SQLCODE is set to +100 if the last row in the table has been returned with the set of rows.

SQLCODE - Successful SQL Execution

SQL Return Code +100 ROW NOT FOUND FOR FETCH, UPDATE OR DELETE, OR THE RESULT OF A QUERY IS AN EMPTY TABLE.Suggestion: If expecting data, verify WHERE clause for accuracy and completeness.

SQL Return Code +117 THE NUMBER OF INSERT VALUES IS NOT THE SAME AS THE NUMBER OF OBJECT COLUMNS.Suggestion: Correct SQL statement to provide only one value for each column in the table.

SQL Return Code +231 CURRENT POSITION OF CURSOR cursor-name IS NOT VALID FOR FETCH OF THE CURRENT ROW.Suggestion: Be certain to FETCH to position on a row after opening a cursor. If cursor is declared SENSITIVE STATIC SCROLL, the row may be a hole, from which no values can be fetched.

SQL Return Code +304 A VALUE WITH DATA TYPE data-type1 CANNOT BE ASSIGNED TO A HOST VARIABLE BECAUSE THE VALUE IS NOT WITHIN THE RANGE OF THE HOST VARIABLE IN POSITION position-number WITH DATA TYPE data-type2.Suggestion: Verify DCLGEN host variable definitions are current with DB2 catalog table/view attributes.

SQL Return Code +347 THE RECURSIVE COMMON TABLE EXPRESSION name MAY CONTAIN AN INFINITE LOOP.

7

Page 8: Imp Mainframe Question

Suggestion: Verify predicate in the SQL WHERE clause of the form "counter_col < constant" or "counter_col < :hostvar".

SQL Return Code +802 EXCEPTION ERROR exception-type HAS OCCURRED DURING operation-type OPERATION ON data-type DATA, POSITION position-number.Suggestion: Check arithmetic operation for divide by zero or result to exceed size of host variable.

SQLCODE - Unsuccessful SQL Execution

SQL Error Code -117 THE NUMBER OF VALUES ASSIGNED IS NOT THE SAME AS THE NUMBER OF SPECIFIED OR IMPLIED COLUMNS.Suggestion: Provide one value for each column in the table.

SQL Error Code -150 THE OBJECT OF THE INSERT, DELETE, OR UPDATE STATEMENT IS A VIEW, SYSTEM-MAINTAINED MATERIALIZED QUERY TABLE, OR TRANSITION TABLE FOR WHICH THE REQUESTED OPERATION IS NOT PERMITTED.Suggestion: Be certain to specify base DB2 table/view names for INSERT statements.

SQL Error Code -180 THE DATE, TIME OR TIMESTAMP VALUE value IS INVALID.Suggestion: Verify the data value is in the correct range and value type.

SQL Error Code -181 THE STRING REPRESENTATION OF A DATETIME VALUE IS NOT A VALID DATETIME VALUE.Suggestion: Verify data format with the SQL Reference Guide.

SQL Error Code -204 name IS AN UNDEFINED NAME.Suggestion: Correct DB2 CREATOR or OBJECT NAMEs located in SQL statements.

SQL Error Code -227 FETCH fetch-orientation IS NOT ALLOWED, BECAUSE CURSOR cursor-name HAS AN UNKNOWN POSITION (sqlcode,sqlstate).Suggestion: CLOSE and re-OPEN the cursor; For scrollable use (FIRST, LAST, BEFORE, AFTER, or ABSOLUTE) to establish valid position.

SQL Error Code -305 THE NULL VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE NO INDICATOR VARIABLE IS SPECIFIED.Suggestion: Add null indicator variable to SELECT statement in the format of "column:hostvarind".

SQL Error Code -501 THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN.Suggestion: Correct logic in application program to OPEN the cursor before the FETCH or CLOSE statement.

SQL Error Code -502 THE CURSOR IDENTIFIED IN AN OPEN STATEMENT IS ALREADY OPEN.Suggestion: Correct logic in application program to CLOSE the CURSOR before the OPEN statement.

8

Page 9: Imp Mainframe Question

SQL Error Code -503 A COLUMN CANNOT BE UPDATED BECAUSE IT IS NOT IDENTIFIED IN THE UPDATE CLAUSE OF THE SELECT STATEMENT OF THE CURSOR.Suggestion: Use FOR UPDATE statement in your cursor.

SQL Error Code -530 THE INSERT OR UPDATE VALUE OF FOREIGN KEY constraint-name IS INVALID.Suggestion: Ensure that INSERT row for DB2 PARENT table is completed before INSERT row in CHILD table.

SQL Error Code -532 THE RELATIONSHIP constraint-name RESTRICTS THE DELETION OF ROW WITH RID X'rid-number'.Suggestion: Change the program to DELETE CHILD table row before DELETE of row on PARENT table.

SQL Error Code -551 auth-id DOES NOT HAVE THE PRIVILEGE TO PERFORM OPERATION operation ON OBJECT object-name.Suggestion: Contact the support DBA to GRANT the needed privilege.

SQL Error Code -803 AN INSERTED OR UPDATED VALUE IS INVALID BECAUSE THE INDEX IN INDEX SPACE indexspace-name CONSTRAINS COLUMNS OF THE TABLE SO NO TWO ROWS CAN CONTAIN DUPLICATE VALUES IN THOSE COLUMNS. RID OF EXISTING ROW IS Xrid.Suggestion: Verify DB2 INDEX and, if needed, change the statement to an UPDATE.

SQL Error Code -805 DBRM OR PACKAGE NAME location-name.collection-id.dbrm-name.consistency-token NOT FOUND IN PLAN plan-name. REASON reason.Suggestion: Ensure COLLECTION name is in DB2 PLAN. Recompile and BIND the DB2 program. Verify correct LOAD library is being used.

SQL Error Code -811 THE RESULT OF AN EMBEDDED SELECT STATEMENT OR A SUBSELECT IN THE SET CLAUSE OF AN UPDATE STATEMENT IS A TABLE OF MORE THAN ONE ROW, OR THE RESULT OF A SUBQUERY OF A BASIC PREDICATE IS MORE THAN ONE VALUE.Suggestion: -811 is often detected after program check for DB2 data existence. Consider using new DB2 V8 FETCH FIRST ROW ONLY feature instead.

SQL Error Code -818 THE PRECOMPILER-GENERATED TIMESTAMP x IN THE LOAD MODULE IS DIFFERENT FROM THE BIND TIMESTAMP y BUILT FROM THE DBRM z.Suggestion: Recompile and BIND the DB2 program. Verify correct LOAD library is being used.

SQL Error Code -904 UNSUCCESSFUL EXECUTION CAUSED BY AN UNAVAILABLE RESOURCE. REASON reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name.Suggestion: -904 is usually caused because a database utility job has started the desired DB2 object in utility mode. Check DB2 Master Log for more details on the resource name – contact DBA.

SQL Error Code -911 THE CURRENT UNIT OF WORK HAS BEEN ROLLED BACK DUE TO DEADLOCK OR TIMEOUT. REASON reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name.

9

Page 10: Imp Mainframe Question

Suggestion: Review DB2 Master Log to find process holding DB2 locks. Consider adding additional COMMITs to program holding the DB2 resource.

SQL Error Code -913 UNSUCCESSFUL EXECUTION CAUSED BY DEADLOCK OR TIMEOUT. REASON CODE reason-code, TYPE OF RESOURCE resource-type, AND RESOURCE NAME resource-name.Suggestion: Review DB2 Master Log to find process holding DB2 locks. Consider adding additional COMMITs to program holding the DB2 resource.

SQL Error Code -922 AUTHORIZATION FAILURE: error-type ERROR. REASON reason-code.Suggestion: Connection to DB2 has failed due authority for USER or PLAN. Contact DBA to check DB2 authorizations.

SQL Error Code -927 THE LANGUAGE INTERFACE (LI) WAS CALLED WHEN THE CONNECTING ENVIRONMENT WAS NOT ESTABLISHED. THE PROGRAM SHOULD BE INVOKED UNDER THE DSN COMMAND.

Introduction

Job Control Language (or JCL) specifies how programs are executed on the mainframe. JCL functions are the interface between the programs and the operating system. Since JCL has the ability to define data set names, parameters and system output devices the individual programs can be flexible in their use because these items are not hard coded in the programs. Without the need for re-compiling, the same program may be used to access different data sets and behave differently based on parameters specified in JCL

JCL Statement Syntax

A JCL source member consists of a file of 80-byte, fixed-length records. The records (or JCL statements) are written using positions 1-71. Position 72 is reserved for continuation, a space character indicates no continuation and a non-space character indicates the next statement will be a continuation of the current statement.. A JCL statement starts with two slashes in positions 1 to 2. The JCL specifies a jobname and can contain one or more steps. Each step will execute a program or procedure (PROC). Comments statements may be added to the JCL using //* in positions 1 to 3. Every JCL member must begin with a '"Job Card" that specifies the job name and other information about how the job will execute. The JCL is completed by using '//' in positions 1 and 2 or when the last statement is processed.

The Job Statement (or Job Card)

10

Page 11: Imp Mainframe Question

Every JCL member (or JOB) you write will require a JOB statement (or JOB card) to identify the job. This must be the first statement in each job. Since the JOB card is a JCL statement it must start with a '//' (two slashes) in positions 1-2. The following is a sample JOB statement.

....:....1....:....2....:....3....:....4....:....5....:....6....:....7..

//SIMOJOB1 JOB (ACCTINFO),'comment',CLASS=A,MSGCLASS=0,

// MSGLEVEL=(1,1),NOTIFY=USERID

Note: The preceding JOB statement is continued across two statements. The length of the text is 72 bytes. Remember, a non-space in position 72 indicates a continuation.

The job name should be in positions 3-n (for a maximum of eight characters) followed by a space.

The job name is specified first, in this example the job name will be SIMOJOB1. The key-word JOB is specified to indicate this is the JOB statement or Job Card.

The (ACCTINFO) is accounting information and is a required. This may be an accounting cost center. The cost center information varies from site to site and may be used to do charge-backs to individual departments for usage of the system.

The 'comment' is an identifying or explanatory field. It is optional but can very useful. It ha a 20 characters maximum length.

The job class is specified by using "CLASS=" key word. This information is used to tell the system how the job is to be run. Jobs will be scheduled and will run under control of a predefined class as determined by the job initiator. The job class may determine the priority of the job and how long it will be allowed to

11

Page 12: Imp Mainframe Question

run. If the job initiator is already running a job then the current job request may be placed in a job queue and have to wait until the initiator is free.

The MSGCLASS=x is used to specify where the job output will be directed. The output classes are predefined and vary from site to site. Two are the normal defaults are as follows.

A Normal system printing and all output listings sent to the default system printer.

0 Hold output in the queue and allow job output to be viewed on-line through the TSO outlist facility.

The MSGLEVEL=(x,y) is used as follows.

x 0 The system prints only the JOB statement.

1 The system prints all JCL statements, JES2, or JES3 control statements, the procedure statements, and IEF653I messages which show the values assigned to symbolic parameters in procedure statements.

2 The system prints only JCL statements and JES2 and JES3 control statements.

y 0 The system prints only JCL messages. It prints JES and operator messages only if the job abnormally terminates.

1 The system prints JCL messages and any JES and operator messages.

If you want to be notified when the job has finished then use the "NOTIFY=" key word. The NOTIFY parameter must specify a valid userid.

A Comment Statement

(Next) (Previous) (Table-of-Contents)

A comment statement is defined by a "//*" in positions 1-3. The following is an example of a JCL comment statement.

//* THIS IS A JCL COMMENT STATEMENT...

12

Page 13: Imp Mainframe Question

Note: The text for the comment should not go past position 71. Remember, a non-space in position 72 indicates a continuation.

The EXEC Statement (or Defining a Job Step)

(Next) (Previous) (Table-of-Contents)

A job step defines the program to run and is created by using the EXEC statement. There may be one step or many steps within a job. The step name should be in positions 3-n (for a maximum of eight characters) followed by a space. The following is an example of a JCL statement that defines a step within a job and executes a program.

//STEPID01 EXEC PGM=IEFBR14

The preceding example defines the step name as STEPID01. The "EXEC" keyword identifies the statement as a job step definition. The "PGM=" keyword and parameter specifies the program to be executed. (i.e. EXECute ProGraM). The program to be executed is IEFBR14.

//STEPID02 EXEC procname

The preceding example defines the step name as STEPID02. The "EXEC" keyword identifies the statement as a job step definition. The next parameter specifies the PROC (or procedure) to be executed.

Defining Data Sets

(Next) (Previous) (Table-of-Contents)

Defining the Data Sets used by a job step requires a Data Definition (or DD) statement. A simple DD statement requires a DDNAME, a Data Set Name (or DSN) and a Disposition (or DISP) keyword.

//* A Sample format for a DD statement ...

13

Page 14: Imp Mainframe Question

//ddname DD DSN=data.set.name,DISP=(status,normal-termination-disp,abnormal-termination-disp)

In the preceding example the ddname in the JCL DD statement corresponds to the name used in the COBOL SELECT statement. The DSN= keyword and parameter specifies the fully-qualified MVS Data Set Name. The DISP= keyword and parameter specifies the disposition as follows.

DISPostion

status Description

OLD The dataset exists and this job step has exclusive use of the dataset.

SHR The dataset exists and other users and jobs can access the dataset, this is the default

MOD The dataset should be kept and new records will be appended to the end of the dataset. The dataset may or may not exist. If it does not exist then a data set will be created.

NEW The dataset does not exist and will be created.

normal-termination-disp Description

DELETE Deletes the data set at the end of the step

KEEP Keeps the data set.

CATLG Places the entry in the system catalog or user catalog. For a NEW data set this is the default.

UNCATLG Deletes the entry from the system catalog or user catalog.

abnormal-termination-disp Description

DELETE Indicates that the data set is to be deleted at the end of a job step.

KEEP Indicates that the data set is to be kept.

CATLG Indicates that the system should place an entry in the system or user catalog.

UNCATLG Indicates that the system is to delete the entry in the system or user catalog.

The DD Statement for an Existing Data Set

(Next) (Previous) (Table-of-Contents)

The DD name should be in positions 3-n (for a maximum of eight characters) followed by a space. The DDNAME should correspond to the name defined in the program. For example, with COBOL the name

14

Page 15: Imp Mainframe Question

defined by the ASSIGN clause of the SELECT statement. The following is an example of a DD statement followed by a COBOL SELECT statement with an ASSIGN clause.

//* A sample JCL DD statement for an existing data set...

//QSAM0080 DD DSN=SIMOTIME.DATA.QSAM0080,DISP=SHR

The following is an example of a COBOL SELECT statement with an ASSIGN clause.

* A COBOL Select Statement...

SELECT QSAM0080-FILE ASSIGN to QSAM0080

In the preceding example the COBOL program will read QSAM0080 and the DD statement will map to the file specified in the DSN parameter (SIMOTIME.DATA.QSAM0080).

The DD Statement for a New Data Set

(Next) (Previous) (Table-of-Contents)

The following is an example and will vary at each mainframe location depending on the system hardware and software configuration. The important items on the following is the DISP and DCB information.

//SQADB512 DD DSN=SIMOTIME.DATA.SQADB512,DISP=(NEW,CATLG,DELETE),

// STORCLAS=MFI,

// SPACE=(TRK,5),

// DCB=(RECFM=FB,LRECL=512,BLKSIZE=5120,DSORG=PS)

The following describes the DISP options.

DISPostion Description

15

Page 16: Imp Mainframe Question

NEW Specifies a new data set.

CATLG Create a new catalog entry.

DELETE If request abnormally terminates then delete the data set if it exist.

The following describes the DCB options.

DCB Description

RECFM Record Format, in this example the record format is Fixed Block (FB).

LRECL Record Length.

BLKSIZE Block Size.

DSORG Data Set Organization.

Data Set Concatenation

(Next) (Previous) (Table-of-Contents)

It is possible to process more than one data set as a single data set by concatenating the DD statements.

//QSAM0080 DD DSN=SIMOTIME.DATA.FILE0001,DISP=SHR

// DD DSN=SIMOTIME.DATA.FILE0002,DISP=SHR

// DD DSN=SIMOTIME.DATA.FILE0003,DISP=SHR

The following is an example of a COBOL SELECT statement.

SELECT QSAM0080-FILE

ASSIGN to QSAM0080

ORGANIZATION is SEQUENTIAL

ACCESS MODE is SEQUENTIAL

16

Page 17: Imp Mainframe Question

FILE STATUS is QSAM0080-STATUS.

In the preceding example the COBOL program will read QSAM0080 and the DD statements will map the three files (FILE0001, FILE0002 and FILE0003) as one file. The program's initial read will get the first record from FILE0001 and will not get an End-of-File condition until the last record of FILE0003 is processed.

Directing System Output

(Next) (Previous) (Table-of-Contents)

The DD statement with a SYSOUT parameter is used to assign an output class to an output data set. The form of this parameter is:

//REPORT1 DD SYSOUT=A

//REPORT2 DD SYSOUT=*

In the preceding example the REPORT1 output will be directed to SYSOUT=A which is usually the system printer. The REPORT2 output will be directed to the location specified in the MSGCLASS of the JOB statement. If MSGCLASS=0 then REPORT2 output will be directed to SYSOUT=0 which is usually placed in the JES Output Queue for a specified period of time (such as 3 days) before being purged.

if the ddname is SYSOUT (i.e. //SYSOUT ...) and SYSOUT=* then the job class will be the same as that specified in the MSGCLASS in the job statement. Since the ddname is SYSOUT the DISPLAY in a COBOL program will be directed to the location specified in the MSGCLASS of the JOB statement. If MSGCLASS=0 then REPORT2 output will be directed to SYSOUT=0 which is usually placed in the JES Output Queue for a specified period of time (such as 3 days) before being purged. The following is a sample JCL statement with SYSOUT as the DD name.

//SYSOUT DD SYSOUT=*

The following is a sample COBOL statement that uses DISPLAY

17

Page 18: Imp Mainframe Question

DISPLAY 'This is a test...'

In the preceding example the text string "This is a test..." will be routed to the JES output queue.

The DUMMY Data Set

(Next) (Previous) (Table-of-Contents)

The use a a DD statement with a DUMMY parameter will allow a program to run if a data set does not exist. The following example show a DD DUMMY statement.

//QSAM0080 DD DUMMY

The following is the COBOL SELECT statement.

SELECT QSAM0080-FILE

ASSIGN to QSAM0080

ORGANIZATION is SEQUENTIAL

ACCESS MODE is SEQUENTIAL

FILE STATUS is QSAM0080-STATUS.

The following shows the COBOL statements for the open, read and close of the QSAM0080 data set (i.e. sequential file).

open input QSAM0080-FILE

...

read QSAM0080-FILE.

18

Page 19: Imp Mainframe Question

...

close QSAM0080-FILE

In the preceding example the OPEN will be successful, the first READ will return an End-of-File return code and the close will be successful.

Passing a Parameter to a Program

(Next) (Previous) (Table-of-Contents)

The two techniques use to pass information (a Parameter) from JCL to a program are as follows.

Technique Description

via PARM= This technique uses a PARM=parameter keyword on the EXEC statement in JCL. The COBOL program requires a LINKAGE SECTION.

via SYSIN This technique requires SYSIN statement followed by the parameter to be placed in the JCL. The COBOL program requires an "ACCEPT parameter from SYSIN" to be coded in the COBOL program. If the SYSIN statement is missing in the JCL the ACCEPT will ABEND with a "File not found" message. To avoid this it will be necessary to use a "//SYSIN DD DUMMY" statement in the JCL when a parameter is not being passed.

The following two section describe parameter-passing in more detail. Simply click on one of the following items to learn more or download a set of sample programs that describe how to pass a parameter string from JCL to a COBOL program.

Passing a Parameter via PARM=

(Next) (Previous) (Table-of-Contents)

To pass a parameter from JCL to a program requires the use of the "PARM=" keyword with the EXEC statement. The following JCL statement shows an EXEC statement without a parameter defined.

//* *******************************************************************

//* Step 1 of 2, Execute the COBOL program without a parameter.

19

Page 20: Imp Mainframe Question

//*

//CBLPARS1 EXEC PGM=CBLPARC1

The following JCL statement shows an EXEC statement with a parameter defined by using the "PARM=" keyword. Notice the comma immediately after the program name. The parameter following the "PARM=" keyword requires the apostrophes if the text string contains space characters.

//* *******************************************************************

//* Step 2 of 2, Execute the COBOL program with a parameter.

//*

//CBLPARS2 EXEC PGM=CBLPARC1,

// PARM='SimoTime, When technology complements business'

Passing a Parameter via SYSIN

(Next) (Previous) (Table-of-Contents)

To pass a parameter from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.

//* *******************************************************************

//* Step 1 of 2, Execute the COBOL program without a parameter.

//*

//SYSIN DD DUMMY

The following JCL statements show what is required to pass information via SYSIN.

//* *******************************************************************

20

Page 21: Imp Mainframe Question

//* Step 2 of 2, Execute the COBOL program with a parameter.

//*

//SYSIN DD *

Parameter from SYSIN...

//*

The following shows the COBOL statement required.

ACCEPT variable-name FROM SYSIN

JCL Procedures or PROC's

(Next) (Previous) (Table-of-Contents)

JCL defines how a job is executed on the mainframe. A job may perform many steps or execute many programs in order to produce the requested information or output. If a segment of JCL is used repeatedly it may be coded once as a PROC (or JCL Procedure) and then used by many different steps within the job. There are two approaches to defining and using PROC's.

Instream Proc

(Next) (Previous) (Table-of-Contents)

The following is an example of an instream PROC that is used three times when the JOB is executed. The job step that calls the instream PROC will provide the name of the PDS to be created via the &DSNAME substitution value.

//PDSCRTJ4 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1

//* *******************************************************************

//* This program is provided by: *

//* SimoTime Enterprises, LLC *

21

Page 22: Imp Mainframe Question

//* (C) Copyright 1987-2010 All Rights Reserved *

//* *

//* Web Site URL: http://www.simotime.com *

//* e-mail: [email protected] *

//* *******************************************************************

//*

//* Subject: Define a PDS using the IEFBR14 with a DD Statement

//* Author: SimoTime Enterprises

//* Date: January 1,1998

//*

//* The JCL member executes the instream PROC called PDSCRTP3 and

//* passes a fully qualified data set name (DSN) via the symbolic name

//* called DSNAME and referenced in the PROC as &DSNAME.

//*

//*********************************************************************

//* The instream PROC for creating a PDS. The Data Set Name (&DSNAME)

//* is provided by the job step that calls the PROC.

//*

//PDSCRTP3 PROC

//PDSCRTS1 EXEC PGM=IEFBR14

//TEMPLIB1 DD DISP=(NEW,CATLG),DSN=&DSNAME,

// STORCLAS=MFI,

// SPACE=(TRK,(45,15,50)),

// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PO)

// PEND

//*

//* *******************************************************************

//* Step 1 of 3 Create a PDS using SET and EXEC

//*

22

Page 23: Imp Mainframe Question

// SET DSNAME=SIMOTIME.DEMO.TEMP01

//STEPJ41 EXEC PDSCRTP3

//*

//* *******************************************************************

//* Step 2 of 3 Create a PDS using EXEC and DSNAME substitution

//*

//STEPJ42 EXEC PDSCRTP3,DSNAME=SIMOTIME.DEMO.TEMP02

//*

//* *******************************************************************

//* Step 3 of 3 Create a PDS using EXEC and DSNAME substitution

//*

//STEPJ43 EXEC PDSCRTP3,DSNAME=SIMOTIME.DEMO.TEMP03

//*

Additional information about the use of JCL and PROCs may be found in the JCLPRC01.HTM document.

JCL Substitution Parameters

JCL substitution is mainly used when a repeatable process is used many times but needs the ability to behave differently based on variable information passed from the job that is excuting the process. Simply click on one of the following items to learn more or download sample JCL that describe how to use variable substitution within JCL.

The SET Statement

The SET statement lets you set the values of symbolic parameters within a JCL or PROC member. Simply click on one of the following items to learn more or download sample JCL that describes the SET statement.

JCL, INCLUDE and JCLLIB Statements

This section provides examples of how to use INCLUDE and JCLLIB statements in JCL. The following from the JES output shows the statements and the substituted values.

23

Page 24: Imp Mainframe Question

20 //*

21 //* *******************************************************************

22 //*

23 // JCLLIB ORDER=SIMOTIME.PDS.JCLINC

24 // INCLUDE MEMBER=JCLINCI1

##*

##* *******************************************************************

##* SET Values from the JCLINCI1.INC Member.

## SET HLQ01=SIMOTEST

## SET HLQ02=TEMP

25 //* *******************************************************************

26 //* Step 1 of 2 This job step will delete a previously created

27 //* hex-dump file.

28 //*

29 //TAKEAWAY EXEC PGM=IEFBR14

30 //TESTFILE DD DSN=&HLQ01..&HLQ02..TESTFILE,DISP=(MOD,DELETE,DELETE),

SUBSTITUTION - DSN=SIMOTEST.TEMP.TESTFILE,DISP=(MOD,DELETE,DELETE),

31 // STORCLAS=MFI,

32 // SPACE=(TRK,5),

33 // DCB=(RECFM=V,LRECL=80,DSORG=PS)

34 //*

Simply click on one of the following items to learn more or download a sample set of programs.

Specifying the Location of Programs

24

Page 25: Imp Mainframe Question

If programs are not stored in the libraries predefined for the operating systems then it will be necessary to specify the location of the programs. For example, if program are located in a private library or a test library then use STEPLIB and/or JOBLIB to tell the system the location of the programs.

STEPLIB and JOBLIB require a DD statement that defines the names of the Load Libraries that are searched to find and load the program. As the names imply the STEPLIB statement applies only to an individual job step, the JOBLIB statement applies to the whole job. If you specify both then the STEPLIB statement will override what is specified by the JOBLIB statement but only for the individual step.

A JOBLIB statement must be specified after the Job statement and before any job steps (or EXEC statements). The STEPLIB must be specified after the EXEC PGM statement of the job step.

//SIMOJOB1 JOB (ACCTINFO),CLASS=A,MSGCLASS=C,NOTIFY=USERID

//JOBLIB DD DSN=SIMOTIME.DEVL.LOADLIB1,DISP=SHR

//*

//STEP0100 EXEC PGM=PROGRAM1

//*

//STEP0200 EXEC PGM=PROGRAM2

//*

//STEP0300 EXEC PGM=PROGRAM3

//STEPLIB DD DSN=SIMOTIME.DEVL.TEMPLIB1,DISP=SHR

//*

//STEP0400 EXEC PGM=PROGRAM4

In the preceding example PROGRAM1 of STEP0100, PROGRAM2 of STEP0200 and PROGRAM4 of STEP0400 will run from the library SIMOTIME.DEVL.LOADLIB1 that is specified in the JOBLIB statement. PROGRAM3 of STEP0300 will run from the library SIMOTIME.DEVL.TEMPLIB1 that is specified in the STEPLIB statement that overrides the JOBLIB statement.

Conditional JCL

(Next) (Previous) (Table-of-Contents)

25

Page 26: Imp Mainframe Question

This suite of programs provides an example of how mainframe JCL can do conditional processing. The first JCL example will focus on the approaches used by JES/2 using the "COND=" parameter on the JOB or EXEC statement. With JES/3 the conditional processing was improved to use "IF" statements. The second JCL example will focus on the IF, THEN, ELSE and ENDIF statement construct. Both JCL examples accomplish the same task. However, the second JCL example has additional information displayed when there is a difference between the actual and expected return code. The use of the COND parameter can be very difficult to code and understand. I would recommend the use of the IF, THEN, ELSE and ENDIF statement construct if you have a choice.

COBOL DB2 PROGRAMMING

Writing a COBOL DB2 Program.

Let us assume we are writing a cobol program to read EMPLOYEEtable and get the details of employee with the name XXXXXXX.

Let us go in step wise..

create the following table in db2 or assume it is there in db2 database.

EMPLYEE

EMPID EMPNAME DEPARTMENT SALARY DESIGNATION1000 XXXXXXX XX 10000 SE1001 YYYYYYY YY 9000 SE1002 ZZZZZZZ ZZ 20000 MA

STEP 1. We need to declare the table structure in the WORKING-STORAGE SECTION or LINKAGE SECTION.

EXEC SQL DECLARE DSNXXX.EMPLOYEE ( EMPID CHAR(10) NOT NULL, EMPNAME CHAR(30) NOT NULL, DEPARTMENT CHAR(2) NOT NULL, SALARY DECIMAL(10,2) NOT NULL, DESIGNATION CHAR(4) NOT NULL ) END-EXEC.

26

Page 27: Imp Mainframe Question

we can use DB2 tool called DCLGEN to generate this declaration for us and can include that copy book here.

if you create a copybook using DCLGEN. Use following sntax to include

EXEC SQL INCLUDE < copybookname > END-EXEC.

STEP 2. Declare host variables in WORKING-STORAGE SECTION.

HOST VARIABLES - A host variable is a data item declared in cobol to use it in embedded SQL.

For EMPLOYEE table, host variable declaration is look like as follows...

01 EMPOYEE-RECORD. 05 HV-EMPID PIC X(10). 05 HV-EMPNAME PIC X(30). 05 HV-DEPARTMENT PIC X(2). 05 HV-SALARY PIC S9(8)V99 COMP-3. 05 HV-DESIGNATION PIC CHAR(4).

If you use db2 tool DCLGEN, it will automatically creates this structure also along with table declaration specified in step1.

STEP 3. Include SQLCA as follows in WORKING-STORAGE SECTION.

EXEC SQL INCLUDE SQLCA END-EXEC.

What is SQLCA?

SQLCA - SQL communication area. When a SQL statement executes, DB2 places a value in SQLCODE AND SQLSTATE host variables or any other fields of SQLCA. based on the values in these variables we can know whether sql ran sucessfully or not. SQLCA contains a declartion of fields like SQLCODE,SQLSTATE and SQLERRD etc....

STEP 4. Add a sql statement in procdure division to get the details of employee with the name XXXXXXX.

27

Page 28: Imp Mainframe Question

DISPLAY ' PROGRAM STARTED .... ' ......... EXEC SQL SELECT SALARY INTO :HV-SALARY FROM EMPLOYEE WHERE EMPNAME = 'XXXXXXX' END-EXEC.

IF SQLCODE = 0

DISPLAY ' SQL EXECUTED SUCESSFULLY ' DISPLAY ' EMPLOYEE SALARY IS ' HV-SALARY

ELSE

DISPLAY ' SQL FAILED ' DIAPLY ' SQL CODE ' SQLCODE

END-IF.

.... ....

DISPLAY ' PROGRAM ENDED'.

Here SQLCODE = 0 means, sql ran sucessfully without any issues. Hencewe are displaying the HV-SALARY into the spool.

If SQLCODE NOT = 0 , there is issue in executing the sql statement.

Now we have compeleted coding a cobol-db2 program. our next step is tocompile the program.

DB2 Precompile-Compilation-Bind Process

INTRODUCTION

Static SQL - COBOL PRE-compile process

For COBOL-Static SQL program, program needs to be precompiled before doing actual

compilation of that program.

28

Page 29: Imp Mainframe Question

Following are the 4 steps to compile a COBOL-DB2 program

STEP 1 - DB2 PRECOMPILE Process

The DB2 Precompile performs three functions. First, it checks the SQL in the program for errors. Second, it adds working storage areas and source code compatible statements that are used to invoke DB2. One of the working storage areas contains a literal "timestamp" called a consistency token. Finally,

29

Page 30: Imp Mainframe Question

all of the SQL statements are extracted from the program source and placed into a member called the DataBase Request Module, or DBRM, which also contains the consistency token.

STEP 2 -COMPILE

The modified source from the precompile is then compiled. The code is checked for errors, and a compiled version of the code is created.

STEP 3 -LINK-EDIT

The compiled code is link-edited along with statically called source language and DB2 run-time modules to create a Load Module. Imbedded in this module is the same consistency token that was generated in the precompile. If multiple DB2 programs are statically linked together, the resulting load module contains a consistency token for each one.

STEP 4 -DB2 BIND

The bind process reads the DBRM that was created in the precompile and prepares an access path to the data. This access path, along with the consistency token, is stored in the DB2 catalog as a Package. Every Package is bound into a Package List, or Collection. The name of the Collection is specified by the PACKAGE parameter. A Collection is a group of Packages that are included in one or more Plans. The QUALIFIER parameter of the bind is used to direct the SQL to the specific set of DB2 objects (tables, views, aliases or synonyms) qualified by this name.

EXECUTING COBOL-DB2 PROGRAM

When COBOL-DB2 Program executes, the plan name must be specified. For online CICS programs, the plan name is specified by Tran ID in the Resource Control Table (RCT). For a batch program, the plan name is specified in the SYSTSIN input DD. The packages for all DB2 programs executed under a Tran ID or batch job step must be included in collection bound into this plan. When the first SQL statement of each program is executed, DB2 searches the collections within the plan using the package name and consistency token from the load module. If an exact match is not found, a -805 SQLCODE is returned.

1) In JCL sort card sum fields = none for eliminating duplicates. How can I retrieve only duplicates?

You could use SORTXSUM dataset and XSUM option in SUM FIELDS.

30

Page 31: Imp Mainframe Question

it will possible by the icetool //toolin dd * select from(in) to(dups) on(1,6,ch) alldups discard(nondups) /* dups--duplicate elements nondups--non duplicate elements

2) How will you make sure that your SELECT query retrieves only one row always?

it will possible by the cursor exec sql declare x cursor select empname,emp from emp1 where city="london";

Using primary key in the where statement of the select would give only one row.

ex: declare cursor x for select y,z from emp where x=y for fecth 1 row only. this serves the purpose.

3) DISTINCT is used for eliminating duplicate rows in DB2. How can retrieve all the duplicates (A sample query is highly appreciated)?

select col1 from tbname where count(col1) > 1;

4) I have a sort requirement like 5 records. In that 4 are same and 1 is different. I want to get only that 1 record. How? Anyone have an idea about "EQUALS" in sort card?

Using sum fields = none in sort.

Anyone have an idea about "EQUALS" in sort card? INCLUDE COND=(1,2,CH,EQ,C'AB?), would take only records with ?AB? in the first two positions in the input file.

//SORT1 EXEC PGM=SORT //SORTIN DD DSN=XXX.YYY.ZZZ,DISP=SHR //SORTOUT DD DSN=AAA.BBB.CCC,DISP=SHR - has distinct data?. //SORTXSUM DD DSN=AAA.BBB.CCC1,DISP=SHR - has duplicates alone //SORTWK01 DD UNIT=WORK,SPACE=(CYL,(200,50)) //SORTWK02 DD UNIT=WORK,SPACE=(CYL,(200,50)) //SORTWK03 DD UNIT=WORK,SPACE=(CYL,(200,50)) //SORTWK04 DD UNIT=WORK,SPACE=(CYL,(200,50))

31

Page 32: Imp Mainframe Question

//SORTWK05 DD UNIT=WORK,SPACE=(CYL,(200,50)) //SYSOUT DD SYSOUT=* //SYSOUD DD SYSOUT=* //SYSIN DD * SORT FIELDS=(1,2,CH,A) SUM FIELDS=NONE,XSUM //

5) What would be your first approach after getting -805?

One of my manual says:

Bind the program 'program name' as the member part of the application plan 'plan name' or * Correct the collection id in the PKLIST and bind the application plan 'plan name' or * Set the current package set special register correctly or * Put the correct 'location name' in the CURRENTSERVER of the BIND command and bind the application plan 'plan name' or * Connect to the correct RDB name or * Correct the location id in the PKLIST and bind the application plan 'plan name' or * Bind the DBRM of the version of the application program to be executed

well this error comes when there is mismatch b/w the Load of a prog. and the bind of the prog . so its better to check whether which load module u r using in ur job ., along with which plan u r using . or if u r not certain abt the load module. better do a compile bind again .

-805 will occur when you run your program without binding it properly in to your test region. Some times it may happen that you compiled your program but there are still some SQL errors which compiler cant locate that time during binding it fails. And when you try to run this program you will hit by ?805. The other common reason is that when you compile your program but forget to bind it, then while execution it will fetch the old edition and due to time stamp mismatch you get ?805. If you want to check the time stamp just go to your LOADLIB library and check for the time stamp. Now if this time stamp not matches with the timestamp in SYSIBM.SYSPACKAGES for that program then you will get ?805.

Explaination :

An attempt was made to execute the application program 'location name.collection id.program name.consistency token' (this token can be 'location name..program name.consistency token' if the current package set special register is blank for the local program execution) that has not been found due to one or more or the following reasons:

32

Page 33: Imp Mainframe Question

*The program 'program name' has not been bound as the member part of the application plan 'plan name' *The 'collection id' in the PKLIST was not correct when the application plan 'plan name' was bound *The current package set special register was not set correctly *The 'location name' in the CURRENTSERVER was not correct when the application plan 'plan name' was bound, *The application was not connected to the proper location *The location id in the package list was not correct when the application 'plan name' was bound *The DBRM of the version of the application program being executed was not bound.

Resolution :

Based on the above reasons, the programmer can perform the following operations to correct the error.

* Bind the program 'program name' as the member part of the application plan 'plan name' * Correct the collection id in the PKLIST and bind the application plan 'plan name' * Set the current package set special register correctly * Put the correct 'location name' in the CURRENTSERVER of the BIND command and bind the application plan 'plan name' * Connect to the correct RDB name * Correct the location id in the PKLIST and bind the application plan 'plan name' * Bind the DBRM of the version of the application program to be executed

6) How can I know my particular program is using particular "PLAN"?

sysibm.syplan would have the data.

8)I have written program, ?PROGRAM-ID. ADD. Saved this particular program in a PDS as member name TEST. Will it work or throw any error?

for eighth when the program name in pds and the id if they are not same then i think it will give an error.

9) I am compiling a COBOL db2 program suddenly my Db2 brought down what will happen?

Regarding The above Question. U will get "DB2 CONNECTION INTERNAL ERROR" and the error number is "-924"

During compilation process it will check whether all the columns in the sql statements are present in Dclgen or not. During compilation it will not check DB2 system Catlogues(sysibm.syscolumns).

33

Page 34: Imp Mainframe Question

At compilation time Db2 is not at all required. During Bind process it will check as per DB2 Tables

for example : you can use a column in sql statement which does not exist in Db2 at all. but it should be Dclgen....thats it ..... your compilation job will be fine but your bind job fails

10) What is Z-OS?

for tenth question Z/OS is the operating system which is an advanced one like MVS.

IMS - PROCOPT

G - can't read a segment while it was holding or updating by another pgm. GO - Can read the segment holding or updating by another pgm. GON - while reading a segment contains invalid pointers (due to access in the middle updation) returns 'GG' status code without abend. GOT - In the same situation above, it tries again and retrieves the segment only if the updation commits or backed out.

G get I insert R get and replace D get and delete A get, insert, replace, and delete P required if the D command code is to be used O do not perform integrity checks for read only processing must be specified as GO, GON, GONP, GOT, GOTP, or GOP N do not abend on invalid pointer, return GG instead must be specified as GON, GONH, or GONP T same as N but automatically retries before returning GG must be specified as GOT, GOTH, or GOTP E enable exclusive use by online program L load

34

Page 35: Imp Mainframe Question

GS get in ascending sequence (hsam only) LS load in ascending sequence (hidam or hdam only) H use high speed sequential processing

Can i ISSUE GNP call first with out using GN OR GU call before?

No you can't. It returns staus code as "GP" - No parentage established.

Preventing a Program from Updating Data: Processing Options

During PCB generation, you can use five options of the PROCOPT parameter (in the DATABASE macro) to indicate to IMS™ whether your program can read segments in the hierarchy, or whether it can also update segments. From most restrictive to least restrictive, these options are:

G

Your program can read segments.

R

Your program can read and replace segments.

I

Your program can insert segments.

D

Your program can read and delete segments.

A

Your program needs all the processing options. It is equivalent to specifying G, R, I, and D.

Related Reading: For a thorough description of the processing options see, IMS Version 9: Utilities Reference: System.

Processing options provide data security because they limit what a program can do to the hierarchy or to a particular segment. Specifying only the processing options the program requires ensures that the program cannot update any data it is not supposed to. For example, if a program does not need to delete segments from a database, the D option need not be specified.

35

Page 36: Imp Mainframe Question

When an application program retrieves a segment and has any of the just-described processing options, IMS locks the database record for that application. If PROCOPT=G is specified, other programs with the option can concurrently access the database record. If an update processing option (R, I, D, or A) is specified, no other program can concurrently access the same database record. If no updates are performed, the lock is released when the application moves to another database record or, in the case of HDAM, to another anchor point.

The following locking protocol allows IMS to make this determination. If the root segment is updated, the root lock is held at update level until commit. If a dependent segment is updated, it is locked at update level. When exiting the database record, the root segment is demoted to read level. When a program enters the database record and obtains the lock at either read or update level, the lock manager provides feedback indicating whether or not another program has the lock at read level. This determines if dependent segments will be locked when they are accessed. For HISAM, the primary logical record is treated as the root, and the overflow logical records are treated as dependent segments.

When using block-level or database-level data sharing for online and batch programs, you can use additional processing options.

The following topics provide additional information:

E option GO option

N option

T option

GOx and data integrity

Related Reading:

For a special case involving HISAM delete byte with parameter ERASE=YES see, IMS Version 9: Administration Guide: Database Manager.

For more information on database and block-level data sharing, see IMS Version 9: Administration Guide: System.

E option

With the E option, your program has exclusive access to the hierarchy or to the segment you use it with. The E option is used in conjunction with the options G, I, D, R, and A. While the E program is running, other programs cannot access that data, but may be able to access segments that are not in the E program's PCB. No dynamic enqueue by program isolation is done, but dynamic logging of database updates will be done.

36

Page 37: Imp Mainframe Question

GO option

When your program retrieves a segment with the GO option, IMS does not lock the segment. While the read without integrity program reads the segment, it remains available to other programs. This is because your program can only read the data (termed read-only); it is not allowed to update the database. No dynamic enqueue is done by program isolation for calls against this database. Serialization between the program with PROCOPT=GO and any other update program does not occur; updates to the same data occur simultaneously.

If a segment has been deleted and another segment of the same type has been inserted in the same location, the segment data and all subsequent data that is returned to the application may be from a different database record.

A read-without-integrity program can also retrieve a segment even if another program is updating the segment. This means that the program need not wait for segments that other programs are accessing. If a read-without-integrity program reads data that is being updated by another program, and that program terminates abnormally before reaching the next commit point, the updated segments might contain invalid pointers. If an invalid pointer is detected, the read-without-integrity program terminates abnormally, unless the N or T options were specified with GO. Pointers are updated during insert, delete and backout functions.

N option

When you use the N option with GO to access a full-function database or a DEDB, and the segment you are retrieving contains an invalid pointer, IMS returns a GG status code to your program. Your program can then terminate processing, continue processing by reading a different segment, or access the data using a different path. The N option must be specified as PROCOPT=GON, GON, or GONP.

T option

When you use the T option with GO and the segment you are retrieving contains an invalid pointer, the response from an application program depends on whether the program is accessing a full-function or Fast Path database.

For calls to full-function databases, the T option causes DL/I to automatically retry the operation. You can retrieve the updated segment, but only if the updating program has reached a commit point or has had its updates backed out since you last tried to retrieve the segment. If the retry fails, a GG status code is returned to your program.

For calls to Fast Path DEDBs, option T does not cause DL/I to retry the operation. A GG status code is returned. The T option must be specified as PROCOPT=GOT, GOT, or GOTP.

37

Page 38: Imp Mainframe Question

GOx and data integrity

For a very small set of applications and data, PROCOPT=GOx offers some performance and parallelism benefits. However, it does not offer application data integrity. For example, using PROCOPT=GOT in an online environment on a full-function database can cause performance degradation. The T option forces a re-read from DASD, negating the advantage of very large buffer pools and VSAM hiperspace for all currently running applications and shared data. For more information on the GOx processing option for DEDBs, see IMS Version 9: Utilities Reference: System.

gn call for the product segment... CALL 'CBLTDLI' USING DLI-GN DB-PCB-MASK PROD-DB-AREA PROD-ID-SSA. 01 PROD-ID-SSA. 05 FILLER PIC X(9) VALUE 'PRODUCT ('. 05 FILLER PIC X(10) VALUE 'PRODCAID ='. 05 PROD-CAT-CID PIC X(5). 05 FILLER PIC X VALUE ')'. gnp call for order segment CALL 'CBLTDLI' USING DLI-GNP DB-PCB-MASK ORDR-DB-AREA ORDR-ID-SSA. 01 ORDR-ID-SSA. 05 FILLER PIC X(9) VALUE 'ORD ('. 05 FILLER PIC X(10) VALUE 'ORDPID ='. 05 ORDR-PID-VALUE PIC 9(5). 05 FILLER PIC X VALUE ')'.

Answer

Always remember that IMS calls are based on POSITION. You can NEVER go backwards - only forwards. You can re-position yourself with a GU. The first thing I would do is to load your key for the prod segment into the prod-cat-cid. I would then issue a GU - not a GN. Behind the scenes - with a GN - even

38

Page 39: Imp Mainframe Question

a qualified, IMS reads each prod segment until it satisfies the loaded key. With a GU, IMS looks at the CI splits to determine where the key may be. (Just in case you wanted to know). I hope you are checking for successful call when you issue the call for the prod. If you don't get it, you should have some sort of error routine for the result of your call depending on what the status code is - anything other the spaces or GE (not found) will be very bad.

gn call for the product segment...

CALL 'CBLTDLI' USING DLI-GN DB-PCB-MASK PROD-DB-AREA PROD-ID-SSA.

01 PROD-ID-SSA. 05 FILLER PIC X(9) VALUE 'PRODUCT ('. 05 FILLER PIC X(10) VALUE 'PRODCAID ='. 05 PROD-CAT-CID PIC X(5). 05 FILLER PIC X VALUE ')'.

Once you have the parent, you will need to retrieve the child - or children. Do you have a key for the order? How do you know which order you are looking for? You cannot issue a qualified call under the root unless you know. You need to explain what you are looking for. It cannot and must not be a qualified call unless you know. Remember that the reason this is a child segment is that there can be 1 to many.

gnp call for order segment

CALL 'CBLTDLI' USING DLI-GNP DB-PCB-MASK ORDR-DB-AREA ORDR-ID-SSA.

01 ORDR-ID-SSA. 05 FILLER PIC X(9) VALUE 'ORD ('. ---------------------------you will need to make this spaces unless you know the order number..... 05 FILLER PIC X(10) VALUE 'ORDPID ='. 05 ORDR-PID-VALUE PIC 9(5). 05 FILLER PIC X VALUE ')'.

39

Page 40: Imp Mainframe Question

IMS Status Codes

The following status codes may be returned after processing an IMS call

blank

call completed successfully

AA

the alternate PCB contains a transaction code instead of a logical terminal as a destination

AB

segment I/O area is missing from call statement

AC

hierarchical error on insert or get call

AD

function argument is not coded correctly

AF

size of variable length record is invalid for GSAM get access

AH

invalid SSA encountered on insert call

AI

error opening database

AJ

SSA specified for the call is invalid

AK

field name specified for qualified SSA is incorrectly coded

AL

40

Page 41: Imp Mainframe Question

batch program has issued a ROLS, ROLB, or SETS call and either the system log does not reside on disk or dynamic backout is not specified

AM

function specified is not compatible with one of segment sensitivity, program type, or PCB processing

AO

a physical I/O error has occurred

AP

a CHKP function issued a transaction oriented BMP or a message call has more than 4 parameters

AT

I/O area specified is too small

AU

length for SSAs specified exceeds the maximum allowed

AY

logical terminal name found in a response alternate PCB has more than one physical terminal assigned

AZ

a PURG or ISRT was ignored in a conversational program

A1

logical terminal name specified incorrectly in I/O area for a CHNG call

A2

PCB specified incorrectly for a CHNG call

A3

PCB specified incorrectly for an ISRT or PURG call

A4

security violation

A5

parameter list specified incorrectly on ISRT or PURG call

41

Page 42: Imp Mainframe Question

A6

ISRT function message length exceeds allowable length

A7

ISRT function number of messages added exceeds maximum allowed

A8

ISRT function issued to a response alternate PCB must follow ISRT to I/O PCB and these statements are reversed

A9

ISRT function message to response alternate PCB ignored because SAMETRM=YES

BA

call not completed because data is not available, operations by current call up to this error have been backed out

BB

call not completed because data is not available, operations since last commit point have been backed out

CA

CMD function command verb invalid

CB

CMD function command from an AOI program not allowed

CC

after command completed successfully, IMS returned one or more command responses

CD

program does not have authority to execute a command listed in this CMD function

CE

IMS rescheduled a message as a result of a call with the function GU since the last CMD call

CF

message scheduled before IMS was started

42

Page 43: Imp Mainframe Question

CG

message retrieved by GU originated from an AOI user exit

CH

Automated Operator Interface (AOI) encountered a system error, current command not ignored

CI

IMS rescheduled a message as a result of a call with the function GU since the last CMD call and message scheduled before IMS was started

CJ

IMS rescheduled a message as a result of a call with the function GU since the last CMD call and message retrieved by GU originated from an AOI user exit

CK

message scheduled before IMS was started and message retrieved by GU originated from an AOI user exit

CL

IMS rescheduled a message as a result of a call with the function GU since the last CMD call, message scheduled before IMS was started, and message retrieved by GU originated from an AOI user exit

CM

exception response occurred when executing a command issued via CMD call

CN

value in PSBIOAZ field is incorrect

DA

REPL or DLET attempted to change segment key field

DJ

get hold issued after REPL or DLET

DX

DLET violated delete rule for segment

FA

43

Page 44: Imp Mainframe Question

arithmetic overflow error

FC

call type and segment type are incompatible

FD

resource deadlock

FE

FLD function received non blank status code in FSA

FF

MSDB did not contain free space when ISRT was issued

FG

FLD function received non blank status code in FSA and program has used all of buffer pool

FH

DEDB was not accessible when database call was issued or commit point was reached

FI

I/O area address not accessible to program

FM

randomizer did not return a DMAC address

FN

field name of FSA undefined in DBD and FLD function issued

FP

invalid hex or packed field in I/O area

FS

buffer limit for region exceeded

FT

number of SSAs exceeds limit of 15 for DEDB or 1 for MSDB

44

Page 45: Imp Mainframe Question

FV

verify operation failed at commit point

FW

program has used all of buffer pool

GA

call completed successfully but higher level crossed for GN or GNP call

GB

end of database reached on GN call

GC

attempted to cross unit-of-work boundary

GD

position in database lost

GE

segment not found

GG

processing with procopt of GON or GOT and concurrent update activity is occurring

GK

call completed successfully but different segment type on same level retrieved for GN or GNP call

GL

LOG request has an invalid log code

GP

GNP issued but parentage was not previously established

II

attempt to insert a segment with a duplicate key

IX

45

Page 46: Imp Mainframe Question

insert rule violation

LB

attempt to load a segment that already exists

LC

attempt to load a segment out of sequence

LD

attempt to load a segment whose parent does not exist

LE

hierarchical sequence in DBD does not match that in the segment to be loaded

MR

terminal name invalid on ISRT message call

NA

one or more databases not available

NE

during index maintenance, a segment was not found

NI

unique secondary index but duplicate key encountered

NO

physical I/O error

NU

information only, REPL DLET or ISRT may return BA status code

QC

GU message request failed

QD

GN requested but no more message segments exist

46

Page 47: Imp Mainframe Question

QE

GN not followed by GU message request

QF

length of message segment is less than 5 bytes

QH

terminal symbolic error encountered

RA

token does not match any on an outstanding SETS call

RC

ROLS call was rejected

RX

replace rule violation

SA

storage space for I/O area unavailable on SETS call

SB

attempted to set 10 levels (only 9 are allowed)

SC

SETS call was rejected

TA

CICS command level failed because PSB is not defined

TC

PSB in use by previous request

TE

unable to initialize the specified PSB

TG

47

Page 48: Imp Mainframe Question

no PSB scheduled for program

TH

no PSB scheduled for program

TI

path to segment is invalid

TJ

DL/I is not active

TL

encountered conflict in scheduling intent

TN

invalid system DIB was found

TO

path replace error found

TP

PROCOPT invalid

TQ

I/O PCB access not allowed in a local DL/I call

TR

CICS XDLIPRE exit cancelled a request

TY

database is not open

TZ

segment length longer than 64k

UC

during batch processing, a checkpoint record was written to the utility control facility (UCF) dataset

48

Page 49: Imp Mainframe Question

UR

during batch processing, IPL is restarted under UCF

US

during batch processing, an IPL is halted

UX

during batch processing both checkpoint and program halted

VI

during an insert or update length of variable length segment is too long

GNP call

A GNP with an unqualified SSA sequentially retrieves the dependent segment occurrences of the segment type you have specified under the established parent.

A GNP with a qualified SSA describes to IMS the segment you want retrieved or the segment that is to become part of the hierarchic path to the segment you want retrieved. A qualified GNP describes a unique segment only if it is qualified on a unique key field and not a data field or a non unique key field.

A GNP with multiple SSAs defines the hierarchic path to the segment you want. If you specify SSAs for segments at levels above the established parent level, those SSAs must be satisfied by the current position at that level. If they cannot be satisfied using the current position, a GE status code is returned and the existing position remains unchanged. The last SSA must be for a segment that is below the established parent level. If it is not, a GP status code is returned. Multiple unqualified SSAs establish the first occurrence of the specified segment type as part of the path you want. If some SSAs between the parent and the requested segment in a GNP call are missing, they are generated internally as unqualified SSAs. This means that IMS includes the first occurrence of the segment from the missing SSAs as part of the hierarchic path to the segment you have requested.

49