20
IBM Student Mainframe Challenge Part Two Time to complete – about six to eight hours You work in the IT department of an Energy Company. Your customers use smart meters which provide energy usage on an hourly basis. There has been a problem with one of the application programs, which has resulted in the details of one customer being deleted. The bug has been fixed and you have been asked to restore the customer data and produce a new billing report. The energy usage data is still available. Customer data is held in a DB2 database and usually accessed via CICS Transaction Server. However, you will use a batch job to add the Customer details back in to DB2. You will create a batch job to produce a billing report. Help You may find the following references useful when completing the tasks: z/OS v1.11 Information Center: http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp CICS Transaction Server v3.2 Information Center: http://publib.boulder.ibm.com/infocenter/cicsts/v3r2/index.jsp IBM Information Management Software for z/OS Solutions Information Center http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp To test out your new z/OS skills, I'd like you to work with the energy report customer data. To check your progress and understanding, I have some questions for you to answer along the way.

IBM Student Mainframe Challenge Part Twopublic.dhe.ibm.com/software/dw/university/students/mainframe_challen… · First, you need to get some understanding about JCL and SDSF. USING

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

  • IBM Student Mainframe Challenge

    Part TwoTime to complete – about six to eight hours

    You work in the IT department of an Energy Company. Your customers use smart meters

    which provide energy usage on an hourly basis.

    There has been a problem with one of the application programs, which has resulted in the

    details of one customer being deleted. The bug has been fixed and you have been asked to

    restore the customer data and produce a new billing report. The energy usage data is still

    available.

    Customer data is held in a DB2 database and usually accessed via CICS Transaction Server.

    However, you will use a batch job to add the Customer details back in to DB2. You will

    create a batch job to produce a billing report.

    Help

    You may find the following references useful when completing the tasks:

    – z/OS v1.11 Information Center:

    http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp

    – CICS Transaction Server v3.2 Information Center:

    http://publib.boulder.ibm.com/infocenter/cicsts/v3r2/index.jsp

    – IBM Information Management Software for z/OS Solutions Information Center

    http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp

    To test out your new z/OS skills, I'd like you towork with the energy report customer data.To check your progress and understanding,

    I have some questions for you to answer along the way.

    http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsphttp://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsphttp://publib.boulder.ibm.com/infocenter/cicsts/v3r2/index.jsp

  • GETTING STARTED

    Before you can start this part of the contest you'll need to obtain the questions that you need to

    answer along the way. These are available in a question and answer sheet in the sequential data set

    called ZOS.CONTEST2.PART2.ANSWER.SHEET.

    ➔ Using ISPF take a copy of this data set, which you can complete as you progress through the tasks.

    Call your sequential data set UKxxxxx.UKxxxxx.ANSWERSIt should be allocated in tracks (TRKS)It should have a primary quantity of 1 and secondary quantity of 1It should have 0 directory blocksThe record format should be FB (fixed block) and the record length should be 80The block size should be 32000The data set name type should be blank

    ➔ Ensure that the first TWO qualifiers of your data set are your user id otherwise your answers might not be marked correctly.

    You will be advised when you should be able to answer each of the questions, but please read the

    comments at the top of the answer sheet carefully before proceeding.

    ➔ Fill in your z/OS user id (i.e. UKxxxxx) in the space provided above question 1.➔ Answer question 1.

    To copy a data set, use utility 3.3 from the ISPF primary panel. (Type =3.3 at

    the command line in ISPF.)

    You can also copy PDSE members fromthis panel, by putting the member name

    in brackets after the data set name.

    If it all goes wrong, don't worry! Delete thedataset by finding it in utility 3.4, and

    typing D in the command column on the left.Then try again!

  • Attempt to Restore Customer Details

    Normally, customer data is entered from an online system. However, you have been informed by one

    of your colleagues that there is a batch program available which can be used to add Customer details.

    This program is called ADDCUST.

    First, you need to get some understanding about JCL and SDSF.

    USING JCL

    If you think about how you might achieve any given task in the real world, you typically break it down

    into one or more steps, where each step completes a particular part of the bigger picture and typically

    requires the use of different resources.

    For every job that you submit, you need to tell z/OS where to find the appropriate input, how to

    process that input (that is, what program or programs to run), and what to do with the resulting

    output. You use JCL to convey this information to z/OS through a set of statements known as job

    control statements.

    JCL's set of job control statements is quite large, enabling you to provide a great deal of information to

    z/OS. Most jobs, however, can be run using a very small subset of these control statements.

    Within each job, the control statements are grouped into job steps. A job step consists of all the control

    statements needed to run one program.

    If a job needs to run more than one program, the job would contain a different job step for each of

    those programs.

    Job Control Statements

    Every job must contain:

    - A JOB statement to mark the beginning of a job and assign it a name. This statement is also used to provide certain administrative information, including security, accounting, and

    identification information. Every job has one and only one JOB statement.

    Job Control Language (JCL) is how youdescribe this information to z/OS, whereby a job represents a task.

  • - At least one EXEC (execute) statement, marking the beginning of a job step, a name for the job step, and the program or procedure to execute. You can add various parameters to

    the EXEC statement to customize the way the program executes and the conditions under which the step should be run.

    Most programs require some input or generate some output and so usually also contain:

    - One or more DD (data definition) statements, to identify and describe the input and output data to be used in the step. This statement may be used to request a previously

    created data set, to define a new data set, to define a temporary data set, or to define and

    specify the characteristics of the output.

    Each job control statement has five fields:

    1. An identifier field, which is typically two forward slashes (//). The entire line is treated as a comment if the two slashes are followed by an asterisk (//*). 2. A name field, identifying the statement so that it can be referred to later 3. An operation field identifying the type of statement, i.e. JOB, EXEC, DD. 4. A parameter field 5. Anything following the parameter field is treated as a comment and ignored.

    JCL statements can be coded only up to column 71. You may question why JCL has this format but it

    was historically input using punch cards that had 80 columns, the last 8 of which were used for line

    numbers.

    For more information on JCL you can look in the JCL Reference section of the MVS book in the z/OS

    Information Center.

    JCL's layout can look a bit confusing whenyou see it for the first time. Luckily the

    ISPF editor can display JCL syntaxhighlighting if you type HILITE JCL

    (or HILITE AUTO) when editing(not browsing) a JCL member.

    http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.ieab600/toc.htm

  • USING SDSF

    In this section, you may find yourself having to repeatedly swap between two different applications, for

    example, between the answer sheet data set in the editor, and SDSF to find out the answers to the

    questions. It can get frustrating to keep having to go in and out of different applications and back

    again, so there is a better way to do it:

    Pressing F2 will cause the screen to "split" at your cursor, showing the two screens separated by a horizontal dotted line. You can then press F9 to swap between the two screens.

    To maximise the available screen size, put your cursor on the very top line of the screen

    before pressing F2.

    SDSF Primer

    System Display and Search Facility (SDSF) provides information that you can use to monitor,

    manage and control a z/OS system.

    You can use SDSF to view the system log and the status of jobs that are running in the system or have finished running, including any held output of jobs that have not yet been purged (discarded).

    You access SDSF from the ISPF primary panel with the command S.

    From there, DA can be used to view the active (running) jobs in the system, including any started tasks, which are a special type of job.

    ST can be used to view the status of jobs, those that are active, those yet to be processed, and those that have completed.

    Once you are viewing a list of jobs, at the command input prompt you can filter the list of

    jobs to just those that you own by entering:OWNER UKxxxxx

    You'll never know howyou lived without it!

  • To revert back to showing all jobs enter:OWNER *

    Similarly you can filter the list of jobs by their name by entering:PREFIX ABC*which would show only those jobs whose names begin with the letters ABC.

    To remove this filter enter:PREFIX *

    You can use both the owner and the prefix filters at the same time.

    These are particularly useful because they hide jobs on the system that you are either not

    interested in or not authorized to look at.

    Be aware that SDSF remembers the filters that you are using. If you are not seeing a job

    that you expect to see, set both filters to a single asterisk (*) so that all jobs are displayed.

    In the DA and ST panels you are presented with a list of jobs. Use the PF7 and PF8 keys to page up and down.

    To view more information about a particular job you can enter S in the left-hand column (NP) and press Ctrl.

    This can provide a lot of data and so alternatively you can enter a question mark (?) instead, which will give a listing of the various sections of the output. You can then use S to select these sections individually.

    Use the PF3 key to exit the screen that you are on and return to the previous one.

    The prefix and owner filters aren't displayedanywhere by default, so if you leave the filterson you might end up with a blank job list! ISPFremembers your filters between sessions, solook in the Options menu at the top of thescreen and choose option 5 to display them.

  • We will now use some JCL to run the ADDCUST program.

    ➔ Create a PDSE called UKxxxxx.CONTEST2.PART2.JCL.

    It should be allocated in tracks (TRKS)It should have a primary quantity of 1 and secondary quantity of 1The record format should be FB (fixed block) and the record length should be 80The block size should be 32000The data set name type should be LIBRARY

    ➔ Create a member in your JCL data set called ADDCUST, copying it from the member of the

    same name in the data set called ZOS.CONTEST2.PART2.JCL.

    ➔ Substitute the placeholders in the job as described. Make up some fictitious customer details for this step – the sillier the better!

    ➔ Submit the job by typing SUBMIT on the command line while editing it, and look at its output using SDSF. Ensure you record down the customer number that ADDCUST creates.

    If the job runs correctly, we should find a Return code of 0. A return code other than 0 indicates that

    the job has failed.

  • You need to create the dataset referred to by the SYSIN DD statement.

    Attempt to create the Customer Data Set

    In order for the JCL to run successfully it requires a data set called

    IDxxxxx.CONTEST2.PART2.CUSTOMER.DATA – where IDxxxxx is your userid. We will try and create this data set by copying an existing data set.

    ➔ Use utility 3.3 from the ISPF primary panel (Type 3.3 at the command line in ISPF).

    ➔ The name of the data set to copy is ZOS.CONTEST2.PART2.CUSTOMER.SECURE

    When you hit the Enter key on the Move/Copy Utility screen, you will see an error message at the top of the screen saying 'Authorization failed'. Press F1 for more information about this message:

    Oh no! The job has ended with a JCL error. Look at the job in SDSF to see why it has failed.

  • z/OS controls security to system resources through an interface called the System Authorization Facility

    (SAF). The SAF provides an interface into an External Security Manager (ESM) which is responsible for

    performing the security checking. Some examples of ESMs are: IBM's RACF, CA's Top Secret and ACF2.

    For this challenge we are using RACF as the ESM.

    RACF controls access to data sets through a series of profiles. A profile may be generic, in which case

    it protects a group of data sets with similar names, or it may be specific to an individual data set, for

    example:

    ◦ A profile called ZOS.CONTEST2.** would apply to all data sets with a HLQ of ZOS.CONTEST2

    ◦ A profile called ZOS.CONTEST2.EXAMPLE.DATA would only apply to a data set with the name ZOS.CONTEST2.EXAMPLE.DATA.

    Where a data set belongs to both a specific and generic profile, the more specific profile takes

    precedence over the more generic profile.

    ➔ Now answer question 2.

    ➔ From the ISPF Primary Options Menu select option 13 for z/OS user applications.➔ Then select option 12 for Security.

    This error occurs because you do not have the correct level of security access to copy the data set.

    Now try to find the profile that is controlling access to the

    ZOS.CONTEST2.PART2.CUSTOMER.SECURE input data set.

  • You should now see a menu like this:

    We are going to examine a security profile that relates to a data set, so we need to select option 1 from

    this panel. On the next screen we will select option S to search for a profile. To search for the profile

    that controls our data set, we will look for all profiles that begin with ZOS.CONTEST2.

    ➔ To do this, enter ZOS.CONTEST2 (without quotes) into the MASK1 field and hit Enter.

    The next screen allows us to refine our search criteria, but in this case we will just hit Enter. All profiles that can potentially affect our data set are now listed.

    ➔ Now answer question 3.

    As a result of our search, we did not find a profile that matches

    ZOS.CONTEST2.PART2.CUSTOMER.SECURE. This is because we do not have access to this profile. We

    have found a profile that has a very similar name. We will now examine this new profile in more detail.

    ➔ Go back to the RACF – Data Set Profile Services screen and enter D to display a

    profile's contents.

    ➔ In the PROFILE NAME field enter the name of the profile (with quotes) that we found as a

    result of the search and press Enter.➔ On the next screen enter YES beside the ACCESS LIST field.

  • ➔ Now answer questions 4, 5 and 6.

    While we do not have the necessary level of authorization to copy the data set

    ZOS.CONTEST2.PART2.CUSTOMER.SECURE, there is an identical data set that we do have the correct level of authorization to copy. This data set is called ZOS.CONTEST2.PART2.CUSTOMER.DATA.

    Now go back to the data set Move/Copy Utility screen (option 3.3) and attempt to perform a copy of the ZOS.CONTEST2.PART2.CUSTOMER.DATA data set. The name of the data set to copy to is IDxxxxx.CONTEST2.PART2.CUSTOMER.DATA where IDxxxxx is your userid. Allocate your copy of the data set using the attributes of the ZOS.CONTEST2.PART2.CUSTOMER.DATA set.

    You should now have successfully made a copy of the data set. You can check your copy has worked

    as expected by going to the Data Set List Utility screen (option 3.4) and entering the name of your data set (e.g. IDxxxxx.CONTEST2.PART2.CUSTOMER.DATA).

    ➔ Edit the contents of the dataset and rerun the job. It should end with return code 0.

    ➔ Answer question 7

    Next, we need to create a billing report for this customer.

    ➔ Create a member in your JCL data set called BILLING, copying it from the member of the same name in the data set called ZOS.CONTEST2.PART2.JCL.

    This will allow us to see who has accessto the data set and at what level.

    If the data set name is not between singlequote marks (e.g. 'IDxxxxx.CUSTOMER.DATA ')

    then a data set name of IDxxxxx.IDxxxxx.CUSTOMER.DATA

    will be created!

  • ➔ Submit the BILLING JCL and check the output.

    ➔ Fix the errors in BILLING, using the COBOL for z/OS 3.4 Language Reference you need to determine what went wrong and how to solve it.

    HINT: The BILLING program requires a parameter that supplies the Customer number, and a date range in the format:

    with no space characters, eg:

    999992011-01-012011-12-12

    You can add the parameters to the JCL using in-stream data. There is already an example of in-stream

    data in this job on the SYSTSIN DD statement.

    ➔ Edit the parameters to produce a billing report for your customer number with a from date of 1st July 2011 to 30th September 2011

    ➔ Now answer question 8.

    Oh no! It looks like thereis a problem with the JCL!

    http://publib.boulder.ibm.com/infocenter/pdthelp/v1r1/index.jsp?topic=/com.ibm.entcobol.doc_4.2/PGandLR/rltitleh.htm

  • INTRODUCTION TO CICS

    CICS

    CICS (Customer Information Control System) Transaction Server is IBM's general-purpose transaction

    processing software for z/OS. It is a powerful application server that meets the transaction-processing

    needs of both large and small enterprises. It builds on z/OS and System z facilities to provide high

    availability and scalability at a low cost per transaction; it supports large transaction volumes with a fast

    and consistent response time.

    Transaction processing is a style of computing, typically performed by large server computers, that

    supports interactive applications. In transaction processing, work is divided into individual, indivisible

    operations, called transactions. For example, withdrawing cash from an ATM and updating the balance

    in a database. By contrast, batch processing is a style of computing in which one or more programs

    processes a series of records (a batch) with little or no action from the user or operator. For example,

    printing out bank statements for every account holder ready to send by mail.

    Transaction processing middleware such as CICS allows application programmers to concentrate on

    writing code that supports the business, by shielding application programs from the details of

    transaction management:

    • It manages the concurrent processing of transactions.

    • It enables the sharing of data.

    • It ensures the integrity of data

    • It manages the prioritization of transaction execution.

    When a transaction starts processing, CICS runs a program that is associated with the transaction. That

    program can transfer control to other programs in the course of the transaction, making it possible to

    assemble modular applications consisting of many CICS programs.

    At any time, in a CICS system, many instances of a transaction can run at the same time. It would be

    inconvenient to have to queue and wait for thousands of other people when buying something online.

    CICS Primer

    Now's a good time to give you some guidance on using CICS.

    You start a CICS transaction by pressing the CLEAR* key to clear the screen, and entering the transaction identifier, either by itself or followed by data, on the command line of the

    screen. The command line is a single line, usually at the top of the screen.

    You can type the transaction identifier by itself and follow the prompts until a complete

    transaction command is built up, or you can type the complete transaction command on the

    command line. If you do not enter enough information, or if the information you enter is

    wrong, you are prompted to complete or correct your input.

  • For example, in the following transaction, CESF is the transaction identifier and the additional data is GOODNIGHT.

    CESF GOODNIGHT

    This transaction is used to log off CICS.

    When the transaction starts, it processes the additional data. At the completion of this

    transaction, you get the following message:

    STATUS: SESSION ENDED

    After a transaction has completed, press the CLEAR* key to get a blank screen in readiness for the next transaction.

    To end a transaction use the PF3 key.

    * The special 3270 CLEAR key is not on most keyboards. However, 3270 emulators either provide this via a context (right-click) menu or allow you to map it to a key of your choice,

    often Pause/Break by default.

    You can find more information on CICS in the CICS Transaction Server v3.1 Information Center.

    https://publib.boulder.ibm.com/infocenter/cicsts/v3r1/index.jsphttps://publib.boulder.ibm.com/infocenter/cicsts/v3r1/index.jsp

  • Using CICS

    ➔ Open a second 3270 session but instead of entering TSO at the SELECT APPLICATION prompt, enter 'LOGON APPLID(CICSZ057)' .

    You should be presented with the CICS sign-on screen.

    ➔ Enter your user id and password and press Enter.

    The screen should clear except for the following message near the bottom:

    DFHCE3549 Sign-on is complete (Language ENU).

    You are now able to execute CICS Transactions. To run a CICS Transaction, simply type the name of the

    transaction at the top of the CICS screen.

  • We want to check the online system to confirm that the data we entered earlier is correct. The

    transaction we use to access the Customer's account is called CUST.

    ➔ Now answer questions 9 to 11.➔ Run the CUST Transaction.

    The CUST Transaction is a transaction we have created to show the Smart Meter details of our

    customers.

    ➔ Enter the Account number you retrieved using the ADDCUST program.

    You should now see some information that looks familiar to you! Pressing Enter here will refresh the data based on the account number provided. Overwriting any data and pressing F2 will update the customer record.

    The customer seems to be a Power User! As cool as that might sound, it means they are actually using

    more power and therefore have a higher rate on their tariff! Pressing F4 will allow you to view the the energy usage of a customer.

    ➔ Now answer question 12.

    We need to change the Tariff. We know the Tariffs are held in a DB2 table called CONTEST2.TARIFF, so we need to look at the contents of the table.

  • INTRODUCTION TO DB2DB2

    DB2 is IBM's relational database. DB2 was originally created for the mainframe, but versions are also

    available on Linux, Windows and Unix. Large businesses choose DB2 for z/OS because they need a

    robust database server that provides superior availability and scalability.

    Relational databases include the following structures:

    Database

    A database is a logical grouping of data. It contains a set of related table spaces and index spaces.

    Typically, a database contains all the data that is associated with one application or with a group of

    related applications. You could have a payroll database or an inventory database, for example.

    Table

    A table is a logical structure made up of rows and columns. Rows have no fixed order, so if you retrieve

    data you might need to sort the data. The order of the columns is the order specified when the table

    was created by the database administrator. At the intersection of every column and row is a specific

    data item called a value, or, more precisely, an atomic value. A table is named with a high-level qualifier

    of the owner's user ID followed by the table name, for example TEST.DEPT or PROD.DEPT.

    Indexes and Keys

    An index is an ordered set of pointers to rows of a table. Unlike the rows of a table that are not in a

    specific order, an index must always be maintained in order by DB2. An index is used for two purposes:

    • For performance, to retrieve data values more quickly

    • For uniqueness

    A key is one or more columns that are identified as such in the creation of a table or index.

    SQL

    Structured Query Language (SQL) is a high-level language that is used to specify what information a

    user needs without having to know how to retrieve it. The database is responsible for developing the

    access path needed to retrieve the data. SQL works at a set level, meaning that it is designed to

    retrieve one or more rows. Essentially, it is used on one or more tables and returns the result as

    a results table.

    At any time, in a CICS system, many instances of a transaction can run at the same time. It would beinconvenient to have to queue and wait for thousands of other people when buying something online.

    DB2 Primer

    Several tools can be used to enter and execute SQL statements. Here we will use the DB2

    batch utility program DSNTEP2.

    DSNTEP2 runs a batch JCL job and executes SQL supplied in the SYSIN DD statement. Here's an example of how you could select and write the result to SYSPRINT DD:

  • //SYSIN DD * SELECT DEPTNO FROM DSN8910.DEPT

    Output is written to the SYSOUT DD statement:

    ********************************* TOP OF DATA *********************PAGE 1 ***INPUT STATEMENT: SELECT DEPTNO FROM DSN8910.DEPT

    +--------+ | DEPTNO | +--------+ 1_| A00 | 2_| B01 | 3_| C01 | 4_| D01 | 5_| D11 | 6_| D21 | 7_| E01 | 8_| E11 |

    9_| E21 | 10_| F22 |

    You can find more information on DB2 in the DB2 Version 9.1 for z/OS Information Center.

    ➔ Switch back to ISPF and create a member in your JCL data set called DSNTEP2Copy it from the member of the same name in the data set called ZOS.CONTEST2.PART2.JCL.

    You need to write an SQL statement that selects all columns from the tariff table. Run the JCL to list

    the Tariffs. There are only 2.

    ➔ Answer question 13.

    ➔ Switch back to CICS, and update the customer details to use the alternative tariff.

    ➔ Answer questions 14 and 15.

    http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2z9.doc/src/alltoc/db2z_09_prodhome.htmhttp://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db2z9.doc/src/alltoc/db2z_09_prodhome.htm

  • COMPLETING PART 2

    ➔ Submit your answers

    To do this go to option 6 (Command - Enter TSO or Workstation commands) and enter:

    XMIT ZOS19.MATTK DA('IDxxxxx.IDxxxxx.ANSWERS')

    Review your answers and then submit them so that

    they can be marked!

    Congratulations! You've finished all the steps for Part Two! Our customers can now accurately monitor their energy usage

    using our smart meters thanks to you restoring the data and ensuringour applications work as they should. If you're one of the first to

    complete the task and answer the questions correctly,I'll send you your prize in due course!

    You've achieved a lot so far, but there's stillplenty more to do! Part Three builds on what

    you've been learning, and gets even more challenging!You'll be helping to modernise the CICS applications

    we use by using web services!

    I'm recommending you to our Web Team tocarry on to Part Three of the contest –

    you'll need access to their mainframe systems.Please send an email to your contest administrator

    to request a new user ID for part 3, including in your email your current user ID.

    Good luck!