Oracle by Example brandingUsing Nested Logic Extensions

section 0Before 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.


section 1Creating 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.

  1. Sign in to the Orchestrator Studio.
  2. Click Logic Extensions.
  3. Click the New button.
  4. In the Name field, enter Calculate Item Cost with Discount.
  5. 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.
  6. Click Save.
  7. In the Data Dictionary tab, to add a data dictionary item, click the +Data Dictionary button.
    The system displays the Data Dictionary window.
  8. In the Alias field, enter NUM1 and click the + button.
  9. Change the name of the newly added data dictionary item to Item Price.
  10. Similarly, add three more NUM1 data dictionary items and change the names to Quantity, Discount Percentage, and Total Cost respectively.
    Note:
    You can also click the Item Price drop-down list and select Duplicate as Data Structure.
  11. For Total Cost, click the IO Type drop-down list, select Output Only.
  12. Logic Extension - Data Structure
    Logic Extension - Data Structure
  13. 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.
  14. Logic Extension - Data Structure
    Logic Extension - Data Structure
  15. Click Save. The system displays the Logic tab.
  16. 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.
  17. 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.
  18. In the Assignment side panel, change the label to Calculate the Total Cost and enter the description as Total Cost = Item Price x Quantity.
  19. To create the assignment statement as Total Cost <- Item Price x Quantity:
    1. 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.
    2. 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.
    3. 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.
    4. In the right panel, select Item Price and then select Quantity.
    5. Assignment Builder Window
      Assignment Builder Window
    6. Click Close.
    7. Assignment Builder Window
      Assignment Block Panel
  20. Hover between the newly added Assignment and the End node. Click the + button.
  21. Select If Else. The If Else panel is displayed on the right.
  22. In the If Else panel, change the label to Apply Discount?.
  23. In the Description field, enter Check whether to apply the discount percentage.
  24. In the IF Branch section, in the Branch Label field, enter Apply Discount and in the Else Branch section, in the Branch Label field, enter Don't Apply Discount.
  25. Click the Edit (Launch Criteria Builder) icon.
    The Criteria Builder window is displayed and the Edit icon in the Left Operand field is highlighted.
  26. For the Left Operand field, select Apply Discount from the right panel.
    In the Compare Operator field, the value Is True is displayed automatically.
  27. Criteria Builder
                      Window
    Criteria Builder Window
  28. Click Close.
  29. If Else Panel
    If Else Panel
  30. 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.
  31. Add Assignment
    Add Assignment
  32. Change the label to Total Price with Discount and enter the description as Total Cost=Total Cost × (1 − Discount Percentage/100)
  33. To create the assignment statement as Total Cost <- Total Cost x ("1" - (Discount Percentage/"100")):
    1. 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.
    2. In the right panel, select Total Cost.
      The system now highlights the Edit icon in the Source field.
    3. In the right panel, click the Expressions icon and select x (multiply symbol).
      The system highlights the first Edit icon in the source field.
    4. From the right panel, select Total Cost. The system highlights the second Edit icon in the source field.
    5. Click the Expressions icon and select - (minus symbol). The assignment statement should look like the following screenshot.
    6. Assignment Builder Window
      Assignment Builder Window
    7. Click the Literal icon in the right panel, in the Single Value field, enter 1 and click OK.
    8. In the right panel, click the Expressions icon and select ÷ (divide symbol). The system highlights the first Edit icon in the source field.
    9. Select Discount Percentage from the right panel.
    10. Click the Literal icon in the right panel, in the Single Value field, enter 100 and click OK.
    11. Assignment Builder Window
      Assignment Builder Window
    12. Click Close.
    13. Calculate Item
                          Cost with Discount Logic Extension
      Calculate Item Cost with Discount Logic Extension
  34. Click Save.

section 2Testing the Child Logic Extension

  1. Click the Test tab.
  2. Enter the values in the Input field for Item Price, Quantity, and Discount Percentage.
    Select the value True for Apply Discount.
  3. Click the Test button. Review the results in the Output field of the Total Cost row.
  4. Test Tab
    Test Tab

