This blog is on continuation to Part 1.
In this part we shall create the BOPF action and display the sale order scenario in the Fiori App using Smart Template.
For the BOPF action, go to BOPF Business Object ZDEMO_I_SALESORDER from Tcode BOBX. Click on change mode. Under the Node Elements, traverse to node ZDEMO_I_SALESORDER and select Action element. Right Click on Action and Click "Create".
Go to Class Builder and create the class ZCL_A-DEMO_SALESORDER.
Implement the method Execute.
Save and Activate. Below is code for Action. Basically the code reads the selected sales order and then change the corresponding BOPF node instance with the new lifecycle status value.
method /bobf/if_frw_action~execute.
case is_ctx-act_key.
"Action - Set overall status
when zif_demo_i_salesorder_c=>sc_action-zdemo_i_salesorder-set_lifecycle_status_to_paid.
" Get output structure of Action
data(lt_sales_order) = value ztdemo_i_salesorder( ).
"Read UI clicked sale order
io_read->retrieve(
exporting
iv_node = is_ctx-node_key " BO Node Name
it_key = it_key " BO Key
importing
et_data = lt_sales_order ). " Data Return Structure
"Assuming single instance for a action
read table lt_sales_order assigning field-symbol(<fs_sales_order>) index 1.
if sy-subrc = 0.
"Set the over all status to Paid ie 'P'
if <fs_sales_order>-lifecyclestatus is initial.
<fs_sales_order>-lifecyclestatus = 'P'.
endif.
endif.
"Now update the BO instance
io_modify->update(
exporting
iv_node = is_ctx-node_key " Node
iv_key = <fs_sales_order>-key " Key
iv_root_key = <fs_sales_order>-root_key " NodeID
is_data = ref #( <fs_sales_order>-node_data ) " Data
it_changed_fields = value #(
( zif_demo_i_salesorder_c=>sc_node_attribute-zdemo_i_salesorder-lifecyclestatus ) )
).
et_data = lt_sales_order.
when others.
"Nothing
endcase.
endmethod.
Okay we are done with all the backend stuff.
Lets display this using as Fiori App using Smart Template.
If all the Web IDE set up explained in Part 1 is fine, we can proceed. Go to Web IDE. Click on File.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
10 | |
10 | |
9 | |
8 | |
7 | |
7 | |
7 | |
7 | |
6 |