Open the Globals window under a Logical Unit and define a new Global.
After the Global is saved, its definitions are kept in the Globals.java file under the same LU and its initial value = Y. This variable can be used by all functions under this LU.
if (CUSTOMER_CHECKS_ENABLED.equals("Y")) {
//do something
}
This example shows how to check the value of a Global variable and to determine whether to perform or to skip specific business logic (validation checks).
Open the Globals window under a Logical Unit and define a new Global.
The global can be used in an SQL prepared statement in an LU function. The syntax is: '@[global_name]@'. For Integer value, the use of apostrophe is optional.
String sql = "SELECT * From ACTIVITY WHERE CUSTOMER_ID = ? AND ACTIVITY_ID = ? AND NEW_NOTE_IND = @NEW_IND@";
ludb().fetch(sql, input1, input2).each(row->{
yield(row.cells());
});
Open the Globals window under a Logical Unit and define two new Globals and then create a new Table Population and add the Globals to it.
This example shows how a Global can be used in a Table Population. Since the SOURCE_PRODUCT_VERSION and ACTIVITY_NOTE Globals are defined in the LU’s Globals list in the Globals.java file, they are part of the LU’s scope and therefore can be used by the Table Population in the same LU.
Click to display an example of Globals under a Logical Unit in the Demo project.
Open the Globals window under Shared Objects and define new Globals and then create a Web Service and use the Globals.
This example shows how Globals can be used within a Fabric Web Service.
Three Globals are defined under Shared Objects Globals in the SharedGlobals.java file and therefore can be used by the Fabric Web Service.
if (contrID == "" && adrID == "") {
result = fnErrorCheck(MISSING_INPUT); //Missing input
return result;
} else if (contrID != "" && adrID != "") {
result = fnErrorCheck(TOO_MANY_INPUTS); //Too many inputs
return result;
}
Click to display an example of Globals under Shared Objects in the Demo project.
Open the Globals window under Shared Objects and define a new Global and then create a Web Service or a Project function that will override the initial value of this Global.
The following examples show how a Global can be overridden in a cluster and per session.
The RECEIVED_ERROR Global is created with an initial value of 0 and in a function its value is overridden per cluster.
if (...) {
...
fabric().execute("set_global global '*.RECEIVED_ERROR="+anotherValue+"'");
}
The RECEIVED_ERROR Global is created with an initial value of 0 and in a function its value is overridden on a session level. Check the value of the overridden variable in another function or a WS, for example to perform business logic.
In fnErrorCheck: override the global or a variable per session:
if (...) {
...
fabric().execute("set RECEIVED_ERROR="+ anotherValue);
}
The wsGetCustomerDetails Web Service calls the fnErrorCheck function and then checks the value of this variable set by the fnErrorCheck function:
Object val;
String receivedErr = "";
Map<String,Object> result = new HashMap<>();
//invoke fnErrorCheck() which sets the value of RECEIVED_ERROR
result = fnErrorCheck(input);
...
//get the value of RECEIVED_ERROR as set by fnErrorCheck() and do something...
val = db("fabric").fetch("set RECEIVED_ERROR").firstValue();
receivedErr = k2_ifNull(val.toString(),"No error");
result.put("p_error", receivedErr);
Open the Globals window under a Logical Unit and define a new Global.
After the Global is saved, its definitions are kept in the Globals.java file under the same LU and its initial value = Y. This variable can be used by all functions under this LU.
if (CUSTOMER_CHECKS_ENABLED.equals("Y")) {
//do something
}
This example shows how to check the value of a Global variable and to determine whether to perform or to skip specific business logic (validation checks).
Open the Globals window under a Logical Unit and define a new Global.
The global can be used in an SQL prepared statement in an LU function. The syntax is: '@[global_name]@'. For Integer value, the use of apostrophe is optional.
String sql = "SELECT * From ACTIVITY WHERE CUSTOMER_ID = ? AND ACTIVITY_ID = ? AND NEW_NOTE_IND = @NEW_IND@";
ludb().fetch(sql, input1, input2).each(row->{
yield(row.cells());
});
Open the Globals window under a Logical Unit and define two new Globals and then create a new Table Population and add the Globals to it.
This example shows how a Global can be used in a Table Population. Since the SOURCE_PRODUCT_VERSION and ACTIVITY_NOTE Globals are defined in the LU’s Globals list in the Globals.java file, they are part of the LU’s scope and therefore can be used by the Table Population in the same LU.
Click to display an example of Globals under a Logical Unit in the Demo project.
Open the Globals window under Shared Objects and define new Globals and then create a Web Service and use the Globals.
This example shows how Globals can be used within a Fabric Web Service.
Three Globals are defined under Shared Objects Globals in the SharedGlobals.java file and therefore can be used by the Fabric Web Service.
if (contrID == "" && adrID == "") {
result = fnErrorCheck(MISSING_INPUT); //Missing input
return result;
} else if (contrID != "" && adrID != "") {
result = fnErrorCheck(TOO_MANY_INPUTS); //Too many inputs
return result;
}
Click to display an example of Globals under Shared Objects in the Demo project.
Open the Globals window under Shared Objects and define a new Global and then create a Web Service or a Project function that will override the initial value of this Global.
The following examples show how a Global can be overridden in a cluster and per session.
The RECEIVED_ERROR Global is created with an initial value of 0 and in a function its value is overridden per cluster.
if (...) {
...
fabric().execute("set_global global '*.RECEIVED_ERROR="+anotherValue+"'");
}
The RECEIVED_ERROR Global is created with an initial value of 0 and in a function its value is overridden on a session level. Check the value of the overridden variable in another function or a WS, for example to perform business logic.
In fnErrorCheck: override the global or a variable per session:
if (...) {
...
fabric().execute("set RECEIVED_ERROR="+ anotherValue);
}
The wsGetCustomerDetails Web Service calls the fnErrorCheck function and then checks the value of this variable set by the fnErrorCheck function:
Object val;
String receivedErr = "";
Map<String,Object> result = new HashMap<>();
//invoke fnErrorCheck() which sets the value of RECEIVED_ERROR
result = fnErrorCheck(input);
...
//get the value of RECEIVED_ERROR as set by fnErrorCheck() and do something...
val = db("fabric").fetch("set RECEIVED_ERROR").firstValue();
receivedErr = k2_ifNull(val.toString(),"No error");
result.put("p_error", receivedErr);