ALV with List Box

cjgbl1475176324ALV with List Box 




The post displays alv with SPFLI table and one additional field for list box. So created a structure with include structure ‘SPFLI’ and an extra field as SIGNAL.


Create a program as below code:

DATAlr_grid  TYPE REF TO cl_gui_alv_grid,
              lt_fcat  TYPE lvc_t_fcat,
               lt_spfli TYPE TABLE OF ztest_s_spfli,
               lt_dd    TYPE lvc_t_drop.

&      Module  DISPLAY_ALV  OUTPUT

MODULE display_alv OUTPUT.
  IF lr_grid IS NOT BOUND.

    CREATE OBJECT lr_grid
        i_parent cl_gui_container=>screen0.

        i_structure_name ‘ZTEST_S_SPFLI’
        ct_fieldcat      lt_fcat.

* Enable field for drop down
    LOOP AT lt_fcat ASSIGNING FIELDSYMBOL(<fs_fcat>).
      CASE <fs_fcat>fieldname.
        WHEN ‘SIGNAL’.
          <fs_fcat>edit abap_true.
          <fs_fcat>drdn_hndl ‘1’.
          <fs_fcat>outputlen 8.
        WHEN OTHERS.

* prepare the dropdown table
      <fs_dd>handle ‘1’.
      IF syindex 1.
        <fs_dd>value ‘ ‘.
      ELSEIF  syindex 2.
        <fs_dd>value ‘Green’.
      ELSEIF  syindex 3.
        <fs_dd>value ‘Yellow’.
      ELSEIF  syindex 4.
        <fs_dd>value ‘Red’.
* Set the drop down table
    CALL METHOD lr_grid->set_drop_down_table
        it_drop_down lt_dd.

    CALL METHOD lr_grid->set_table_for_first_display
        it_outtab       lt_spfli
        it_fieldcatalog lt_fcat.

Screen flow logic.


Output: SIGNAL field with list box





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s