Application Development and Automation 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: 
Read only

Drop Down lists in the selection parameters

Former Member
0 Likes
3,533

Hi guru's

Can any one help me in adding drop downlists to selection screen fields.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,976
PROGRAM zcmtest01. 
 TYPE-POOLS: vrm. 
 DATA: name TYPE vrm_id, 
       list TYPE vrm_values, 
       value LIKE LINE OF list. 
 
PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT. 
  name = 'PS_PARM'. 
  value-key = '1'.
  value-text = 'Line 1'.
  APPEND value TO list.
  value-key = '2'. 
  value-text = 'Line 2'.
  APPEND value TO list. 
  CALL FUNCTION 'VRM_SET_VALUES' 
    EXPORTING id     = name 
              values = list. 
              
START-OF-SELECTION. 
  WRITE: / 'Parameter:', ps_parm. 
report z.
type-pools: vrm.
data: it_val type vrm_values,
      w_line like line of it_val.
parameters p_bukrs like t001-bukrs as listbox
           visible length 25 obligatory.
 
initialization.
  select bukrs butxt from t001 into (w_line-key, w_line-text).
    append w_line to it_val.
    check p_bukrs is initial.
    p_bukrs = w_line-key.
  endselect.
 
at selection-screen output.
  call function 'VRM_SET_VALUES'
       exporting
            id     = 'P_BUKRS'
            values = it_val.
 
end-of-selection.
  write: / 'Company Code:', p_bukrs.

Hi guru's

Can any one help me in adding drop downlists to selection screen fields.

7 REPLIES 7
Read only

dani_mn
Active Contributor
0 Likes
1,976
REPORT zwa_test2.

TYPE-POOLS : vrm.
tables: bkpf.

DATA : values TYPE vrm_values.
DATA : wa LIKE LINE OF values.

PARAMETERS : list_box(10) TYPE c AS LISTBOX VISIBLE LENGTH 10.

PARAMETERS: dd type bkpf-BSTAT user-command abc.

select-options: a for bkpf-bukrs MODIF ID buk.

select-options: b for bkpf-belnr MODIF ID SEL.


at selection-screen output.
  If list_box = 2.
    loop at screen.

      if screen-group1 = 'SEL'.
        screen-input = 0.
        modify screen.
      endif.

    endloop.

  endif.


INITIALIZATION.

  wa-key = '1'.
  wa-text = 'Orange'.
  APPEND wa TO values.

  wa-key = '2'.
  wa-text = 'Red'.
  APPEND wa TO values.

  wa-key = '3'.
  wa-text = 'Blue'.
  APPEND wa TO values.

  wa-key = '4'.
  wa-text = 'Gray'.
  APPEND wa TO values.


  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            id              = 'LIST_BOX'
            values          = values
       EXCEPTIONS
            id_illegal_name = 1
            OTHERS          = 2.
Read only

Former Member
0 Likes
1,976

hi

refer to this prog. DEMO_DROPDOWN_LIST_BOX

thx

pavan

Read only

Former Member
0 Likes
1,976

hi,

use the FM VRM_SET_VALUES

check this thread...

https://forums.sdn.sap.com/click.jspa?searchID=1235922&messageID=2951115

do reward if it helps,

priya.

Read only

Former Member
0 Likes
1,976

Hello,

Demo program:<b>RSDEMO_DROPDOWN_LISTBOX</b>

Regards,

Beejal

**reward if this helps

Read only

Former Member
0 Likes
1,977
PROGRAM zcmtest01. 
 TYPE-POOLS: vrm. 
 DATA: name TYPE vrm_id, 
       list TYPE vrm_values, 
       value LIKE LINE OF list. 
 
PARAMETERS: ps_parm(10) AS LISTBOX VISIBLE LENGTH 10.
AT SELECTION-SCREEN OUTPUT. 
  name = 'PS_PARM'. 
  value-key = '1'.
  value-text = 'Line 1'.
  APPEND value TO list.
  value-key = '2'. 
  value-text = 'Line 2'.
  APPEND value TO list. 
  CALL FUNCTION 'VRM_SET_VALUES' 
    EXPORTING id     = name 
              values = list. 
              
START-OF-SELECTION. 
  WRITE: / 'Parameter:', ps_parm. 
report z.
type-pools: vrm.
data: it_val type vrm_values,
      w_line like line of it_val.
parameters p_bukrs like t001-bukrs as listbox
           visible length 25 obligatory.
 
initialization.
  select bukrs butxt from t001 into (w_line-key, w_line-text).
    append w_line to it_val.
    check p_bukrs is initial.
    p_bukrs = w_line-key.
  endselect.
 
