Hi All,
I have a requirement where in I have to get all the materials based on some 4 material groups.
For this I have declared a ranges table like this :
data : r_mat_group for mara-matkl.
r_mat_group-sign = 'I'.
r_mat_group-option = 'EQ'.
r_mat_group-low = 'mat_grp1'.
APPEND r_mat_group.
r_mat_group-low = 'mat_grp2'.
APPEND r_mat_group.
r_mat_group-low = 'mat_grp3'.
APPEND r_mat_group.
r_mat_group-low = 'mat_grp4'.
APPEND r_mat_group.
Getting the data from mara
loop at r_mat_group.
select matnr from mara
appending table it_matnr
where maktl eq r_mat_group-low.
endloop.
My question is 'Is it the right way to do or is there any other way we can write the
select statement for better performance '..
Regards,
Vishnu.
You have to do like this:
data : r_mat_group for mara-matkl. r_mat_group-sign = 'I'. r_mat_group-option = 'EQ'. r_mat_group-low = 'MAT_GRP1'. "<< Group name must be in Upper case APPEND r_mat_group. r_mat_group-low = 'MAT_GRP2'. APPEND r_mat_group. r_mat_group-low = 'MAT_GRP3'. APPEND r_mat_group. r_mat_group-low = 'MAT_GRP4'. APPEND r_mat_group. * Getting the data from mara select matnr from mara appending table it_matnr where maktl in r_mat_group. "<<<
Regards,
Naimesh Patel
Use
select matnr from mara
into table it_matnr
where maktl <b>in r_mat_group</b>
select matnr from mara into tbale it_matnr
Where matkl IN r_mat_group.
Try this one., but for better performance <u>try to use</u> all key fields
-Pavan
Add a comment