Table of Contents Previous Next PDF


Using Batch Runtime

Using Batch Runtime
This chapter contains the following topics:
Configuration Files
The Configuration files are implemented in the directory CONF of the RunTime Batch.
BatchRT.conf
This file contains variables definition.
These variables must be set before using the RunTime Batch.
Messages.conf
This file contains messages used by RTBatch.
The messages may be translated in a local language.
FunctionReturnCode.conf
This file contains internal codes associated with a message.
ReturnCode.conf
This file contains return codes associated with a messageand returned to the KSH script.
Setting Environment Variables
Some variables (such as ORACLE_SID, COBDIR, LIBPATH, COBPATH …) are shared variables between different components and are not described in this current document. See the Rehosting Workbench Installation Guide.
Table 3‑1 lists the environment variables are used in the KSH scripts and must be defined before using the software.
Table 3‑2 lists the environment variables are used by Batch Runtime and must be defined before using the software.
(See the BatchRT.conf configuration file)
(See the BatchRT.conf configuration file)
A mandatory environment variable which indicates the directory to GDG technical functions. The default is directory GENERATION_FILE. If the value is specified as NULL or with an incorrect directory name, error occurs when using this environment variable.
Timing of implicit GDG commitment. If it is set to JOB, implicit GDG commitment is performed at the end of job; if it is set to STEP, implicit GDG commitment is performed at the end of step (See Committing a GDG for details).
(See the BatchRT.conf configuration file)
(See the BatchRT.conf configuration file)
(See the BatchRT.conf configuration file).
(See the BatchRT.conf configuration file)
MT_JESDECRYPT must be set to jesdecrypt object file.
(See the BatchRT.conf configuration file)
(See the BatchRT.conf configuration file)
TUXEDO SRVGRP value of the ARTDPL server.
(See the BatchRT.conf configuration file)
Creating a Script
General Structure of a Script
Oracle Tuxedo Application Runtime for Batch normalizes Korn shell script formats by proposing a script model where the different execution phases of a job are clearly identified.
Oracle Tuxedo Application Runtime for Batch scripts respect a specific format that allows the definition and the chaining of the different phases of the KSH (JOB).
Within Batch Runtime, a phase corresponds to an activity or a step on the source system.
A phase is identified by a label and delimited by the next phase.
At the end of each phase, the JUMP_LABEL variable is updated to give the label of the next phase to be executed.
In the following example, the last functional phase sets JUMP_LABEL to JOBEND: this label allows a normal termination of the job (exits from the phase loop).
The mandatory parts of the script (the beginning and end parts) are shown in bold and the functional part of the script (the middle part) in normal style as shown in Table 3‑3. The optional part of the script must contain the labels, branching and end of steps as described below. The items of the script to be modified are shown in italics.
 
Table 3‑3 Script Structure
m_JobBegin -j JOBNAME -s START -v 2.00
(PENULTIMATESTEP)
For the label, which must point to END_JOB. The _ is necessary, because the character is forbidden on z/OS.
Script Example
Listing 3‑1 shows a Korn shell script example.
Listing 3‑1 Korn shell Script Example
#!/bin/ksh
#@(#)--------------------------------------------------------------
#@(#)-
m_JobBegin -j METAW01D -s START -v 1.00 -c A
while true ;
do
m_PhaseBegin
case ${CURRENT_LABEL} in
(START)
# -----------------------------------------------------------------
# 1) 1st Step: DELVCUST
# Delete the existing file.
# 2) 2nd Step: DEFVCUST
# Allocates the Simple Sample Application VSAM customers file
# -----------------------------------------------------------------
#
# -Step 1: Delete...
JUMP_LABEL=DELVCUST
;;
(DELVCUST)
m_FileAssign -d OLD FDEL ${DATA}/METAW00.VSAM.CUSTOMER
m_FileDelete ${DD_FDEL}
m_RcSet 0
#
# -Step 2: Define...
JUMP_LABEL=DEFVCUST
;;
(DEFVCUST)
# IDCAMS DEFINE CLUSTER IDX
m_FileBuild -t IDX -r 266 -k 1+6 ${DATA}/METAW00.VSAM.CUSTOMER
JUMP_LABEL=ENDJOB
;;
(ABORT)
break
;;
(ENDJOB)
break
;;
(*)
m_RcSet ${MT_RC_ABORT} "Unknown label : ${JUMP_LABEL}"
break
;;
esac
m_PhaseEnd
done
m_JobEnd
#@(#)--------------------------------------------------------------
 
Defining and Using Symbols
Symbols are internal script variables that allow script statements to be easily modifiable. A value is assigned to a symbol through the m_SymbolSet function as shown in Listing 3‑2. To use a symbol, use the following syntax: $[symbol]
Note:
Listing 3‑2 Symbol Use Examples
(STEP00)
m_SymbolSet VAR=40
JUMP_LABEL=STEP01
;;
(STEP01)
m_FileAssign -d SHR FILE01 ${DATA}/PJ01DDD.BT.QSAM.KBSTO0$[VAR]
m_ProgramExec BAI001
 