at selection-screen output.
  call function 'VRM_SET_VALUES'
       exporting
            id     = 'P_BUKRS'
            values = it_val.
 
end-of-selection.
  write: / 'Company Code:', p_bukrs.
Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
1,976

Hi

VRM is a Type-pool like SLIS type-pool.

Through VRM type-group, we can achieve the Drop-down list boxes in the selection-screen.

Check for VRM type-group you can know that.

Regards,

kumar

Read only

Former Member
0 Likes
1,976

Hi,

Check this link to populate the listbox.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a07a330f-126c-2910-c684-d2a45f0f...

report tabbed_sel_screen.

*-- Definitions to hold user command for subscreens

data:

ucomm1 like sy-ucomm,

ucomm2 like sy-ucomm,

ucomm3 like sy-ucomm.

*-- Macro to put checkbox on selection screen

*-- &1 - checbox parameter name

*-- &2 - text element (description)

*-- &3 - default value for checkbox

define make_checkbox.

selection-screen begin of line.

parameters: &1 as checkbox default &3.

selection-screen comment 3(60) &2.

selection-screen end of line.

end-of-definition.

*-- Macro to put radiobutton on selection screen

*-- &1 - radiobutton parameter name

*-- &2 - text element (description)

*-- &3 - radiobutton group

define make_radiobutton.

selection-screen begin of line.

parameters: &1 radiobutton group &3.

selection-screen comment 3(60) &2.

selection-screen end of line.

end-of-definition.

*-- Macro to put a parameter on selection screen

*-- &1 - parameter name

*-- &2 - text element (description)

*-- &3 - like data element

*-- &4 - default value

define make_parameter.

selection-screen begin of line.

selection-screen comment 1(30) &2.

selection-screen position pos_low.

parameters: &1 like &3 default &4.

selection-screen end of line.

end-of-definition.

*-- Macro to put a dropdown listbox on selection screen

*-- &1 - parameter name

*-- &2 - length of listbox

*-- &3 - default value

*-- &4 - text element (description)

define make_dropdown.

selection-screen begin of line.

selection-screen comment 1(30) &4.

selection-screen position pos_low.

parameters: &1 as listbox visible length &2 default &3 obligatory.

selection-screen end of line.

end-of-definition.

*-- Define subscreen for upload options

selection-screen begin of screen 1100 as subscreen.

selection-screen begin of block file_options with frame.

make_parameter p_filein fil_desc rlgrap-filename '/filename.txt'.

make_radiobutton rb_unix unx_desc src.

make_radiobutton rb_local dos_desc src.

make_parameter p_filety typ_desc rlgrap-filetype 'DAT'.

selection-screen end of block file_options.

selection-screen end of screen 1100.

*-- Define subscreen for BDC/CT Processing Options

selection-screen begin of screen 1200 as subscreen.

selection-screen begin of block bdc_options with frame.

make_radiobutton rb_callt ctr_desc typ.

make_radiobutton rb_bdc bdc_desc typ.

make_dropdown p_mode(1) 30 'N' mod_desc.

make_dropdown p_uptyp(1) 30 'S' upd_desc.

selection-screen end of block bdc_options.

selection-screen end of screen 1200.

*-- Define subscreen for Output Options

selection-screen begin of screen 1300 as subscreen.

selection-screen begin of block output_opts with frame.

make_checkbox c_detail det_desc ' '.

make_checkbox c_error err_desc 'X'.

make_checkbox c_stats sta_desc 'X'.

selection-screen end of block output_opts.

selection-screen end of screen 1300.

*-- Define Main Selection screen that will incorporate the subscreens

selection-screen begin of tabbed block tabs for 10 lines.

selection-screen tab (15) tabs1 user-command ucomm1

default screen 1100.

selection-screen tab (30) tabs2 user-command ucomm2

default screen 1200.

selection-screen tab (15) tabs3 user-command ucomm3

default screen 1300.

selection-screen end of block tabs.

*-- Fill the dropdown list boxes before displaying them

at selection-screen output.

perform fill_dropdown_list using 'P_MODE'.

perform fill_dropdown_list using 'P_UPTYP'.

at selection-screen on value-request for p_filein.

perform choose_filename using p_filein

changing p_filein.

initialization.

tabs1 = 'Upload Options'.

tabs2 = 'BDC/Call Transaction Options'.

tabs3 = 'Output Options'.

*-- Setup descriptions for Selection Screen items

err_desc = 'Show Errors (Call Transaction Only)'.

