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

Substring in Select

Hallo

I have problem with following code. Can some body tell me how can I do it better.

SELECT pspnr FROM prps INTO TABLE lt_prps

WHERE fakkz = 'X'

AND pspnr+0(3) = 'C-55'.

I want to check for first four position of prps

Thank

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 02:23 PM

    Hi,

    Try the below:

    SELECT pspnr FROM prps INTO TABLE lt_prps

    WHERE fakkz = 'X'

    AND pspnr LIKE 'C-55%'.

    % for a sequence of any characters (including spaces).

    _ for a single character.

    Hope this helps you

    Regards

    Shiva

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 02:28 PM

    Hi,

    SELECT pspnr FROM prps INTO TABLE lt_prps

    WHERE fakkz = 'X'

    AND pspnr like 'C-55%'.

    Thanks.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 02:31 PM

    Hi Ahmad,

    As also told by other's do it this way:

    SELECT pspnr FROM prps INTO TABLE lt_prps
    WHERE fakkz = 'X'
     and pspnr like 'C-55%'.

    With luck,

    Pritam.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 18, 2009 at 02:35 PM

    Try this way:

    DATA: des TYPE STANDARD TABLE OF selopt,
          w_des TYPE selopt.
    
      CONCATENATE  p_text '*' INTO p_text.
    
      w_des-sign = 'I'.
      w_des-option = 'CP'.
      w_des-low = p_text.
      APPEND w_des TO des. CLEAR w_des.

    select...
         where FIELD IN des.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 18, 2009 at 02:37 PM

    Hi,

    Declare a field for flag,

    Fetch all the prps fields into internal table,

    Then compare the prps, and delete all other records which do not match.

    SELECT pspnr 
                 FROM prps INTO TABLE lt_prps
                 WHERE fakkz = 'X'.
    
    LOOP AT it_prps INTO wa_prps.
    
    IF wa_prps-pspnr+0(4) = 'C-55'.
    wa_prps-flag = 'X'.
    MODIFY it_prps FROM wa_prps INDEX sy-tabix TRANSPORTING flag.
    ENDIF.
    
    ENDLOOP.
    
    DELETE it_prps WHERE flag = ' '.

    Regards

    Bala Krishna

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Mar 18, 2009 at 03:31 PM

    Thanks a lot it was very helpful.

    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.