Creating a Step That Executes a Program
A step (also called a phase) is generally a coherent set of calls to Batch Runtime functions that enables the execution of a functional (or technical) activity.
The most frequent steps are those that execute an application or utility program. These kind of steps are generally composed of one or several file assignment operations followed by the execution of the desired program. All the file assignments operations must precede the program execution operation shown in Listing 3‑3
Listing 3‑3 Application Program Execution Step Example
(STEPPR15)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBPRO099
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBPRO001
m_OutputAssign -c “*” SYSOUT
m_FileAssign -i LOGIN
IN-STREAM DATA
_end
m_FileAssign -d MOD LOGOUT ${DATA}/PJ01DDD.BT.QSAM.KBPRO091
m_ProgramExec BPRAB001 "20071120"
JUMP_LABEL=END_JOB
;;
 
Creating a Procedure
Oracle Tuxedo Application Runtime for Batch offers a set of functions to define and use "procedures". These procedures follow generally the same principles as z/OS JCL procedures.
The advantages of procedures are:
Procedures can be of two types:
Creating an In-Stream Procedure
Unlike the z/OS JCL convention, an in-stream procedure must be written after the end of the main JOB, that is: all the in-stream procedures belonging to a job must appear after the call to the function m_JobEnd.
An in-stream procedure in a Korn shell script always starts with a call to the m_ProcBegin function, followed by all the tasks composing the procedure and terminating with a call to the m_ProcEnd function. Listing 3‑4 is an example.
Listing 3‑4 In-stream Procedure Example
m_ProcBegin PROCA
JUMP_LABEL=STEPA
;;
(STEPA)
m_FileAssign -c “*” SYSPRINT
m_FileAssign -d SHR SYSUT1 ${DATA}/PJ01DDD.BT.DATA.PDSA/BIEAM00$[SEQ]
m_FileAssign -d MOD SYSUT2 ${DATA}/PJ01DDD.BT.QSAM.KBIEO005
m_FileLoad ${DD_SYSUT1} ${DD_SYSUT2}
JUMP_LABEL=ENDPROC
;;
(ENDPROC)
m_ProcEnd
 
Creating an External Procedure
External procedures do not require the use of the m_ProcBegin and m_ProcEnd functions; simply code the tasks that are part of the procedure shown in Listing 3‑5
In order to simplify the integration of a procedure’s code with the calling job, always begin a procedure with:
JUMP_LABEL=FIRSTSTEP
;;
(FIRSTSTEP)
and end it with:
JUMP_LABEL=ENDPROC
;;
(ENDPROC)
Listing 3‑5 External Procedure Example
JUMP_LABEL=PR2STEP1
;;
(PR2STEP1)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBPRI001
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBPRO001
m_OutputAssign -c “*” SYSOUT
m_FileAssign -d SHR LOGIN ${DATA}/PJ01DDD.BT.SYSIN.SRC/BPRAS002
m_FileAssign -d MOD LOGOUT ${DATA}/PJ01DDD.BT.QSAM.KBPRO091
m_ProgramExec BPRAB002
JUMP_LABEL=ENDPROC
;;
(ENDPROC)
 
Using a Procedure
The use of a procedure inside a Korn shell script is made through a call to the m_ProcInclude function.
As described in Script Execution Phases, during the Conversion Phase, a Korn shell script is expanded by including the procedure's code each time a call to the m_ProcInclude function is encountered. It is necessary that after this operation, the resulting expanded Korn shell script still respects the rules of the general structure of a script as defined in the General Structure of a Script.
A procedure, either in-stream or external, can be used in any place inside a calling job provided that the above principals are respected shown in Listing 3‑6
Listing 3‑6 Call to the m_ProcInclude Function Example
(STEPPR14)
m_ProcInclude BPRAP009
JUMP_LABEL=STEPPR15
 
Modifying a Procedure at Execution Time
The execution of the tasks defined in a procedure can be modified in two different ways:
Listing 3‑7 and Listing 3‑8 are examples.
Listing 3‑7 Defining Procedure Example
m_ProcBegin PROCE
JUMP_LABEL=STEPE
;;
(STEPE)
m_FileAssign -d SHR SYSUT1 ${DATA}/DATA.IN.PDS/DTS$[SEQ]
m_FileAssign -d MOD SYSUT2 ${DATA}/DATA.OUT.PDS/DTS$[SEQ]
m_FileLoad ${DD_SYSUT1} ${DD_SYSUT2}
JUMP_LABEL=ENDPROC
;;
(ENDPROC)
m_ProcEnd
 
Listing 3‑8 Calling Procedure Example
(COPIERE)
m_ProcInclude PROCE SEQ="1"
JUMP_LABEL=COPIERF
;;
 
Using Overrides for File Assignments
As specified in Best Practices, this way of coding procedures is provided mainly for supporting Korn shell scripts resulting from z/OS JCL translation and it is not recommended for Korn shell scripts newly written for the target platform.
The overriding of a file assignment is made using the m_FileOverride function that specifies a replacement for the assignment present in the procedure. The call to the m_FileOverride function must follow the call to the procedure in the calling script.
Listing 3‑9 shows how to replace the assignment of the logical file SYSUT1 using the m_FileOverride function.
Listing 3‑9 m_FileOverride Function Example
m_ProcBegin PROCE
JUMP_LABEL=STEPE
;;
(STEPE)
m_FileAssign -d SHR SYSUT1 ${DATA}/DATA.IN.PDS/DTS$[SEQ]
m_FileAssign -d MOD SYSUT2 ${DATA}/DATA.OUT.PDS/DTS$[SEQ]
m_FileLoad ${DD_SYSUT1} ${DD_SYSUT2}
JUMP_LABEL=ENDPROC
;;
(ENDPROC)
m_ProcEnd
 
