PROCs are called from within the SELECT sub-command in the Processing section of an Apply Engine script using the CALL function.
Example
Assume that there are two (2) PROCs that contain different mapping logic based on the contents of a status (STATUS) in the source datastore records. These PROCs are defined as follows:
CREATE PROC MAP_CASE1 AS
SELECT
{
TARGET_FIELD1 = SOURCE_FIELD1
TARGET_FIELD2 = SOURCE_FIELD2
}
FROM SOURCE_DATASTORE;
CREATE PROC MAP_CASE2 AS
SELECT
{
TARGET_FIELD1 = ADD(SOURCE_FIELD1, SOURCE_FIELD3)
TARGET_FIELD2 = ADD(SOURCE_FIELD2, SOURCE_FIELD4)
}
FROM SOURCE_DATASTORE;
In the main SELECT sub-command, check the STATUS field in the source datastore. If the STATUS field is ‘AAA’ then call PROC MAP_CASE1 otherwise, call PROC MAP_CASE2 as shown below.
SELECT
{
if STATUS, = ‘AAA
CALLPROC(MAP_CASE1)
else
CALLPROC(MAP_CASE2)
}
FROM SOURCE_DATASTORE;