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: 

Create dropdown in selection screen

Former Member
0 Kudos
36,140

Hi all,

I need to create the dropdown for a field in my selection screen. Please advice me how can i do that.

Rgds

Preeti

1 ACCEPTED SOLUTION

Former Member
14,986

Hi,

<b>List Box in ABAP Report</b>

*

REPORT ZLIST.

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.

Regards

Sudheer

9 REPLIES 9

Former Member
0 Kudos
14,986

Hi,

Check this sample code


Ex..


TYPE-POOLS: vrm.
 
 
DATA: ivrm_values TYPE vrm_values.
DATA: xvrm_values LIKE LINE OF ivrm_values.
DATA: name TYPE vrm_id.
 
PARAMETERS: p_INT AS LISTBOX VISIBLE LENGTH 10.
 
INITIALIZATION.
 
  name = 'P_INT'.
 
  xvrm_values-key = '1'.
  xvrm_values-text  =  'First value'.
  APPEND xvrm_values TO ivrm_values.
 
  xvrm_values-key = '2'.
  xvrm_values-text  =  'Second value'.
  APPEND xvrm_values TO ivrm_values. 
 
 
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id     = name
      values = ivrm_values.


Thanks,

Naren

Former Member
14,987

Hi,

<b>List Box in ABAP Report</b>

*

REPORT ZLIST.

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.

Regards

Sudheer

gopi_narendra
Active Contributor
0 Kudos
14,986
PARAMETER : p_int AS LISTBOX VISIBLE LENGTH 10.

DATA : name  TYPE vrm_id,
       list  TYPE vrm_values,
       value LIKE LINE OF list.


AT SELECTION-SCREEN OUTPUT.
  name = 'P_INT'.

  value-key = '1'.
  value-text = 'One'.
  APPEND value TO list.
  value-key = '2'.
  value-text = 'Two'.
  APPEND value TO list.

  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            id     = name
            values = list.
  CLEAR list.

Regards

Gopi

kiran_k8
Active Contributor
0 Kudos
14,986

Preeti,

Use funtion module vrm_get_values.

K.Kiran.

Former Member
0 Kudos
14,986

Hi

see the sample code

See the following ex:

TYPES: BEGIN OF TY_MBLNR,

MBLNR LIKE MKPF-MBLNR,

END OF TY_MBLNR.

DATA: IT_MBLNR TYPE STANDARD TABLE OF TY_MBLNR WITH HEADER LINE.

data: it_ret like ddshretval occurs 0 with header line.

At selection-screen on value-request for s_mat-low.

Select MBLNR from mkpf into table it_mblnr.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

  • DDIC_STRUCTURE = ' '

RETFIELD = 'MBLNR'

  • PVALKEY = ' '

  • DYNPPROG = ' '

  • DYNPNR = ' '

  • DYNPROFIELD = ' '

  • STEPL = 0

  • WINDOW_TITLE =

  • VALUE = ' '

VALUE_ORG = 'S'

  • MULTIPLE_CHOICE = ' '

  • DISPLAY = ' '

  • CALLBACK_PROGRAM = ' '

  • CALLBACK_FORM = ' '

  • MARK_TAB =

  • IMPORTING

  • USER_RESET =

TABLES

VALUE_TAB = IT_MBLNR

  • FIELD_TAB =

RETURN_TAB = IT_RET

  • DYNPFLD_MAPPING =

  • EXCEPTIONS

  • PARAMETER_ERROR = 1

  • NO_VALUES_FOUND = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

IF SY-SUBRC = 0.

read table it_ret index 1.

move it_ret-fieldval to S_mat-low.

ENDIF.

Go through the test program.

REPORT Ztest_HELP .

TABLES : MARA.

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS : P_MATNR(10) TYPE C.

SELECTION-SCREEN END OF BLOCK B1.

DATA : BEGIN OF ITAB OCCURS 0,

MATNR TYPE MATNR,

END OF ITAB.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MATNR.

SELECT MATNR

FROM MARA

INTO TABLE ITAB

UP TO 10 ROWS.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = 'MATERIAL NUMBER'

DYNPPROG = SY-REPID

DYNPNR = SY-DYNNR

DYNPROFIELD = 'P_MATNR'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = ITAB

EXCEPTIONS

PARAMETER_ERROR = 1

NO_VALUES_FOUND = 2

OTHERS = 3.

For F4 Values on Screen:

PROCESS ON VALUE_REQUEST

