Abapinho

Manually populate a LISTBOX

In 2012 I wondered why LISTBOX is so rarely used. I taught how to use it with standard data elements, which automatically populate it. Today I’ll teach you how you can populate it yourself.

It’s easy. But not obvious at all. You need to use a standard FM which populates it from an internal table:


PARAMETERS: p_virus TYPE C AS LISTBOX VISIBLE LENGTH 25.

INITIALIZATION.
  DATA(values) =
    VALUE vrm_values(
      ( key = '1' text = 'COVID-19' )
      ( key = '2' text = 'Bird flu' )
      ( key = '3' text = 'Spanish flu' )
    ).

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'P_VIRUS'
      values          = values
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.

Done.

Photo credit: MarianaLeme.

Greetings from Abapinho.

Exit mobile version