Category: nice to know

  • =3.4 or the most important mainframe command

    Once you are on a mainframe, the most important command is: =3.4. This command is issued on the command line of the so-called ISPF screens.

    See:

     

    If you are in this screen, simply issue =3.4 and you are in the screen that gives you access to all files. This is the stepping stone into the work that you might create: it gives you access to output, input, jobs and everything else that is important in your mainframe life.

    There is a second command that is of equal importance: the PF3 command (for some reason, the IBM mainframe boys and girls use PF3 for the F3 function key). This means: go one step back. Repeatedly tapping the F3 key leads to the exit: the end of a session. I noticed that the PF3 command is also labeled as “End”. This means that if you read : “enter end command to return to the primary option menu” should be interpreted as press F3 to return. Do do tap on the end key: it does not give you the desired result. No use the F3 key. Hum, a fact of life.

    I would place a bet that you are able to do a simple session on a mainframe with just these two commands: the =3.4 and the PF3 command. If I was to write a quick guide for a mainframe, I would start with these two commands.

  • Going back in time – or re-enter the mainframe

    When I entered the world of the mainframe, I realised that this is a world on it own; it has their own rules and newbies are not easily accepted here. From a support form I read this message from a sysadm: “.. (this) is a system for people who know what to do and how to do it. It is not a system for obvious clueless newbies like you. I suggest you start reading manuals for the next few weeks.
    You are telling us “But I fail.”
    Fail with what, failing to read manuals? Failing to tell us what error messages you get?”.
    Ouch that hurts and it does not help the poor user who gets an error and doesn’t know what to do.

    From the same forum : “Open a book on JCL – they are all available online and start reading about the required format…
    .. further notes:
    To other members: Do not provide “xxxx” with a solution, let him figure out what is wrong by opening a manual”.
    Another example of the helpful sysadm. Another example of a user who is left in the dark.

    This is the mainframe.

    Compare these type of reactions to the gentle reactions on the Ubuntu site. It starts with: “You can find support from a variety of sources. Take a look – you’re likely to find an answer to every question. If you can’t find an answer, just ask the people in our active forums.”

    The mainframe is completely different. A quick guide is nowhere to find; the manual are difficult to understand; the sysadm seriously believe that they are next to God.

    However, I strongly believe that mainframe is less difficult than one might think. After all, it is created by ordinary people and their work should be understandable by us humble beings. I give first three books that may help you out:

    • Menendez & Lowe “Murach’s  OS/390 and z/os JCL”
    • Murach, Prince & Menendez “Murach’s mainframe COBOL”
    • Garvin & Eckols “Db2 for the COBOL programmer”

    I will return with some elements that helped me understanding the mainframe.

  • Scheduling jobs in SAS

    With SAS, I see SAS DI Studio being more and more employed to write data loading jobs. It is understandable to see this development. Within a data warehouse environment we encounter similar procedures, like reading from a file, adding technical keys, combining tables etc, that could be created with the help of pre-built stones.
    When such a data loading jobs is written interactively, one could generate the code and create a job that uses this generated code. Such a job looks like: “C:\SAS\DIserver\Lev1\SASMeta\BatchServer\sasbatch.bat -log C:\SAS\DIserver\Lev1\SASMeta\BatchServer\Logs\Flow_Laad_Orders_#Y.#m.#d_#H.#M.#s.log -batch -noterminal -logparm “rollover=session” -sysin C:\SAS\DIserver\Lev1\SASMeta\SASEnvironment\SASCode\Jobs\Laad_Orders.sas” with Laad_Orders.sas being the generated code.

    So far, so good.

    However, the generated code seems to use some macros and macro-variables that are not defined. They are only defined in the interactive SAS DI Studio. It is unfortunate but we need to use a work-around. Even worse, the work-around as provided by the SAS-Institute does not work. We may solve this issue by adding a few lines on top of the generated code to create the definition for the omitted macr vars and macros. This code seems to work:

    %global job_rc trans_rc sqlrc;
    %let sysrc = 0;
    %let job_rc = 0;
    %let trans_rc = 0;
    %let sqlrc = 0;
    
    %macro perfstrt(txnname,metrNam6,METRDEF6);
    %mend;
    %macro perfstop(metrVal6);
    %mend;
    %macro perfend;
    %mend;
    %macro perfinit(applname);
    %mend;
    
    

    Hum, hum, SAS needs to do some extra homework. Hope it is solved in next release,

  • Representation of numerics on a mainframe

    I now work with a mainframe. I realised once more that numeric variables have different formats on a mainframe. As we do not always have a clear description, we should somehow recognise how the data are stored. Let us first show how numeric data can be stored.
    As an example, I take the number 123.

    mainframe repres

    In the upper row, we see the number 123. This is how we see externally this number. In the two rows below, we see the internal format: F1F2F3. This is the most common format: PIC(n) display in Cobol terminology. When we use SAS, we must use the s370fzdu6.2 format, the so-called unsigned zoned decimal.

    This brought me the idea to show 6 different internal formats of 123, along with the Cobol format and the SAS format.

    Let me give you the results:

    How does 123 look           Likely Cobol representation	                        SAS format
    internally?     externally
    F0F0F0F1F2F3	000123      PIC 9(n) DISPLAY	                                s370fzdu6.2
    C0F0F0F1F2F3	{00123      PIC S9(n) DISPLAY SIGN LEADING	                S370FZDL6.2
    4EF0F0F1F2F3	+00123      PIC S9(n) DISPLAY SIGN LEADING SEPARATE	        S370FZDS6.2
    F0F0F1F2F34E	00123+      PIC S9(n) DISPLAY SIGN TRAILING SEPARATE	        S370FZDT6.2
    00000000123C	            pic S(9)  comp-3	                                s370fpd6.2
    00000000123F	            PIC 9(n) PACKED-DECIMAL	                        s370fpdu6.2
    

    In fact, two different formats are used:

    • Zoned decimals where digits can be internally seen as a combination of F and a digit. Hence 7 is stored as F7. Externally, we see the 7. The only difference between the different zoned decimal representation is to whether a sign is available(the +) and where it is placed: at a trailing position or at a leading position.
    • Packed decimals where digit are stored efficiently as one byte is used to internally store two digits. The result is we can recognise 123 in the internal format quite easily (in 00000000123C). However the external representation doesn’t make much sense.
  • Mainframes

    About hundred years ago, I worked on a mainframe. I those days, the mainframe was basically the mainstream computer that many people used. In those days, financial institutions started automating their business processes.
    In the nowadays world, these mainframes are still the workhorses of these financial institutions. But how did we access them?
    Now, I am back in a finncial institute where getting access to such an environment is very handy as the real work is done there. The PC is only used for Email purposes and minor Word editing. Unix is only used in the marketing department but the real stuff is in a mainframe.

    So I had to refresh my mainframe knowledge.

    But how?

    I first got a free access to a mainframe. I found a possibility with http://www.efglobe.com/cgi-bin/mainframe/mainuser .
    TSOAccess.
    Within two days a clear message was given – I asked access Friday night and got replay Sunday afternoon. Good work. The message gave a clear indication on how to access the mainframe.

    But to access a mainframe, you need a terminal application. This can be downloaded from http://x3270.bgp.nu/download.html . This is an open source application that emulates a 3270 terminal.

    I recovered the knowledge with an old book Doug Lowe, “MVS TSO”. These three items (a book, a client terminal app and a TSO account) will help to renew my mainframe knowledge. Back in time.

  • Accessing Oracle from Perl

    This weekend had bad weather. Rain pouring from the sky and a drop of snow.

    Such weather is good to undertake something that is absolutely useless like writing a Perl programme on Linux to access a remote Oracle database.

    The first hurdle to overcome is to install an Oracle client along with some Perl routines that will allow us to write Perl code to get things done. This hurdle can be overcome with help of http://usestrict.net/2009/07/12/perl-installing-dbdoracle-on-ubuntu-904-and-oracle-instant-client/ . This site gives a nice cookbook to install both the Oracle client and the Perl modules.

    It took me about 4 hours to get this done. But then I had the software that I needed. The actual code that I wrote is:

    
    #!/usr/bin/perl -wT
    
    use Oraperl;
    
    print "Content-type: text/html\r\n\r\n";
    print "<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN>";
    print "<html><head>";
    print "<title>Test Perl Script</title>";
    print "</head>";
    $ENV{"ORACLE_HOME"} = "/usr/lib/oracle/xe/app/oracle/product/10.2.0/server";
    $hConnection = &ora_login("xe", "uid", "psw") || die $ora_errstr;
    $hQuery = &ora_open($hConnection, "SELECT naam, nummer from scott.klant") || die $ora_errstr;
    @asQueryReturn = &ora_fetch($hQuery);
    while (@asQueryReturn != 0)
    {
    print "<p>naam: $asQueryReturn[0] nummer: $asQueryReturn[1]";
    @asQueryReturn = &ora_fetch($hQuery);
    }
    &ora_close($hQuery);
    &ora_logoff($hConnection);
    exit;
    
    

     

    This code is not very well documented on the Internet. The best resource is http://www.tutorialspoint.com/perl/oraperl_manual.htm . Nevertheless I could not get this code right until I saw in another source (http://www.cs.purdue.edu/homes/cs290w/perlLecs/PerlOracle.html ) that you also give the full path to ORACLE_HOME as an environmental variable. This is a bit strange as this variable is also known on Linux, but without it, the code did not run.

    I wrote this piece of code as a cgi programme. To retrieve the results, I had to start the output with:  print “Content-type: text/html\r\n\r\n”; and print “<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN>”; as to avoid the strings to get lost in the Internet. Only after these strings, the output is interpreted as HTML and it can be displayed in the browser.

     

     

  • Layers in Visio

    Sorry to say, but I love Microsoft Visio. Plse do not spread the word. But from time to time, I had to create a document that served two distinct groups: a group who was just interested in getting a highlight and a group who wanted to go into details. In earlier times, I created two documents: one for the highlights and one for the details. But I then had to maintain two documents. A change in the highlights has to be introduced in the details as well.
    This can be shown in next figure:

    Visio2layers

    The highlights are included in the first layer only; the details are composed of the first and second layer. If you maintain this in two documents, you will have to introduce a change in the first layer in two documents simultaneously.

    However, this is not necessary as Viso knows the concepts of layers. One could add some objects to the first layer and some to the second. Subsequently, one may choose to print either the first or the second layers or both. This can be directly started when several layers are created.
    Take view>Layer Properties

    Visio2layers

    Once the layers are created, one could add the objects to the layer. Take format>Layer:

    Visio2layers

    This could make life easier.
    I owe thanks here to gert-Jan Kooren who pointed me at the Vision feature: it allows us to create complicate diagrams, that can also be shown at a lower level of detail. Nice!

  • Add blobs in your database

    For some reason, I always overlooked the possibility to include pictures in a database. I decided to overcome this flaw and started experimenting with it.
    The first step was to create a table in Access. In Access, we have the possibility to use the datatype “OLE Object”. A field with this datatype can be used to store pictures. The inclusion of a picture is then straightforward. Rightclick on the field brings you in a menu that allows you to include a picture:
    screenprint
    That was really easy.
    Let us move to Oracle.
    In Oracle, it is really easy sailing. Let us first create a table.

    CREATE TABLE "SCOTT"."BLOBJE" 
       (	"NUMMER" NUMBER, 
    	"PLAATJE" BFILE
       )
    

    Then, we create a storage where to put the images in.

    CREATE OR REPLACE DIRECTORY 
    PLAATJE_DIR AS 
    '/home/tom/oracle';
    

    This is then followed by storing a nice picture in the storagearea (=/home/tom/oracle). Let us say, we stored a file “thumbsup.gif” there.
    The final step is to store a record in the table that was created first:

    INSERT INTO blobje VALUES(4,bfilename('PLAATJE_DIR','thumbsup.gif'));
    

    We can then see the picture from within an Oracle table:
    Oracle
    Then with Teradata, it was not so simple. Like in Oracle, I created a table first:

    CREATE SET TABLE financial.blobje
         (
          plaatje BLOB(2097088000),
          nummer INTEGER NOT NULL)
    UNIQUE PRIMARY INDEX ( nummer );
    

    I then changed the mode of Teradata SQL Assistant by listening to import. This was accomplished by File>Import Data. I then started a query, saying:

    insert into  financial.blobje(nummer,plaatje) values (3,?B);
    

    .
    This started a dialogue where a reference was made to a control file that contained the name of the picture. The controlfile was stored in the same directory as the picture and it only contained the name of the picture.
    This is not trivial. Nor could it be found in Teradata manual (at least I couldn’t). The information was retrieved from “http://developer.teradata.com/applications/articles/large-objects-part-1-loading”.

    In this website, I found another solution that uses the BTEQWIN client. Let us first create a table:

    create table financial.blobje(
        id varchar (80),
        binary_lob binary large object
    )
    unique primary index (id);
    

    Then store several pictures in a directory (say in D:\tmaanen\Desktop\). Say we store “thumpsup.gif” and “thumbsdown.gif” in tht directory.
    Also create an import.ctl file that contains:

    D:\tmaanen\Desktop\thumbsup.gif,xxxx
    D:\tmaanen\Desktop\thumbsdown.gif,yyyy
    

    In BTEQWIN, we create a loop that reads the lines in this import.ctl file. This can be achieved by:

    .import vartext ‘,’ LOBCOLS=1 file=’D:\tmaanen\Desktop\import.ctl’;

    followed by:

    .repeat *
    using (lobFile blob as deferred,id varchar(40))
    insert into financial.blobje (id, binary_lob)
    values (:id, :lobFile);
    

    It is not really easy, but it can be admittingly done.

    Uoef:

    teradata

  • Use bteqwin as a Teradata client

    I installed teradata recently. The installation was really straight forward. And as a bonus, you get tons of client tools. It is possible to use several clients to start your sql.
    A popular tool is BTEQWIN. However, if you google on BTEQWIN, you get lots of questions that ask: how do I connect to the Teradata server. The answer is quite easy (but not very well documented).
    If you use BTEQWIN on your server, you issue the command: .logon =tpid=/dbc. The tpid can be found in the hosts file in C:\Windows\System32\drivers\etc. Most likely you will something like: 127.0.0.1 localhost localtdcop1. Leave out the “cop1” and you have your tpid. In this case: .logon localtd/dbc. You get prompted for the password and you go.
    If you use BTEQWIN on a client, the situation is slightly different: use .logon =server=/dbc. I just used the ip-address. This looks like: .logon 192.168.1.72/dbc. I got prompted for the password and I started.

    Strangely enough, I found it difficult to find a clue how to use the .logon command. Hum – now we know.

  • Installing Oracle – the host is localhost!

    Yesterday, I started installing Oracle. I decided to download the newest version: version 11g R. I used windows xp as a platform with DHCP switched off. It really looked simple: the screens look simple and the questions asked were straight forward. I let it go for about 2 hours and after this time I returned to the machine and I looked if everything was successfull. It certainly was: an encooraging “successfull” looked at me.
    I checked the installation by a command “tnsping”. This command was issued at the same machine where Oracle was installed.
    I then issued the command “sqlplus uid/psw” that also gave access to the Oracle database.
    Finally, I installed TOAD on the same machine as Oracle installed and also TOAD gave access to the database.
    Much to my surprise, I could not get access from another machine as the machine on which I had installed Oracle. I got an error saying “TNS-12541: TNS: geen listener”. I really did not understand as to why this happened. If you google this error, you get ideas on network problems, but this was not the case. I checked every possible typo but this did not happen either.
    The clue as to why the error happened came as I compared the outcomes form the tnsping command. From the server, it looked like:

    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
    OK (20 msec)

    look at the host! It reads localhost where I expected to see the serveraddress.

    The outcome from the remote computer was:

    Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.9)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = ORCL)))
    TNS-12541: TNS: geen listener

    the host is 192.168.1.9 which in itsself is ok.

    Apparently the listener on the server listens to the localhost whereas it had to listen to the server address 192.168.1.9.

    The solution was twofold.
    First I changed the hosts file on the server in \windows\system32\drivers\etc. I commented out the localhost and I introduced the serveraddress.
    Secondly, I changed the tnsnames.ora, listener.ora that can be found in \network\Administrator on the server. Every “localhost” reference was replaced by the serveraddress 192.168.1.9.

    This seemed to help: the listener started to listen to the network address and it was possible to access the database from outside.

    Oops – took a few hours but Oracle was up and running.