det_desc = 'Show details on records being processed'.

sta_desc = 'Show statistics on what has been processed'.

unx_desc = 'File is on App Server (unix)'.

dos_desc = 'File is on Presentation Server (pc)'.

typ_desc = 'File Type'..

fil_desc = 'Name of File'.

ctr_desc = 'Process in Call Transaction Mode'.

bdc_desc = 'Process in BDC Mode'.

mod_desc = 'Transaction Processing Mode'.

upd_desc = 'Update Type'.

start-of-selection.

*-- Open input file or Read data from database tables

end-of-selection.

*-- Loop at data, and create BDC/Call Transactions

----


  • FORM fill_dropdown_list *

----


  • Populate the dropdown list for the parameter provided *

----


  • --> VALUE(F_PARAMETER) *

----


form fill_dropdown_list using value(f_parameter).

type-pools: vrm. " For parameter drop down lists

*-- Definitions for parameter drop down lists

data:

name type vrm_id,

list type vrm_values,

value like line of list.

name = f_parameter.

case f_parameter.

when 'P_MODE'.

value-key = 'N'. value-text = 'Do not display any screens'.

append value to list.

value-key = 'A'. value-text = 'Display ALL screens'.

append value to list.

value-key = 'E'. value-text = 'Only display screens in error'.

append value to list.

when 'P_UPTYP'.

value-key = 'S'. value-text = 'Update in Synchronous Mode'.

append value to list.

value-key = 'A'. value-text = 'Update in Asynchronous Mode'.

append value to list.

when others.

endcase.

call function 'VRM_SET_VALUES'

exporting

id = name

values = list.

endform." fill_dropdown_list

----


  • FORM choose_filename *

----


  • Select a filename. Only provied if a local file is selected *

  • as the source of the input file. A *

  • custom function or routine could be *

  • written to provide the same functionality *

  • for unix. *

----


  • --> F_FILENAME_IN *

  • <-- F_FILENAME_OUT *

----


form choose_filename using f_filename_in

changing f_filename_out.

data:

lc_fieldname like dynpread-fieldname,

lc_fieldvalue like dynpread-fieldvalue.

*-- Get the value of p_local

perform read_value_from_screen using sy-repid

sy-dynnr

'RB_LOCAL'

changing lc_fieldname

lc_fieldvalue.

if lc_fieldvalue = 'X'. " User chose a local file

perform query_local_filename changing f_filename_out.

endif.

endform." get_filename

----


  • FORM READ_VALUE_FROM_SCREEN *

----


  • ........ *

----


  • --> F_REPID *

  • --> F_DYNNR *

  • --> VALUE(F_FIELDNAME_IN) *

  • <-- F_FIELDNAME_OUT *

  • <-- F_FIELDVALUE *

----


form read_value_from_screen using f_repid

f_dynnr

value(f_fieldname_in)

changing f_fieldname_out

f_fieldvalue.

data: ltab_fields like dynpread occurs 0 with header line.

data: lc_dyname like sy-repid.

data: lc_dynumb like sy-dynnr.

data: lc_dummy(1) type c.

*-- Read the screen to see if the user has entered a value for WERKS

ltab_fields-fieldname = f_fieldname_in.

append ltab_fields.

lc_dyname = f_repid.

lc_dynumb = f_dynnr.

call function 'DYNP_VALUES_READ'

exporting

dyname = lc_dyname

dynumb = lc_dynumb

tables

dynpfields = ltab_fields

exceptions

others = 01.

read table ltab_fields index 1.

*-- Return the value from the screen

if sy-subrc eq 0.

split ltab_fields-fieldname at '-'

into lc_dummy

f_fieldname_out.

f_fieldvalue = ltab_fields-fieldvalue.

endif.

endform.

----


  • FORM query_filename *

----


  • ........ *

----


  • --> F_FILENAME_OUT *

  • --> DATA *

  • --> : *

  • --> L_FILENAME *

----


form query_local_filename changing f_filename_out like rlgrap-filename.

data: l_filename like rlgrap-filename.

data: l_mask(80) type c.

  • Build Filter

l_mask =

',All Files (.),..'.

call function 'WS_FILENAME_GET'

exporting

def_filename = f_filename_out

def_path = 'c:\'

mask = l_mask

  • mode = O or S

title = 'Choose input file'

importing

filename = l_filename

exceptions

inv_winsys = 01

no_batch = 02

selection_cancel = 03

selection_error = 04.

if sy-subrc = 0.

f_filename_out = l_filename.

endif.

endform.

Hope this helps.

Regards,

Sruthi