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: 

Need help

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

Try with the code like this:

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

Regards,

Naimesh Patel

8 REPLIES 8

naimesh_patel
Active Contributor
0 Kudos

Try with the code like this:

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

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh,

I have tried your code.It's working perfectly.Thanks a lot.

Vishnu.

0 Kudos

It worked? I think you have to use underscores in a SELECT statement.

Rob

0 Kudos

Hi Rob,

It worked even with + character.Please let me know in case of any issues.

Vishnu.

0 Kudos

I tried it and it didn't work and the documentation says to use underscores. Maybe they've changed it in higher releases. Which release are you on?

Rob

former_member191735
Active Contributor
0 Kudos

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.

0 Kudos

Hi

I think selecting all Materials from Mara also will be a performance issue.

Experts should share there thoughts.

Thanks,

chaithanya.

0 Kudos

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