The sys_init function is used to initialize the JCL module. You must call sys_init at the start of your JCL job. The function performs the following tasks.
Initializes internal variables.
Reads system configuration files.
Reads job specific settings from the job conf file.
Reads the primary command line.
Opens log and trace files.
Validates documentation contained in the job file.
If the verbose option has been specified on the primary command line, the function will output to the console the jobname, process number, primary command line switches used, and the current date and time. A banner is included in the output.
>test_job.pl -r -v __ ______ __ / // ____// / DBIx::JCL __ / // / / / Job Control Library, version x.xx / /_/ // /___ / /___ http://dbixjcl.org/ \____/ \____//_____/ Use -h for help Jobname: test_job Process: 4452 Command: -r -v Mon Feb 22 08:00:00 2010
Example showing the no banner primary command line option.
>test_job.pl -r -v -nb Jobname: test_job Process: 4452 Command: -r -v Mon Feb 22 08:00:00 2010
Returns 0 on success.
Here is an example of common usage of this function. Most calls to sys_init are made using only the first parameter which contains the job name.
use strict; use warnings; use DBIx::JCL qw( :all ); my $jobname = 'test_job'; sys_init( $jobname );
Three extra paramaters can be passed to sys_init as shown below. One or more can be passed at a time. These are passed as a hash. The “logplain” parameter tells JCL to write log file entries with no datetime stamp on each line, this creates a bare log file. This is useful for creating report output directly from a JCL job log file. The “nobanner” option supresses the banner. This is the same as using the no banner switch on the primary command line. The “connectfailok” option causes JCL to continue execution even if a database connection fails.
use strict; use warnings; use DBIx::JCL qw( :all ); my $jobname = 'test_job'; sys_init( $jobname, ( logplain => 'yes' nobanner => 'no' connectfailok => 'yes' ) );
Job Configuration File
Specific job initialization settings are read from the job configuration file when sys_init is called. All of these settings are optional, but it is recommended that at a minimum you specify your log file name in the job configuration file as shown below.
job: logfile: test_job.log
Other job settings besides “logfile” are read at initialization. An example of all of the job initialization settings is shown below.
job: logfile: test_job.log logging_levels: FATAL,ERROR,WARN,INFO console_levels: FATAL,ERROR,WARN,INFO log_gdg: 5 log_prefix: LOG emailto: email@example.com,firstname.lastname@example.org email_levels: FATAL,ERROR,WARN
Reasonable default values are provided for all of these settings, if a setting is provided in the job configuration file, the value supplied will be used instead of the default value. For a discussion of these values, see Job Initialization.
There is no need to check the return value from this function.
Notice that values in the job configuration file are aligned on the same column. It is required that values on the same level all line up with respect to column. This also benefits readibility.