![]() |
![]() |
![]() |
![]() |
![]() |
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‑1 KSH script environment variables Table 3‑2 lists the environment variables are used by Batch Runtime and must be defined before using the software.
Within Batch Runtime, a phase corresponds to an activity or a step on the source system.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 JUMP_LABEL=STEP2 (PENULTIMATESTEP) For the label, which must point to END_JOB. The _ is necessary, because the character is forbidden on z/OS. Listing 3‑1 shows a Korn shell script example.Listing 3‑1 Korn shell Script ExampleSymbols 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]Listing 3‑2 Symbol Use ExamplesThe 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‑3Listing 3‑3 Application Program Execution Step ExampleAn 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 ExampleExternal 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‑5Listing 3‑5 External Procedure ExampleThe 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‑6Listing 3‑6 Call to the m_ProcInclude Function ExampleListing 3‑7 and Listing 3‑8 are examples.Listing 3‑7 Defining Procedure ExampleListing 3‑8 Calling Procedure ExampleAs 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 ExampleListing 3‑10 m_FileOverride Procedure Call: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 ExampleThe 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.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
• 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_CondEnd functions: see Conditioning the Execution of a Step.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.When using Batch Runtime, a file can be used either by a Batch Runtime function (for example: m_FileSort, m_FileRename etc.) or a 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.Listing 3‑13 Example of File AssignmentListing 3‑14 Example of Using a File by a COBOL ProgramA GDG (generation data group) file is defined through the m_GenDefine function. The only parameter to be specified is the maximum number of versions to keep on the disk:Note: the function m_GenDefine is not mandatory to define a GDG file. As shown in Listing 3‑15, the GDG file will be created with a limit of 9999.Listing 3‑15 Example of using a generation file:The m_FileAssign function has a special parameter (-g) that serves to specify that the file being assigned is a generation file and to set the desired version of the file as shown in Listing 3‑16.Listing 3‑16 Example of Using a Generation File:The m_FileAssign function may be used to address all the generations of a GDG.As shown in Listing 3‑17, the SORT function envolves all generations of the GDG file named AP.GDG.Listing 3‑17 GDG File ExampleTo 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‑18.Listing 3‑18 In-stream Data ExampleTo 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‑19.Listing 3‑19 Using a Concatenated Set of Files ExampleTo use an “external sysin” file which contains commands to be executed, use the m_UtilityExec function.Files (including generation files) can be deleted using the m_FileDelete function: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).When executing an application program that needs to connect to the RDBMS, the -b option must be used when calling the m_ProgramExec function.
• Set the environment variable MT_DB_LOGIN before booting the TuxJES system.
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.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‑20.Listing 3‑20 RDBMS Connection ExampleThe 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 runbatch program, is in charge to:For each launched job, Batch Runtime produces a log file containing information for each step (phase) that was executed. This log file has the following structure: as shown in Listing 3‑21.Listing 3‑21 Log File ExampleWhen not using TuxJes, the log file is created under the ${MT_LOG} directory with the following name: <Job name>_<TimeStamp>_<Job id>.logEntry 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.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.