cancel
Showing results for 
Search instead for 
Did you mean: 

Drag and Drop in Web dynpro ALV

Former Member
0 Kudos


I have a requirement in wda where I am supposed to select few records from source table and drop it in target table. The dropped records should be inserted at the right index /destination, dropped at.  I see SAP examples but they are all associated with tables and none of them are ALV grids.

Could anyone of you please share steps or code to achieve drap and drop in SALV_WD_TABLE.

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

Which NW version you are on? Drag and Drop in ALV's is supported from Netweaver 7.02. You can check this help doc for reference: Drag and Drop - Web Dynpro for ABAP - SAP Library

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

I am in 703 so drag and drop should work good .

I am required to drag and drop records from ALV1(bottom) to ALV2(top) (and not table UI). I could create drag source but somehow the whole piece is not working .

Drop target field is dynamic. Wherever the user drops, the data in ALV2 should be inserted/updated exactly at that spot/cell . Here, I am not sure how to fill target row/field details runtime.

Just to simplify, I am doing 1 column move. Hard coded the target field ‘AUFNR3’ but still than My “On drop event” is not triggering. I always see a prohibitory sign when trying to move the ghost image across areas as if the column is not defined as DropTarget.

My code looks something like this:

Drop from AUFNR of ALV2 to AUFNR3 of ALV1 :

In WDDOINIT:*...get alv models
  lr_dd_alv1 ?= wd_this
->r_model_calen.
  lr_dd_alv2 ?= wd_this
->r_model_operlist.

l_tags_alv2 = 'AUFNR'.* create or enable/disable alvs as drag source
 
IF NOT lr_dd_alv2->r_drag_source_info IS BOUND.
    lr_dd_alv2
->create_drag_source_info(
     
EXPORTING
       
data = 'ALV2'
        tags
= l_tags_alv2 "'alv2'
        enabled
= abap_true ).
 
ELSE.
    lr_dd_alv2
->r_drag_source_info->set_enabled( abap_true ).
 
ENDIF.

l_tags_alv1 = 'AUFNR3'.

  lr_dd_alv1
->set_drop_row_name_fieldname( 'AUFNR3' ).
  lr_dd_alv1
->set_drop_row_name( ' ' ).

  lr_dd_alv1
->create_drop_row_target_info(
   
EXPORTING
     
id   = 'ALV1'
      name
= 'alv1'
      tags
= l_tags_alv1
      enabled
= abap_true ).

In drop event: I am trying to fetch the selected row and update the ALV2 accordingly

lr_element = lr_node->get_lead_selection( ).
 
IF lr_element IS BOUND.
    lr_element
->get_attribute(
       
EXPORTING
          name
= 'AUFNR'
       
IMPORTING
         
value = l_value ).
 
ENDIF.

    lo_nd_nd_calendar = wd_context->get_child_node( name = wd_this->wdctx_nd_calendar ).
*
  lo_nd_nd_calendar->bind_table( new_items = lt_nd_calendar set_initial_elements = abap_true ).
ENDMETHOD.

Any help is greatly appreciated..

former_member184578
Active Contributor
0 Kudos

Hi,

Your 'tag' name must be same in both DRAG source and Drop Target.

Regards,

Kiran

Answers (1)

Answers (1)

former_member184578
Active Contributor
0 Kudos

Hi,

As there are no source available, just created a document for the same. You can check this for reference:

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Thank you..

I could fix my logic..But it seems that Drag and Drop within Web Dynpro is designed to work at the row level and not at cell level.

Actually, after I drop the record , I should be able to update my ALV contentsexactly at  that cellular level and not just row.

Probably, I need to use cell action event ..

Please let me know if I can achieve this using just drag and drop functionality .

Thanks

former_member184578
Active Contributor
0 Kudos

Hi,

You can also, just update the single cell. write the below code in ON_DROP event handler:


lr_node_drag    = wd_context->get_child_node( 'ALV1' ).

    lr_element_drag = lr_node_drag->get_lead_selection( ).

    IF lr_element_drag IS BOUND.

      lr_element_drag->get_attribute(

        exporting

          name = 'ATTR_SRC'  " Attribute name of drag source

        importing

          value = lv_value ).

    ENDIF.

 

* Get Index of ALV DROP Target

  lr_node_drop    = wd_context->get_child_node( 'ALV2' ).

  lr_element_drop = lr_node_drop->get_element( index = r_param->row_index ).

  IF lr_element_drop IS BOUND.

*   Set the ALV DROP Target data from ALV DRAG Source

    lr_element_drop->lr_element->set_attribute(

      exporting

        name = 'ATTR_TRGT'   " Attribute name of Cell

        value = lv_value ).

  ENDIF.

hope this helps,

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

The user may drop the record at cell1 or cell2 of a particular row. I need to update the dropped data on to the right cell context.

So, not only I need to know the right record but also the right column dropped at..

Thanks

Geeta

former_member184578
Active Contributor
0 Kudos

Hi,

You can only get the Row on which the cell was dropped. but not the cell index.

The user may drop the record at cell1 or cell2 of a particular row

Let say, ALV1 has cell1 of type numc and cell2 of type char and ALV2 has cell1 of type Numc and cell2 of type char. Now if you drag cell2 of ALV1 and drop on cell1 of ALV2, you want to update the char value of cell2 to Numc value of cell1 in ALV2??

I believe, when you drag from ALV1 to ALV2 and drop on cell2 you want to update cell2 of ALV1 to cell2 of ALV2!!

But, unfortunately its not possible. You can get the Row index on which the cell was dropped, and you have to decide which cell to update by writing the code in ON_DROP event using set_attribute( ) method.

Regards,

Kiran

Former Member
0 Kudos

Yeah, it seems that drag and drop does not determine cell location , just rows..

thanks