HRS Batch Header Utility

Many programs create data for entry to an SCT system through a batch maintenance utility. These data records must have a batch header record. Each batch header must have a unique identifier composed of (1) the batch identifier (6 characters) and (2) the batch date (mmddccyy format). This combination must be unique. This routine will use a batch identifier and batch date and will determine if it is unique. If not, it will attempt to find a unique batch identifier for the given date and will return it to the calling program.

The routine is only useable in Easytrieve Plus. There are two include members, and one DD statement is required in the JCL.

Include #1
The first include member is HR9900A. It contains the working storage fields and DB2 Declares necessary for the routines to work. It should be the last entry in your Files section (the last entry before your first Job statement).

This include uses an Easytrieve Plus Macro variable. This Macro variable is named HRSVER and must be a Macro variable in the original program.

Include #2
This Include is named HR9900B. It does the actual work to determine if the batch header you are creating is unique. It takes two arguments:

The HR9900B Include is invoked as follows:

%HR9900B xxx yyy

where xxx is the variable containing the 6 character batch identifier and yyy is the variable containing the 8 character batch date.

Mechanics

This routine first looks at a specified transaction file. It searches it for a batch header that duplicates the one you are creating. Blank dates on a batch header record will have the current date substituted. If it finds a duplicate, it adds 1 to your batch identifier and searches again until it comes up with a unique batch identifier for the batch date specified.

Once this is done, it continues and looks and the SCT HRS table where previously processed batches are stored and performs the same process as described above. HRS stores batch information in the HRS_BATCH_TB table (short name is EQRTTS).

Once these two processes are complete, the routine returns the batch identifier and batch date. The batch date will always be identical to what you specified. The batch identifier returned is what your program should use to insure it is unique.

JCL Requirements

This routine requires one addition to your JCL, namely:

//HRSTRN DD DSN=xxx,DISP=SHR

where xxx is the dataset name(s) of the file(s) containing batch transactions waiting for processing. This file(s) is not updated in any way, but is opened and read several times. It must be present in your JCL.

HR9900 Example

A sample program (call it TEST01) might look as follows:


MACRO HRSVER
FILE FILE01
   WBATCHID          W           006 A   VALUE 'JAE001'
   WBATCHDATE        W           008 A   VALUE '08271997'
  %SI0900A &HRSVER

JOB INPUT NULL
  %HR9900B WBATCHID WBATCHDATE
  DISPLAY 'BATCH ID=' WBATCHID
  DISPLAY 'BATCH DATE=' WBATCHDATE
  STOP

This is a very simplistic example of use of the HR9900B routine. It will determine whether JAE001 is a unique batch identifier for 08/27/1997. If not, it will determine an appropriate batch identifier (WBATCHID) for the 08/27/1997 date that will make it unique. When run with test data on 02/10/1998, the batch identifier returned was JAE003.

The JCL required for this routine (step JCL only) would look similar to the following:


//TEST01   EXEC  EASYPLUS,ACCOUNT=ISP32,VER=TEST,TBLVER=PROD
//HRSTRN   DD    DSN=AUP03.hrs.INST.tran081,DISP=SHR
//SYSIN    DD    *
  %TEST01  'INST'
/*

Limitations

This routine first searches the transaction file. Once that is complete, it searches the HRQ EQRTTS DB2 table. If it makes changes based on what it finds in EQRTTS, it does not return to the transaction file to recheck it for uniqueness. As a result, there is a small chance that a batch identifier may still not be unique.

Technical

There is also an HR9900C module in Cobol. This module is called from the HR9900B Include. Its purpose is to search the HRSTRN transaction file(s) to determine uniqueness of a batch identifier.

The checking of the EQRTTS table is done through Easytrieve Plus code that uses a SQL DECLARE CURSOR. The name of the cursor is BTCUR, which is defined in the HR9900A Include. It is this Include that uses the &HRSVER Macro variable. This Macro variable contains the owner code of the DB2 EQRTTS table to be used, e.g., BASE, INST, TEST or PROD).