using module call starting with FIELD i.e FIELD field MODULE module

There are number of function modules that can be used for the purpose, but these

can fullfill the task easily or combination of them.

DYNP_VALUE_READ

F4IF_FIELD_VALUE_REQUEST

F4IF_INT_TABLE_VALUE_REQUEST

POPUP_WITH_TABLE_DISPLAY

DYNP_VALUE_READ

This function module is used to read values in the screen fields. Use of this

FM causes forced transfer of data from screen fields to ABAP fields.

There are 3 exporting parameters

DYNAME = program name = SY-CPROG

DYNUMB = Screen number = SY-DYNNR

TRANSLATE_TO_UPPER = 'X'

and one importing TABLE parameter

DYNPFIELDS = Table of TYPE DYNPREAD

The DYNPFIELDS parameter is used to pass internal table of type DYNPREAD

to this FM and the values read from the screen will be stored in this table.This

table consists of two fields:

FIELDNAME : Used to pass the name of screen field for which the value is to

be read.

FIELDVALUE : Used to read the value of the field in the screen.

e.g.

DATA: SCREEN_VALUES TYPE TABLE OF DYNPREAD ,

SCREEN_VALUE LIKE LINE OF SCREEN_VALUES.

SCREEN_VALUE-FIELDNAME = 'KUNNR' . * Field to be read

APPEND SCREEN_VALUE TO SCREEN_VALUES. * Fill the table

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

DYNAME = SY-CPROG

DYNUMB = SY-DYNNR

TRANSLATE_TO_UPPER = 'X'

TABLES

DYNPFIELDS = SCREEN_VALUES.

READ TABLE SCREEN_VALUES INDEX 1 INTO SCREEN_VALUE.Now the screen value for field KUNNR is in the SCREEN_VALUE-FIELDVALUE and can be used for further processing like using it to fill the internal table to be used as parameter in F4IF_INT_TABLE_VALUE_REQUEST ETC.

F4IF_FIELD_VALUE_REQUEST

This FM is used to display value help or input from ABAP dictionary.We have to pass the name of the structure or table(TABNAME) along with the field name(FIELDNAME) . The selection can be returned to the specified screen field if three

parameters DYNPNR,DYNPPROG,DYNPROFIELD are also specified or to a table if RETRN_TAB is specified.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

TABNAME = table/structure

FIELDNAME = 'field name'

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNR

DYNPROFIELD = 'screen field'

IMPORTING

RETURN_TAB = table of type DYNPREAD

.

F4IF_INT_TABLE_VALUE_REQUEST

This FM is used to dsiplay values stored in an internal table as input

help.This FM is used to program our own custom help if no such input help

exists in ABAP dictionary for a particular field. The parameter VALUE_TAB is used to pass the internal table containing input values.The parameter RETFIELD

is used to specify the internal table field whose value will be returned to the screen field or RETURN_TAB.

If DYNPNR,DYNPPROG and DYNPROFIELD are specified than the user selection is passed to the screen field specified in the DYNPROFIELD. If RETURN_TAB is specified the selectionis returned in a table.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

RETFIELD = field from int table whose value will be returned

DYNPPROG = SY-CPROG

DYNPNR = SY-DYNNR

DYNPROFIELD = 'screen field'

VALUE_ORG = 'S'

TABLES

VALUE_TAB = internal table whose values will be shown.

RETURN_TAB = internal table of type DDSHRETVAL

EXCEPTIONS

parameter_error = 1

no_values_found = 2

others = 3.

POPUP_WITH_TABLE_DISPLAY

This FM is used to display the contents of an internal table in a popup window.The user can select a row and the index of that is returned in the CHOISE

parameter.The VALUETAB is used to pass the internal table.

A suitable title can be set using TITLETEXT parameter. The starting and end position of the popup can be specified by the parameters STARTPOS_COL / ROW and ENDPOS_ROW / COL .

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'

EXPORTING

ENDPOS_COL =

ENDPOS_ROW =

STARTPOS_COL =

STARTPOS_ROW =

TITLETEXT = 'title text'

IMPORTING

CHOISE =

TABLES

VALUETAB =

EXCEPTIONS

BREAK_OFF = 1

OTHERS = 2.

e.g.

DATA: w_choice TYPE SY-TABIX.

DATA: BEGIN OF i_values OCCURS 0 WITH HEADER LINE,

values TYPE I,

END OF i_values.

PARAMETRS : id TYPE I.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR id

i_values-values = '0001'.

