String search syntax

Hi All,
I would like to know what is the syntax to be used to check if a particular word exists in a sentence. I tried the below, but it is not giving me the desired result.  I am checking to see if the word Comp exists in the name & also would like to know is this a case-sensitive search? i.e would Comp be treated differently from comp? if i want the search to check for 'comp' irrespective of the case, how should i do it?
SELECT SINGLE NAME1 FROM KNA1 INTO Y_NAME1
  WHERE KUNNR EQ VBRK-KUNRG.
IF Y_NAME1 CA 'Comp'.
  Y_TYP_SAL = 'INTERNAL'.
ELSE.
  Y_TYP_SAL = 'EXTERNAL'.
ENDIF.

Hi,
To search a character field for a particular pattern, use the SEARCH statement as follows:
SEARCH <c> FOR <str> <options>.
The statement searches the field <c> for <str> starting at position <n1>. If successful, the return code value of SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in the field <c>. Otherwise, SY-SUBRC is set to 4.
<str>----Function
<pattern>--Searches for <pattern> (any sequence of characters).--
Trailing blanks are ignored.
.<pattern>.----
Searches for <pattern>. Trailing blanks are not ignored.
*<pattern>----
A word ending with <pattern> is sought.
<pattern>*----
Searches for a word starting with <pattern>.
Words are separated by blanks, commas, periods, semicolons, colons, question marks, exclamation marks, parentheses, slashes, plus signs, and equal signs.
<option> in the SEARCH FOR statement can be any of the following:
  ABBREVIATED
Searches the field <c> for a word containing the string in <str>. The characters can be separated by other characters. The first letter of the word and the string <str> must be
the same.
  STARTING AT <n1>
Searches the field <c> for <str> starting at position <n1>. The result SY-FDPOS refers to the offset relative to <n1> and not to the start of the field.
  ENDING AT <n2>
Searches the field <c> for <str> up to position <n2>.
  AND MARK
If the search string is found, all the characters in the search string (and all the characters in between when using ABBREVIATED) are converted to upper case.
Ex.
DATA STRING(30) VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
ULINE /1(26).
SEARCH STRING FOR 'X'.
WRITE: / 'X', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'
SEARCH STRING FOR 'itt '.
WRITE: / 'itt ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'
SEARCH STRING FOR '.e .'.
WRITE: / '.e .', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
SEARCH STRING FOR '*e'.
WRITE: / '*e ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
SEARCH STRING FOR 's*'.
WRITE: / 's* ', SY-SUBRC UNDER 'SY-SUBRC',
SY-FDPOS UNDER 'SY-FDPOS'.
Regards,
Bhaskar

