How to create own enviromnent.init method?

The skeleton program was prepared for this purpose. In the QSAMPLES source file devlivered together with aperio You can find SKELETON06 source which is ready to fill. You can copy it and adjust or change if needed.

The skeleton of environment.init method was build based on DC1 initialization program and requires three parameters:

  • environmentBaseLibrary <– This is library where the main information is stored for environment
  • environmentId <– The ID of environment which can be used by program to find what to do (how to build environment)
  • comanyCode <– This parametr indicates which company will be used to initialize environment.

The environment.init method should return (it is not manadatory but reccomendation):

  • locale <– current language set up for used in application on iSeries
  • appInstanceId <– unique code of Your application. For example: “DEV111:DV” This is later used to differentiate notifications.

It is not necesarry that Your environment.init pgoram should support all above parameters/data. The initialization program may support more or less parameters. It could be mandatory of optional parameters. All the parameter values are passed to the initiation method by dispatcher. On dispather there is section where You can define default parameters for environment.init method. There are some restrictions or recomendations:

  • The login panel contains only: user, password, company, dispatcher. User and password are used to login to iSeries. The dispatcher is the communication server and the configuration of dispatcher determines which iSeries will be used, what will be the initial library list etc… Then if environmant.init method is defined dispatcher calls it with parameters. The company code comes from login panel the environmantBaseLibrary and environmentId come from dispatcher settings. If You would like to provide more parameters, please define them on dispatcher.

Login panel

Dispatcher config

Dispatcher config

  • Make sure the metadata is correctly updated for environmen.init method. Before environment.init method is called the dispatcher looks into metadata for information what are parameters for this method. Then it tries to gather all required information based on its configuratin. If somethng isnot fedined then it is not passed to environment.init program.
  • Current user profile can be found in program data structure
  • Avoid to open files by environment.init program. The initialization program is called in open shared path. It means all files which are open by initiation program will remain open until end of job. For example If You open file for input only in initiation program then latre on it could be hard to write something to this file.
  • use SQLRPGLE and read/update files using SQL. This solves all problems with share file path.