Listing 3‑10 m_FileOverride Procedure Call:
(COPIERE)
m_ProcInclude PROCE SEQ="1"
m_FileOverride -i -s STEPE SYSUT1
Overriding test data
_end
JUMP_LABEL=COPIERF
;;
 
Controlling a Script's Behavior
Conditioning the Execution of a Step
Using m_CondIf, m_CondElse, and m_CondEndif
The m_CondIf, m_CondElse and m_CondEndif functions can be used to condition the execution of one or several steps in a script. The behavior is similar to the z/OS JCL statement constructs IF, THEN, ELSE and ENDIF.
The m_CondIf function must always have a relational expression as a parameter as shown in Listing 3‑11. These functions can be nested up to 15 times.
Listing 3‑11 m_CondIf, m_CondElse, and m_CondEndif Example
(STEPIF01)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF000
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF001
m_ProgramExec BAX001
m_CondIf "STEPIF01.RC,LT,5"
JUMP_LABEL=STEPIF02
;;
(STEPIF02)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF001
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF002
m_ProgramExec BAX002
m_CondElse
JUMP_LABEL=STEPIF03
;;
(STEPIF03)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF000
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF003
m_ProgramExec BAX003
m_CondEndif
 
Using m_CondExec
The m_CondExec function is used to condition the execution of a step. The m_CondExec must have at least one condition as a parameter and can have several conditions at the same time. In case of multiple conditions, the step is executed only if all the conditions are satisfied.
A condition can be of three forms:
m_CondExec 4,LT,STEPEC01
m_CondExec EVEN
m_CondExec ONLY
The m_CondExec function must be the first function to be called inside the concerned step as shown in Listing 3‑12.
Listing 3‑12 m_CondExec Example with Multiple Conditions
(STEPEC01)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF000
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF001
m_ProgramExec BACC01
JUMP_LABEL=STEPEC02
;;
(STEPEC02)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF001
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF002
m_ProgramExec BACC02
JUMP_LABEL=STEPEC03
;;
(STEPEC03)
m_CondExec 4,LT,STEPEC01 8,GT,STEPEC02 EVEN
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF000
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIF003
 
Controlling the Execution Flow
The script's execution flow is determined, and can be controlled, in the following ways:
The start label specified by the m_JobBegin function: this label is usually the first label in the script, but can be changed to any label present in the script if the user wants to start the script execution from a specific step.
The value assigned to the JUMP_LABEL variable in each step: this assignment is mandatory in each step, but its value is not necessarily the label of the following step.
The usage of the m_CondExec, m_CondIf, m_CondElse and m_CondEndif functions: see Conditioning the Execution of a Step.
Changing Default Error Messages
If Batch Runtime administrator wishes to change the default messages (to change the language for example), this can be done through a configuration file whose path is specified by the environment variable: MT_DISPLAY_MESSAGE_FILE.
This file is a CSV (comma separated values) file with a semicolon as a separator. Each record in this file describes a certain message and is composed of 6 fields:
1.
2.
3.
4.
5.
6.
Using Files
Creating a File Definition
Files are created using the m_FileBuild or the m_FileAssign function.
Four file organizations are supported:
You must specify the file organization for the file being created. For indexed files, the length and the primary key specifications must also be mentioned.
m_FileBuild Examples
m_FileBuild -t LSEQ ${DATA}/PJ01DDD.BT.VSAM.ESDS.KBIDO004
m_FileBuild -t IDX -r 266 -k 1+6 ${DATA}/METAW00.VSAM.CUSTOMER
m_FileAssign examples
m_FileAssign -d NEW -t SEQ -r 80 ${DATA}/PJ01DDD.BT.VSAM.ESDS.KBIDO005
Assigning and Using Files
When using Batch Runtime, a file can be used either by a Batch Runtime function (for example: m_FileSort, m_FileRename etc.) or by a program, such as a COBOL program.
In both cases, before being used, a file must first be assigned. Files are assigned using the m_FileAssign function that:
The environment variable defined via the m_FileAssign function is named: DD_IFN. This naming convention is due to the fact that it is the one used by Micro Focus Cobol to map internal file names to external file names.
Once a file is assigned, it can be passed as an argument to any of Batch Runtime functions handling files by using the ${DD_IFN} variable.
For COBOL programs, the link is made implicitly by Micro Focus Cobol.
Listing 3‑13 Example of File Assignment
(STEPCP01)
m_FileAssign -d SHR INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIDI001
m_FileAssign -d SHR OUTFIL ${DATA}/PJ01DDD.BT.VSAM.KBIDU001
m_FileLoad ${DD_INFIL} ${DD_OUTFIL}
 
