Thursday, 27 September 2012

EXEC statement

As JOB conatains steps which have to be executing so EXEC statement tells compiler that this is my step which has to be executed.

It specifies program or procedure to be executed.

Syntax:

Stepname EXEC pgm or proc,parameters

A maximum 255 EXEC statements can be coded within a JOB.

Parameters on EXEC statements:

A) Positional parameters:

1)PGM
2)PROC

B) Keyword parameter:1)ACCT
2)COND
3)REGION
4)ADDRSPC
5)PARM
6)TIME

1) PGM parameter
This parameter specifies a program name or utility name which has to be executed from that step.

Syntax:

//STEPNAME  EXEC pgm=program-name

PGM is first parameter on EXEC statement.

EXAMPLE:
STEP1 EXEC pgm=ADDPGM

2) PROC parameter

Used to call an instream procedure or catlog procedure.

Syntax:

stepname exec proc=procedure-name
or
stepname exec procname.

Example:

step1 exec proc=newproc
or
step1 exec newproc.

3) ACCT

This parameter specifies Accounting information.

This is used for billing or charge back purpose information.
In production environment there are many teams are working for different purposes so each of them have a different accounting ID for billing purpose.

Syntax:

(Account-number additional accounting information)
Total number of character is 142.

4) PARM
This will pass the information to your program.

Syntax:
PARM=information.

information is maximum 100 character in length.

//step1 exec pgm=pgm1,PARM= welcome to mainframe

Below parameters are common to JOB as well as EXEC statements

5) TIME
This parameter if specified then it will override the default installation TIME value.

Syntax:

TIME=(min,sec) or

        (NOLIMIT) or

       (MAXIMUM) or

       (0)

min=from 0 to 357912 i.e max 248 days.

sec=from 0 to 59.

NOLIMIT = specifies JOB or JOB step can use unlimited processing time.

Maximum = Specifies JOB or JOB step uses maximum processing time i.e 248 days.

0  means JOB step can use remaning time from previous time and if it require more time to process then job will abend.

Examples:

//JOB1 JOB ,,TIME=(10,3)

//JOB1 JOB ,,TIME=10

//JOB1 JOB ,TIME=MAXIMUM

//STEP1 EXEC PGM=IEBCOPY,TIME=(,30)

//STEP1 EXEC PGM=pgm1,TIME=NOLIMIT



6) ADDRSPC

Specifies the JOB or JOB step use either virtual or Real storage.


Syntax:
ADDRSPC=(VIRT or REAL)

7) REGION

This parameter override default memory allocated to JOB or JOB step.

Syntax:

REGION= value in KB or

                   value in MB.

KB value is max. 7 digit and
MB value is max.4 digit

If REGION=0K or 0M ,then all the available storage will be assigned to that job.
          
Example:

      //JOB1 JOB ,,REGION=126K
     //STEP1    EXEC PGM=IEFBR14,REGION=95M





    





JCL statement

JCL statements

There  are 3 types of JCL statements used

1) JOB  - Used for identification of JOB.
2) EXEC - Used for identification of Execution.
3) DD   - Used for identification of Data source.

Other statements are NULL statement and Comment statement.

JOB statements contains detail about JOB name programmer name etc.

EXEC statements contains name of program to be executed.

DD statement contains source and output dataset name.

At end JCL terminated by Null statement.

JOB statement:
This is first statement of JOB card.
It identifies beginning of JOB.
It contains positional parameter as well as Keywword parameter.

Positional parameter:

 
1) JOB accounting information

 2) Programmer name.

Keyword parameter:

 1) CLASS
 2) MSGCLASS
 3) MSGLEVEL
 4) PRIORITY
 5) NOTIFY
 6) COND
 7) TIME
 8) RESTART
 9) REGION
 10)TYPRUN

1) JOB Accounting Information.

This is used for billing or charge back purpose information.
In production environment there are many teams are working for different purposes so each of them have a different accounting ID for billing purpose.

Syntax:

(Account-number, additional accounting information)
Total number of character is 142.

You can write Accounting information like TEAM
If we omit this parameter then give comma.

2) Programmers Name

This parameter gives information about programmer who has written and submitted the JOB.
Max lenth is 20 char.

Example:

//IEFBR14 JOB ACCT, AVINASH
//IEBCOPY JOB ACCT, AVINASH

3) CLASS

Used to assign JOB class which decides nature of JOB.

Syntax:

CLASS=JOB class

JOB class may be from A-Z and from 0-9

Frankly speaking you dont need to give this parameter this is installation dependent.

4) PRTYThere are different classes as mentioned above and the schedular picks up the different classes JOB based on PRTY basis.

Syntax:

PRTY=number from 0-15.

This is also installation dependent you need not to specify this.

5) MSGCLASS

This parameter used to specify the output device to which output message like system message and JCL message to be routed

Syntax:

MSGCLASS=output-class-name

It is A-Z or 0-9

This is also installation dependent.


6) MSGLEVEL
As you have submitted the job then messages like JCL message, System message ,Log message are to be recorded on output device specified by MSGCLASS parameter.

Syntax:

