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: 

Drop down list

Former Member
0 Kudos

Hi all,

I am using a drop down list in a program. It has got some 10 values. How do i grab the value which user has selected and set that value to that field.

Regards,

Sunil

17 REPLIES 17

athavanraja
Active Contributor
0 Kudos

R u using it abap program? is it a parameter field as list box?

Are you using FM VRM_SET_VALUES.

Need more info to help you out.

Regards

Raja

Former Member
0 Kudos

Hi Raja,

I am not using as parameter but using VRM_SET_VALUES to set the values for that particular field.The probem is how to grab the selected value?

Regards,

Sunil

0 Kudos

Doesn't the "<b>particular field</b>" have that value, when you have selected from the dropdown list ?

Can you post the code snippet ?

Regards,

Subramanian V.

Message was edited by: Subramanian Venkateswaran

0 Kudos

You would be passing the <b>"particular field"</b> as the name property for VRM_SET_VALUES .

that particular filed will hold the selected value.

Raja

Former Member
0 Kudos

Hi all,

I am using function VRM_SET_VALUES to set the possible values for that particular field. Now when i select a particular value from those values i am not able to see that value rather i am seeing a blank for that field.

Regards,

Sunil

0 Kudos

Hello Sunil,

It is not clear from your description whether you are using a selection-screen or a normal screen. Hence the confusion with the term "parameter".

When you use the FM VRM_SET_VALUES, the exporting parameter NAME should contain the name of the field on the screen (in case of a selection-screen, this would generally be a <i>parameter</i>). The exporting parameter list will contain the values to be displayed in the drop down. When the user selects a value from the dropdown, it will automatically get assigned to the field , which you have sent to the FM through the exporting parameter <b>name</b>.

For further information, you can refer to the program DEMO_DYNPRO_DROPDOWN_LISTBOX.

Regards,

Anand Mandalika.

0 Kudos

Sunil,

The following link to the documentation might provide you more information: http://help.sap.com/saphelp_46c/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm

Regards,

Anand Mandalika.

Finally, I would like to introduce you the SDN forums points system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;

- one 10 points (solved)

- two 6 points (very helpful answer)

- many 2 points (helpful answer)

Former Member
0 Kudos

Hi Anand,

I am not using any selection screen as you specified. It's a screen field and i made it as listbox.

I have assigned values using VRM_SET_VALUES but i am unable to select the values from the list box. what ever i select i am only getting space as value for that field.

I hope this is clear for you.

Regards,

Sunil

0 Kudos

Hello,

Please check the prg. RSDEMO_DROPDOWN_LISTBOX. Hope this helps you.

Regds, Murugesh AS

0 Kudos

Hello Sunil,

From your description, I suspect the problem to be with the exporting parameter VALUES of the FM VRM_SET_VALUES.

Let us say you have a Screen Field called CARRID. and you wish to provide a dropdown with some Airline Carriers. The following code would do the trick:



TYPE-POOLS VRM.

DATA: NAME  TYPE VRM_ID,
      LIST  TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST.

  NAME = 'CARRID'.
  
  value-key = 'LH'.
  value-text = 'Lufthansa'.
  append value to list.

  value-key = 'IA'.
  value-text = 'Indian Airlines'.
  append value to list.
 
  CALL FUNCTION 'VRM_SET_VALUES'
       EXPORTING
            ID              = NAME
            VALUES          = LIST.

Now, what the user will see on the screen in the dropdown list will be the <i>texts</i>. When the user selects, for example, Lufthansa, in the program the screen variable CARRID will contain the value 'LH'.

Hope this is clear. Please refer to the documentation in the link that I have given in my previous post. If you are still unable to achieve the result, then please paste the code you have used for this purpose.

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hi Anand,

I am able to do if that field is from dictionary.but here the field is user defined field.Pls suggest.

Regards,

Sunil

0 Kudos

Hello Sunil,

Your mention to the word dictionary raises a serious doubt here. Providing the DropDown ListBox Functionality , to my knowledge , has got nothing to do with the dictionary. Are you really trying to create a drop-doun list box ? Or are you trying to code for the F4 Functionality (Input help)?

Please provide the code you are using .

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hi anand,