Listing 3‑14 Example of Using a File by a COBOL Program
(STEPCBL1)
m_FileAssign -d OLD INFIL ${DATA}/PJ01DDD.BT.QSAM.KBIFI091
m_FileAssign -d MOD OUTFIL ${DATA}/PJ01DDD.BT.QSAM.KBIFO091
m_ProgramExec BIFAB090
 
Concurrent File Accessing Control
Batch Runtime provides a lock mechanism to prevent one file from being written simultaneously in two jobs.
To enable the concurrent file access control, do the following:
1.
Use environment variable MT_ACC_FILEPATH to specify a directory for the lock files required by concurrent access control mechanism.
2.
Create two empty files, AccLock and AccWait, under the directory specified in step 1.
Make sure the effective user executing jobs has read/write permission to these two files.
Notes:
The file names of AccLock and AccWait are case sensitive.
Following two lines in ejr/CONF/BatchRT.conf should be commented out:
${MT_ACC_FILEPATH}/AccLock
${MT_ACC_FILEPATH}/AccWait
Using a Generation File (GDG)
Oracle Tuxedo Application Runtime for Batch allows you to manage GDG files either based on file or based on database (DB). In file-based management way, Batch Runtime manages GDG files in separate "*.gens" files, and one "*.gens" corresponds to one GDG file. In DB-based management way, Batch Runtime manages GDG information centrally in Oracle database.
GDG Management Functionalities
In order to emulate the notion of generation files and present on the z/OS mainframe which is not a UNIX standard, Batch Runtime provides a set of functions to manage this type of file. These functions are available to both file-based management and DB-based management.
Defining a GDG
A GDG (Generation Data Group) file is defined through the m_GenDefine function. A GDG can be defined explicitly or implicitly, and can be "redefined".
As shown in Listing 3‑15, the first line defines a GDG explicitly and sets its maximum generations to 15, the second line redefines the same GDG maximum generations to 30, the third line defines a GDG without specifying "-s" option (its maximum generations is set to 9999), and the fourth line defines a GDG implicitly and sets its maximum generations to 9999.
Listing 3‑15 Example of Defining a Generation File
m_GenDefine -s 15 ${DATA}/PJ01DDD.BT.FILE1
m_GenDefine -s 30 -r ${DATA}/PJ01DDD.BT.FILE1
m_GenDefine ${DATA}/PJ01DDD.BT.FILE2
m_FileAssign -d NEW,CATLG -g +1 SYSUT2 ${DATA}/PJ01DDD.BT.FILE3
 
Adding Generations in a GDG
To add a new generation file into a GDG, call m_FileAssign with "-d NEW,…" and "-g +n" parameters. The generations files can only be added into a GDG generation by generation. That is, generation n+1 can only be added after generation n is already added. Following are two examples for adding generation files into a GDG, Listing 3‑16 demonstrates a correct usage, while Listing 3‑17 demonstrates an incorrect usage.
Listing 3‑16 Adding a Few Generation Files into a GDG (Correct Usage)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
m_FileAssign -d NEW,CATLG -g +2 SYSUT2 ${DATA}/PJ01DDD.BT.GDG
m_FileAssign -d NEW,CATLG -g +3 SYSUT3 ${DATA}/PJ01DDD.BT.GDG
 
Listing 3‑17 Adding a Few Generation Files into a GDG (Incorrect Usage)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
m_FileAssign -d NEW,CATLG -g +3 SYSUT3 ${DATA}/PJ01DDD.BT.GDG
 
Note:
Referring an Existing Generation in a GDG
To refer to an existing generation in a GDG, call m_FileAssign with "-d OLD,…" and "-g -n" or "-g 0" parameters. "-g 0" refers to the current generation, "-g -n" refers to the generation file which is the nth generation counting backward from the current generation (as 0 generation). See Listing 3‑18 for an example of referring to existing generation files in a GDG:
Listing 3‑18 Referring to Existing Generation Files in a GDG
m_FileAssign -d OLD.CATLG -g 0 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
m_FileAssign -d OLD,CATLG -g -3 SYSUT3 ${DATA}/PJ01DDD.BT.GDG
 
Note:
Deleting a GDG
You can only delete a GDG as whole by calling m_FileDelete with the GDG base name, as shown in Listing 3‑19. Deleting a specific generation file is not supported.
Listing 3‑19 Deleting a GDG
m_FileDelete ${DATA}/PJ01DDD.BT.GDG
 
Committing a GDG
There are two kinds of commitment for GDG changes in Batch Runtime, explicit committing or implicit committing.
Committing a GDG Explicitly
To commit all the changes of GDG to be persistent, m_GenCommit is called explicitly with the GDG base name, as shown in Listing 3‑20. After the committing, all the new generation files become to old generations and all the changes to old generation files are committed too. If no GDG base name is provided with m_GenCommit, all the GDG files that have been accessed in a job are committed. This kind of committing is called explicit committing.
Listing 3‑20 Committing All the Changes on a GDG
m_GenCommit ${DATA}/PJ01DDD.BT.GDG
 
