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

Help me - Select statement - urgent

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.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    Posted on Nov 30, 2007 at 07:49 PM

    Use like this in your selection screen

    parameters: l_maktx like makt-maktx lower case.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 07:50 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 08:03 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 30, 2007 at 08:05 PM

    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-8ee0a29e0fc7

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:06 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:06 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2007 at 08:10 PM

    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.

    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.