Salesforce

When to Perform Initialization (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

When to Perform Initialization (Magic xpa 3.x)

Previously we spoke about what may be initialized. In this section we will discuss when to initialize and also give some guidelines about how to initialize. We will explain which element can be initialized at each stage.

The different stages of initialization are:

  • Global initialization

  • Subsystem initialization

  • Thread initialization

Global Initialization

Global initialization is sometimes called application initialization. This level encompasses the initialization of objects that will be available for every subsystem in this application. All objects mentioned in the previous section can be initialized at this level.

Any executed context runs the application’s Main Program. As a result, you can use the Main Program Task Prefix to initialize objects you require.

For example, if you want to initialize a memory table with a list of operation codes, you can call a program from the Main Program’s Task Prefix that fills this memory table.

Subsystem Initialization

The subsystem level encompasses the initialization of objects that will only be available for use when this subsystem runs. Any object mentioned in the previous section can be initialized at this level.

You can use the program’s Task Prefix to execute the initialization of objects you need. For example, if you want to insert values into a string that will be used in a combo box, instead of a data control, you can do this in the program’s Task Prefix. You can also have a variable with a unique name that can be used to create a PDF or text file, which can be initialized here.

Another example is a variable that holds the current US$ exchange rate, which can be in a database table. Instead of issuing a Link Operation in every program to issue a server call, you can call a subtask in the Task Prefix that fetches the required data and updates the variable.

Sample Application:

When the Login task is successful, it calls a ‘User Initialization’ batch task that saves the user details as global variables for the subsystem.

Thread Initialization

Thread initialization is sometimes called procedure initialization. The thread initialization level encompasses the initialization of objects that will only be available for a specific procedure. This is regular programming, and there should be no surprises here. Any objects mentioned in the previous section can be initialized at this level.

There are many ways to initialize objects at this level. Two of them are:

  • Issue a Call Program or Update Variable in the Task Prefix of the first program in the procedure. The called program can initialize any memory tables that the procedure needs or clean up temporary tables.

  • Initialize the various objects before calling the first program in this procedure. An event handler can be created to call this program. Within such a handler you may call a program to initialize memory tables. Variables can be updated at this stage as well. The handler should issue a call program for the first program in the procedure after the initialization-related operations.

Reference
Attachment 
Attachment