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: 

List Boxes on a Selection Screen

Former Member
0 Kudos
206

Hi,

I have a list box on the selection screen. In the At Selection Screen Output, I filled the List box with 12 Values.

Now, I want to default the List box value with one of those values.

So, after the CALL FM 'VRM_SET_VALUES', I say p_field = 'Value'.

But this Value is being shown in the Drop down list twice.

I could not understand the mistake.

Please suggest.

Thanks,

Suryakiran D.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
180

Hi suryakiran,

1. Its happening bcos

u must be giving NAME

2. give p_field = Key

3. ie. 1 for Jan

2 for Feb etc

*----


in the FM VRM_SET_VALUES

we are filling the parameter VALUES

VALUES-key

VALUES-TEXT

*----


so, give KEY, (and not text)

after calling this FM.

4.

REPORT abc.

TYPE-POOLS : vrm.

DATA : v TYPE vrm_values.

DATA : vw LIKE LINE OF v.

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

INITIALIZATION.

vw-key = '1'.

vw-text = 'Jan'.

APPEND vw TO v.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'A'

values = v

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

a = '1'.

*----


Problem

a = 'Jan'.

regards,

amit m.

Message was edited by: Amit Mittal

6 REPLIES 6

Former Member
0 Kudos
181

Hi suryakiran,

1. Its happening bcos

u must be giving NAME

2. give p_field = Key

3. ie. 1 for Jan

2 for Feb etc

*----


in the FM VRM_SET_VALUES

we are filling the parameter VALUES

VALUES-key

VALUES-TEXT

*----


so, give KEY, (and not text)

after calling this FM.

4.

REPORT abc.

TYPE-POOLS : vrm.

DATA : v TYPE vrm_values.

DATA : vw LIKE LINE OF v.

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

INITIALIZATION.

vw-key = '1'.

vw-text = 'Jan'.

APPEND vw TO v.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'A'

values = v

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

a = '1'.

*----


Problem

a = 'Jan'.

regards,

amit m.

Message was edited by: Amit Mittal

athavanraja
Active Contributor
0 Kudos
180

in the initialization event just pass the value to be defaulted to the parameter .

parameters: p_obj(2) as listbox visible length 50 .

initialization .

p_obj = 'G' . " the key of the entry

Regards

Raja

Former Member
0 Kudos
180

HI

the problem is you have added the values in the list box using the VRM_set_values so the list box contains all the values even the value which your assign currently. that's why it is displaying twice.

regards.

Former Member
0 Kudos
180

hi Surya,

checkout the example code..,

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.

regards,

Vinoth

former_member188685
Active Contributor
0 Kudos
180

check this code..

copy paste it and see...

REPORT  ZTEST_CODE_VRM.

TYPE-POOLS: VRM.

TYPES: NAME TYPE VRM_VALUE-TEXT.
DATA: V_VBELN LIKE VBAK-VBELN.
DATA: IT_VALUES TYPE STANDARD TABLE OF VRM_VALUE.
DATA: WA TYPE VRM_VALUE.
TABLES: KNA1.

SELECT-OPTIONS: S_VBELN FOR V_VBELN.
PARAMETERS: P_KUNNR AS CHECKBOX USER-COMMAND ABC.
PARAMETERS: P_CHK1 AS CHECKBOX USER-COMMAND ABC.
PARAMETERS: P_KUNNR1 TYPE NAME AS LISTBOX VISIBLE LENGTH 30.

INITIALIZATION.
  S_VBELN-LOW = '123'.
  APPEND S_VBELN.

  WA-KEY = '1'.
  WA-TEXT = 'One'.
  APPEND WA TO IT_VALUES.
  CLEAR WA.

  WA-KEY = '2'.
  WA-TEXT = 'Two'.
  APPEND WA TO IT_VALUES.
  CLEAR WA.
  READ TABLE IT_VALUES INTO WA INDEX 1.
  P_KUNNR1 = WA-KEY.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = 'P_KUNNR1'
      VALUES          = IT_VALUES
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.
  IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.



AT SELECTION-SCREEN.
  CLEAR S_VBELN.
  REFRESH S_VBELN.
  S_VBELN-LOW = '456'.
  APPEND S_VBELN.


AT SELECTION-SCREEN ON P_KUNNR.
* This event should fire only only for parameters not for select options
  P_KUNNR = 'X'.

*
AT SELECTION-SCREEN OUTPUT.

  IF P_KUNNR = 'X'.
    P_KUNNR = ' '.
  ENDIF.
  IF P_CHK1 = ' '.
    P_CHK1 = 'X'.
  ELSE.
    P_CHK1 = ' '.
  ENDIF.

regards

vijay

Former Member
0 Kudos
180

Hi

At the time of populating the values, populate all the values except the one you want to set as default.

Then Call the FM with p_field = 'value', where 'value' is your default string that is displayed.

Regards,

Sunil.