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

Help me - Select statement - urgent

Former Member
0 Likes
2,077

Hi Friends,

In a report I have to get all the material based on the material descriptions .

I am inputting the material description as a range.

Here my problem is if I give the input 'material description' as 'Mat' , I am getting only the materials with description as 'MAT' ( All caps ) , but not getting any others like materials with description 'mat' ( all lower case ) , 'mAt', etc.

What I found is when I am entering the value 'Mat' in the selection-screen, when I execute , the input is converting into upper case .Hence I am getting only those values ( whose materials with description as 'MAT' ).

Hope u got my problem.Please let me know the solution to get the materials with descriptions with any case ( If we enter the input value 'mat', we shud get the materials with 'MAT', 'Mat', 'mAt' etc').

Thanks in advance,

Vishnu.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,939

Use like this in your selection screen

parameters: l_maktx like makt-maktx lower case.

I don't think its possible in select query. If there is some condition by which you can restrict the no of entries, then fetch all the enties from MARA Join MAKT into an internal table.

Then convert the description to UPPER case and then you can search the internal table for your text

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/48cfaa90-0201-0010-cebb-8ee...

17 REPLIES 17
Read only

Former Member
0 Likes
1,940

Use like this in your selection screen

parameters: l_maktx like makt-maktx lower case.

Read only

0 Likes
1,939

No it won't solve my problem as I will get only the materials with description in lower case.I have materials with lower case as descrption, First letter caps and all letters caps as below:

MATNR MAKTX

000001 Mat1

000002 mat2

000003 mAt3

I have to get all the above materials if I enter mat in my selection-screen.

Regards,

Vishnu.

Read only

0 Likes
1,939

Viswanath,

Oops sorry , I misunderstood.

Message was edited by:

Pavan Kothapalli

Read only

0 Likes
1,939

Hi

U should use the view M_MAT1W (or table MAKT) in order to select the material by description, here you can use the field MAKTG, in this field the description is written always in UPPER CASE.

This is the field used by material search help std.

Max

Read only

0 Likes
1,939

Yes i agree with Max

this is the solution

you need to use MAKTG.

Read only

0 Likes
1,939

Hi Vishnu,

If you are fetching information from MAKT table then probably you can use MAKTG field instead of MAKTX. MAKTG will always have material description in upper case. so, you need to convert your selection parameter in upper case and use that for further selection.

Hope this will help you.

Regards.,

Pranav

Read only

0 Likes
1,939

Hi Max,

That's a very good solution.So can go ahead and use the filed MAKTG instead of MAKTX.I mean is it an ideal way to do?

Regards,

Vishnu.

Read only

0 Likes
1,939

Hi Max,

It is working .Thanks a lot for ur quick help.Thanks everyone for your contribution.

Regards,

Vishnu.

Read only

0 Likes
1,939

Hi

It's only an old trick: every search help based on the description uses alway a field where description is translated in upper case.

For example: Search Help for Vendor or Customer doesn't use the field NAME1 but MCOD1.

So the next time you need to search something by description check which field is used in the search help.

Max

Read only

Former Member
0 Likes
1,939

Vishwa,

I think this is a big process. If suppose you have multiple words in the description, How do you manage to get the materials?

Regards,

Satish

Read only

0 Likes
1,939

Satish,

Is there any way where we can ignore the case in the description and select all the data?

Vishnu.

Read only

0 Likes
1,939

I don't think you will get materials based on the description in a single select query.

Read only

naimesh_patel
Active Contributor
0 Likes
1,939

The best possible way, I can think is..

Get all the material description,

translate to Upper case

translate your input to upper case

delete the entries from the interal table

Try with this code:

REPORT  ZTEST_NP.

TABLES: MAKT.

TYPES: BEGIN OF TY_MAKT,
       MATNR TYPE MATNR,
       MAKTX TYPE MAKTX,
       DESC  TYPE MAKTX,
       END   OF TY_MAKT.

DATA: IT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
      WA_MAKT TYPE TY_MAKT.

SELECT-OPTIONS: S_MAKTX FOR MAKT-MAKTX VISIBLE LENGTH 15.

START-OF-SELECTION.
  SELECT MATNR MAKTX
         INTO  TABLE IT_MAKT
         FROM  MAKT.
  LOOP AT IT_MAKT INTO WA_MAKT.
    WA_MAKT-DESC = WA_MAKT-MAKTX.
    TRANSLATE WA_MAKT-DESC TO UPPER CASE.
    MODIFY IT_MAKT FROM WA_MAKT.
    CLEAR  WA_MAKT.
  ENDLOOP.

  LOOP AT S_MAKTX.
    TRANSLATE S_MAKTX TO UPPER CASE.
    s_maktx-option = 'CP'.
    concatenate '*' s_maktx-low  '*' into s_maktx-low.
    if not s_maktx-high is initial.
    concatenate '*' s_maktx-high '*' into s_maktx-high.
    endif.
    MODIFY S_MAKTX.
    CLEAR  S_MAKTX.
  ENDLOOP.

  DELETE IT_MAKT WHERE NOT DESC IN S_MAKTX.

  WRITE: 'Material contains entered pattern'.
  LOOP AT IT_MAKT INTO WA_MAKT.
    WRITE: / WA_MAKT-MATNR,
             WA_MAKT-MAKTX.
  ENDLOOP.

Regards,

Naimesh Patel

Read only

former_member195698
Active Contributor
0 Likes
1,939

I don't think its possible in select query. If there is some condition by which you can restrict the no of entries, then fetch all the enties from MARA Join MAKT into an internal table.

Then convert the description to UPPER case and then you can search the internal table for your text

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/48cfaa90-0201-0010-cebb-8ee...

Read only

Former Member
0 Likes
1,939

Your best solution is to use MAKT-MAKTG. this is an all uppercase version of MAKT-MAKTX.

Best of all, theres an index in this table on this field.

Otherwise, it's native SQL.

Rob

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
1,939

Vishwanath,

Use select options instead of parameterrs.

TABLES : MAKT.

SELECTION-SCREEN : BEGIN OF BLOCK 1 WITH FRAME TITLE TEXT-001.

SELECT-OPTIONS : P_MAKTX FOR MAKT-MAKTX NO INTERVALS.

*PARAMETERS : P_MAKTX LIKE MAKT-MAKTX.

SELECTION-SCREEN : END OF BLOCK 1.

SELECT SINGLE * FROM MAKT INTO MAKT WHERE MAKTX = P_MAKTX.

WRITE : 'SHREE'.

Hope this helps.

Shreekant

Read only

Former Member
0 Likes
1,939

as per my answer above, replace the '=' by 'IN' in the select query.

SELECT SINGLE * FROM MAKT INTO MAKT WHERE MAKTX [bIN</b> P_MAKTX.