Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

trying to create a selection screen dynamically

Former Member
0 Kudos

Hi All,

My requirement is to fetch values from database table.A particular field in the table

has certain values,which i am supposed to create as radiobuttons.i.e

i need to pick the values and create a dynamic selection screen.

Can any one help me in this.

Thanks in Advance!!

5 REPLIES 5

tarangini_katta
Active Contributor
0 Kudos

Hi Phani,

Can you please leaborate ur question.

Thanks

Former Member
0 Kudos

Hi,

Create the Dfferent Blocks on the selection screen....depending on the radio button display the corresponing block. For this use Loop at Screen....Endloop in the At Selection-screen Event.

tarangini_katta
Active Contributor
0 Kudos

Former Member
0 Kudos

Hi MVPhani,

If u wish to create radio-buttons ( or check-boxes only ) dynamically, then u can achieve the same functionality using the below simpler alternative...

Put a button and while clicking it show the list of possible values ( taken from ur DB table ).. based on the selection display ur report... something like F4 help...

Check the below example..

TYPE-POOLS : slis.

TYPES : BEGIN OF ty_radiobuttons,
        matnr  TYPE matnr,
        maktx  TYPE maktx,
        END  OF ty_radiobuttons.

DATA : lt_radiobuttons TYPE STANDARD TABLE OF ty_radiobuttons,
       ls_radiobutton  TYPE ty_radiobuttons,
       lt_fcat         TYPE slis_t_fieldcat_alv,
       ls_fcat         TYPE LINE OF slis_t_fieldcat_alv.

PARAMETER selvalue TYPE matnr.
SELECTION-SCREEN PUSHBUTTON 60(20) text USER-COMMAND push.

INITIALIZATION.
  MOVE 'Dynamic selection' TO text.

  SELECT matnr
         maktx
    FROM makt UP TO 10 ROWS
    INTO CORRESPONDING FIELDS OF TABLE lt_radiobuttons
   WHERE spras EQ sy-langu.

AT SELECTION-SCREEN .

  CASE sy-ucomm.
    WHEN 'PUSH'.
      PERFORM popup.
    WHEN OTHERS.
  ENDCASE.

START-OF-SELECTION.

END-OF-SELECTION.


*&---------------------------------------------------------------------*
FORM popup.

  DATA : selected_row TYPE slis_selfield,
         action.

  PERFORM build_fcat.

  CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
    EXPORTING
      i_selection   = 'X'
      i_zebra       = 'X'
      i_tabname     = 'LT_RADIOBUTTONS'
      it_fieldcat   = lt_fcat
    IMPORTING
      es_selfield   = selected_row
      e_exit        = action
    TABLES
      t_outtab      = lt_radiobuttons
    EXCEPTIONS
      program_error = 1
      OTHERS        = 2.

  CHECK sy-subrc EQ 0.
  CHECK action   NE 'X'.
  READ TABLE lt_radiobuttons INTO ls_radiobutton INDEX selected_row-tabindex.
  MOVE ls_radiobutton-matnr TO selvalue.
ENDFORM.                    "popup

*&---------------------------------------------------------------------*
FORM build_fcat.

  FREE lt_fcat.
  ls_fcat-fieldname = 'MATNR'.
  ls_fcat-seltext_l = 'Material'.
  ls_fcat-outputlen = '10'.
  APPEND ls_fcat TO lt_fcat. CLEAR ls_fcat.

  ls_fcat-fieldname = 'MAKTX'.
  ls_fcat-seltext_l = 'Description'.
  ls_fcat-outputlen = '20'.
  APPEND ls_fcat TO lt_fcat.
  CLEAR ls_fcat.
ENDFORM.                    "build_fcat

Cheers,

Jose.

Former Member
0 Kudos

Phani,

check this link http://saptechnical.com/Tutorials/ABAP/ABAPMainPage.htm and you will find many examples on creating selection screen

Thanks

Bala Duvvuri