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

Need help

Hi SAP Gurus,

I have a requirement as below :

Parameters : DENSITY(3) TYPE C.

Actually this DENSITY field is 4th , 5th and 6th characters of the 10 digit material number .

Say if the material number is A123456789 then the DENSITY would be 456.

Now if the user enters this DENSITY in his selection screen, he has to get all the materials having this DENISTY from the table MARA.

I tried with the following code:

select matnr from mara into itab where matnr like %DENSITY%.

But it can give me materials with this DENSITY starting at the first character or 2nd character or anywhere.Hope u got my doubt.

Could any one help me out .It's very helpful to me.

Regards,

Vishnu.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Nov 29, 2007 at 04:48 PM

    Try with the code like this:

    select matnr from mara into itab where matnr like '+++DENSITY%'.

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 29, 2007 at 04:48 PM

    it is not good idea because of performance.

    why dont you select all and then delete from internal table by comparing with your input values.

    loop at itab into wa_tab.

    if wa_tab+4(3)<> density.

    delete from itab.

    endif.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You won't be able to use the index anyway.

      But you can do this:

      TABLES mara.
      
      parameters p_den(3).
      
      DATA: f1(10).
      
      CONCATENATE '___' p_den '%' INTO f1.
      
      SELECT * FROM mara 
        into table itab
        WHERE matnr LIKE f1.
      

      I removed a period from 'into itab'.

      Rob

      Message was edited by:

      Rob Burbank

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.