cancel
Showing results for 
Search instead for 
Did you mean: 

Add and Add All button functionalities

Former Member
0 Kudos

Dear Experts,
Can anyone help me how to achieve ADD and ADD ALL functionality in webdynpro?

The scenario is:

I have two tables(Source table and target table) and in my source table,i have100 entries,When user selects any of his desired entries in source table and click on ADD button, the entries from source table will be added in target table.

And when the user do filteration on source table( for suppose, after filteration,the entries in source table are 3). Now without selecting those three values, he clicks on ADD ALL button.Now instead of adding 3 entries in target table,it is adding 100 values which are initially present in source table.

Pls let me know how to achieve this functionality.

Thanks
Santhosh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Santhosh,

Try this.

   TRY.
      lr_interfacecontroller =   wd_this->wd_cpifc_used_component( ).
    CATCH cx_wdr_rt_exception.
  ENDTRY.

   IF NOT lr_interfacecontroller IS INITIAL.
     l_value = lr_interfacecontroller->get_ui_info( ).

"Check if filter is applied.
    IF  l_value-s_service_info-is_filtered = abap_true.

  lt_salv_bs_t_int = l_value-t_displayed_elements.
      CLEAR lt_visible_indices[].


      LOOP AT   l_value-t_displayed_elements  INTO l_displayed_element.
        l_index-index = l_displayed_element.
        APPEND l_index TO lt_visible_indices.
      ENDLOOP.
      SORT lt_visible_indices BY index.

   LOOP AT lt_visible_indices INTO lw_visible_indices.


        READ TABLE <original table>INTO workarea INDEX lw_visible_indices-index.


        IF sy-subrc IS  INITIAL.
          rw_roles-sign    = 'I'.
          rw_roles-option  = 'EQ'.
          rw_roles-low     = workarea-requiredfield.
          APPEND rw_roles TO rt_roles.
          CLEAR rw_roles.

        ENDIF.

      ENDLOOP.
      DELETE <original_table> WHERE field NOT IN rt_roles. (RT_ROLES =  RANGE TABLE).


    ENDIF.

ENDIF.

This will resolve your issue.

Thanks

KH

Former Member
0 Kudos

Thanks Katrice.

My issue resolved my following your sample code.

Thanks

Santhosh

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello Santhosh,

1. On action of Add button..

" Read all selected Row ...

DATA lt_element_set  TYPE wdr_context_element_set.

DATA ls_element_set  TYPE REF TO if_wd_context_element.


<lo_nd_node>->get_selected_elements( RECEIVING set = lt_element_set ).

LOOP AT lt_element_set INTO ls_element_set.
           CALL METHOD ls_element_set->get_static_attributes
             IMPORTING
               static_attributes = <ls_WA>.

" Here WA will have 1st selected value, so add all value''.

endloop.



2. On add all button, read the node(filter node) which is used in binding with filter in table, that node will have the parameter entered by user while filtering, and based on those value filter your table and add the data.



0 Kudos

Santhosh,

For add , you can achieve by getting index of the selected elements.

For add all, you can achieve with help of below code snippets,

To get the Filtered values:

DATA: lr_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE,

        l_VALUE type If_Salv_Wd_Table=>S_Type_Param_Get_Ui_Info.

try.

      lr_INTERFACECONTROLLER =   wd_This->wd_CpIfc_<b>component usage</b>( ).

    catch CX_WDR_RT_EXCEPTION.

  endtry.

if not lr_INTERFACECONTROLLER is initial.

    l_VALUE = lr_INTERFACECONTROLLER->Get_Ui_Info(

    ).

  endif.

<b>component usage</b> above must be replaced by the name of your usage component.

L_VALUE-T_DISPLAYED_ELEMENTS contains the index's of all the resultant data of the filter.



                                                                                     OR


You can achieve also,By using the class CL_SALV_BS_RESULT_DATA_TABLE which contains the results of the filter in T_RESULT_DATA.


Do reward if its helpful.


Regards

Saravanan



ramakrishnappa
Active Contributor
0 Kudos

Hi Santhosh,

You can achieve your requirement as below


For Add: ( only selected records )

  • On Add action, get the selected elements of SOURCE context node by using method GET_SELECTED_ELEMENTS of interface IF_WD_CONTEXT_NODE
  • Bind the elements to TARGET context node

For Add All

You need to read the filter values and delete the entries which are not needed.

  • On add all action, we need to check if any filter set. let us say node FILTER having column name "Department" and its value set as "Administration"
  • Read the filter values from the context node FILTER into ls_filter.
  • Get the context data of SOURCE node into internal table lt_source_data
  • Delete the records from source internal table which are not matching filter value i.e.

          delete lt_source_data where department np ls_filter-department

  • Now we are left with the records which are filtered out in the source table and bind the data to target node

Check this link for concept : filtering in WD table ui element

Hope this helps you.

Regards,

Rama