Working with User-Written Functions

In addition to the functions built into EngageOne™ Enrichment, you can write or use existing subroutines within rule files as functions. These functions can be written in COBOL, Assembler, or C. You identify the user-written subroutine for use within the rule file by adding the USERFUNCTION declaration in that file. Once you define a function, you can use it in the same manner as any other EngageOne™ Enrichment function.

The following diagram illustrates how the interface for the user-written function works.

The rules shown below define a user-written function called ims_database—COBOL load module FNIMS2—that uses an account number to look up a client’s age in an IMS database. Either field %%Account or %%Account2 can contain the customer account. FNIMS2 is a normal user-written function subroutine with an input string of up to 25 bytes that returns an output string (%%Age) of up to 3 bytes. The Input call area (maxin) is 65 bytes (25+40) and the Output call area (maxout) is 43 bytes (3+40).

USERFUNCTION ims_database FNIMS2 COBOL N 65 43
IF %%Account <> ' ' THEN
   %%Age = ims_database(%%Account)
ELSE
   %%Age = ims_database(%%Account2)
ENDIF

The USERFUNCTION keyword identifies the function within the rule file. Once identified, EngageOne™ Enrichment can access the function using the same syntax as with built-in functions, with one exception: you can pass only one variable to and from the user-written function.

To pass or receive more than one variable, concatenate multiple arguments into one and use the built-in RGET or SUBSTR functions to split data into multiple variables for the function's return value.