section 3Creating 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.

  1. Sign in to the Orchestrator Studio.
  2. Click Logic Extensions.
  3. Click the New button.
  4. In the Name field, enter Generate Discount Message.
  5. 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.
  6. Click Save.
  7. Click the Logic tab.
  8. In the design panel, hover over the line between the Start and the End node and click the + icon.
  9. 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.
  10. In the Logic Extension panel, change the value in the Label field to Call Calculate Item Cost with Discount and in the Description field, enter Call the logic extension to calculate cost with discount.
  11. In the Logic Extension Name field, click Search.
  12. Select Calculate Item Cost with Discount.
  13. Generate Discount
                      Message Logic Extension
    Generate Discount Message Logic Extension
  14. To map the parameters, click the Edit icon in the Logic Extension side panel. The system displays the Logic Extension Parameter Mapping window.
  15. Click the drop-down list next to Item Price and select Add to Data Structure.
    Logic Extension
                        Parameter Mapping Window
    Logic Extension Parameter Mapping Window

  16. Similarly, click the drop-down list next to Quantity and Discount Percentage, and select Add to Data Structure.
  17. Click the drop-down list next to Total Cost, and select Add to Variables.
  18. 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.
  19. Logic Extension
                      Parameter Mapping Window
    Logic Extension Parameter Mapping Window
  20. Click Close.
  21. To rename the Total Cost1 variable, click the Variables tab. Change the value in the Name field to Total with Discount.
  22. Generate Discount Message Logic Extension - Variables Tab
    Generate Discount Message Logic Extension - Variables Tab
  23. Click the Logic tab.
  24. Right-click on the Call Calculate Item Cost with Discount logic extension and click Copy.
  25. Generate
                      Discount Message Logic Extension
    Generate Discount Message Logic Extension
  26. 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.
  27. Copy and Paste Logic Extension
    Copy and Paste Logic Extension
  28. 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 to Call the logic extension to calculate cost without discount.
  29. In the Logic Extension panel, click the Edit icon.
  30. In the Apply Discount row, click True.  In the side panel, change the value in the Type field to False and click OK.
  31. Logic
                      Extension Parameter Mapping Window
    Logic Extension Parameter Mapping Window
  32. Click the drop-down list next to Total Cost and select Add to Variable.
  33. Click Close.
  34. Click the Variables tab. Change the name of the second variable to Total without Discount.
  35. Generate Discount
                      Message Logic Extension Variables Tab
    Generate Discount Message Logic Extension Variables Tab
  36. To add the message string, click the Data Structure tab, and click +Data Dictionary.
    The system displays the Data Dictionary window.
  37. In the Alias field, enter ALPH and click the + button.
  38. Change the value in the Name field for ALPH as Message.
  39. For Message, click the IO Type drop-down list and select Output Only.
  40. Rename the values in the Name field for other data dictionary items as shown in this screenshot.
  41. Generate Discount
                      Message Logic Extension Data Structure Tab
    Generate Discount Message Logic Extension Data Structure Tab
  42. Click the Logic tab.
  43. Hover over the line after the second logic extension and click the + icon.
  44. 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 to Generate the discount message and enter the description as Generate the discount message.
  45. Generate Discount
                      Message Logic Extension
    Generate Discount Message Logic Extension
  46. To create the assignment statement as Message <- concatenate("With discount you save:", round(Total without Discount - Total with Discount), "2"):
    1. 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.
    2. Select Message from the right panel.
      The Edit icon in the Source field is highlighted.
    3. In the right panel, click the Text Functions icon and select concatenate.
    4. Click the Literal icon. In the Single Value field, enter With discount you save: and click OK.
    5. Click the Math Functions icon, and select round (Numeric, Numeric).
    6. Click the Expressions icon, and select - (minus symbol).
    7. Click the Variables icon. Select Total without Discount and then select Total with Discount.
    8. Click the Literal icon. In the Single Value field, enter 2 to round to 2 decimal places.
    9. Assignment
                          Builder Window
      Assignment Builder Window
    10. Click Close.
  47. Click Save.
  48. Generate Discount
                      Message Logic Extension
    Generate Discount Message Logic Extension

section 4Testing the Logic Extension

  1. Click the Test tab.
  2. Enter the values in the Input field for Item Price, Quantity, and Discount Percentage.
  3. Click the Test button. Review the results in the Output field of the Message row.
  4. Test Tab
    Test Tab

section 5Conclusion

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.


more informationWant to Learn More?