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

Need help

Former Member
0 Likes
985

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
Read only

naimesh_patel
Active Contributor
0 Likes
957

Try with the code like this:

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

Regards,

Naimesh Patel

8 REPLIES 8
Read only

naimesh_patel
Active Contributor
0 Likes
958

Try with the code like this:

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

Regards,

Naimesh Patel

Read only

0 Likes
957

Hi Naimesh,

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

Vishnu.

Read only

0 Likes
957

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

Rob

Read only

0 Likes
957

Hi Rob,

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

Vishnu.

Read only

0 Likes
957

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

Read only

former_member191735
Active Contributor
0 Likes
957

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.

Read only

0 Likes
957

Hi

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

Experts should share there thoughts.

Thanks,

chaithanya.

Read only

0 Likes
957

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