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

Re: creation of ALV with dropdown list

$
0
0

Hi Snehal,

 

Try Below code :

 

------------------------------------------------------

*&---------------------------------------------------------------------*

*& Report  ZTEST_ALV_DROP

*&

*&---------------------------------------------------------------------*

*&

*&

*&---------------------------------------------------------------------*

 

REPORT ZPRG_ALV_DROP.

TYPE-POOLS : slis.

 

DATA: g_grid  TYPE REF TO cl_gui_alv_grid,

       g_custom_container TYPE REF TO cl_gui_custom_container,

       gt_fieldcat TYPE lvc_t_fcat,

       gs_layout TYPE lvc_s_layo.

 

DATA: gt_vbak TYPE STANDARD TABLE OF vbak,

       wa_vbak TYPE vbak.

 

START-OF-SELECTION.

 

   CALL SCREEN 9000.

*---------------------------------------------------------------------*

*       MODULE PBO OUTPUT                                             *

*---------------------------------------------------------------------*

MODULE DISPLAY_9000 OUTPUT.

   PERFORM alv_output.

ENDMODULE.                    "pbo OUTPUT

 

*---------------------------------------------------------------------**&---------------------------------------------------------------------*

*&      Form  BUILD_FIELDCAT

*&---------------------------------------------------------------------*

FORM build_fieldcat.

   DATA ls_fcat TYPE lvc_s_fcat.

*Build the field catalogue

   CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

     EXPORTING

       i_structure_name = 'VBAK'

     CHANGING

       ct_fieldcat      = gt_fieldcat.

* To assign dropdown in the fieldcataogue

   LOOP AT gt_fieldcat INTO ls_fcat.

     CASE ls_fcat-fieldname.

       WHEN 'ERNAM'.

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

         ls_fcat-drdn_hndl = '1'.

         ls_fcat-outputlen = 25.

         MODIFY gt_fieldcat FROM ls_fcat.

 

     ENDCASE.

   ENDLOOP.

ENDFORM.                    "build_fieldcat

*&---------------------------------------------------------------------*

*&      Form  ALV_OUTPUT

*&---------------------------------------------------------------------*

FORM alv_output .

*Create object for container

   CREATE OBJECT g_custom_container

          EXPORTING container_name = 'CONTAINER'.

*create object for grid

   CREATE OBJECT g_grid

          EXPORTING i_parent = g_custom_container.

* Build fieldcat and set column

*Assign a handle for the dropdown listbox.

   PERFORM build_fieldcat.

*Build layout

   PERFORM build_layout.

* Define a drop down table.

   PERFORM dropdown_table.

*fetch values from the T517A table

   SELECT * FROM VBAK INTO TABLE gt_vbak.

*Display ALV output

   CALL METHOD g_grid->set_table_for_first_display

     EXPORTING

       is_layout       = gs_layout

     CHANGING

       it_fieldcatalog = gt_fieldcat

       it_outtab       = gt_vbak.

ENDFORM.                               "ALV_OUTPUT

*&---------------------------------------------------------------------*

*&      Form  dropdown_table

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*  -->  p1        text

*  <--  p2        text

*----------------------------------------------------------------------*

FORM dropdown_table.

*Declarations for drop down lists in ALV.

   DATA: lt_dropdown TYPE lvc_t_drop,

         ls_dropdown TYPE lvc_s_drop.

* First SLART listbox (handle '1').

   ls_dropdown-handle = '1'.

   ls_dropdown-value = 'VISHAL'.

   APPEND ls_dropdown TO lt_dropdown.

 

 

   ls_dropdown-handle = '1'.

   ls_dropdown-value = 'JOHN'.

   APPEND ls_dropdown TO lt_dropdown.

   ls_dropdown-handle = '1'.

   ls_dropdown-value = 'Ashish'.

   APPEND ls_dropdown TO lt_dropdown.

*method to display the dropdown in ALV

   CALL METHOD g_grid->set_drop_down_table

     EXPORTING

       it_drop_down = lt_dropdown.

ENDFORM.                               " dropdown_table

*&---------------------------------------------------------------------*

*&      Form  build_layout

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

*layout for ALV output

FORM build_layout .

   gs_layout-cwidth_opt = 'X'.

   gs_layout-grid_title = 'Sales Document'.

   gs_layout-edit = 'X'.

ENDFORM.                    " build_layout



Reagrds,

Vishal


Viewing all articles
Browse latest Browse all 2106

Latest Images

Trending Articles



Latest Images

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