Committing a GDG Implicitly
GDG changes can be committed implicitly at the end of a job or a step according to a configuration variable MT_GDG_COMMIT. If MT_GDG_COMMIT is configured to JOB, all GDG changes in a job are committed implicitly at the end of job if the job succeeds. If MT_GDG_COMMIT is configured to STEP or COMP, all GDG changes in a step are committed implicitly at the end of step if the step succeeds. The difference between STEP and COMP is that current generation is not changed with MT_GDG_COMMIT=COMP but changed with MT_GDG_COMMIT=STEP at the end of each step. The difference between JOB and COMP is that all the changes to GDG prior to a failed step are kept with MT_GDG_COMMIT=COMP, but lost with MT_GDG_COMMIT=JOB.
Note:
If MT_GDG_COMMIT is not configured, COMP is used as the default behavior for committing.
Following are two typical cases:
Listing 3‑21 and Listing 3‑22 add two generation files in two steps separately.
Listing 3‑23 and Listing 3‑24 add one generation file in one step and then refer to that new file in another step.
The major differences between two similar examples with different options are shown in bold.
Listing 3‑21 Adding two generation files in two steps separately, with MT_GDG_COMMIT=JOB or COMP
(STEP1)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
(STEP2)
m_FileAssign -d NEW,CATLG -g +2 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
 
Note:
In Listing 3‑21, if STEP2 fails, the new file corresponding to -g +1 is kept with MT_GDG_COMMIT=COMP, but lost with MT_GDG_COMMIT=JOB.
Listing 3‑22 Adding two generation files in two steps separately, with MT_GDG_COMMIT=STEP
(STEP1)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
(STEP2)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
 
Listing 3‑23 Adding one generation file in one step and referring to new file, with MT_GDG_COMMIT=JOB or COMP
(STEP1)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
(STEP2)
m_FileAssign -d OLD,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
 
Listing 3‑24 Adding one generation file in one step and referring to new file, with MT_GDG_COMMIT=STEP
(STEP1)
m_FileAssign -d NEW,CATLG -g +1 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
(STEP2)
m_FileAssign -d OLD,CATLG -g 0 SYSUT1 ${DATA}/PJ01DDD.BT.GDG
JUMP_LABEL=STEP2
;;
 
Rolling Back a GDG
There are two kinds of roll-back for GDG changes in Batch Runtime, explicit roll-back or implicit roll-back.
Rolling Back a GDG Explicitly
To roll back all the changes on a GDG, call m_GenRollback with the GDG base name, as shown in Listing 3‑25. After rolling back, the GDG is kept as before.
Listing 3‑25 Rolling Back All the Changes on a GDG
m_GenRollback ${DATA}/PJ01DDD.BT.GDG
 
Rolling Back a GDG Implicitly
GDG changes can be rolled back implicitly at the end of a job or a step according to a configuration variable MT_GDG_COMMIT. If MT_GDG_COMMIT is configured to JOB, all GDG changes in a job are rolled back implicitly at the end of job if the job fails. If MT_GDG_COMMIT is configured to STEP, all GDG changes in a step are rolled back implicitly at the end of step if the step fails.
File-Based Management
Configuration
MT_GENERATION variable specifies the way of managing GDG files. To manage GDG in *.gens files, you need to set the value to GENERATION_FILE.
Concurrency Control and Authorization
In file-based GDG management mechanism, one GDG file can only be accessed by one job at any time, that is, a single GDG cannot be accessed by multiple jobs simultaneously. To access a GDG file, the file lock must be acquired by the existing internal function mi_FileConcurrentAccessReservation. File-based GDG management mechanism uses a file *.gens (* represents the GDG base name) to control concurrency and authorization. User access checking depends on whether the *.gens file can be accessed or not.
DB-Based Management
For DB-based management, currently only Oracle Database 11g is supported.
Database Tables
Table 3‑4 shows the general management for each GDG managed by Batch Runtime. In this table, each row represents a GDG. All GDG files share a single GDG_DETAIL table.
 
Table 3‑4 GDG_DEFINE
It cannot contain only a relative path relative to a single repository. The length of GDG_BASE_NAME is limited to 1024, i.e. the minimum of PATH_MAX on different UNIX platforms.
It contains the upper limit of generations specified by -s option. -s option can be set in the range of 1-9999.
Primary Key: GDG_BASE_NAME
Table 3‑5 shows the detailed information of all the GDG generation files. In this table, each row represents a generation file of a GDG.
 
Table 3‑5 GDG_DETAIL
Primary Key: GDG_BASE_NAME+ GDG_ABS_NUM
GDG_FILE_NAME (the physical generation file name) is not stored in table GDG_DETAIL since it can be constructed from GDG_BASE_NAME in GDG_DEFINE and GDG_ABS_NUM in GDG_DETAIL.
Note:
Generation File Naming Rule
Table 3‑6 shows the rule of generation file name:
 
