May 02

Create Determination – BOPF

As a pre-requisite, Go through the blog with title Custom BOPF Business Object

By the end of this blog, you will be able to..

  • Understand the concept of Determination
  • Create “Determination” on node
  • Understand different patterns available while creating determination

A determination is an entity assigned to a node, which describes internal business logic that changes the business object. Like a database trigger, a determination is automatically executed by Business Object Processing Framework (BOPF) as soon as the trigger condition is fulfilled. This trigger condition is checked by BOPF at different points during the transaction, depending on the pattern of the determination. For each determination, it is necessary to specify the changes that form the trigger condition. Changes can include creating, updating, deleting, or loading node instances.

You can use a determination primarily to compute data that are derived from the values of other attributes. The determined attribute and the determining attributes of the trigger condition either belong to the same node or to different nodes. Furthermore, there are values that do not depend on other values but still must automatically be determined during the creation or modification of a node instance

Create Determination:

Right click on the ROOT node to create determination..2017-05-01 15_32_21-183.82.114.111_4444 - Remote Desktop Connection

Enter Determination name and description:2017-05-01 15_34_01-183.82.114.111_4444 - Remote Desktop Connection

Implementation class will be proposed by the wizard:2017-05-01 15_34_24-183.82.114.111_4444 - Remote Desktop Connection

Below section is very important..

  • “Derive dependent data immediately after modification”

This pattern allows us to react to changes made to a given BO node. For example, we might use this event to go clean up some related data.

  • “Derive dependent data before saving”

This pattern allows us to hang some custom logic on a given BO node before it is saved. This could be as simple as using a number range object to assign an ID value to a node attribute or as complex as triggering an interface.

  • “Fill transient attributes of persistent nodes”

This pattern is often used in conjunction with UI development. Here, we might want to load labels and descriptive texts into a series of transient attributes to be displayed on the screen.

  • “Derive instances of transient nodes”

This pattern allows us to load transient nodes into memory on demand. Here, for example, we might lookup real-time status data from a Web service and load it into the attributes of a transient node from downstream consumption.

  • “Create Properties”

This pattern allows us to control the attributes (making fields Mandatory, Read only) of UI fields.

I will proceed with pattern 3 as Quote Status Text field is transient field of persistent node ROOT

2017-05-01 15_34_42-183.82.114.111_4444 - Remote Desktop Connection

Place below code in the class ZCL_RZ_D_FILL_QUOTE_STATUS_TXT, generated by the wizard

 DATA : lt_data TYPE zrz_t_root,
 lr_data TYPE REF TO zrz_s_root,
 lt_change TYPE /bobf/t_frw_name.

*--Retrive method will pull the data related to specific node
 CALL METHOD io_read->retrieve
 EXPORTING
 iv_node = zif_rz_sales_quote_c=>sc_node-root
 it_key = it_key
 iv_fill_data = abap_true
 IMPORTING
 eo_message = eo_message
 et_data = lt_data
 et_failed_key = et_failed_key.

 READ TABLE lt_data ASSIGNING FIELD-SYMBOL(<fs_data>) INDEX 1.
 IF <fs_data> IS ASSIGNED.

 CREATE DATA lr_data.

 IF <fs_data>-quote_status EQ 'N'.
 lr_data->quote_status_txt = 'New'.
 ELSEIF <fs_data>-quote_status EQ 'P'.
 lr_data->quote_status_txt = 'Published'.
 ENDIF.

 APPEND INITIAL LINE TO lt_change ASSIGNING FIELD-SYMBOL(<fs_change>).
 <fs_change> = zif_rz_sales_quote_c=>sc_node_attribute-root-quote_status_txt.

*--Update method is used to modify data of the node
 CALL METHOD io_modify->update
 EXPORTING
 iv_node = zif_rz_sales_quote_c=>sc_node-root
 iv_key = <fs_data>-key
 is_data = lr_data
 it_changed_fields = lt_change.
 ENDIF.

Test the changes in BOBT, You can notice that status text got populate in the below screenshot.

2017-05-02 14_40_52-183.82.114.111_4444 - Remote Desktop Connection

 

As QUOTE_STATUS_TXT is editable, I will create another determination to control the properties of node attribute.

2017-05-01 15_32_21-183.82.114.111_4444 - Remote Desktop Connection

2017-05-02 14_20_59-183.82.114.111_4444 - Remote Desktop Connection

2017-05-02 14_21_33-183.82.114.111_4444 - Remote Desktop Connection.

This time, I will select last option “Create Properties” to control the attributes (making fields Mandatory, Read only) of UI fields.

2017-05-02 14_21_54-183.82.114.111_4444 - Remote Desktop Connection

2017-05-02 14_23_25-183.82.114.111_4444 - Remote Desktop Connection

2017-05-02 14_24_02-183.82.114.111_4444 - Remote Desktop Connection

Place below code in EXECUTE method to make QUOTE_STATUS_TXT as Read only field.

 READ TABLE it_key ASSIGNING FIELD-SYMBOL(<fs_key>) INDEX 1.
 IF <fs_key> IS ASSIGNED.
 CALL METHOD io_property->set_attribute_read_only
 EXPORTING
 iv_attribute_name = zif_rz_sales_quote_c=>sc_node_attribute-root-quote_status_txt
 iv_key = <fs_key>-key
 iv_value = abap_true.
 ENDIF.

When I tested the changes in BOBT, QUOTE_STATUS_TXT is non-editable.

2017-05-02 14_42_39-183.82.114.111_4444 - Remote Desktop Connection

2 Comments

  1. Sunil May 7, 2018

    Hi Rizwan,
    Can you tell me how to determine a field in the header node from the items. For example: Sum of Price of 10 items in the header as total cost.

    Like

  2. Shubham Singh April 18, 2019

    Hi Rizwan,
    I have done the same steps for standard Business Object and tried to make read only a standard field but it didn’t work. Will it work in case of a standard Business object which is enhanced and the same is done for a particular field.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: