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

dropdown list at screen

Former Member
0 Likes
3,587

Hello experts,

I am creating dropdown list on screen with the help of VM_SET_VALUES function in PBO module.

I am declaring field with the same name in abap program. I had also assigned function code to this dropdown list.

The problem is when I am selecting the value in dropdown list PAI event is getting trigerred, but the value which I am selecting is not getting transfered in the program.

How should I transfer the selected value from dropdown list to abap program.

Please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,424

Hi,

iN Top Include
TYPE-POOLS VRM.
TABLES : SFLIGHT.
DATA : CID TYPE VRM_ID, " For List Box
       CAR TYPE VRM_VALUES,
       WCAR LIKE LINE OF CAR,
       CARRID TYPE SPFLI-CARRID,
       OK TYPE SY-UCOMM.
DATA : ITAB TYPE TABLE OF SFLIGHT WITH HEADER LINE, " For Second List Box
       CONID TYPE VRM_ID,
       CON TYPE VRM_VALUES,
       WCON LIKE LINE OF CON.
On The screen create 2 list box with names
1) SFLIGHT-CARRID " For this assign any dummy Code and it will trigger PBO once you leave select
 
2) SFLIGHT-CONNID
in PBO
 
module status_100.
 
in Program
 
module status_100 output.
  REFRESH CAR.
  WCAR-KEY = 'AA'.          " The Key Value and Text Value should be same
  WCAR-TEXT = 'AA'.
  APPEND WCAR TO CAR.
  WCAR-KEY = 'LH'.
  WCAR-TEXT = 'LH'.
  APPEND WCAR TO CAR.
  CID = 'SFLIGHT-CARRID'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = CID
      VALUES          = CAR
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.

Please check the below thread

Cheerz

Ramchander Rao.K

12 REPLIES 12
Read only

Former Member
0 Likes
2,424

Hello Subha,

Please check the below SAP help link with some examples:-

ht[http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/9f/dbabe435c111d1829f0000e829fbfe/content.htm]

Hope this answers your questions.

Thanks,

Greetson

Read only

0 Likes
2,424

Hi Greetson,

I read the document, Here values are automatically getting transfered from screen to abap program after selecting entry from dropdown list.

But In my program values are not automatically getting transferred, am I missing something.

I already checked screen field name and abap program field name are same.

Read only

0 Likes
2,424

Hi,

I created one list box and i assign the function code as LIST. the list box field name is GENDER.

in that PBO event i right the code like


v_val = 'GENDER'."(Field Name)

x_list-key = 'MALE'. "(Here v_value type t_list)
append x_list to t_list.
         clear x_list.
x_list-key = 'FEMALE'. "(Here v_value type t_list)
append x_list to t_list.
         clear x_list.

CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id                 =  v_val
      values          = t_list
    EXCEPTIONS
      id_illegal_name = 1
      OTHERS          = 2.
  IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

and in my PAI i write the code like


save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
  WHEN 'BACK'.
    leave PROGRAM.
  WHEN 'EXIT'.
    LEAVE PROGRAM.
  WHEN 'LIST'."call the function code here
    IF gender = 'MALE'.
      MESSAGE gender TYPE 'I'.
    ENDIF.
  WHEN OTHERS.

ENDCASE.

here if i select the gender field as male, i am getting information message as MALE.

the value will be passed to the program. event i debug the code after selecting the list box as male i am getting the male in gender field.

Regards,

Dhina..

Read only

0 Likes
2,424

Hi,

When you select any value in the list , the PAI gets triggered,

Now in the PAI, you can check teh function code that you have assigned to the list.

Here check teh function code, put a break point in the if statement and see if it goes inside it.

Once it goes, check the value of your screen-field.

Make sure the program field name & screen field name are same

Read only

Former Member
0 Likes
2,424

Hi,

If for example you have kept dropdown for choosing CARRID, and the field in the screen is as 'ZFTR_CARRID'. Try like this:

First assign a variable of type vrm_id.

data: v_val type vrm_id
data: t_list type vrm_values,
         x_list type vrm_value.

In the PBO module:

module listbox.

v_val = 'ZFTR_CARRID'.(Field Name)
 select carrid from the corresponding table and pass it to a work area.

v_value-key = work area-carrid. (Here v_value type t_list)
append v_value to t_list.
         clear v_value.

CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id                 =  v_val
      values          = t_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.

here if u select the particular carrid, its value will be passed to the program.

Read only

0 Likes
2,424

Hi Sindhu,