Configuration Variables
MT_GENERATION
Specifies how to manage GDG files. To manage GDG files in database set the value to GENERATION_FILE_DB and configure MT_GDG_DB_ACCESS appropriately.
MT_GDG_DB_ACCESS
Used along with MT_GENERATION when set to GENERATION_FILE_DB, and must be set with the valid database login account. To access Oracle DB, it should be specified in the following format: userid/password@sid, for example, scott/tiger@orcl.
MT_GDG_DB_BUNCH_OPERATION
Used along with MT_GENERATION when set to GENERATION_FILE_DB. It indicates how to commit GDG changes to database during the commit phase. If configured to "Y", the GDG changes are committed using a single database access. If configured to "N", the GDG changes are committed using one or more database accesses.
External Shell Scripts
You can use the two external shell scripts to create and drop the new database table automatically.
CreateTableGDG.sh
Description
Creates table GDG_DEFINE and GDG_DETAIL in database
Usage
CreateTableGDG.sh <DB_LOGIN_PARAMETER>
Sample
CreateTableGDG.sh scott/tiger@orcl
DropTableGDG.sh
Description
Drops table GDG_DEFINE and GDG_DETAIL from database.
Usage
DropTableGDG.sh <DB_LOGIN_ PARAMETER>
Sample
DropTableGDG.sh scott/tiger@orcl
Concurrency Control and Authorization
DB-based GDG management mechanism maintains the same concurrency control behavior as File-based GDG management mechanism, but has a different *.ACS (* represents the GDG base name) file format. In DB-based GDG management mechanism, you don’t need to lock the tables mentioned in Database Tables as any job that accesses the rows corresponding to a GDG must firstly acquire the file lock of the GDG. That is to say, there is no need to perform concurrency control in the database access level. You cannot access database if you don’t have access permission (read or write) to the corresponding *.ACS file. If you need to modify a GDG file, you must have write permissions to the generation files and the directory holding the generation files, and MT_GDG_DB_ACCESS must be configured correctly to have appropriate permissions to the tables mentioned in Database Tables.
You can only copy DB-based GDG management description entirely and replace the file name.
Exception Handling
There are four kinds of information in DB-based GDG management mechanism:
*.ACS file
These information should be kept consistently for a GDG file. Batch Runtime checks the consistency from GDG_DEFINE to Physical files when a GDG file is accessed the first time in a job. If exceptions happen and result in inconsistency among these information, Batch Runtime terminates the current job and reports error.
This behavior is different from the existing file-based mechanism, which does not check the consistency but only reports exceptions encountered in the process.
Using an In-Stream File
To define and use a file whose data is written directly inside the Korn shell script, use the m_FileAssign function with the -i parameter. By default the string _end is the “end” delimiter of the in-stream flow as shown in Listing 3‑26.
Listing 3‑26 In-stream Data Example
(STEP1)
m_FileAssign -i INFIL
data record 1
data record 2
_end
 
 
Using a Set of Concatenated Files
To use a set of files as a concatenated input (which in z/Os JCL was coded as a DD card, where only the first one contains a label), use the m_FileAssign function with the -C parameter as shown in Listing 3‑27.
Listing 3‑27 Using a Concatenated Set of Files Example
(STEPDD02)
m_FileAssign -d SHR INF ${DATA}/PJ01DDD.BT.QSAM.KBDDI002
m_FileAssign -d SHR -C ${DATA}/PJ01DDD.BT.QSAM.KBDDI001
m_ProgramExec BDDAB001
 
Using an External “sysin”
To use an “external sysin” file which contains commands to be executed, use the m_UtilityExec function.
m_FileAssign -d NEW SYSIN ${SYSIN}/SYSIN/MUEX07
m_UtilityExec
Deleting a File
Files (including generation files) can be deleted using the m_FileDelete function:
m_FileDelete ${DATA}/PJ01DDD.BT.QSAM.KBSTO045
RDB Files
In a migration project from z/Os to UNIX/Linux, some permanent data files may be converted to relational tables. See the File-to-Oracle chapter of the Oracle Tuxedo Application Runtime Workbench.
When a file is converted to a relational table, this change has an impact on the components that use it. Specifically, when such a file is used in a z/Os JCL, the converted Korn shell script corresponding to that JCL should be able to handle operations that involve this file.
In order to keep the translated Korn shell script as standard as possible, this change is not handled in the translation process. Instead, all the management of this type of file is performed at execution time within Batch Runtime.
In other words, if in the z/OS JCL there was a file copy operation involving the converted file, this is translated to a standard copy operation for files in Batch Runtime, in other words an m_FileLoad operation).
The management of a file converted to a table is made possible through an RDB file. An RDB file is a file that has the same name as the file that is converted to a table but with an additional suffix:.rdb.
Each time a file-related function is executed by Batch Runtime, it checks whether the files were converted to table (through testing the presence of a corresponding .rdb file). If one of the files concerned have been converted to a table, then the function operates the required intermediate operations (such as: unloading and reloading the table to a file) before performing the final action.
All of this management is transparent to the end-user.
Using an RDBMS Connection
When executing an application program that needs to connect to the RDBMS, the -b option must be used when calling the m_ProgramExec function.
Connection and disconnection (as well as the commit and rollback operations) are handled implicitly by Batch Runtime and can be defined using the following two methods:
Set the environment variable MT_DB_LOGIN before booting the TuxJES system.
Note:
The MT_DB_LOGIN value must use the following form: dbuser/dbpasswd[@ssid]or “/”.
Note:
"/" should be used when the RDBMS is configured to allow the use of UNIX authentication and not RDBMS authentication, for the database connexion user.
Please check with the database administrator whether "/" should be used or not.
The -b option must also be used if the main program executed does not directly use the RDBMS but one of its subsequent sub-programs does as shown in Listing 3‑28.
Listing 3‑28 RDBMS Connection Example
(STEPDD02)
m_FileAssign -d MOD OUTF ${DATA}/PJ01DDD.BT.QSAM.REPO001
m_ProgramExec -b DBREP001
 
