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 box Problem

Former Member
0 Kudos

I have MARA and MARC table,Key field Matnr,two list box.

When i select material in one field,Second field must show regarding plant.

How can i do so?

4 REPLIES 4

Vijay
Active Contributor
0 Kudos

hi,

you can specify function code for ur first list box..

by specifying ucomm f_abc after ur list box declaration.

now when value in first list box is selected it will trigger the function code f_abc and at this function code u can fill the second list box.

regards

vijay

former_member188685
Active Contributor
0 Kudos

using the user-command and the event AT SELECTION-SCREEN ON matnr. you can do that.

check this sample code..

REPORT  ztest_listbox.

DATA: BEGIN OF it_mara OCCURS 0,
       matnr TYPE mara-matnr,
      END OF it_mara.
DATA: BEGIN OF it_marc OCCURS 0,
       matnr TYPE mara-matnr,
       werks TYPE werks_d,
      END OF it_marc.
TYPE-POOLS vrm.

DATA: mat_list  TYPE vrm_values WITH HEADER LINE,
plant_list  TYPE vrm_values WITH HEADER LINE.



PARAMETERS: matnr TYPE matnr AS LISTBOX VISIBLE LENGTH 20 USER-COMMAND abc,
werks TYPE werks_d AS LISTBOX VISIBLE LENGTH 8 USER-COMMAND abc.


INITIALIZATION.
  SELECT matnr FROM mara
  INTO TABLE it_mara
  UP TO 20 ROWS.
  LOOP AT it_mara.
    mat_list-key = it_mara-matnr.
    mat_list-text = it_mara-matnr.
    APPEND mat_list.
  ENDLOOP.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'MATNR'
      values          = mat_list[]
    EXCEPTIONS
      id_illegal_name = 1.

AT SELECTION-SCREEN ON matnr.
  SELECT matnr
  werks
   INTO TABLE it_marc
   FROM marc
  WHERE matnr = matnr.
  CLEAR plant_list. REFRESH plant_list.
  LOOP AT it_marc.
    plant_list-key = it_marc-werks.
    plant_list-text = it_marc-werks.
    APPEND plant_list.
  ENDLOOP.
  CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING
      id              = 'WERKS'
      values          = plant_list[]
    EXCEPTIONS
      id_illegal_name = 1.

Former Member
0 Kudos

Create an event like

AT SELECTION-SCREEN ON p_matnr.*

*fill second CALL FUNCTION 'VRM_SET_VALUES'

EXPORTING

id = 'WERKS'

values = plant_list[]

EXCEPTIONS

id_illegal_name = 1.

listbox*

Former Member
0 Kudos

Hi,

Use a table which have the H_MARC search-help. I found table KALAMATCON2 should be good. Now, if you define your variables referencing this table, automatically you have the effect you want.

PARAMETERS: matnr TYPE kalamatcon2-matnr,
            werks TYPE kalamatcon2-werks.

Try it, it's simple.

Regards!