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

Retrieve data from drop down list

Former Member
0 Likes
1,817

I am making a module pool program using VRM to create drop down lists.

The problem I am having is after the user chooses the from the selection of the drop down list, how can I use what he chose? Is there a global variable being used here?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,790

bump

20 REPLIES 20
Read only

Former Member
0 Likes
1,791

bump

Read only

0 Likes
1,790

Hi,

The name of your drop dowm field would be holding the values which was selcted in the dropdown.

Thanks,

Harini

Read only

0 Likes
1,790

The name of my dropdown field is LB_VKORG, however, when I try to use it in a program, or even in debugging to see the contents, nothing is there. It just gives me the error that it doesn't exist.

Edited by: Tom Aprik on Oct 13, 2009 4:45 PM

Read only

0 Likes
1,790

Hi,

Can you post your code here,

I will have a look at it.

Thanks,

Harini

Read only

0 Likes
1,790

  DATA:
        DROPDOWN_ID   TYPE VRM_ID,
        LT_VRM_VALUES TYPE VRM_VALUES,
        LS_VRM_VALUES LIKE LINE OF LT_VRM_VALUES.
TYPE-POOLS: VRM.


MODULE FILL_DROP_DOWNS OUTPUT.

  DATA V_COUNT TYPE I VALUE 1.

  PERFORM FILL_DROPDOWN_VKORG.
  PERFORM FILL_DROPDOWN_VTWEG.
  PERFORM FILL_DROPDOWN_VKBUR.
  PERFORM FILL_DROPDOWN_KUNNR.

ENDMODULE.                 " FILL_DROP_DOWNS  OUTPUT


DROPDOWN_ID = 'LB_VKORG'.

  TYPES:
      BEGIN OF T_TVKO,
        VKORG LIKE TVKO-VKORG,
      END OF T_TVKO.

  DATA:
        IT_TVKO TYPE STANDARD TABLE OF T_TVKO,
        WA_TVKO TYPE T_TVKO.

  SELECT VKORG FROM TVKO INTO CORRESPONDING FIELDS OF TABLE IT_TVKO.

  LOOP AT IT_TVKO INTO WA_TVKO.
    LS_VRM_VALUES-KEY = V_COUNT.
    V_COUNT = V_COUNT + 1.
    LS_VRM_VALUES-TEXT = WA_TVKO-VKORG.
    APPEND LS_VRM_VALUES TO LT_VRM_VALUES.
    CLEAR LS_VRM_VALUES.
    AT LAST.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          ID                    = DROPDOWN_ID
          VALUES                = LT_VRM_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.
      CLEAR: V_COUNT, WA_TVKO, LT_VRM_VALUES.
    ENDAT.
  ENDLOOP.

In my PAI I have...


  DATA:
        G_STATUS1(20) TYPE C,
        G_STATUS2(20) TYPE C,
        G_STATUS3(20) TYPE C,
        G_STATUS4(20) TYPE C.

*  G_STATUS = LB_VKORG.
*  G_STATUS = LB_VTWEG.
*  G_STATUS = LB_VKBUR.
*  G_STATUS = LB_KUNNR.
  DROPDOWN_ID = 'LB_VKORG'.
  "g_name1 = c_status.
  CALL FUNCTION 'VRM_GET_VALUES'
    EXPORTING
      ID                 = DROPDOWN_ID
   IMPORTING
     VALUES              = LT_VRM_VALUES
*   EXCEPTIONS
*     ID_NOT_FOUND       = 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.


  READ TABLE LT_VRM_VALUES INTO LS_VRM_VALUES WITH KEY KEY = DROPDOWN_ID.
  IF SY-SUBRC = 0.
    G_STATUS = LS_VRM_VALUES-TEXT.
  ENDIF.

Which I know it doesn't work. Any ideas?

Read only

0 Likes
1,790

Hi,

Try declaring the drop down field as,

data: LB_VKORG type vrm_id.

Please try like this and let me know.

Thanks,

Harini

Read only

0 Likes
1,790

Doesn't seem to work. Once it enters PAI LB_VKORG is blank.

Read only

0 Likes
1,790

Hi,

I dont think you require the function module 'VRM_GET_VALUES' in PAI to get the value.

Just directly use the LB_VKORG to read the values. It works for me like this.

Thanks,

Harini

Read only

0 Likes
1,790

How exactly do you use LB_VKORG in the PAI?

When I try to assign it to a variable of type c, it tells me LB_VKORG is unknown.


MODULE GET_DROP_DOWNS INPUT.

  DATA:
        G_STATUS1(20) TYPE C,
        G_STATUS2(20) TYPE C,
        G_STATUS3(20) TYPE C,
        G_STATUS4(20) TYPE C.

  G_STATUS1 = LB_VKORG.
*  G_STATUS = LB_VTWEG.
*  G_STATUS = LB_VKBUR.
*  G_STATUS = LB_KUNNR.
  "DROPDOWN_ID = 'LB_VKORG'.
  "g_name1 = c_status.


  *READ TABLE LT_VRM_VALUES INTO LS_VRM_VALUES WITH KEY KEY = LB_VKORG.
  *IF SY-SUBRC = 0.
  *  G_STATUS1 = LS_VRM_VALUES-TEXT.
  *ENDIF.
