Counting SPACES in a string field.

Hi ,
       can any one plz send me the code for counting the number of spaces in a particular string.
   like if we have the value as 100 00 0000.  we must get the out put as 2 .

try this...
DATA : str TYPE string VALUE '100 00 0000',
       str_len TYPE i,
       str_len2 TYPE i,
       space_count TYPE i.
str_len = STRLEN( str ).
CONDENSE str NO-GAPS.
str_len2 = STRLEN( str ).
space_count = ( str_len - str_len2 ).
WRITE :/ space_count.

Similar Messages

  • I want count "space" token in my table field and separate them

    I want count "space" token in my table one field column and separate the word between them.
    word are store in another table.
    possibly give solution in[b] Postgres DB and Oracle DB
    for example
    table name search
    column name is keyword
    keyword
    " chinese colaba" --> spaces are 2
    " chinese borivali (W)" --> spaces are 3
    " deal shoes bandra (E)" --> spaces are 4
    and separate word in new table
    field
    chinese
    colaba
    chinese
    borivali
    (W)
    deal
    shoes
    bandra
    E)
    Message was edited by:
    Rajiv_Birari

    Hi,
    Can you rephrase you Question..!!
    My understanding with your quesiton might be thinking about Partitions or Moving the data to Different tablespace.
    Thanks & Regards,
    Pavan Kumar N

  • PreparedStatement space and empty String

    Hi, I have this problem:
    PreparedStatement bookedQtyPS = null;
    String qry="SELECT * from djwsearch where djwitem=?;
    bookedQtyPS = conn.prepareStatement(qry);
    if(item.equals(""){ //item is an empty String
    bookedQtyPS.setString(1," "); // I set space instead of empty String
    }else{
    bookedQtyPS.setString(1,item);
    My problem is that I need to set space insteadOf empty String, but I think that I can not use PreparedStatement to do this. I have performance problems (my query is much more complicated than this one) so I choose PreparedStatement and not Statement.
    How can I do? Is this bug solved using PreparedStatement?
    Thanks.

    you can do it with the help of PreparedStatement.
    Here the type of field(djwitem) and setmethod is should be match..i mean if the type of ur field is String then you need to use the setSting method.
    you can do one thing specify one string variable.
    String space=" ";
    and now put this sapce variable at the second parameter of setString method.

  • Replacing inconsistant spacing with single space in a string

    is it possible to replace multiple spaces within a string with one space only. Number of spaces is different all the time.
    say one field contains strings with imbedded spaces
    I need to replace all these values so that there will be only one space between words.
    For Eg.
    Input                             Expected Result
    aaa    bbb                       aaa bbb
    ww                vv             ww vv
    ww ss      kk                    ww ss kk
    [/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    user11253970 wrote:
    I am in Oracle 9i :( I can not use reg exp
    Assuming strings do not contain CHR(0) (character with ascii code 0):
    SQL> SELECT  'aaa          bbb  aaa bbb' str,
      2          replace(replace(replace('aaa          bbb  aaa bbb',' ',' ' || CHR(0)),CHR(0) || ' '),CHR(0)) new_str
      3    FROM  dual
      4  /
    STR                                 NEW_STR
    aaa          bbb  aaa bbb           aaa bbb aaa bbb
    SQL> SY.

  • How to set a string field with people picker control group

    Hi Guys
    I have a problem with a form list, when I need to set a string field with de content of people picker control that have more than one "user".
    Is there any way to put in string a list of user like the people picker control shows in a form?
    The really problem is I don't know how to read an array of user in a formula rule.
    any example or idea should be appreciated.
    tnks.

    Hi ,
    Please try out in following way :
            /// <summary>
            /// Set value to people picket control
            /// </summary>
            /// <param name="key"></param>
            /// <param name="ppl"></param>
            /// <param name="item"></param>
            private void SetDatatoPeopleEditor(string key, PeopleEditor ppl, SPListItem item)
                try
                    if (item[key] != null)
                        string users = string.Empty;
                        SPFieldUserValueCollection userCol = new SPFieldUserValueCollection(web, item[item.Fields.GetField(key).Id].ToString());
                        foreach (SPFieldUserValue usrItm in userCol)
                            users += usrItm.User.ToString() + ",";
                        ppl.CommaSeparatedAccounts = users.Remove(users.LastIndexOf(","), 1);
                catch (Exception ex)
                    lblErrorMessage.Text = ex.Message;
    private SPUser GetAccountName(PeopleEditor accountPE)
                SPUser user = null;
                string strAccountName = String.Empty;
                try
                    for (int i = 0; i < accountPE.ResolvedEntities.Count; i++)
                        PickerEntity objEntity = (PickerEntity)accountPE.ResolvedEntities[i];
                        user = web.AllUsers[objEntity.Key];
                    return user;
                catch (Exception ex)
                return user;
    It works for me .

  • How to transfer trailing spaces in the source field type c

    Hello,
    I have to splitt a string key of 120 characters into two InfoObjects (CHAR). The problem is, that the trailing spaces are lost in the character Field.
    Has anybody an idea to avoid the lost?
    Thank you.
    Conversion Table for Source Field Type c
    The characters in the source field are inserted in the target field, left-aligned. Trailing spaces in the source field are not transferred. If the target field is longer than the number of characters transferred, it is filled with blank characters to the right. If the target field is shorter, the number is truncated from the right.

    Hi ,
    Create two Characteristic InfoObjects in BW With length 60 Char  and then in the Transfer Rules of this two InfoObjects write the Formula using Left() and right() function present in the Formula Builder .
    That is First infoObject Contains the Left 60 Char and next one Contains the right 60 Char.
    Regards,
    Vijay.

  • Removing number appended at the end from a string field

    Hi,
    I have a string field which has numbers appended to its end. I need to remove the numbers and display only the string values.
    The string is not of fixed length, and the numeric values can be single digit or 2 digits and might be separate by a space but not always.
    Here is some sample data:
    SHOWCASE NOTT12
    SHOWCASE PETE12
    SHOWCASE BRIST7
    SHOWCASE READI1
    CINEDROME PAD1
    RITZ BELPER   1
    STEPH.JOSEPH S1
    I need to display this as below (without any numbers appended at the end)
    SHOWCASE NOTT
    SHOWCASE PETE
    SHOWCASE BRIST
    SHOWCASE READI
    CINEDROME PAD
    RITZ BELPER  
    STEPH.JOSEPH S
    Please let me know how this can be achieved.
    Thanks!

    Hi there,
    Just a quick option is to use the REPLACE function, i.e.
    REPLACE(REPLACE(REPLACE({contr_actv.dept_id},'1' ,''),'2', ''), '3', '');
    You just have to build it up a little more so it caters for numbers 0 - 9.  At the moment it only works for numbers 1 - 3.  Another way you could do this is write some code to loop through the length of the string looking at each individual character to test for a number.
    I don't have time today to write something like that but the above should work as long as you don't have numbers in the middle of names etc.
    Cheers,
    Chris

  • How to replace multiple occurences of space in a string to a single space?

    How to replace multiple occurences of space in a string to a single space?

    Hi,
    try this code.
    data : string1(50) type c,
              flag(1) type c,
              dummy(50) type c,
              i type i,
              len type i.
    string1 = 'HI  READ    THIS'.
    len = strlen( string1 ).
    do len times.
    if string1+i(1) = ' '.
    flag = 'X'.
    else.
    if flag = 'X'.
    concatenate dummy string1+i(1) into dummy separated by space.
    clear flag.
    else.
    concatenate dummy string1+i(1) into dummy.
    endif.
    endif.
    i = i + 1.
    enddo.
    write : / string1.
    write : / dummy.

  • Add a carriage return in a Unbound String Field

    Post Author: Razzle00
    CA Forum: Formula
    Hi,
         How can I add a carriage return to an unbound string field in a crystal report.  I am using the bundled version of CR with MS Visual Studio 2003 & 2005.  My formula needs to look something like this....
    'Heading One:' + CARRIAGE RETURN + trim({tablename.fld_1}) + CARRIAGE RETURN + 'Heading Two:' + CARRIAGE RETURN  + trim({tablename.fld_2})
    this code all needs to be in 1 unbound string field.  Is this possible?
    Thanks,
    Razzle

    Post Author: SKodidine
    CA Forum: Formula
    To add a carriage return, add CHRW(13)
    For example:
    'Heading One:' & chrw(13) & 'sample text';
    will result in:
    Heading One:
    sample text

  • A record selection problem with a string field when UNICODE database

    We used report files made by Crystal Reports 9 which access string fields
    (char / varchar2 type) of NON-UNICODE database tables.
    Now, our new product needs to deal with UNICODE database, therefore,
    we created another database schema changing table definition as below.
    (The table name and column name are not changed.)
        char type -> nchar type
        varchar2 type -> nvarchar2 type
    When we tried to access the above table, and output a report,
    the SQL statement created from the report seemed to be wrong.
    We confirmed the SQL statement using Oracle trace function.
        SELECT (abbr.) WHERE "XXXVIEW"."YYY"='123'.
    We think the above '123' should be N'123' because UNICODE string
    is stored in nchar / nvarchar2 type field.
    Question:
    How can we obtain the correct SQL statement in this case?
    Is there any option setting?
    FYI:
    The environment are as follows.
        Oracle version: 11.2.0
        ODBC version: 11.2.0.1
        National character set: AL16UTF16

    With further investigating, we found patterns that worked well.
    Worked well patters:
        Oracle version: 11.2.0
        ODBC version: 11.2.0.1
        National character set: AL16UTF16
        Report file made by Crystal Reports 2011
        Crystal Reports XI
    Not worked patters:
        Oracle version: 11.2.0 (same above)
        ODBC version: 11.2.0.1 (same above)
        National character set: AL16UTF16 (same above)
        Report file made by Crystal Reports 2011 (same above)
        Crystal Reports 2008 / 2011
    We think this phenomenon is degraded behavior of Crystal Reports 2008 / 2011.
    But we have to use the not worked patters.
    Anything wrong with us? Pls help.
    -Nobuhiko

  • Edirectory ldap, what do I put in the DN String field?

    Experts,
    I am trying to configure LDAP authentication. I've done this many, many times against Active Directory. In AD it is usually DOMAIN_NAME\%LDAP_USER%.
    This has been driving me nuts today. We are running eDirectory. I have my server's IP address and port.
    What do I put in the DN String field? I've tried many combinations of TREENAME\%LDAP_USER%, nothing seems to work.
    If it is more complicated than that, where do I look in NDS to figure out what I need to put in the DN String field?
    Thanks!
    Dan

    Dan,
    I'm actually surprised you had success with that on AD as I never did. I recommend you get a little lower level and use DBMS_LDAP. Here's a little sample code to get you started:
       FUNCTION ldap_authenticate (
          p_username IN VARCHAR2
        , p_password IN VARCHAR2
          RETURN BOOLEAN
       AS 
          l_dn      VARCHAR2(256) := p_username || '@domain.com';
          l_bind    PLS_INTEGER;
          l_session DBMS_LDAP.SESSION;
       BEGIN
          IF p_username IS NULL
          THEN
             RAISE_APPLICATION_ERROR(-20001,'A username must be supplied');
          END IF;
          IF p_password IS NULL
          THEN
             RAISE_APPLICATION_ERROR(-20002,'A password must be supplied');
          END IF;
          dbms_ldap.use_exception := TRUE;
          l_session := dbms_ldap.init(
             hostname  =>  'server.domain.com'
           , portnum   =>  389
          l_bind := dbms_ldap.simple_bind_s(
             ld      =>  l_session
           , dn      =>  l_dn
           , passwd  =>  p_password
          l_bind := dbms_ldap.unbind_s(l_session);
          RETURN TRUE;
    EXCEPTION
       WHEN OTHERS
       THEN
          RETURN FALSE;
    END;Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen

  • Stripping extra white space from a string

    I am trying to strip extra spaces from a string, so it there are 2 or more spaces between a word I want to remove all but one. I am trying the following code
    getStringTwo().replaceAll("/\s+/is","");
    but all I get is an error saying Invalid escape sequence
    Thanks
    G

    >
    This strips out all the whitespace. I ended up
    getting round it by walking through the string and
    checking the values of each char and comparing that
    to the next value. What a wast of effortt A small modification of my earlier post gives -
    public class Test040320a
        public static void main(String[] args)
            String str = "this    is       a \t test";
            str = str.replaceAll("\\s+"," ");
            System.out.println(str);
    }

  • Purpose of using string field

    how to use string field and its purpose...

    STRING: Character string with variable length This data type can be used only in types (data elements, structures, table types) and domains. In the dictionary a length can be specified for this type (at least 256 characters). It can be used in database tables only with restrictions. For a description of them, refer to the documentation of the ABAP statement 'STRING'. In ABAP, this type is implemented as a reference to a storage area of variable size. The system proposes 132 characters as default for the output length. You cannot attach search helps to components of this type.
    SSTRING: Short character string with variable length. In the Dictionary the number of characters can be specified for this type (from 1 to 1333). This data type can be used only in types (data elements, structures, table types) and domains. It can be used in database tables. To do so, refer to the documentation of the ABAP statement 'STRING'. In ABAP, this type is implemented as a reference to a storage area of variable size. String fields of this type can be used in indexes and in the WHERE condition of a SELECT statement. You cannot use them in table keys

  • Remove blank spaces in a text field?

    How can I remove blank spaces in a text field? Some text fields have a lot of blank fields that need to be removed so that I can report only on the text.
    CRXI
    Edited by: Burton Roger on Feb 10, 2009 5:48 PM

    Ex:
    "Hi,
    I have a need for monthly service desk reporting.
    Please provide data on single sheet.
    Thank you"
    I would like to shrink it down to -
    Hi, I have a need for monthly service desk reporting. Please provide data on single sheet. Thank you"

  • String Field rendering as Number Field in CR Basic for VS2008

    I recently migrated from CR for VS2005 to CR Basic for VS2008 and am creating my first report using CR 2008. The SQL result set returns rows containing strings (nvarchar), integers and decimal (7,2) fields.
    The report is getting all rows in the result set, but the string fields as defined in the SQL are 1) rendering in the report as numbers, and 2) showing as empty. The non-string fields render fine. I tried reformatting the report field to string, but only the Number tab appears in the formatting dialog. I also tried converting the SQL field result into an unbound string field, as well as tried the ToText function, but the results were the same. I suspect the field appears empty because of the formatting issue.
    How can I get CR Basic for VS2008 to render a string (nvarchar) field as a string?

    Try placing the field inside a formula field or inside a text field.  That should cause the field to be shown no matter what type of data it is.  If the data is still not showing, then perhaps it is not being returned properly. 
    Things to check:
    -Are you connecting directly to the tables - or are you connecting to a stored procedure?  If you are connecting to a stored procedure and you are using Temp Tables, then make sure you add the line "SETNOCOUNT ON" to your stored proc.
    -Run SQL profiler - see what query is being made, then try running that exact same query through the SQL admin console (Or some other utility that lets you run SQL queries)
    Thanks
    Shawn

Maybe you are looking for