Showing posts with label ISPF. Show all posts
Showing posts with label ISPF. Show all posts

Friday, October 6, 2017

Interpreting TSO ISRDDN command in mainframe ISPF

The TSO ISRDDN command is a useful tool that lets you browse/view your active TSO session libraries. From any session, type TSO ISRDDN and the below widow will open up.




















 On the right side of the display is a list of DDNAME(in white colour)  and their associated data sets ( (in Green colour) currently allocated to the user session.
**Dataset names in green are blurred on purpose

 The left side of the display contains columns of information about individual data sets like the volume information and all. When you scroll right (using F11)or left(or F10) , the left side of the screen changes. Initially, the left side of the screen contains the volume name and disposition,if the dataset is SMS managed or not ,etc . If the disposition is red, there are other jobs waiting to use this data set as shown. 

Generally the dataset associated with sysproc ddname contains the pds for the clist macros available in the system.

Try issuing  the command LINKLIST or LPA. Either command will add both the system LINKLIST and LPA libraries to the display.The LINKLIST and LPALIB (Link Pack Area LIBrary) are related concepts. The LINKLIST is a collection of libraries, established during the IPL, that contain system and user load modules. Any program in the LINKLIST does NOT require a JOBLIB or STEPLIB to point to the load library -- the system can find such programs without any JCL statements. The LPALIB basically contains read-only programs (which may system or user load modules) that are reenterable.

Saturday, July 30, 2016

Zoned Decimal and packed Decimal (COMP- 3) fields. How Does COMP 3 saves storage space?

Two computer codes which are used  for internal representation of data are EBCDIC and ASCII.
Extended Binary coded decimal interchange(EBCDIC)  code is a 8 bit character encoding standard used in IBM environment.
Most of the other Non IBM machines use ASCII standard.
Below is the EBCDIC representation of the alphabets and numbers followed in IBM environment.
EBCDIC represenation of Aphabets and Numerals

Following the chart, we can see 'a' (2nd row in above chart)  is represented in binary in 1000000001 and has the hex value of  81.

 All characters & numbers are represented in 8 bits. These 8 bits can be  broken into two 4 bit segments. For historical reasons, the  high order 4 bits are called zone part and low order 4 bits are called digits part.
Each of these 4 bits are represented by one hexadecimal character. Thus each 8 bit EBCDIC can be represented by  two character hexadecimal value. The high order 4 bits are used to represent whether the value stored is a letter,positive or negative number. Low order 4 bits represents numbers 0-9.

Let us see how the letter D is stored internally.(Map with the chart above)

In similar fashion, we can see how the letter 8 will be stored in the system( Map with the chart above)

Thus we see that in zoned decimal each byte represents one digit.

So, how will the positive number 62587 be stored in the system?
Zoned decimal number in EBCDIC repreentaion
In  zoned decimal, the zone portion of the rightmost byte represents the sign of the number.
For positive number, the zone portion is always 1111.
For negative number the zone portion becomes  1101.
Thus -6 can will be represented  as: 1101(Zone part) 0110(Digit part)

Packed Decimal fields: How does it save spaces?  Let's see how it works.

In  packed decimal format, the zone portion is stripped from each byte, so that two digits can be packed together in one byte.This way the space for zone portion of each byte can be used to represent another digit. Thus two digits are represented in single byte there by saving the space.
Only the zone portion of the low order or the rightmost byte is kept for storing the sign of the field.
Considering the same example, see how the number 62587 will be stored in packed decimal format.
Space utilized will be reduced from 5 bytes to 3 bytes.

Number :                                6               2              5             8                7
Packed decimal representation
We can see that two digits are packed in single byte by stripping of the zone portion of all the bytes except the last byte (marked in brown).
Had it been a negative number the last byte would have contained 1101 in place of 1111.

This way, a packed decimal number saves space by packing two digits in one byte.


Thursday, June 16, 2016

RENT compiler option in cobol - Understanding reentrant programming

For understanding RENT compiler option, we need to know  what is a  re-entrant program.
A re-entrant is a program that doesn’t change itself. “How can a program change itself?” Does the word "Multi threading " looks familiar?  Reentrant and mutithreading are related but somewhat different topics.
We can divide our program(logically) into  three parts:
1. Program code – the instructions that are executed when a program runs.
2. Constants – constants used in a program. These are set when the program is written, and never change.
3.Working  Storage area – or variables. This area changes when different user fires the same program.

"A reentrant Cobol program gives each user their own copy of working storage. " 
For every user,MVS supplies the GETMAIN and STORAGE macros to support this and they can be
used by subsystems such as CICS or IMS or whatever to support reentrant programs.

For each user the copy of the working storage is dynamically acquired and initialized from the original copy. When a user interacts with the program , he only modifies his copy of the variables.

When the program is interrupted to give another user a turn to use the program, information about the data area associated with that user is saved.

So, what will happen if we write a CICS program as non-renetrant?
When one transaction waits, a second transaction can come and modify the working storage variables, and thus providing unstable or undesirable results.

Thus, Re-entrant programs allow a single copy of a program or routine to be used concurrently by two or more processes.


For cobol, we use the compiler option RENT to generate reentrant object program.

Thursday, February 18, 2016

TSO WHOHAS code in REXX

Sometimes we face job abends, or job waiting for resource owing to the fact that some datasets get into contention with some other jobs or some user is using that particular file. Most of the organizations use TSO WHOHAS command to check the user holding the dataset. In this post we will see the piece of code in REXX which makes the command work.

/* REXX*/
DSNAME = ARG(1)
IF DSNAME = ' ' THEN DO
          SAY  'ENTER DATASET NAME'
PARSE UPPER EXTERNAL DSNAME
END
ADDRESS TSO
IF SYSDSN("'"DSNAME"'") <>  'OK' THEN DO
    SAY "DATASET DOES NOT EXIST"
    ADDRESS ISREDIT
    EXIT
END
ADDRESS TSO "ISRDDN E  ' "DSNAME" ' "
EXIT
Simple piece of code and it uses ISRDDN utility. It is an IBM utility which lists all the allocated DDNAME for your current TSO session.

Without the rexx code also , we even can execute the command
TSO ISRDDN ENQ 'Data-set Name'
and it will show the corresponding information

Tuesday, August 4, 2015

Can we delay the execution of a mainframe job?OPSWAIT is an option

Have you ever tried to keep a job or certain steps in a job to wait for sometime and then execute without using any scheduler ?

When would it be useful to ask mainframes to sleep like this?

Few days back ,came across a specific scenario when it was needed to put a job step on hold for sometime and then execute it.

Say for unit testing you want to execute two jobs in certain instance to check dataset conflict or table conflict.
Suppose we have a job with 3  steps. We want to execute step1 an then wait for sometime, say 1 minute, and then execute the remaining 2 steps. How do we do it ?

OPSWAIT is the option which can help us in this scenario.  (We need CA tool to be installed in our environment).
The OPSWAIT function suspends processing of the program or rule for a specified period in an OPS/REXX program or REQ rule.This  function can be used in OPS/REXX, AOF rules, TSO/E REXX, or CLIST.

//Jobcard..
//PSTEP01 EXEC PGM=TSTPGM
...
//PSTEP02  EXEC PGM=OPSWAIT,PARM='FOR(01:00)'
//PSTEP03  EXEC PGM=TSTPGM2
....
Once you submit this JCL, it till execute the step PSTEP01,then it will cause the mainframe to sleep for 1 min and then execute step 2.
We can try this command going into TSO command (option 6) and typing OPSWAIT 01:00.(01=mins,00=seconds)

We can also use this JCL to put the program on hold.
//SLEEP EXEC PGM=IKJEFT01 
//SYSPRINT DD SYSOUT=* 
//SYSTSPRT DD SYSOUT=* 
//SYSTSIN DD * 
OPSWAIT FOR(01:10) 
//* 

Friday, April 10, 2015

Create Dataset name dynamically using system date and time or timestamp - using EZACFSM1

Many times we face the scenario, where we are in need to create a file suffixed with today's date ,time ,ie  the system date and time. It can be done in various ways. In this post we will see how to use one utility EZACSFM1 to achieve the same. It is a good utility and accepts many parameters which can be used tactfully to achieve good results.

//JOHNEZC JOB 1,'TEST', CLASS=I,NOTIFY=&SYSUID
//STEP1        EXEC PGM=EZACSFM1
//SYSOUT DD SYSOUT=(,INTRDR)   <= submit the below job via internal reader
//SYSIN DD DATA,DLM='..'
//TTEST JOB 1,'EZACSFM1',CLASS=I,NOTIFY=&SYSUID
//STEP2        EXEC PGM=IEFBR14
//MYDATA  DD DSN=TEST.DATA.D&DAY.M&LMON ,
//                          DISP=(,CATLG,DELETE),
//                         SPACE=(CYL,(10,10),RLSE),
//                         DCB=(RECFM=FB,LRECL=10,BLKSIZE=0)
(Tested code. Runs fine)
Explanation:
We are submitting the IEFBR14 job to create the dataset  TEST.DATA.DMON.M04 via internal reader as mentioned above.
If you see, i have  kept 'D&DAY' and  'M&LMON' in blue. Just to keep our attention there. The utility EZACSFM1 substitutes the value of day and month values there which will be created dynamically. &day, &lmon are the parameters of the utility.
If we submit the job, two jobs will be submitted. The first job will submit the second job creating the dataset with IEFBR14 dynamically with the date and time parameters.

To display the values in spool in sysout, try this piece of code.We will come across more options.
<Tested code >
//STEP1     EXEC PGM=EZACFSM1      
//SYSOUT    DD  SYSOUT=*          
//SYSIN     DD  *                
&YR.-&LMON.-&LDAY
&YR./&LMON./&LDAY
DATE IS : &YR.&LMON.&LDAY
/*
//
Some more parameters which EZACFSM1 takes. There are many more.

 '&DAY'                
 '&HHMMSS'              
 '&HR'                  
 '&JOBNAME'          
'&SEC'              
'&SEQ'                
'&YYMMDD'            
Test these small piece of code.M sure, you will find it very useful!!!

Thursday, March 12, 2015

Difference between PDS and PDSE - Brief discussion

We all know that a PDS (partioned data set), commonly referred to as Library in Z/OS world is a collection of several data sets which we call as members. A PDS internally contains a directory which keeps track of the member names.
A PDS is created with a Data Set Organization of PO , (DSORG=PO), which stands for partitioned organization.

Creating PDS using 3.2 option
Directory blocks  . . 20
Data set name type  : PDS
Using JCL:
SPACE=(TRK,(50,10),20)

However a PDS have certain disadvantages:
1. When we delete a member from a PDS, the space remains unused. We need to compress the PDS using 'Z' at the command line , or we can use IBM utility  IEBCOPY to reclaim the unused space.

2. Also as we know, a PDS internally contains a directory. As the size of the PDS grows, ie, as we add more and more members into the pds, the directory size gets near to the threshold (This Directory size we give when we define a PDS), after which we can not add any more members in the PDS.
Then we need to copy all the members into a new PDS with increased Directory size.

PDSE ( partitioned data set extended ):  Exactly same as PDS in many respects.
However , PDSE  data sets can be  stored only on DASD, not on tape. Interesting thing is the directory can expand automatically  as needed. Additionally it has an index which helps to locate the members inside the PDSE faster . SPACE from deleted members are automatically reused in PDSE .

PDSE files have DSORG=PO and DSTYPE=LIBRARY.
JCL to create PDS
//ALLOC    EXEC  PGM=IDCAMS
//SYSPRINT DD    SYSOUT=A
//SYSIN    DD    *
    ALLOC -
    DSNAME(TEST.PDSE1.EXAMPLE1) -
    NEW -
    STORCLAS(RM06) -
    MGMTCLAS(RM06) -
    DSNTYPE(LIBRARY)

Saturday, October 18, 2014

Command shell (option 6) in mainframe - Executing commands through Terminal Utility program IKJEFT01

Most of us have definitely seen or used in some way or other  the command shell(option 6) from ISPF panel. This is very useful command window. TSO /E allows us to talk to MVS  either through TSO E commands , or the ISPF pannel(like option 6) as i was mentioning above. In some work , i came across a scenario where i need to execute certain commands in command shell.
For example the following  commands:
REMOVE  I1612XX GROUP(MYGROUP) OWNER(MYGROUP)               
REMOVE  I171    GROUP(MYGROUP) OWNER(MYGROUP)               
CONNECT I151    GROUP(MYGROUP) OWNER(MYGROUP) AUTHORITY(USE)
CONNECT I151    GROUP(MYGROUP) OWNER(MYGROUP) AUTHORITY(USE)
The simplest way is to to go to ISPF and go to option 6. Then execute each command manually .

But the tweek in my case was to execute these commands in  batch and collect the command logs, ie, whether these commands were executed or not and all details.

So, here is the utility IKJEFT01 which we can use. Its other name is terminal utility program.
Whatever we want to execute in the pannel screen can be executed from batch as well using ikjeft01.
So, lets have the JCL for  using this utility.
Way1
//STEP001  EXEC PGM=IKJEFT01                
//SYSTSIN  DD   DSN=Your-Dataset,DISP=SHR
//SYSTSPRT DD   SYSOUT=*
Way 2
//STEP002    EXEC PGM=IKJEFT01             
//SYSTSPRT DD SYSOUT=*                     
//SYSTSIN  DD  *                           
    tso commands here


your-dataset would be the ps file having all the commands which needs to be executed
or  give all the commands in SYSTSIN DD *

Now if we explore further we can use this utility to perform many functions which in some cases may turn out to be very useful
Few useful commands which we can perform  in batch
1. Rename a dataset
2. Copy a file to some new name  (we can use other  ibm utilities as well)
3. Copy pds member to a new pds with a new name or same name
4 . Check job status and many other useful functions.
There are lot many others as well...
Have a look into jobs for some of the functions:
//STEP001    EXEC PGM=IKJEFT01                  
//SYSTSPRT DD SYSOUT=*                          
//SYSTSIN  DD  *                                
   SMCOPY FDS('USER12.JCL(TEST1)')  -           
          TDS('USER22.SAS(TEST2)') NOTRANS      

//SYSPRINT DD  SYSOUT=*                         
//SYSIN    DD  DUMMY                            
//* *****copy files                                            
//STEP002    EXEC PGM=IKJEFT01                  
//SYSTSPRT DD SYSOUT=*                          
//SYSTSIN  DD  *                                
   SMCOPY FDS('USER-ID.TST.FILE1')  -           
          TDS('USER-ID.TST.FILE2.FILE3') NOTRANS

//SYSPRINT DD  SYSOUT=*                         
//SYSIN    DD  DUMMY                            
 The  first step STEP001 copies pds members to other pds
The next step,STEP002 copies files
SMCOPY is the command to copy. FDS and TDS means From dataset and To dataset respectively.
Will explore some more and update as time permits!.

Tuesday, February 11, 2014

What are control blocks in Mainframes?

Control blocks are the memory units which represents/contains the status of what is going on or what has just happened, in short the TASK information when task is executed in the operating system. It provides the information about the job, CICS task and much other information.

Types of Control Blocks:

System Related Control Blocks
Resource Related Control Blocks
Job Related Control Blocks
Task Related Control Blocks

These provide debugging functionality in the event an operating system component or user application fails while the system is running.

Most commonly used system related control blocks are as follows:
1. CVT (Communication Vector Table)
2. SSCVT (Subsystem CVT)
3. ASCB (Address Space Control Block)
4. TCB (Task Control Block)
5. ASXB (Extended Address Space Control Block)

Where we use Control Blocks:
Dump Reading
CICS Abend Analysis
z/OS Data Areas
Diagnosing Dump
Abends  and many more..

TCBs represent tasks executing within an address space, such as user programs with multi tasking.

SRBs  executing from one address space and  perform a task in other some address space.
Each address space then has its own chain of ready SRBs and/or TCBs, pointed to from its ASCB. Whenever an event completes which changes the status of an address space, the relevant z/OS function updates the dispatching queues to reflect it.

ASCB – Address Space control Block
ASCB contains information and pointer addresses required for the management of this address space. Each address space is represented by an ASCB within the z/OS operating system.

ASVT – Address Space Vector Table
ASVT used to keep track of all address spaces in the system image, therefore it contains a list of all possible address space IDs, if assigned with associated ASCB. Remember an address space is created for each job, started task or mount request. CVTASVT which is the location of ASVT from system CVT.

ASXB – Address Space Extended Block
control block also contains information about an address space which has crucial information about number of TCB etc.     

PSA – Prefixed Save Area
Contains PSW ( Program Status Word) , interruption codes, registers  & register save area for lock manager & interrupt handler. It holds the basic information z/OS needs when scheduling work on a Central Processor (CP) , it always start at address ‘0’. One PSA per processor  & it contains processor related information.

FLCCVT - A pointer to the CVT

PSAAOLD - A pointer to the Address Space Control Block (ASCB) of the address space currently scheduled on this CP. The ASCB holds basic information about an address space, including Job name and Address Space ID. More information is held in the Address Space Extension Block (ASXB), which is pointed to by the ASCB.

PSATOLD - A pointer to the Task Control Block (TCB) of the task currently scheduled on this CP. The TCB holds information on a specific task.


Friday, August 9, 2013

Mainframe ISPF Tricks

ISPF tips
f p'###'  to find a string of 3 numeric characters
f p'.'    to find character that can not be displayed.
f p' #'   to find blank followed by a numeric character.
f p'#D'   to find numeric character followed by ‘D’. Give any character in place of ‘D’ like ‘VB’ etc

FIND OUT MVS VERSION
Open SDSF and give  WHO.

Remove all comments from the program
Type the following in the command line opening the program in view mode

X ALL '*' 7  -> This will remove all the comments. Then do
DEL X ALL