For your reference i am giving the code i am using.

REPORT z_dropdown .

TYPE-POOLS vrm.

DATA init.

DATA save_ok LIKE sy-ucomm.

DATA ok_code LIKE sy-ucomm.

DATA:values1 TYPE vrm_values.

*CLEAR INIT.

CALL SCREEN 100.

&----


*& Module fill_list OUTPUT

&----


  • text

----


MODULE fill_list OUTPUT.

DATA values TYPE vrm_values WITH HEADER LINE.

IF init IS INITIAL.

DO 10 TIMES.

values-text = space.

values-key = sy-index.

APPEND values.

ENDDO.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'INPUT1'

values = values[]

EXCEPTIONS

id_illegal_name = 1

OTHERS = 2.

ENDIF.

ENDMODULE. " fill_list OUTPUT

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'TEST'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'LIST'.

CALL FUNCTION 'VRM_GET_VALUES'

EXPORTING

id = 'INPUT1'

IMPORTING

values = values1

EXCEPTIONS

id_not_found = 1

OTHERS = 2.

WHEN 'BACK'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

0 Kudos

Try this one instead -


REPORT z_dropdown .

TYPE-POOLS vrm.

DATA init.

DATA save_ok LIKE sy-ucomm.
DATA ok_code LIKE sy-ucomm.
DATA:values1 TYPE vrm_values.

*CLEAR INIT.

CALL SCREEN 100.
*&---------------------------------------------------------------------*
*& Module fill_list OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE fill_list OUTPUT.



DATA values TYPE vrm_values WITH HEADER LINE.

IF init IS INITIAL.
DO 10 TIMES.
values-text = sy-index.
values-key = sy-index.
APPEND values.
ENDDO.

CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'INPUT1'
values = values[]
EXCEPTIONS
id_illegal_name = 1
OTHERS = 2.


ENDIF.


ENDMODULE. " fill_list OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'TEST'.


ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

save_ok = ok_code.
CLEAR ok_code.

CASE save_ok.
WHEN 'LIST'.


WHEN 'BACK'.
LEAVE PROGRAM.


ENDCASE.


ENDMODULE. " USER_COMMAND_0100 INPUT 

By the way, what do you want to do with the value you have obtained in the field ? I cannot see any processing with that field.

Did you assign the function code LIST to the dropdown listbox ?

Regards,

Anand Mandalika.

Former Member
0 Kudos

Hello anand,

I am using frop down functionality only. But tha values which i am setting are defined in ABAP program and those values are set to the use defined field using FM. I have given you the code i am using.

Regards,

Sunil

0 Kudos

Hello Sunil,

The problem is not with the dropdown functionality. It is with the lack of proper understanding of the data-type conversions!!

Consider the following code and see if it helps. Give particular attention to the DO...ENDDO loop.



data number(1) type c.

TYPE-POOLS VRM.

DATA: NAME  TYPE VRM_ID,
      LIST  TYPE VRM_VALUES,
      VALUE LIKE LINE OF LIST.



start-of-selection.

  call screen 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.

IF LIST IS INITIAL.
  name = 'NUMBER'.

  DO 9 TIMES.
    MOVE SY-INDEX TO : VALUE-KEY+0(1),
                       VALUE-TEXT+0(1).
    APPEND VALUE TO LIST.
  ENDDO.

ENDIF.

CALL FUNCTION 'VRM_SET_VALUES'
  EXPORTING
    ID                    = NAME
    VALUES                = LIST
 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.


ENDMODULE.                 " STATUS_0100  OUTPUT

0 Kudos

Hi Sunil

I haven't read all the codes you sent. However, did you set the related property of the field to get values from the flow logic of your screen?

That is, at screen painter, at the "DATA" tabstrip of field properties section, you should set the relevant field to "A" which means the listbox will be filled via the VRM function.

<i>And as a last thing, let me introduce you the SDN forums pointing system: You can assign points to posts you find helpful while solving your question. You can reward points by clicking the yellow star icon at header of each reply post. You can reward;

- one 10 points (solved)

- two 6 points (very helpful answer)

- many 2 points (helpful answer)</i>

Kind Regards...

*--Serdar