Skip to end of metadata
Go to start of metadata

Author: Azaz Ali Shaik
Submitted: November 23, 2006

This code sample gives the idea about providing drop down list box in the Selection Screen. The code has been tested under SAP R/3 Enterprise Release 4.70, mySAP Technology Components Release 6.20. It may also work under earlier versions with minor modifications

Error rendering macro 'code': Invalid value specified for parameter 'com.atlassian.confluence.ext.code.render.InvalidValueException'
REPORT z_ddlb.

DEFINE lb_macro_koart.

  selection-screen begin of line.
  selection-screen comment 1(31) &3.
  parameters: &1 as listbox visible length &2 obligatory.
  selection-screen end of line.

END-OF-DEFINITION.


************************************************************************
* SELECTION-SCREEN *
************************************************************************
SELECTION-SCREEN BEGIN OF BLOCK s1 WITH FRAME TITLE text-001.
lb_macro_koart mylist(1) 5 comment.
SELECTION-SCREEN END OF BLOCK s1.


************************************************************************
* AT SELECTION - SCREEN
************************************************************************
AT SELECTION-SCREEN OUTPUT.

  PERFORM add_values_to_koart.
  comment = 'Account type'.



*&---------------------------------------------------------------------*
*& Form ADD_VALUES_TO_KOART
*&---------------------------------------------------------------------*
* Fill the values in dropdownlistbox
*----------------------------------------------------------------------*
FORM add_values_to_koart .

  TYPE-POOLS: vrm.

  DATA: my_list TYPE vrm_values,
  value LIKE LINE OF my_list.

  DATA : BEGIN OF i_tab OCCURS 0,
  koart TYPE c,
  END OF i_tab.

  CLEAR i_tab.
  i_tab-koart = 'A'.
  APPEND i_tab.
  CLEAR i_tab.

  i_tab-koart = 'D'.
  APPEND i_tab.
  CLEAR i_tab.

  i_tab-koart = 'K'.
  APPEND i_tab.
  CLEAR i_tab.

  i_tab-koart = 'M'.
  APPEND i_tab.
  CLEAR i_tab.

  i_tab-koart = 'S'.
  APPEND i_tab.
  CLEAR i_tab.


*&---------------------------------------------------------------------*
*& Filling the list structure with values from MARA table
*&---------------------------------------------------------------------*

  LOOP AT i_tab.
    value-key = sy-tabix.
    value-text = i_tab-koart.
    APPEND value TO my_list.
  ENDLOOP.

*&---------------------------------------------------------------------*
*& Finally calling the function module to create the list box.
*&---------------------------------------------------------------------*

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = 'MYLIST'
      values = my_list.


ENDFORM. " ADD_VALUES_TO_KOART