ENDMODULE.                 " GET_DROP_DOWNS  INPUT

Edited by: Tom Aprik on Oct 13, 2009 5:28 PM

Edited by: Tom Aprik on Oct 13, 2009 5:36 PM

Read only

0 Likes
1,790

Hi,

I have shared my code below with a similar logic. Please have a look at it. I am getting the output.

ZMPTEST_TOP:

PROGRAM ZMPTEST.

TYPE-POOLS: VRM.

DATA:

field1 TYPE VRM_ID,

itab TYPE VRM_VALUES,

wa LIKE LINE OF itab.

data: a type i.

PBO Module:

if a = 0.

wa-key = '1'.

wa-text = 'Value1'.

APPEND wa TO itab.

CLEAR wa.

wa-key = '2'.

wa-text = 'Value2'.

APPEND wa TO itab.

CLEAR wa.

wa-key = '3'.

wa-text = 'Value3'.

APPEND wa TO itab.

CLEAR wa.

CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'FIELD1'

values = itab.

a = 1.

endif.

PAI Module:

CASE sy-ucomm.

WHEN 'DISPLAY'.

LEAVE TO LIST-PROCESSING.

WRITE:/ field1.

WHEN 'EXIT'.

LEAVE PROGRAM.

ENDCASE.

i have kept a drop down box and a display button to display what the user has selected in the drop down.

The selected value in the drop down gets displayed when the display button is clicked.

Thanks,

harini

Edited by: Harini Gopinath on Oct 13, 2009 9:17 PM

Read only

0 Likes
1,790

The attributes for my dropdown are:


NAME: LB_VKORG
TEXT: (empty)
Dropdown: Listbox

Under program:
Input Field: checked
Input: possible
output field: checked
Value List: A (also I have tried with it being blank)

Edited by: Tom Aprik on Oct 13, 2009 11:55 AM

Read only

0 Likes
1,790

HI,

Try declaring LB_VKORG in the global declaration as type VRM_ID.

Use this as the name of the drop down box.

Use this within quotes in the function module 'VRM_SET_VALUES' in PBO.

In PAI, try to see if this value is captured by debugging.

Thanks,

Harini

Edited by: Harini Gopinath on Oct 13, 2009 9:29 PM

Read only

0 Likes
1,790

Hi,

The field recognizes the value only if the 'KEY' is given for each entry as i have given in my code.

I tried commenting the KEY while appending the values to itab and appended only TEXT and the FIELD1 does not recognize the value. So you try giving KEY value for each entry and let me know.

Thanks,

Harini

Edited by: Harini Gopinath on Oct 13, 2009 9:32 PM

Read only

0 Likes
1,790

I have this now in a FM in my PBO


  TYPES:
      BEGIN OF T_TVKO,
        VKORG LIKE TVKO-VKORG,
      END OF T_TVKO.

  DATA:
        IT_TVKO TYPE STANDARD TABLE OF T_TVKO,
        WA_TVKO TYPE T_TVKO.

  SELECT VKORG FROM TVKO INTO CORRESPONDING FIELDS OF TABLE IT_TVKO.

  LOOP AT IT_TVKO INTO WA_TVKO.
    <b>LS_VRM_VALUES-KEY = V_COUNT.</b>
    V_COUNT = V_COUNT + 1.
    LS_VRM_VALUES-TEXT = WA_TVKO-VKORG.
    APPEND LS_VRM_VALUES TO LT_VRM_VALUES.
    CLEAR LS_VRM_VALUES.
    AT LAST.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
         <b> ID                    = 'LB_VKORG'</b>
          VALUES                = LT_VRM_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.
      CLEAR: V_COUNT, WA_TVKO, LT_VRM_VALUES.
    ENDAT.
  ENDLOOP.

I have bolded where I have made the changes you described. I also declared LB_VKORG as VRM_ID in my top declaration. However, still in my PAI LB_VKORG is blank.

Read only

0 Likes
1,790

Hi,

Did you get the output?

Thanks,

Harini

Read only

0 Likes
1,790

HI,

Another thing, Only the value of the key will be stored in the dropdown field and not the text value.

Try debugging the program when the control comes to PAI and see if the key is stored in the field.

Thanks,

Harini

Read only

0 Likes
1,790

Nope, no output.

In the debugger when I'm in PAI and type LB_VKORG in data objects, it is completely blank. Nothing is in there.

Read only

0 Likes
1,790

Hi,

I have tried the same logic and its working for me.... Try selecting listbox with key in the menu painter.

Else try using the FM 'F4IF_INT_TABLE_VALUE_REQUEST'.

Thanks,

Harini

Read only

0 Likes
1,790

Are my setting for the listbox itself correct?

Read only

0 Likes
1,790

I figured out the problem. Just like you said, my LB_VKORG will return the key, not the value. The problem I had was I was assigning an integer to a char. So I need to switch


V_COUNT = LS_VRM_VALUES-KEY.

to make it work with char. Any suggestions? And thanks for your help!