APPEND i_values.

i_values-values = '0002'.

APPEND i_values.

i_values-values = '0003'.

APPEND i_values.

i_values-values = '0004'.

APPEND i_values.

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'

EXPORTING

ENDPOS_COL = 40

ENDPOS_ROW = 12

STARTPOS_COL = 20

STARTPOS_ROW = 5

TITLETEXT = 'Select an ID'

IMPORTING

CHOISE = w_choice

TABLES

VALUETAB = i_values

EXCEPTIONS

BREAK_OFF = 1

OTHERS = 2.

CHECK w_choice > 0.

READ TABLE i_values INDEX w_choice....now we can process the selection as it is contained

...in the structure i_values.

Other FM that may be used to provide input help is HELP_START .

Reward points for useful Answers

Regards

Anji

Former Member
0 Kudos
14,986

U can do it so using

VRM_VALUE from Type Pool VRM

Former Member
0 Kudos
14,986

Hi,

copy paste this statement in your report.

parameters: p_mat type matnr AS LISTBOX VISIBLE LENGTH 6.

Reward with points if helpful.

Regards,

Naveen

roton_hossain
Explorer
0 Kudos
14,986

types: begin of t_ekko,

   ebeln type ekko-ebeln,

   end of t_ekko.

data: it_ekko TYPE STANDARD TABLE OF t_ekko,

       wa_ekko like line of it_ekko.

TYPE-POOLS: VRM.

DATA: NAME  TYPE VRM_ID,

       LIST  TYPE VRM_VALUES,

       VALUE LIKE LINE OF LIST.

PARAMETERS: P_PARM(20) AS LISTBOX VISIBLE LENGTH 20.

*********************************************************

*AT SELECTION-SCREEN OUTPUT.

AT SELECTION-SCREEN OUTPUT.

   SELECT ebeln

    up to 10 rows

     from ekko

     into table it_ekko.

   loop at it_ekko into wa_ekko.

     VALUE-KEY wa_ekko-ebeln.

     VALUE-TEXT = wa_ekko-ebeln.

     APPEND VALUE TO LIST.

   endloop.

   NAME = 'P_PARM'.

   CALL FUNCTION 'VRM_SET_VALUES'

     EXPORTING

       ID     = NAME

       VALUES = LIST.

********************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

   WRITE: / 'SELECTED VALUE KEY:', P_PARM.

Manojkumar_S
Discoverer
0 Kudos
4,739

TYPE-POOLS : VRM.

DATAp_name TYPE vrm_id,
      list   TYPE vrm_values,
      value  LIKE LINE OF list.
DATAgwa_list    TYPE vrm_value.
DATAgt_values  TYPE TABLE OF dynpread,
      gwa_values TYPE dynpread.
******************************************************

PARAMETERS : p_prctr     TYPE bsis-prctr  MODIF ID prk  AS LISTBOX VISIBLE LENGTH 10.

**********************************************

AT SELECTION-SCREEN ON p_prctr.
  CLEAR: GWA_VALUESgt_values.
  REFRESH gt_values.
GWA_VALUES-fieldname 'P_PRCTR'.
  APPEND GWA_VALUES TO GT_VALUES.
  CALL FUNCTION 'DYNP_VALUES_READ'
    EXPORTING
      dyname             sy-cprog
      dynumb             sy-dynnr
      translate_to_upper 'X'
    TABLES
      dynpfields         gt_values.

  READ TABLE gt_values INDEX INTO gwa_values.
  IF sy-subrc AND gwa_values-fieldvalue IS NOT INITIAL.
    READ TABLE list INTO gwa_list
                      WITH KEY key gwa_values-fieldvalue.
    IF sy-subrc 0.
*      gv_selected_value = gwa_list-text.
      MOVE gwa_list-text TO p_prctr.
    ENDIF.
  ENDIF.

***********************************************************

AT SELECTION-SCREEN OUTPUT.
IF list[] IS INITIAL.
  p_name 'P_PRCTR'.
  value-key '1'.
  value-text '5000'.
  APPEND value TO list.

  value-key '2'.
  value-text '5003'.
  APPEND value TO list.

  value-key '3'.
  value-text '5004'.
  APPEND value TO list.

  value-key '4'.
  value-text '5005'.
  APPEND value TO list.

  value-key '5'.
  value-text '5007'.
  APPEND value TO list.

  value-key '6'.
  value-text '5010'.
  APPEND value TO list.

  CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id p_name values list.

ENDIF.