Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 9239

Re: ALV help:Dropdown using REUSE_ALV_GRID_DISPLAY.

$
0
0

Hi Abhishek,

 

Changing data in ALV and saving to database table can be easily achieved with classic ALV (Reuse_ALV_grid_display)

 

But the drop down feature of column is better implemented using OOPS ALV. With classic ALV it is possible though, to provide an F4 help which will also serve the purpose.

 

With oops ALV,

 

Drop down

 

CREATE OBJECT g_custom_container
          EXPORTING container_name = 'CCONT'.

*create object for grid
   CREATE OBJECT g_grid
          EXPORTING i_parent = g_custom_container.

 

perform field_catolog.  " Create field catalog for 42 fields.

* For all the fields set the edit attribute to 'X'. For drop down fields, F1, F2, F3, F4, set the drop down attribute too.

 

perform drop_table.  " Populate all the list boxes.

 

CALL METHOD g_grid->set_table_for_first_display
     EXPORTING
       is_layout       = gs_layout
     CHANGING
       it_fieldcatalog = gt_fieldcat
       it_outtab       = it_out.

 

 

 

 

form field_catalog.

....

        ls_fcat-fieldname = 'F1'.

        ls_fcat-tabname   = 'IT_OUT'.
       ls_fcat-seltext_l = text-h15.

       ls_fcat-col_pos   = lv_pos.

         ls_fcat-edit = 'X'.
         ls_fcat-drdn_hndl = '1'.

* drdn-hndl = '1' is the first list box

         ls_fcat-outputlen = 15.


APPEND ls_fieldcat TO gt_fieldcat.

 

Similarly for fields F2, F3, F4


  ls_fcat-drdn_hndl = '2'.


  ls_fcat-drdn_hndl = '3'.

 

  ls_fcat-drdn_hndl = '4'.   respectively.

 

... ...

 

endform

 

 

form drop_table.

 

DATA: lt_dropdown TYPE lvc_t_drop,
         ls_dropdown TYPE lvc_s_drop.

* First F1 listbox (handle '1').
   ls_dropdown-handle = '1'.
   ls_dropdown-value = 'Value 1'.
   APPEND ls_dropdown TO lt_dropdown.

   ls_dropdown-handle = '1'.
   ls_dropdown-value = 'Value 2'.
   APPEND ls_dropdown TO lt_dropdown.

 

Similarly for other drop down fields.

* For F2,

   ls_dropdown-handle = '2'.
   ls_dropdown-value = 'Value A'.
   APPEND ls_dropdown TO lt_dropdown.

   ls_dropdown-handle = '2'.
   ls_dropdown-value = 'Value B'.
   APPEND ls_dropdown TO lt_dropdown.

 

CALL METHOD g_grid->set_drop_down_table
     EXPORTING
       it_drop_down = lt_dropdown.

 

endform.

 

Save Data

 

Now to save data, code the following in the PAI of the ALV screen.

case ok_code.

 

when 'SAVE'.

    CALLMETHOD g_grid->check_changed_data.

     loopat it_out into wa_out.
                  modify ztable from wa_out.
     ENDLOOP.

 

 


 



Viewing all articles
Browse latest Browse all 9239

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>