Before You Begin
This 30-minute OBE (Oracle by Example) shows you how to create a logic extension by using the nested logic extension feature to generate a message for how much is saved with a discount.
In this OBE, you will:
- Create a child logic extension to calculate the total cost of an item with or without a discount.
- Create a parent logic extension that reuses the child logic extension and calculates the amount saved after the discount and then generates a discount message.
- Test the logic extension.
Background
Logic extensions are a key component of the JD Edwards
extensibility framework. They enable nontechnical business
analysts as well as JD Edwards developers to use the familiar
syntax of EnterpriseOne event rules to create logic without the
need for a development client and without the need to build and
deploy a package.
Logic extensions function like a module of programming code,
although the intuitive user interface allows users without
programming knowledge to create effective logic. And like other
modules of programming code, it is often useful to create logic
that can be reused in other contexts. For example, you might
create a logic extension that performs some arithmetic, adds a
certain number of days to a given date, or converts a numeric
value to a string.
Starting with Tools Release 9.2.7.3, you can create logic
extensions that call other logic extensions thus enabling a
common pattern in programming in which code snippets are
designed as reusable objects.
What Do You Need?
To perform the steps in this OBE, you will need:
- Access to a JD Edwards EnterpriseOne environment with Tools Release 9.2.7.3 or later. JD Edwards EnterpriseOne Trial Edition running on Oracle Cloud Infrastructure is suitable, but you can use any environment with the proper Tools release.
- Security access to use Orchestrator Studio.
Scenario
You want to build a logic extension to calculate the cost of an item with or without a discount and then generate a discount message for the customer.
Creating the Child Logic Extension
In this section, you will learn how to create a new logic extension to calculate the total cost of an item with or without a discount.
- Sign in to the Orchestrator Studio.
- Click Logic Extensions.
- Click the New button.
- In the Name field, enter
Calculate Item Cost with Discount
. - In the Description field, enter
Calculate the total cost of an item with or without a discount. Inputs are the Item Price, Quantity, Discount Percentage, and Apply Discount (True/False). The output is the Total Cost.
- Click Save.
- In the Data Dictionary tab, to add a data dictionary item,
click the +Data Dictionary button.
The system displays the Data Dictionary window. - In the Alias field, enter
NUM1
and click the + button. - Change the name of the newly added data dictionary item to
Item Price.
- Similarly, add three more NUM1 data dictionary items and
change the names to
Quantity
,Discount Percentage
, andTotal Cost
respectively.
Note: You can also click the Item Price drop-down list and select Duplicate as Data Structure. - For Total Cost, click the IO Type drop-down list, select Output Only.
- Click the +Boolean button and change the
value of the Boolean item in the Name field to
Apply Discount.
This Boolean is later used in the logic extension to determine whether the discount is applied or not.
- Click Save. The system displays the Logic tab.
- First, we will add an assignment to calculate the total cost (Item Price x Quantity). In the design panel, hover over the line between the Start and the End node and click the + icon.
- Select Assignment from the context menu.
The Assignment Panel is displayed on the right.
Note: You can also drag and drop the Assignment statement from the Statements tab to the + icon between the Start and the End nodes in the design panel. - In the Assignment side panel, change the label to
Calculate the Total Cost
and enter the description asTotal Cost = Item Price x Quantity.
- To create the assignment statement as
Total Cost <- Item Price x Quantity
:- In the Assignment Block panel, click the Edit
(Launch Assignment Mapping Wizard) icon.
The Assignment Builder window is displayed and the Edit icon in the Target field is highlighted. - In the right panel (Object Selector panel), select Total
Cost.
The value Total Cost is displayed in the Target field, and the Edit icon in the Source field is highlighted. - In the right panel, click the Expressions
icon, and select
x
(multiply symbol).
The system now highlights the first Edit icon in the source field. - In the right panel, select Item Price and then select Quantity.
- Click Close.
- In the Assignment Block panel, click the Edit
(Launch Assignment Mapping Wizard) icon.
- Hover between the newly added Assignment and the End node. Click the + button.
- Select If Else. The If Else panel is displayed on the right.
- In the If Else panel, change the label to
Apply Discount?
. - In the Description field, enter
Check whether to apply the discount percentage.
- In the IF Branch section, in the Branch Label field, enter
Apply Discount
and in the Else Branch section, in the Branch Label field, enterDon't Apply Discount.
- Click the Edit (Launch Criteria Builder)
icon.
The Criteria Builder window is displayed and the Edit icon in the Left Operand field is highlighted. - For the Left Operand field, select Apply Discount
from the right panel.
In the Compare Operator field, the valueIs True
is displayed automatically. - Click Close.
- To calculate the total amount with discount, in the design
panel, hover over the line after the Apply Discount label, and
click the + icon. Select Assignment
from the context menu.
The Assignment Block panel is displayed on the right. - Change the label to
Total Price with Discount
and enter the description asTotal Cost=Total Cost × (1 − Discount Percentage/100)
- To create the assignment statement as
Total Cost <- Total Cost x ("1" - (Discount Percentage/"100"))
:- In the Assignment Block panel, click the Edit (Launch
Assignment Mapping Wizard) icon.
The Assignment Builder window is displayed and the system highlights the icon in the Target field. - In the right panel, select Total Cost.
The system now highlights the Edit icon in the Source field. - In the right panel, click the Expressions icon
and select x (multiply symbol).
The system highlights the first Edit icon in the source field. - From the right panel, select Total Cost. The system highlights the second Edit icon in the source field.
- Click the Expressions icon and select - (minus symbol). The assignment statement should look like the following screenshot.
- Click the Literal icon in the right
panel, in the Single Value field, enter
1
and click OK. - In the right panel, click the Expressions icon
and select
÷
(divide symbol). The system highlights the first Edit icon in the source field. - Select Discount Percentage from the right panel.
- Click the Literal icon in the right
panel, in the Single Value field, enter
100
and click OK. - Click Close.
- In the Assignment Block panel, click the Edit (Launch
Assignment Mapping Wizard) icon.
- Click Save.
Testing the Child Logic Extension
- Click the Test tab.
- Enter the values in the Input field for Item Price,
Quantity, and Discount Percentage.
Select the value True for Apply Discount. - Click the Test button. Review the results in the Output field of the Total Cost row.
Creating the Nested Logic Extension
In this section, you will learn how to create a parent logic extension by reusing the Calculate Item Cost with Discount logic extension created in the previous section. You will add the Calculate Item Cost with Discount logic extension twice in this parent logic extension to calculate the amount saved after the discount and then generate a discount message.
- Sign in to the Orchestrator Studio.
- Click Logic Extensions.
- Click the New button.
- In the Name field, enter
Generate Discount Message
. - In the Description field, enter
Generate a message for how much is saved with a discount. Inputs are Item Price, Quantity, and Discount Percentage. This logic extension calls "Calculate Item Cost with Discount" to calculate the cost
. - Click Save.
- Click the Logic tab.
- In the design panel, hover over the line between the Start and the End node and click the + icon.
- From the context menu, select Logic Extension.
The system displays the Logic Extension panel on the right.
Note: You can also drag and drop Logic Extension from the Statements tab to the + icon between the Start and the End nodes in the design panel. - In the Logic Extension panel, change the value in the Label
field to
Call Calculate Item Cost with Discount
and in the Description field, enterCall the logic extension to calculate cost with discount.
In the Logic Extension Name field, click Search.
- Select Calculate Item Cost with Discount.
- To map the parameters, click the Edit icon in the Logic Extension side panel. The system displays the Logic Extension Parameter Mapping window.
- Click the drop-down list next to Item Price and select
Add to Data Structure.
- Similarly, click the drop-down list next to Quantity and Discount Percentage, and select Add to Data Structure.
- Click the drop-down list next to Total Cost, and select Add to Variables.
- Click the Edit icon in the Mapping Field of the Apply Discount row, and select the Literal icon in the right panel. Make sure that the value True is selected in the Type field, and click OK.
- Click Close.
- To rename the Total Cost1 variable, click the Variables
tab. Change the value in the Name field to
Total with Discount
. - Click the Logic tab.
- Right-click on the Call Calculate Item Cost with Discount logic extension and click Copy.
- Right-click on the line after the Call Calculate Item Cost with Discount logic extension and click Paste. The system adds another Call Calculate Item Cost with Discount logic extension.
- Click the second Call Calculate Item Cost with
Discount logic extension, and in the Logic
Extension side panel, change the value in the Label field to
Call Calculate Item Cost without Discount
. Change the value in the Description field toCall the logic extension to calculate cost without discount
. - In the Logic Extension panel, click the Edit icon.
- In the Apply Discount row, click True. In the side panel, change the value in the Type field to False and click OK.
- Click the drop-down list next to Total Cost and select Add to Variable.
- Click Close.
- Click the Variables tab. Change the name
of the second variable to
Total without Discount
. - To add the message string, click the Data Structure
tab, and click +Data Dictionary.
The system displays the Data Dictionary window. - In the Alias field, enter
ALPH
and click the + button. - Change the value in the Name field for ALPH as
Message
. - For Message, click the IO Type drop-down list and select Output Only.
- Rename the values in the Name field for other data dictionary items as shown in this screenshot.
- Click the Logic tab.
- Hover over the line after the second logic extension and click the + icon.
- To add an assignment statement to generate a discount
message, select Assignment from the context
menu.
The Assignment Block panel is displayed on the right.
Change the value in the label field toGenerate the discount message
and enter the description asGenerate the discount message
. - To create the assignment statement as
Message <- concatenate("With discount you save:", round(Total without Discount - Total with Discount), "2"):
- In the Assignment Block panel, click the Edit icon.
The system displays the Assignment Builder window, and the Edit icon in the Target field is highlighted. - Select Message from the right panel.
The Edit icon in the Source field is highlighted. - In the right panel, click the Text Functions icon and select concatenate.
- Click the Literal icon. In the Single
Value field, enter
With discount you save:
and click OK. - Click the Math Functions icon, and select round (Numeric, Numeric).
- Click the Expressions icon, and select - (minus symbol).
- Click the Variables icon. Select Total without Discount and then select Total with Discount.
- Click the Literal icon. In the Single
Value field, enter
2
to round to 2 decimal places. - Click Close.
- In the Assignment Block panel, click the Edit icon.
- Click Save.
Testing the Logic Extension
- Click the Test tab.
- Enter the values in the Input field for Item Price, Quantity, and Discount Percentage.
- Click the Test button. Review the results in the Output field of the Message row.
Conclusion
In this OBE, you learned how to build a simple logic extension to calculate the cost of an item with or without a discount. That is a function that can be reused in many situations. In this lesson you called that logic extension from another logic extension to generate a discount message for a customer. But you can imagine using it in other situations as well, for example, to calculate taxes, or to calculate amounts in foreign currencies, or to iterate over an array to calculate a large number of item discounts. As with common programming techniques, you can create logic extensions as objects that perform some specific function, and then reuse those objects by calling them from other logic extensions. Be sure to use the Description fields to document your logic extensions well so that others can clearly understand them and use them in their own solutions.