Chapter 13. Scenario 2: Using Debug Tool 391
13.2 Walkthrough of the batch Trader application
The batch Trader application is used to maintain stock portfolios held by
individuals. You execute a batch job that processes a days worth of trading
activity, which:
򐂰 Lists portfolios and their value
򐂰 Buys shares of a companys stock
򐂰 Sells shares of a companys stock
13.2.1 The Trader batch job
The batch job that executes the Trader application is shown in Example 13-1.
Example 13-1 JCL to run the batch Trader application
//DAVINR2R JOB (123,A,TESTING,'WILFRIED'),'ENHANCE',
// CLASS=A,MSGCLASS=H,MSGLEVEL=(1,1),
// REGION=32M,NOTIFY=&SYSUID
//********************************************************************
//* LICENSED MATERIALS - PROPERTY OF IBM *
//* 5655-ADS (C) COPYRIGHT IBM CORP. 2000 *
//* ALL RIGHTS RESERVED *
//********************************************************************
//GO EXEC PGM=TRADERB
//STEPLIB DD DISP=SHR,DSN=DAVINR2.DEMOS.PDPAK.LOAD
// DD DISP=SHR,DSN=CEE210.SCEERUN
//SYSPRINT DD SYSOUT=*
//SYSABEND DD SYSOUT=*
//COMPFILE DD DISP=SHR,DSN=DAVINR2.DEMOS.PDPAK.COMPFILE
//CUSTFILE DD DISP=SHR,DSN=DAVINR2.DEMOS.PDPAK.CUSTFILE
//TRANSACT DD DISP=SHR,DSN=DAVINR2.DEMOS.PDPAK.SAMPLES(TRANFILE)
//REPOUT DD SYSOUT=*
//TRANREP DD SYSOUT=*
//*
The job invokes program TRADERB, which reads a sequential file (TRANSACT)
to obtain the days transactions. The program processes each of the records in
this file. At the same time, the program reads the company file (COMPFILE) and
reads and updates the customer file (CUSTFILE).
Note: This example was designed to demonstrate the capabilities of the
Problem Determination Tools. Therefore, a minimal amount of code was
developed. This application does not represent real-world securities
processing.
392 IBM Application Development Tools for z/OS and OS/390
After the program processes the input file, it generates two output reports:
REPOUT, which contains a list of all customer portfolios and TRANREP, which
contains a detailed list of the transaction activity and processing status.
13.2.2 The transaction file
The transaction file is an 80-byte, sequential file that is input to the Trader
application. It can contain three types of requests:
򐂰 List shares
򐂰 Buy shares
򐂰 Sell shares
Example 13-2, shows typical records in the transaction file.
Example 13-2 Batch Trader application transaction file
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
12345RB_DEMO .IBM BUY_SELL 00301
12345RB_DEMO .Veck_Transport BUY_SELL 00251
12345RB_DEMO SHARE_vaLUE
The record layout for the transaction file is shown in Table 13-2.
Table 13-2 Transaction file record layout
After the program, TRADERB, reads each record, it examines the
TR-REQUEST-TYPE field to determine the type of processing to perform.
Column Description Field name
1-5 Account number TR-ACCOUNT-NUMBER
6-35 Customer name TR-CUSTOMER-NAME
36 Dot FILLER
37-51 Company name TR-COMPANY-NAME
52-71 Request type TR-REQUEST-TYPE
72-75 Number of shares (for Buy
or Sell requests)
TR-NO-OF-SHARES
76 Transaction type (for Buy
or Sell requests)
TR-SUBTYPE
77-80 Blank FILLER
Chapter 13. Scenario 2: Using Debug Tool 393
13.2.3 Listing shares
If the field, TR-REQUEST-TYPE, contains the value, SHARE_vaLUE, the program uses
the value in the TR-CUSTOMER-NAME field to print a report that lists the shares held
by that customer in each company the customer owns.
A typical report is shown in Example 13-3.
Example 13-3 Batch Trader application List Shares Report
CUSTOMER : RB_DEMO 09/30/2002
-----------------------------------------------------------------
COMPANY SHARES SHARE TOTAL
HELD vaLUE COST
-----------------------------------------------------------------
Glass_and_Luget_plc 120 19.00 2,280.00
IBM 1890 163.00 308,070.00
Veck_Transport 925 36.00 33,300.00
13.2.4 Buying shares
If the field, TR-REQUEST-TYPE, contains the value, BUY_SELL, and the field,
TR-SUB-TYPE, contains a value of 1, the program processes a request to buy the
number of shares in TR-NO-OF-SHARES.
After the process completes successfully, the program updates the Customer
file, DEMOS.PDPAK.CUSTFILE.
The program also produces a transaction report, as shown in Example 13-4. This
report lists the transaction file input request and the status of the processing. The
STATUS column in the report lists how the request was processed. If the
processing is successful, the message PROCESSED is printed, otherwise the
message *ERROR* is printed.
Example 13-4 Batch Trader application Transaction report listing BUY shares
----------------------------------------------------------------------------
CUSTOMER COMPANY QTY REQ-TYP STATUS
----------------------------------------------------------------------------
RB_DEMO IBM 30 BUY PROCESSED
RB_DEMO Veck_Transport 25 BUY PROCESSED
13.2.5 Selling shares
If the field, TR-REQUEST-TYPE, contains the value, BUY_SELL, and the field,
TR-SUB-TYPE, contains a value of 2, the program processes a request to sell the
number of shares in TR-NO-OF-SHARES.

Get Introduction to the IBM Application Development Tools on z/OS and OS/390 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.