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.

1

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.

START-OF-SELECTION.
  CALL SCREEN 0001.
&———————————————————————
&      Module  DISPLAY_ALV  OUTPUT
*&———————————————————————

MODULE display_alv OUTPUT.
  IF lr_grid IS NOT BOUND.

    CREATE OBJECT lr_grid
      EXPORTING
        i_parent cl_gui_container=>screen0.
    SELECT FROM spfli INTO CORRESPONDING FIELDS OF TABLE lt_spfli.

    CALL FUNCTION ‘LVC_FIELDCATALOG_MERGE’
      EXPORTING
        i_structure_name ‘ZTEST_S_SPFLI’
      CHANGING
        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.
      ENDCASE.
    ENDLOOP.

* prepare the dropdown table
    DO TIMES.
      APPEND INITIAL LINE TO lt_dd ASSIGNING FIELDSYMBOL(<fs_dd>).
      <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’.
      ENDIF.
    ENDDO.
* Set the drop down table
    CALL METHOD lr_grid->set_drop_down_table
      EXPORTING
        it_drop_down lt_dd.

    CALL METHOD lr_grid->set_table_for_first_display
      CHANGING
        it_outtab       lt_spfli
        it_fieldcatalog lt_fcat.
  ENDIF.
ENDMODULE.


Screen flow logic.

3.jpg


Output: SIGNAL field with list box

4.jpg

 


 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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