Skip to Content
author's profile photo Former Member
Former Member

Ranges table

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Dec 04, 2007 at 03:34 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 03:31 PM

    Use

    select matnr from mara

    into table it_matnr

    where maktl <b>in r_mat_group</b>

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 04, 2007 at 03:32 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 04, 2007 at 03:33 PM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.