MSGLEVEL=(statements,messages) failed

where statements may be a number from 0 to 2 and message value is either 0 or 1.

This parameter is also system defined.

1) statements value and its meaning0 means only Job related messages to be recorded.
1 means all JCL statements including procedure to be recorded
2 means only input JCL statement to be recorded.

2) Message value and its meaning

0 means JOB allocation or termination messages to be output if job terminates abnormally.
1 means JOB allocation or deallocation messages to be output even if job terminates normally or abnormally.

7) NOTIFY parameter

This parameter notify user about job completion whether it is successful or failed due to some reason.

Syntax:

NOTIFY=userid or &sysuid.

//jobname job,notify=&sysuid


8)TYPRUN
This parameter specifies enviroment for JOB execution.

Syntax:

TYPRUN=SCAN or HOLD or JCLHOLD or COPY

If TYPRUN=SCAN then it will SCAN the JCL statements for syntax error and reports it. This will not execute job even if no errors.

If TYPRUN=HOLD then JOB will held for execution until user released it.It will check for errors when JOB is submitted.

If TYPRUN=copy then job is printed as sysout datast but not processed.

9) RESTARTThis parameter is important one when a submitted job abends on step3 then to start the execution of same JOB from step3 use RESTART parameter.

Syntax:

RESTART=* or stepname or stepname.procstepname

where * indicates default first step.
Stepname specifies specific step name.
stepname.procstepname specifies start of specified step from a procedure.

Example:

//JOB1,RESTART=STEP3.STEP4



JCL introduction

                                                    Introduction to Mainframe programming.

Before that I would like to highlight on two different programming technique that we used in Mainframe.

           1) Batch programming means there is no any human interaction . Here you run your code which will not accept any human values .

          2) Online programming here human interaction is must. The values passed by human will decide the flow of execution of program.



                                                     What is JCL ?

  JCL = Job control language.
  JOB =   It is the execution of one or more related programs in sequence. Each program to be executed by  a job is called a job step.

  JCL is the command language of MVS and consists of a set of control statements that identifies the program to be executed and the data to be read or written. Jobs written in JCL are managed by an operating system (OS) component called the Job Entry Subsystem or JES. For every job that is submitted to OS for execution, we need to tell the OS, the programs it has to execute, the inputs that are required, the location of input and the location for output. These information are provided using statements known as Job Control Statements.

       1) JCL statements are coded in 80 byte records –

            Only 72 of the 80 chars are available to code the JCL. The columns 73-80 is reserved for   sequence number or comment means the compiler will ignore it.

                          2) Each JCL statement is logically divided into five fields. All five fields may not appear on every statement.
  
 3) JCL statements has the following fields
a.      Identifier
b.      Name
c.       Operation
d.      Parameters
e.      Comments

              

 1)      Identifier - Two slashes ( // ) starting in col 1.     Exceptions are
                  For a delimiter statement, /* starting in col 1
                  For a comment statement , //* starting at col 1

2)      Name – It can be from one to eight characters long, consisting of alphanumeric (A-Z and 0-9) and National (@,#,$) characters. Name should start with an alphabet or national ($, #, @) character. It must begin at col 3.

3)      Operation – A valid operation code, such as JOB, EXEC or DD. Must be preceded and followed by a space.
      Parameters – One or more parameters depending on the operation. Individual parameters are separated from one another by commas.


           4) JCL parameters :
             
          a) Positional parameters
  
 are coded first in the parameter field. If you omit a positional parameter and code a following                positional parameter, then code a comma to indicate the omitted parameter. 

      Do not code the replacing comma if:
         The omitted positional parameter is the last positional parameter.
         All following positional parameters are also omitted.
         Only keyword parameters follow.
         All positional parameters are omitted

In the JOB card there are 2 positional parameters 

          1) JOB accounting information.
           2) Programmer name.

Eg. See below job card I have written with positional parameters only.
//Ak47,   Job,  a123,  avinash

1) The JOB which is operation field must started between column 8 to 11.
2) A123 is accounting information.
3) Avinash is programmer name.

If I skipped any positional parameter then give comma.

 b) Keyword parameters -

      A keyword consists of characters that appear in uppercase followed by an equals sign (e.g. NOTIFY=&SYSUID) followed by either characters that must be coded or variable information. Code any of the keyword parameters for a statement in any order in the parameter field after the positional parameters. Because of this positional independence, never code a comma to indicate the absence of a keyword parameter.

                Class, notify, msgclass, msglevel, prty, typrun are the keyword parameter used in JOB card.

        5) Comments:
 comments may follow parameters, preceded by one space and not extending beyond col 71.

                                                How the JOB is processed in mainframe ?

There is JOB entry subsystem which will  handle the execution of JOB. As there are user across the world uses mainframes for their day to day activities. But then also JES manages all these execution process smoothly.




1) Determine the job requirement and characterstics.
2) write JCL
3) Submit the JCL.

After submitting the JCL the user part is over now its turn of JES system which proceed below.





4)  JES receive submitted job and initiate initiator.
5) JCL steps are executing
6) JES collects output.
7) JES prints output.
8) User views output.