The m_ProgramExec function may submit three types of executable files (Cobol executable, command language script, or C executable). It launchs the runb program. We have provided the runb for $ARTDIR/Batch_RT/ejr_mf_ora (on Linux) and ejr_ora (other platforms). If you use neither Microfocus COBOL compiler nor Oracle Database, go to $ARTDIR/Batch_RT/ejr and run "make.sh" to generate your required runb.
The runb program, runtime compiled with database librairies, runs the runbatch program.
The runbatch program, is in charge to :
- do the connection to the database (if necessary)
- run the user program
- do the commit or rollback (if necessary)
- do the disconnection from the database (if necessary)
Submitting a Job Using INTRDR Facility
The INTRDR facility allows you to submit the contents of a sysout to TuxJES (see the TuxJES documentation). If TuxJES is not present, a command “nohup EJR” is used.
Example:
m_FileAssign -d SHR SYSUT1 ${DATA}/MTWART.JCL.INFO
m_OutputAssign -w INTRDR SYSUT2
m_FileRepro -i SYSUT1 -o SYSUT2
The contents of the file ${DATA}/MTWART.JCL.INFO (ddname SYSUT1) is copied into the file which ddname is SYSUT2 and using the option “-w INTRDR” is submitted.
Note that the ouput file must contain valid ksh syntax.
Submitting a Job With EJR
When using Batch Runtime, TuxJES can be used to launch jobs (see the TuxJES documentation), but a job can also be executed directly using the EJR spawner.
Before performing this type of execution, ensure that the entire context is correctly set. This includes environment variables and directories required by Batch Runtime.
Example of launching a job with EJR:
# EJR DEFVCUST.ksh
For a complete description of the EJR spawner, please refer to the Oracle Tuxedo Application Runtime for Batch Reference Guide.
User-Defined Entry/Exit
Batch Runtime allows you to add custom pre- or post- actions for public APIs. For each m_* (* represents any function name) function, you can provide m_*_Begin and m_*_End function and put them in ejr/USER_EXIT directory. They are invoked automatically when a job execution entering or leaving an m_* API.
Whether an m_* API calls its user-defined entry/exit function depends on the existence of m_*_Begin and m_*_End under ejr/USER_EXIT.
A pair of general user entry/exit APIs, mi_UserEntry and mi_UserExit, are called at the entry and exit point of each external API. The argument to these APIs consists of the function name in which they are called, and the original argument list of that function. You don’t need to modify these two APIs, but just need to provide your custom entry/exit for m_* external APIs. mi_UserEntry and mi_UserExit are placed under ejr/COMMON.
Note:
You are suggested not to call exit in user entry/exit function. Because In the framework, exit is aliased an internal function, mif_ExitTrap, which is invoked ultimately if exit in user entry/exit function is called. If exit 0 is called, the framework does nothing and job is continue, if exit not_0 is called, a global variable is set and may terminate the current job.
Configuration
You should include only one function, e.g. m_*_Begin or m_*_End, in a single file with the same name as the function, and then put all such files under ejr/USER_EXIT.
You are not allowed to provide custom entry/exit functions for any mi_ prefix function provided by Batch Runtime.
Batch Runtime Logging
This section contains the following topics:
General Introduction
Log Message Format
Each log message defined in CONF/Messages.conf is composed of six fields, as listed in Table 3‑7:
 
Table 3‑7 Log Message Format
The levels of these messages are set to 4 by default.
You can specify the message level of Batch Runtime to control whether to print these three messages in job log.
Log Message Level
Table 3‑8 lists the Log message levels provided by Batch Runtime:
 
Table 3‑8 Log Message Level
Log Level Control
The default level of displaying messages in job log is 3. You can also choose one of the following ways to change the level:
Use -V option of EJR
The display level set by EJR can override the level set by MT_DISPLAY_LEVEL.
Log File Structure
For each launched job, Batch Runtime produces a log file containing information for each step that was executed. This log file has the following structure as shown in Listing 3‑29.
Listing 3‑29 Log File Example
JOB Jobname BEGIN AT 20091212/22/09 120445
BEGIN PHASE Phase1
Log produced for Phase1
.......
.......
.......
END PHASE Phase1 (RC=Xnnnn, JOBRC=Xnnnn)
BEGIN PHASE Phase2
Log produced for Phase2
.......
.......
.......
END PHASE Phase2 (RC=Xnnnn, JOBRC=Xnnnn)
..........
..........
BEGIN PHASE END_JOB
..........
END PHASE END_JOB (RC=Xnnnn, JOBRC=Xnnnn)
 
JOB ENDED WITH CODE (C0000})
Or
JOB ENDED ABNORMALLY WITH CODE (S990})
 
