Excel and ISPF automation resource

Automated email notification for z/OS

0 comments
Despite the tools available in the mainframe, there are still tasks done manually.

Operation support personnel are needed to monitor jobs for abends. They spent their days staring at the screen, refreshing the screen manually by pressing the Return key.

Even mainframe developers cannot escape this. When you are doing testing, you may be required to wait for a long-running job before you can initiate your own tests.

Fortunately there is a simple way to address this using the email service commonly available in the mainframe.


Since most companies are using TN3270 (with TCP/IP) to connect to the mainframe, the Simple Mail Transfer Protocol (SMTP) service is probably already active in your system. If not, you will need the help of your systems support group to enable it.

Getting started.
Setting up a JCL that sends email from the mainframe is easy. You can start with any copy step using mainframe utilities with repro capability. IEBGENER, IDCAMS, SAS, Fileaid, and Eztrieve are some of the many choices available.

My personal preference is SORT and the jobstep will be similar to the one below.

//SORT EXEC PGM=SORT,REGION=0M
//SYSOUT DD SYSOUT=*
//SORTMSG DD SYSOUT=*
//SORTIN DD DISP=SHR,DSN=
your.email.dsn
//SORTOUT DD SYSOUT=(B,SMTP)
//SORTWK01 DD UNIT=SYSDA,SPACE=(CYL,(10,10),RLSE),DISP=(NEW,PASS)
//SYSIN DD *
SORT FIELDS=COPY


As you can see, it looks like any regular SORT job. The only noticeable difference is with the output (SORTOUT). Instead of a dataset, the output is being routed to the sysout that will be picked up by the SMTP later for processing.

There is another difference that is not apparent. The data found in the input (SORTIN) requires to follow a certain format. The simplest of which is shown below.

helo hostname
mail from: <youremail@address>
rcpt to: <receiver@address>
data
From:
youremail@address
To: receiver@address
Subject:
your subject

your body text

You need to update the items in italics. Most of these are familiar variables found in any other email except for the hostname. This variable refers to the JES node name for your system.

The items you need to think about are the subject and the body text. For abend monitoring, the common information included in the subject are the jobname, abending step and the return code. Depending upon the nature of the abend, you can include additional details in the body text of the email.

Beyond end-of-job notification.
What if you can do formatting?

How about adding some attachments?

These capabilities are available through Multipurpose Internet Mail Extensions (MIME). MIME is the standard for multi part, multimedia, and binary data in e-mails.

MIME is important as it opens the opportunity to create reports and sending them directly to the users. No more need for printing. Reports are sent on time. There is an added security as no other person has access to the reports except for the intended recipients.


Email standards discussion is another article in itself. If you want to learn more about this, I recommend reading this good article from Planet MVS.

Excel solution for a mainframe task

0 comments
People always goes back to what is familiar. IT professionals are no different.

When confronted with an issue, mainframe developers will look for solutions within the legacy system. Most will deal with these using Cobol. Others will lean on using other utilities.

But sometimes you can get solution outside of your development platform.

Previously, I have shown how to create a simple utility that can convert julian date to a gregorian format. Now, I will show you another simple alternative using Excel implemented through the formula shown below.

=DATE(A1/1000),1,MOD(A1,1000))

where A1 is the cell containing a number representing the julian date with ccyyddd format.


Different approaches. Both delivers similar level of simplicity.

So why even bother?

If your focus is on cutting mainframe-related costs, moving processes away from the systems can help. There are many opportunities for this in the area of data analysis and manipulation. How much you can gain will depend on how much of your processes you can migrate.

Non-mainframe solutions can provide a fail safe process. Connection issues, although maybe a rare occurrence, will impact your ability to deliver - especially those high-profile adhoc requests.

For mainframe developers, this breaks the monotony of green texts on a dark screen. This kind of exercise nurtures creativity as it allows you to think differently.

So the next time you are assigned a mainframe task, try coming up with two solutions - one mainframe and another non-mainframe. See how it goes?

Julian Date Conversion : Automation in five lines

0 comments
Working with legacy data, it is common to encounter dates in Julian format - a product from an era when a character of data was very precious. This format is meaningless to most unless converted to the more familiar Gregorian format - a task we can easily automate.

You may already have a solution in place in your system. Just in case you don't, I am sharing one with you.

First, create a new member in one of the SYSPROC libraries. Copy the code below and paste to this new member.

/* REXX */
PARSE ARG JDATE
GDATE = DATE('S',JDATE,'J')
SAY GDATE
EXIT 0

That's it. Five lines of code and you are done.

To use the tool, type TSO membername yyddd in the command line. The membername corresponds to the name of the new member created and yyddd is the Julian date to be converted.

