Friday, November 23, 2012

Drop down in Table Web Dynpro




method wddoinit .

  data lo_nd_status_drop type ref to if_wd_context_node.
 data lt_status_drop type wd_this->elements_status_drop.
 data ls_status_drop type wd_this->element_status_drop.

 ls_status_drop-status_value = 'Resubmit All'.
 append ls_status_drop to lt_status_drop.

 ls_status_drop-status_value = 'Reject All'.
 append ls_status_drop to lt_status_drop.

 ls_status_drop-status_value = 'Approve All'.
 append ls_status_drop to lt_status_drop.

 data lo_nd_approval_mng type ref to if_wd_context_node.
 data lo_element type ref to if_wd_context_element.
 data lt_approval_mng type wd_this->elements_approval_mng.
 data ls_approval_mng type wd_this->element_approval_mng.
 data lv_status_value type wd_this->element_status_drop-status_value.
 data lo_el_status_drop type ref to if_wd_context_element.
* navigate from <CONTEXT> to <APPROVAL_MNG> via lead selection
 lo_nd_approval_mng = wd_context->get_child_node( name = wd_this->wdctx_approval_mng ).
* import the details of the table
 lo_nd_approval_mng->get_static_attributes_table( importing table = lt_approval_mng ).
 loop at lt_approval_mng into ls_approval_mng. " binding the drop down
   lo_element = lo_nd_approval_mng->get_element( sy-tabix ).
   lo_nd_status_drop = lo_element->get_child_node( 'STATUS_DROP' ).
   lo_nd_status_drop->bind_table( new_items = lt_status_drop set_initial_elements = abap_true ).
 endloop.

** set your values to the drop down

 data lv_index type sytabix.
 loop at lt_approval_mng into ls_approval_mng where status is not initial.
   lv_index = sy-tabix.
   lo_element = lo_nd_approval_mng->get_element( sy-tabix ).
   lo_nd_status_drop = lo_element->get_child_node( 'STATUS_DROP' ).
   lo_el_status_drop = lo_nd_status_drop->get_element( ).
     case ls_approval_mng-status.
       when 'KEEP'.
         lv_status_value = 'Resubmit All'.
       when 'REJ'.
         lv_status_value = 'Reject All'.
       when 'APPR'.
         lv_status_value = 'Approve All'.
     endcase.
*     * set single attribute
     lo_el_status_drop->set_attribute(
       name =  `STATUS_VALUE`
       value = lv_status_value ).
     modify lt_approval_mng from ls_approval_mng index lv_index
     transporting status.
 endloop.

endmethod.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.