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

Ranges table

Former Member
0 Likes
658

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.

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
604

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

4 REPLIES 4
Read only

former_member195698
Active Contributor
0 Likes
604

Use

select matnr from mara

into table it_matnr

where maktl <b>in r_mat_group</b>

Read only

Former Member
0 Likes
604

For starters:

select matnr from mara 
appending table it_matnr 
where MATKL in r_mat_group.      "<====

(Corrected the field name)

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
604

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

Read only

naimesh_patel
Active Contributor
0 Likes
605

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