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: 

selection-screen

former_member549415
Participant
0 Kudos

HI all experts ,

In selection screen I have three fields, plant mat no and material group. If I input plant how do I get the mat no and material group based on plant dynamically?.

please do let me how i can do this?

4 REPLIES 4

Former Member
0 Kudos

Hi Somnath,

Try the below code:

tables vbap.

data itab like table of vbap with header line.

parameters: plant type vbap-werks,

matno type vbap-matnr,

matgrp type vbap-matkl.

at selection-screen.

select single matnr matkl from vbap into corresponding fields of itab where werks = plant.

matno = itab-matnr.

matgrp = itab-matkl.

Please reward points if helpful

Manish

anversha_s
Active Contributor
0 Kudos

hi,

try this code.

report ztest.
 
parameters: p_plant type vbap-werks,
	    p_matno type vbap-matnr,
            p_matgrp type vbap-matkl. 

at selection-screen.
 
PERFORM f_fill_data.


*---------------------------------------------------------------------*
*       FORM f_fill_data                                       *
*---------------------------------------------------------------------*
FORM f_fill_data.

clear : p_matno,p_matgrp.

select single matnr matkl from VBAP into (p_matno,p_matgrp) where werks = p_plant.

ENDFORM.

Regards,

Anversha

Former Member
0 Kudos

Hai,

Think the scenario like this. You have two selection screens and if you give plant in the first selection screen and press enter it will call second selection screen which contains all the three fields but the plant comes automatically and the material and material group for that plant is possible.

Reward.

vinod_vemuru2
Active Contributor
0 Kudos

Hi Somnath,

First thing is ur material number and material group must be select options to meet this requirement. Because for one plant u can have more than one material. If u enter plant and press enter then u have to get all the materials and mat groups into the screen. For this u have to define material number and group as select options.

Check below code which will exactly does as what u need. Just copy paste this code and check the functionality

TABLES: MARA, MARC.

TYPES: BEGIN OF T_MARA,

MATNR TYPE MARA-MATNR,

MATKL TYPE MARA-MATKL,

WERKS TYPE MARC-WERKS,

END OF T_MARA.

DATA: I_MARA TYPE STANDARD TABLE OF T_MARA,

WA_MARA TYPE T_MARA.

PARAMETER: PO_WERKS TYPE MARC-WERKS.

SELECT-OPTIONS:SO_MATNR FOR MARA-MATNR,

SO_MATKL FOR MARA-MATKL.

AT SELECTION-SCREEN ON PO_WERKS.

CHECK NOT PO_WERKS IS INITIAL.

SELECT AMATNR AMATKL B~WERKS

INTO TABLE I_MARA

FROM MARA AS A INNER JOIN MARC AS B

ON AMATNR EQ BMATNR

WHERE B~WERKS EQ PO_WERKS.

SO_MATNR-SIGN = 'I'.

SO_MATNR-OPTION = 'EQ'.

SO_MATKL-SIGN = 'I'.

SO_MATKL-OPTION = 'EQ'.

CLEAR WA_MARA.

LOOP AT I_MARA INTO WA_MARA.

SO_MATNR-LOW = WA_MARA-MATNR.

SO_MATKL-LOW = WA_MARA-MATKL.

APPEND: SO_MATNR,

SO_MATKL.

CLEAR WA_MARA.

ENDLOOP.

Thanks,

Vinod.