When not using TuxJes, the log file is created under the ${MT_LOG} directory with the following name: <Job name>_<TimeStamp>_<Job id>.log
For more information, see Using Tuxedo Job Enqueueing Service (TuxJES).
Log Header
Batch Runtime logging functionality provides an informative log header in front of each log line, in the following format:
YYYYmmdd:HH:MM:SS:TuxSiteID:JobID:JobName:JobStepName
You can configure the format of log header, but should not impact any configuration and behavior of existing specific message header: type 0, 1 and b.
Table 3‑9 shows the variables you can use for specifying the general log header:
 
Name of the job assigned by m_JobBegin in the job script.
Name of the proc when the code included from a PROC by m_ProcInclude is executing; empty otherwise.
Configuration
MT_LOG_HEADER is a new configuration variable added in CONF/BatchRT.conf, for example:
MT_LOG_HEADER='$(date'+%Y%m%d:%H%M%S'):${MTI_SITE_ID}:${MTI_JOB_NAME}:${MTI_JOB_ID}:${MTI_JOB_STEP}: '
If the value of MT_LOG_HEADER is not a null string, its contents are evaluated as a shell statement to get its real value to be printed as the log header, otherwise this feature is disabled.
Note:
The string that configured to MT_LOG_HEADER is treated as a shell statement in the source code, and is interpreted by "eval" command to generate the corresponding string used as log header:
Syntax inside: eval mt_MessageHeader=\"${MT_LOG_HEADER}\"
To configure this variable, you need to comply with the following rules:
MT_LOG_HEADER must be a valid shell statement for "eval", and must be quoted by single quotation marks.
All the variables used in MT_LOG_HEADER must be quoted by "${}". For example: ${ MTI_JOB_STEP }
All the command line used in MT_LOG_HEADER must be quoted by "$()". For example: $(date '+%Y%m%d:%H%M%S')
You can modify the above examples according to your format needs using only the variables listed in Table 3‑9.
This configuration variable is commented by default, you need to uncomment it to enable this feature.
File Information Logging
Logging system can logs the detailed file information in job log, as well as the information when a file is assigned to a DD and when it is released.
File assignment information is logged in the following functions:
m_FileAssign
File release information is logged in the following functions:
m_PhaseEnd
File information is logged in the following functions:
Configuration
Messages.conf
The following message identifiers are defined in CONF/Messages.conf to support using of mi_DisplayFormat to write file assignment and file information log.
Notes:
CONF/Messages.conf is not configurable. Do not edit this file.
The string "%s" at the end of each identifier represents it will be written to log file. You can configure its value using the following variables defined in CONF/Batch.conf. For more information, see Table 3‑11.
MT_LOG_FILE_ASSIGN (for FileAssign)
MT_LOG_FILE_RELEASE (for FileRelease)
MT_LOG_FILE_INFO (for FileInfo)
BatchRT.conf
Three configuration variables should be defined in CONF/BatchRT.conf to determine the detailed file information format. With the placeholders listed in Table 3‑10, you can configure file log information more flexibly.
 
Table 3‑10 Placeholders
SHR or NEW
 
Note:
"operation" is hard-coded into source code, such as FileCopy source, FileCopy Destination, and FileDelete etc.
To configure strings to these MT_LOG_FILE_* variables, replace the placeholders with corresponding values (just string replacement). The result is treated as a shell statement, and is interpreted by "eval" command to generate the corresponding string writing to log:
Syntax inside: eval mt_FileInfo=\"${MT_LOG_FILE_INFO}\"
To configure these variables, you need to comply with the following rules:
After placeholders are replaced, MT_LOG_FILE_* must be a valid shell statement for "eval", and must be quoted by single quotation marks.
Only the placeholders listed in Table 3‑10 can be used in MT_LOG_FILE_*.
All the command line used in MT_LOG_HEADER must be quoted by "$()". For example: $(ls -l --time-style=+'%Y/%m/%d %H:%M:%S' --no-group <%FULLPATH%> )
If the level of FileInfo message is equal to or less than the message level specified for Batch Runtime and MT_LOG_FILE_* is set to a null string, FileInfo message will not be displayed in job log. If MT_LOG_FILE_* is set to an incorrect command to make file information invisible, FileInfo message will not be displayed in job log as well, but the job execution will not be impacted.
Note:
Using Batch Runtime With a Job Scheduler
Entry points are provided in some functions (m_JobBegin, m_JobEnd, m_PhaseBegin, m_PhaseEnd) in order to insert specific actions to be made in relation with the selected Job Scheduler.
Executing an SQL Request
A SQL request may be executed using the function m_ExecSQL.
Depending on the target database, the function executes a “sqlplus” command with ORACLE database, or a “db2 -tsx” command with UDB.
Note that the environment variable MT_DB_LOGIN must be set (database connection user login).
The SYSIN file must contain the SQL requests and the user has to verify the contents regarding the database target.
Simple Application on COBOL-IT / BDB
Based on BDB with XA protocal, the Batch COBOL programs compiled by COBOL IT can access the indexed ISAM files which are converted from Mainframe VSAM files through the ART Workbench. To enable this application in Batch runtime, you need to unset COB_ENABLE_XA before running Batch COBOL program.

Copyright © 1994, 2017, Oracle and/or its affiliates. All rights reserved.