I had done exactly the same and dropdown box is also working fine on the screen but problem is after I select value from dropdown list it is triggering PAI module(as I had assigned Fcode to dropdown) but in PAI the value which I am selecting in dropdown is not getting transferred.

I already had checked, the screen field name and field in abap program have same name and data type.

How should I transfer value from dropdown to my ABAP program?

Edited by: shubh_ag on Jun 29, 2011 8:03 AM

Read only

Former Member
0 Likes
2,425

Hi,

iN Top Include
TYPE-POOLS VRM.
TABLES : SFLIGHT.
DATA : CID TYPE VRM_ID, " For List Box
       CAR TYPE VRM_VALUES,
       WCAR LIKE LINE OF CAR,
       CARRID TYPE SPFLI-CARRID,
       OK TYPE SY-UCOMM.
DATA : ITAB TYPE TABLE OF SFLIGHT WITH HEADER LINE, " For Second List Box
       CONID TYPE VRM_ID,
       CON TYPE VRM_VALUES,
       WCON LIKE LINE OF CON.
On The screen create 2 list box with names
1) SFLIGHT-CARRID " For this assign any dummy Code and it will trigger PBO once you leave select
 
2) SFLIGHT-CONNID
in PBO
 
module status_100.
 
in Program
 
module status_100 output.
  REFRESH CAR.
  WCAR-KEY = 'AA'.          " The Key Value and Text Value should be same
  WCAR-TEXT = 'AA'.
  APPEND WCAR TO CAR.
  WCAR-KEY = 'LH'.
  WCAR-TEXT = 'LH'.
  APPEND WCAR TO CAR.
  CID = 'SFLIGHT-CARRID'.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID              = CID
      VALUES          = CAR
    EXCEPTIONS
      ID_ILLEGAL_NAME = 1
      OTHERS          = 2.

Please check the below thread

Cheerz

Ramchander Rao.K

Read only

0 Likes
2,424

Hi,

I was assigning different values to 'KEY' and 'TEXT' fields of VRM_VALUES table in PBO.

Now, I am assigning values to only 'KEY' field and eliminated assignment of values to 'TEXT' field , dropdown list is now working fine.

But I am unable to get what is difference in the functionality of 'KEY' and 'TEXT' fields.

Edited by: shubh_ag on Jun 29, 2011 12:30 PM

Read only

0 Likes
2,424

Hi,

When you use the function module VRM_SET_VALUES the table it takes, has two important fields, KEY and VALUE.

KEY should be unique in the table and VALUE will be displayed in the drop-down output.

Eg:

Key Value

-


1 ABC

2 BCA

3 CDE

4 FGH

etc., and the drop-down output will have the values ABC,BCA,CDE,FGH.

Hope you got it.

Read only

0 Likes
2,424

Hi,

@Dhina: I think there is no 'VALUE' field in VRM_VALUE structure instead there is 'TEXT' field.

Here, is my code from PBO and PAI module.

MODULE initialize OUTPUT.
  refresh: itab.      
  clear:itab,cnt.

loop at myline.
  cnt = cnt + 1.
  itab-key = cnt.
  itab-text = myline-field1.
  append itab.
  endloop.

  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      ID                    = 'IO'
      VALUES                = ITAB[].

MODULE input INPUT.

  save_code = ok_code.
  clear ok_code.
  case save_code.
    when 'DD'.
      if IO = 'HELLO'.
      MESSAGE i888(sabapdocu) WITH IO.
      endif.
      endcase.
ENDMODULE.

When I am using above code in PBO then no data is returning in IO field in PAI but in PBO, if I am using:

loop at myline.
 itab-key = myline-field1.
  append itab.
  endloop.

then values are returning in corresponding 'IO' field.

Can someone explain me why?

Read only

0 Likes
2,424

Hi,

in that PAI you should change the code like dnt check the hello in the IO field you should check like key field in the IO field.

your passing the vrm-key is cnt. cnt have 1,2,3.

just check in that debug the IO field contains only cnt field value only.


case save_code.
    when 'DD'.
      if IO = 'HELLO'."dont pass the hello here pass the key value IO like 1,2,3
      MESSAGE i888(sabapdocu) WITH IO.
      endif.
      endcase.

Regards,

Dhina..

Read only

0 Likes
2,424

issue is solved.

I made following corrections.

I was assigning integer values to 'key', but screen field and abap field is of different data type.

Secondly I was comparing 'HELLO' with 'IO' instead of 'key' value which is integer type(IO = 1).

Thank you all.

Edited by: shubh_ag on Jun 29, 2011 4:24 PM