Skip to end of metadata
Go to start of metadata
This wiki will show you :
1. how to navigate from ABAP webdynpro ALV to your own detail page
2. edit your object in detail page
3. navigate from your detail page back to ALV page
Click on one hyperlink ID will lead you to the detail page:
Click on Edit button, the detail page will be toggled to change mode:
You can click save button to persist your change into database table. You can also click "Back" button to go back to the overview page.
Below are the steps how to achieve the above scenario.
1. You can first follow the wiki to embed the ALV component into your own webdynpro component. The host UI component is ZPOST.
2. Create a second ABAP webdynpro component to display the detail page. Since the content of detail page is mapped from the context node defined in ZPOST, so in ZPOSTDETAIL we need to define a component usage pointing to ZPOST, in order to finish the context node mapping.
In the component controller, create a new context node POSTDETAIL. Mark the checkbox "Interface Node", as it will be used as the context node mapping target. Also mark the checkbox "Input Element(Ext.)", which indicates the data of this context node is fed externally.
3. Develop your detail page. The three elements Post ID, Post Content and Post Create On are mapped to the attributes of context node POSTDETAIL. 
A new attribute POST_LOCKED is created, which controls the availability of button Save and Edit, and also the read only property of Post Content.
The enable property of Save button is bound to POST_LOCKED, since it only makes sense to click a save button when an object is locked.
For Edit button, the binding must be done in a inverted way since it only makes sense to switch an object into change mode, if it is not locked yet.
in the implementation of Edit button, call your own lock function module to lock object. Once lock is done successfully, also update the attribute POST_LOCKED. 
   DATA: lv_guid TYPE CRMT_SOC_POST_ATTR-uuid,
         lv_lock_ok TYPE abap_bool.
   DATA(lo_node) = wd_context->get_child_node( 'POSTDETAIL' ).
   lo_node->get_attribute( EXPORTING name = 'UUID' IMPORTING value = lv_guid ).
       iv_guid = lv_guid
       ev_lock_success = lv_lock_ok.
   IF lv_lock_ok = abap_true.
      wd_context->set_attribute( EXPORTING name = 'POST_LOCKED' value = abap_true ).
In Save button implementation, call your save function module. Once saved successfully, release the lock and update the POST_LOCKED attribute. 
METHOD onactionsave .
  DATA(lo_detail) = wd_context->get_child_node( 'POSTDETAIL' ).
  DATA:ls_new_content    TYPE crmt_soc_post_attr,
       lt_changed_fields TYPE crmt_attr_name_tab,
       lv_uuid           TYPE crmt_soc_post_attr-uuid.
  lo_detail->get_attribute( EXPORTING name = 'CONTENT' IMPORTING value = ls_new_content-content ).
  lo_detail->get_attribute( EXPORTING name = 'UUID' IMPORTING value = lv_uuid ).
  APPEND 'CONTENT' TO lt_changed_fields.
      iv_guid      = lv_uuid
      is_attributes = ls_new_content
      it_changed_fields = lt_changed_fields
      OTHERS = 1.
  ASSERT sy-subrc = 0.
      iv_guid = lv_uuid
      OTHERS = 1.
  IF sy-subrc = 0.
          iv_guid   = lv_uuid.
     wd_context->set_attribute( EXPORTING name = 'POST_LOCKED' value = abap_false ).
     DATA: lv_success TYPE string.
     MESSAGE ID 'CRM_GENIL_SOC' TYPE 'I' NUMBER '003' INTO lv_success.
     wd_this->mo_message_manager->report_success( message_text = lv_success ).
4. Now it's time to implement the navigation from ALV table to the detail page in ZPOSTDETAIL.
Since now we should finish the mapping for context node POSTDETAIL in ZPOSTDETAIL which is marked as "Input Element (Ext)" is true, so we need to add a component usage for ZPOSTDETAIL.
Finish the mapping of POSTDETAIL node in component ZPOSTDETAIL.
In interface window of ZPOST, embed the interface window of ZPOSTDETAIL. Create an outbound plug in view of ZPOST, and then create a new navigation link which points to the inbound plug of detail component ZPOSTDETAIL. The window structure and navigation link property could be found below:
Implement the event handler when the hyperlink ID in ALV table is clicked. The event handler could be created by following the wiki
You could refer to code below. The index of selected object in ALV table is available in r_param->index. 
  DATA: ls_current_post TYPE CRMT_SOC_POST_ATTR.
  DATA(lo_result) = wd_context->get_child_node( 'POSTRESULT' ).
  DATA(lo_selected) = lo_result->get_element( EXPORTING index = r_param->index ).
  lo_selected->get_static_attributes( IMPORTING static_attributes = ls_current_post ).
  DATA(lo_detail) = wd_context->get_child_node( 'POSTDETAIL' ).
  lo_detail->bind_structure( ls_current_post ).
  wd_this->fire_to_detail_plg( ).
5. The implementation of Back button in detail component ZPOSTDETAIL has the same logic as the navigation from ALV table TO detail page.
Detail the component usage for ZPOST.
Embed the interface window of ZPOST into window ZPOSTDETAIL, create an outbound plug and a navigation link in latter window.

In Back button implementation, just fire the outbound plug:
  wd_this->fire_to_search_result_plg( ).

  • No labels