Import
Import makes accessible functions from other .ctl
files. It is similar to import
statement in Java or include
statement in C/C++. Files to be included must be defined at the beginning before any other declaration(s) and/or statement(s).
import 'fileURL';
import "fileURL";
You must decide whether you want to use single or double quotes. Single quotes do not escape so called escape sequences. For more details see Literals below. For these fileURL
, you must type the URL of some existing source code file.
Example 51. Example of an import of a CTL file
//#CTL2
import "trans/filterFunctions.ctl";
function integer transform() {
$out.0.field1 = filterChars($in.0.field1);
return ALL;
}
Example 52. Example of importing a CTL file with a graph parameter
//#CTL2
import "${FUNCTION_DIR}/filterFunctions.ctl";
function integer transform() {
$out.0.field1 = filterChars($in.0.field1);
return ALL;
}
Metadata Import in CTL2
It is also possible to import metadata from an external .fmt
file, similarly to importing external .ctl
files. Then you can use these metadata definitions in CTL when creating record structures. This enables you to use metadata that are unavailable in the current graph. Note that imported metadata can overlay metadata with the same name that already exist in the current graph.
import metadata "<path>";
or
import metadata "<path>" <new name>;
The scope of these new metadata definitions is limited just to the current CTL script, so other components don’t see them.
Example 53. CTL Metadata Import
//#CTL2
import metadata "${META_DIR}/OrderItem.fmt"; // import OrderItem
// import metadata from Person.fmt and rename it to "Customer"
import metadata "${META_DIR}/Person.fmt" Customer;
OrderItem item;
item.productId = 12345;
item.quantity = 5;
Customer c;
c.firstName = "John";
Updated 11 months ago