Skip to Content

How to check if a word in a string field?

I have an internal table named AA which has a field named status. This field is a string field may has word such like 'DLV' or 'TECO' etc.

I want to delete all fields in this internal table that status field has word 'DLV' or 'TECO'.

How can I do this?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on May 27, 2005 at 08:27 AM

    Hi Mark

    Try:

    DELETE aa WHERE status CS ' DLV ' OR
                    status CS ' TECO ' .

    Be careful that CS is case insensitive.

    Or you may use CP to handle with patterns like 'DLV' .

    Regards

    *--Serdar https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 27, 2005 at 10:07 AM

    Hi Mark,

    ...or use select-options / ranges

    SELECT-OPTIONS status FOR tj02t-txt04.
    
    INITIALIZATION.
      status-low = 'DLV' .
      status-sign = 'I'.
      status-option = 'EQ'.
      APPEND status.
      status-low = 'TECO' .
      APPEND status.
      ...
      DELETE itab WHERE status IN status.

    regards

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 27, 2005 at 08:26 AM

    Hi,

    delete AA where status = 'DLV' or status = 'TECO'.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 27, 2005 at 08:36 AM

    Hi,

    If you want to delete the record if the field contains the DLV or TECO,you can use cp to achieve this.

    delete aa where status cp 'DLV' or status cp 'dlv'

    or status cp 'TECO' or status cp 'teco'.

    For more information about CP , just have a look on this.

    The logical expression

    <f1> CP <f2>

    is true if <f1> matches the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:

    • for any character string: *

    • for any single character: +

    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.

    If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify

    • characters in upper and lower case

    • the wildcard character "" (enter:#)

    • the wildcard character "" (enter: # )

    • the escape symbol itself (enter: ## )

    • blanks at the end of a string (enter: #___ )

    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.