Similar Messages

  • Search syntax for Safari history? how to remove items from specific pages?

    I'm using Safari 5.0.3 and I prefer keeping the browsing history quite long for accessing contents I had been searching in the net some weeks ago.
    However, that way I'm collecting lots of clutter and therefore I'd like to remove selected entries from the history, e. g. from the page where I'm reading daily news etc.
    I tried to use the search field (accessible with Cmd-F in the history view) to search for parts of the corresponding web address, e. g. "http://www.heute.de", but I do not only get the history items from that site but many others from google and other pages.
    So I'd like to know: is there a search syntax to use the search field, like address=www.heute.de* which enables wild cards, operators like OR/AND etc.?
    If not, is there a 3rd party tool which can help or can I use spotlight/the finder to find and remove the unwanted items from the browser history?

    Hi beckmart
    there might be ready-made apps or add-ons to do that - but this may help...
    quit safari, open Home/Library/Safari/History.plist using PrefSetter
    enter the url you want removed in the search box, no need for quotes - say www.google.com
    expand the 'web history dates' section at left to see individual results, then select the first one & shift-click the last (don't use select all) to highlight/select all the results - then press the delete key to remove them. Then save the file.
    Naturally, a backup copy of history.plist would be wise - but the above seems to work very well.

  • Problem in String Search using OKAPI in 9i Lite

    We are creating an Symbian EPOC application using Oracle 9iLite in stand-alone mode. We have managed to create a C++ program that creates an Oracle database on the Nokia Communicator 9210.
    The problem is that a string search returns either null or all of the searched records, ie. it does not work.
    The code below should do the string search and return the strings that match the given keyword. Any idea why this is not working? We are using OKAPI.
    TempCond[0].Operator = OK_GT;
    TempCond[0].AttrPos = KEYWORDREFERENCE_INDEX_FOR_KEYWORD;
    TempCond[0].AttrVal.BufPtr = (unsigned char*) szGivenKeyword;
    TempCond[0].AttrVal.BufSize = OK_NEW_ARRAY | strlen szGivenKeyword);
    TempCond[0].AttrVal.Indicator=1;
    TempCond[0].Collate=0;
    TempCond[0].Connective=OK_AND;
    // Iterate through the entire group, extracting the key data
    //(whatever the key may be) and the object reference, and
    // append to the end of the array.
    e = okCreateIterator( iEnv,
    iEbmgKeywordReferenceGroupRef,
    iEbmgKeywordReferenceClassRef,
    FALSE,
    1,
    TempCond,
    20,
    0,
    NULL,
    &iter
    Thanks for any help you may provide.

    I am sorry, this is not an answer to your question but a little help from you is well appeciated.
    I have just started exploring oracle 9i Lite to develop apps. on Palm and WinCE using OKAPI but the documentation does not seem enough. Is there some book or sample programs available that demonstrate OKAPI to develop form based apps ? CodeWarrior and Satellite Forms are not good when someone wants to try writing demp app.
    Thanks,
    Ashish

  • String search

    i hI have a string "1234, abcdef, bbbbb"
    How do one get/search for the "abcdef" or "bbbb" out of the string using substring?
    If anyone has source code or references (for similar code) searching for "abcdef�(normally text enter in a text field that will be used to search through a string) It would be appreciated

    // This might help!
    String search = "test";
    Pattern pattern = Pattern.compile(".*" +search +".*");
    boolean test = pattern.matcher(testString).matches();

  • Help me in writing ajax string search from database

    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}

    shadab_think_globally wrote:
    {noformat}*hi everybody,
    please send me a ajax with jsp application
    suppose i enter a word in text area ajax will populate/suggest all string from database ,who started
    from that entering character(s).like a google string search.
    please send full source code
    *{noformat}how about you do it yourself?

  • Faster string search options

    Hi
    I am an intern at a mobile technology firm assigned the job of enhancing the search performance of a tool, which is coded completely in java. This tool, along with other features basically searches for the substring in a string array by using the string.indexof() method which is very slow, since i am dealing with vast amount of data..
    Now the last two weeks all I did was try and understand the massive code. These are the alternatives I came up with. I could do with suggestions about the feasibilities of these ideas.. or any new suggestions are welcome..
    1. are there any faster ways instead of string.indexof() that i can use to do my string search?
    2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example??
    3. will using a the .nio package instead of .io package work???
    4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons??
    thanks
    mahima

    yumjay wrote:
    1. are there any faster ways instead of string.indexof() that i can use to do my string search?You seem to have found one in section 2.
    2. How about replacing this indexof() method with a faster search algorithm? something like boyer-moore for example?? Well obviously you can't override or replace String's indexOf, but you could certainly change the code to use a different algorithm. What's stopping you?
    3. will using a the .nio package instead of .io package work??? Not sure, there may be virtue in some of the memory mapping additions, but I don't really know your requirements or situation.
    4. how about completely scrapping this string search and taking in the data from input stream as integer format.. and then doing the comparisons?? The string search is essentially doing integer comparisons on data 16 bits at a time (that's the width of a char). So first, remember that the int returned by InputStream.read() isn't really an int but a byte stuffed into an int (so they can return -1 on EOS). That said, you might experience a performance gain if you put the data into ints or longs (depending on your computer architecture) and then use something like boyer-moore, because your computer can likely do comparisons of two bytes, chars, shorts, ints (and perhaps even longs on a 64-bit architecture) in the exact same amount of time. They're probably even the same machine instruction. You also wouldn't therefore have to decode the input data into a string either. But you'd have to encode your search string into integers. So yeah you could potentially squeeze a bit more speed, not likely more than 50% though.

  • Exact string search

    i was wondering if there was a way to do an exact string search in a document.
    If i have a document that has punctuation i want to be able to find the document only if i query whith an exact string match, including stopwords and punctuations.
    if the query is
    select *
    from documents1
    where contains(OBJECT_VALUE,'{hello, world}') > 0
    I want only to return the documents that have exactly "hello, world" whith the comma included.
    If i add the comma to printjoins, it would work, But when i query for only "hello" it wont match "hello, world"
    basicaly im looking for something that does a normal search but then check if the exact string is in the match area.

    Try this
    select substr(&P, (INSTR(&P, CHR('32'), 1))+1, (INSTR(&P, CHR('32'), 1)))
    from dual
    &p is a variable
    I am sure this will help you in any of case
    chr(32) will return space, If you have any other thing except space then you just replace 32 with that ascii code. Such as for
    1(we)2 then query will be
    select substr(&P, (INSTR(&P, CHR('40'), 1))+1, (INSTR(&P, CHR('41'), 1)))
    from dual
    Try it and tell is it working fine

  • Like %, string search

    Hi all,
    I am making a application in which there is string search but i dont know how to find a solution.
    For example in sql, there is (like %) expression to find similar words. But in java how can I do that.
    For instance word1 = mehmet, word2 = mehemet.
    How can i do it?
    Thanks...

    regerybets wrote:
    Hi all,
    I am making a application in which there is string search but i dont know how to find a solution.
    For example in sql, there is (like %) expression to find similar words. But in java how can I do that.
    For instance word1 = mehmet, word2 = mehemet.
    How can i do it?
    Thanks...Sounds like a job for Levenshtein. Apache has an implementation in their Commons-Lang API:
    import org.apache.commons.lang.StringUtils;
    public class LevenshteinDemo {
        public static final int MINIMUM_LIKE_DISTANCE = 4;
        public static boolean like(String wordA, String wordB) {
            return like(wordA, wordB, MINIMUM_LIKE_DISTANCE);
        public static boolean like(String wordA, String wordB, int permittedDistance) {
            return StringUtils.getLevenshteinDistance(wordA, wordB) <= permittedDistance;
        public static void main(String[] args) {
            String a = "mehmet";
            String b = "mehemet";
            String c = "ambulance";
            String d = "meehemeet";
            String e = "mhmt";
            System.out.println(like(a, b));
            System.out.println(like(a, c));
            System.out.println(like(a, d));
            System.out.println(like(a, e));
    /* output:
                    true
                    false
                    true
                    true
    */Download it here: [http://commons.apache.org/downloads/download_lang.cgi], stick the file commons-lang-2.4.jar in your classpath and the snippet above will compile. Of course, you may want to make permittedDistance variable depending on the size of the input words. Now it will only work for small strings/words, not larger chunks of text.

  • Approximate string search

    Hi everyone,
    If anyone here is interested in approximate string search algorithms, take a look at this prototype: http://scientechs.com/servlet/smartsearch.test.ApproxiMatchServlet . Keyword DB was compiled from the list of canadian business names and has right now ~200K of words, so don't expect to find every english word there.
    Source code would be uploaded to sourceforge soon (smartsearch.sourceforge.net). If anyone wants to participate in improving the project, drop a note. All feedback is welcome.

    From the description:
    "Approximate string search algorithm implementation (the algorithm was developed from the scratch, so it is NOT an implementation of existing algorithms), written in Java and runs under any OS that supports Java2 platform."
    I know there are a number of approximate string matching out there. My question is how does your algorithm relate to the other ones?
    I tried keyword apple, so it seems there is more work to do, but at least it worked.

  • Is there any API available to do string search and replace?

    as above?

    For simple string searching have a look at java.util.StringTokenizer.
    Regular Expressions are included in v1.4.
    Have there a look at the String class itself and the new java.util.regex package.
    Greets
    Puce

  • Bing Search syntax - specify a single site in Default text?

    I know that when doing a search using the web browser that I can use
    site:wherever.com as part of the search string.
    Is it possible to do this using Bing Search inside Project Siena ? If yes, some sample syntax for text, image, composite search would be much appreciated.

    Thanks.
    What I'm trying to do is set a default String in the input box and at the very
    end change the visibility.
    So, I'm not allowing user input.
    So hypothetically I want to search (I wouldn't do this for real, this is just an
    example) for images of Barack Obama at whitehouse.gov
    So my input text1 field would have Barack O'Bama and I would change the default
    from "Input" to "Barack O'Bama" and make it invisible.
    without limiting the site scope I'd have
    BingSearch!Image(InputText1Text)!results
    For my use case I just would add
    BingSearch!Image(InputText1Text& " site:whitehouse.gov")!results
    with a space between & and "site....              Correct?
    (I'll go play around...)
    On Thu, 27 Mar 2014 16:33:53 +0000, Robin Abraham [MSFT] wrote:
    >Image search: BingSearch!Image(InputText1!Text & " site:youtube.com")!results  -- in this case MediaUrl column of the results is what you need to bind to your image controls.
    -- Barb Bowman

  • Why String Search in not working in ADF.?

    Hi,
        I've created application in ADF with Search Options. Search Operation is working for all the Integer Values in that page but its not working for String Values.
    I dont know why its not able to search String Values.
    My AppModule bean Code :
                    package model.portfolio.portfolio.am;
    import model.portfolio.portfolio.am.common.PortfolioAppModuleAM;
    import model.portfolio.portfolio.view.ResourceViewChildObjImpl;
    import oracle.jbo.VariableValueManager;
    import oracle.jbo.ViewCriteria;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    public class PortfolioAppModuleAMImpl extends ApplicationModuleImpl implements PortfolioAppModuleAM {
         * This is the default constructor (do not remove).
        public PortfolioAppModuleAMImpl() {
        public void applyVCforGlobalSearchPortfolios(String theString){
            ViewObjectImpl vo = getPortfolio1();
            ViewCriteria vc = vo.getViewCriteria("PortfolioVOCriteria");
            System.out.println("On Criteria");
            vc.resetCriteria();
            VariableValueManager vvm = vc.ensureVariableManager();
            System.out.println("On String");
            vvm.setVariableValue("globalSearchString", theString);
            System.out.println("After String");
            vo.applyViewCriteria(vc,true);
            vo.executeQuery();
    *All Getters and Setter of all VO and VLs****
    My Query created in View Criteria :
    ( (UPPER(SHORTNAME) LIKE UPPER( :globalSearchString || '%') ) OR (UPPER(DESCRIPTION) LIKE UPPER( :globalSearchString || '%') ) AND (PROGRAMMES_COUNT = :globalSearchString ) OR (KK_COUNT = :globalSearchString ) OR (KPI_KRA_VALUE = :globalSearchString ) )
    One more interesting thing in After Creating the View Criteria If i try to Test this Query, Its giving me error msg as
    "Cannot complete query to determine the view attributes.  Either the query is invalid or timeout occurs.  Please revise the query or create the view attributes manually.
    "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':globalSearchString || '%') ) OR (UPPER(QRSLT.DESCRIPTION) LIKE UPPER( :globalSe' at line 1"
    I don know why... Can somebody please help me?
    Im using Jdev 12C

    Binding variables will be different from oracle database and My Sql database.
    Oracle database use this (:) for defining bindVariable but in My Sql use this (?)
    Try to remove the view criteria which you define in View Object and you can make it programmatically like this:
        ViewObject vo = getPortfolio1();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcr = vc.createViewCriteriaRow();
        vcr.setAttribute("Attribute1", value);
        vcr.setAttribute("Attribute2", value);
        vc.add(vcr);
        vo.applyViewCriteria(vc);
        vo.executeQuery();

  • String search in SAP Script and Smartforms

    Hi All,
    We have an urgent requirement where we need to search for a character string in all SAP Scripts and Smartforms in our system.
    It would also help if we can get the names of programs/function modules which are internally generated for the same.
    Any pointers on the same would be helpful.
    Regards,
    Saurabh

    You can create a variable window in the main window.
    You can restrict the last item of the main window by varying the size of main window. In your wite-form ,
    CALL FUNCTION 'WRITE_FORM'
          EXPORTING
             element                  = 'ITEM'
          function                 = 'SET'
          type                     = 'BODY'
          window                   = 'MAIN'
          EXCEPTIONS
            element                  = 1
            function                 = 2
            type                     = 3
            unopened                 = 4
            unstarted                = 5
            window                   = 6
            bad_pageformat_for_print = 7
            spool_error              = 8
            codepage                 = 9
            OTHERS                   = 10.
        IF sy-subrc <> 0.
    DO this. in the bottom of the main window, create a variable window.
    you can add your text in the variable window inside main window.
    it will be displayed just after the item ends.
    Reagrds,
    Pritha.
    Message was edited by:
            Pritha Agrawal

  • Test string equals syntax in configure.ac

    Hi all, I recently started a project that uses autoconf, and many examples around the place use the following syntax for string equality tests:
    if test "x$str" = "xyes"; then ...
    I was wondering why this is used as opposed to
    if test "$str" = "yes"; then ...
    which seems a bit more elegant and in plain bash seems to work fine (even with empty strings etc). Anyone know the reason why it is usually done the first way and not the second?

    but autoconf was made for POSIX sh (not sure what that supports exactly), and so many developers try to be overly cautious. I know we are not with the linux-only product.s.
    it might also be a holdover from people writing tests without the quotes, like  if x$var = xyes; then ...
    if you write without the x and $var is an empty string, you'll get a syntax error

  • Using Right {field, 5} in string search

    Hello,
    I have an array with the following data  xyz5 = 'US 10411', 'US 10421', 'US 10431', 'US 10441'
    The SN field is 5 character length with data such as 10411, 10421 10441 etc..
    How do I search for the last 5 digits of each of the data in the array?
    myaop6report.RecordSelectionFormula = "{aop5.SN}in right {[" & xyz5 & "],5}"
    Thankls,
    Victor

    Hi Victor,
    To search for the SN database field in the array, you can create a Record Selection Formula like:
           (" " + + ",") in (Join(YourArray,",")+",")
    Where should be replaced by your database fields that contains the SN number, and where YourArray is your array.
    The formula convert the array in a string seperated by commas.
    Then add a comma to your database field as well as a space in front. Finally it compare the SN fields to the long string.
    So for example if the database fields SN contains 10431, then the value we will search is: 
    10431,
    The array will now be a long string like:
    US 10411, US 10421, US 10431, US 10441,
    And it will look for the value 10431, in the string.
    The comma at the end and the space at the beginning it's to ensure it doesn't find any values that may exist within another one. It shouldn't be an issue in your case since it is always going to be equal to 5 characters for the SN value, but just in case it doesn't, we do not want to return 1043133 when we are searching for only 10431.
    Regards,
    Patrick

Maybe you are looking for

  • How to get an ImageIcon

    Hi! I havent found a method to get the absolute path of an ImageIcon/Image i produced this way: Image img; img = getToolkit().getImage( chooser.getSelectedFile().getAbsolutePath() ); jLabel9.setIcon( new ImageIcon( img ) ); I need a String with the a

  • Why does my ipad drop off the Internet frequently?

    Why does my ipad drop ff the Internet frequently? It will be going fine then just won't connect

  • Item text field

    HI      we develeping zreport in the report i need to add a column which has to show the data from po item text so fromwhich field and table i will get this inputs . Thanks & Regards, Raman.

  • Does anyone know what time ios7 will be available in AEST ?

    Does anyone know what time and date ios7 will be available in AEST/Brisbane? Thanks.

  • Connection Fail

    I just finished one fresh installation successfully for Edge package. The system is Windows Server 2003 x64 edition. When I test efashion sample, I found that all connection inside list got "The server is not responding! (SBO0001)" error. I checked D