This is one of the very first tools I created. The tool's simplicity does not diminish its value as I and the people I shared this with are still using this even today (although the one I have was modified to include a GUI).

Now, if you hear that automation is complex, show them this example.

Mainframe tool for regression testing

2 comments
It's just a typical regression testing for a mainframe developer. You submit a JCL and wait until it is completed. You open a new session window to review the output dataset and verify that it matches the expected results. Quite simple.

But when you spend your whole week repeating the same task, this is very mind numbing. You are bound to commit errors. You can't do away with it so you must find ways to address this - by automating some of the steps in the process.

One of the thing you can do is be able to view the output datasets without getting out of the JCL (without starting a new seesion window). An ISPF Edit macro is appropriate for this type of task.

To create one, you will need to edit a new member in one of the libraries associated to SYSPROC. Copy and paste the code below to that member.

/* REXX */
/* Visit WWW.TECHNOLOGYSHIFT.COM */
ADDRESS ISREDIT
"MACRO"
"RESET"
"(CURRLN) = LINE .ZCSR"
CURRLN = TRANSLATE(CURRLN,' ',"=,'")
"(ROW1,COL1) = CURSOR"
CURRLN = LEFT(CURRLN,POS(' ',CURRLN,COL1) - 1)
CURRLN = WORD(CURRLN,WORDS(CURRLN))

IF SYSDSN(CURRLN) = "OK" THEN
ADDRESS ISPEXEC "VIEW DATASET('"CURRLN"')"

EXIT 0

To invoke the macro, you just go and edit any JCL you are testing. Type the macro name (corresponds to the member name) in the command line, position the cursor under the name of the dataset you want to review, then press enter. You should be viewing the dataset now.

Congratulations! With a few lines of code, you created your very first automation. Now you see how simple it is?

Excel's "missing" date function

0 comments
While working on one of my personal projects, I needed an Excel date function that I have used before. I typed the formula in a cell and a weird thing happened - the Intellisense did not show me the parameters I need to put in.



So I did what a clever Excel user does, press F1. To my surprise, my query did not retrieve anything from Help. I know the function exists because Excel was able to recognize it and I have used before.

You know what I found out - it is still available but undocumented. Typical Microsoft behavior. Luckily, I was able to find the syntax for it.

(Re)Introducing DATEDIF

DATEDIF returns the difference between two dates. The results is expressed in either years, months or days.

Syntax

=DATEDIF(start_date, end_date, return_type)

start_date is the date that represents the start date

end_date is the date that represents the end date

return_type determines the type of the return value.

Interval Value returned

m Complete calendar months between the dates.

d Number of days between the dates.

y Complete calendar years between the dates.

ym Complete calendar months between the dates as if they were

of the same year (disregards year in evaluation).

yd Complete calendar days between the dates as if they were

of the same year (disregards year in evaluation).

md Complete calendar days between the dates as if they were

of the same month and same year (disregards both year and

month in evaluation).


I have tried the function parameters written here but I can't guarantee its accuracy (MS does not even acknowledge its existence). Feel free to use it and provide me some feedback it what I written here is incorrect.



Excel navigation made easy

0 comments
Have you ever wondered what is the best way to move around Excel? You may not believe this but using the keyboard is the best way to do this - quicker than the fastest mouse clicks you could muster.



You don't believe me? Let me show you.

Say you are working with column with 500 contiguous cells and you want to get to the last cell. Easy. Just press page up/down and the arrow keys until you see the last cell.

What if your data is bigger - 100,000 records? You can use your mouse with the scroll bar. Navigating through this is tricky but it is more practical than using the keyboard, right?

Not quite. A quicker keyboard stroke exists. Try doing this. Go to the column you are working on press Ctrl then the down Arrow key. Now you are in the last cell.

What if you want to select all of the non-empty cells in the contiguous list? Simple. You only need to add one key to the previous two. Go to the first cell and press Ctrl, the Shift and the Arrow keys. That's it.

The use of the Ctrl and Shift keys along with the navigation keys allows you to navigate around the worksheet quicker. The way to use them is listed below.
  • Ctrl+navigation key activates the last cell in a contiguous list for the direction specified.
  • Ctrl+Shift+nav key selects the cells from the original active cell to the last cell in a contiguous list for the direction specified.
  • Ctrl+Page up(down) key gets you to the next (previous) worksheet.
  • Ctrl+Shift+Page up(down) key allows you to select and group worksheets together.
  • Ctrl+End activates the last cell used in the worksheet.
  • Ctrl+ShiftEnd select the cells from the original activate cell to the last cell used in the worksheet.
Take time to use these keystrokes until they become intuitive. This is one Excel skill worth mastering.

 

Copyright 2007-2009 Technology Shift All Rights Reserved