How to find number of characters in a character string

Hi,
  Can anyone please tell me about how to find the number of characters in a character string type variable.
Reagards,
Siva

hi,
Use STRLEN for Calculating String Length..
Assign it to integer variable for Further Use.Suppse u need to find string length for "hai".. this piece of code will help u
data:  var type string value 'hai',
         len type i.
len = strlen(var).
write len.

Similar Messages

  • How to find number of lines in an internal table

    Dear all,
    how to find number of records present in an internal table.

    DESCRIBE TABLE
    Syntax
    DESCRIBE TABLE itab [KIND knd] [LINES lin] [OCCURS n].
    Extras:
    1. ... KIND knd
    2. ... LINES lin
    3. ... OCCURS n
    Effect
    This statement determines some properties of the internal table itab and assigns them to the specified variables. The various additions enable you to determine the table type, the number of currently filled rows and the initial memory requirement.
    In addition, the system fields sy-tfill and sy-tleng are filled with the current number of table rows and the length of a table row in bytes.
    Notes
    For detailed information about an internal table, you should use the methods of RTTS of the DESCRIBE TABLE statement.
    Without the specification of an addition, the statement DESCRIBE TABLE only sets the system fields sy-tfill and sy-tleng.
    Addition 1
    ... KIND knd
    Effect
    The table type of the internal table itab is determined and a corresponding one-digit identification is assigned to the data object knd. A character-type data type is expected for the data object. The identifications are "T" for standard tables, "S" for sorted tables and "H" for hashed tables. These values are also defined as constants sydes_kind-standard, sydes_kind-sorted, and sydes_kind-hashed in the type group SYDES.
    Addition 2
    ... LINES lin
    Effect
    The current number of table rows of the internal table itab is determined and is assigned to the data object lin.The data type i is expected for the data object.
    Note
    As of release 6.10, the current number of rows of an internal table can also be determined using the in-built function lines.
    Addition 3
    ... OCCURS n
    Effect
    The initial memory requirement defined during the creation of the internal table with the addition INITIAL SIZE or the obsolete addition OCCURS is determined and assigned to the data object n. The data type i is expected for the data object.
    Example
    Descending sorting of a generically typed internal table in a subprogram. Since sorted tables cannot be sorted in a descending order, the table type is checked to avoid an exception that cannot be handled.
    TYPE-POOLS sydes.
    FORM sort_descending CHANGING itab TYPE ANY TABLE.
      DATA tabkind(1) TYPE c.
      DESCRIBE TABLE itab KIND tabkind.
      IF tabkind = sydes_kind-standard OR
         tabkind = sydes_kind-hashed.
        SORT itab DESCENDING.
      ELSEIF tabkind = sydes_kind-sorted.
        MESSAGE '...' TYPE 'E'.
      ELSE.
        MESSAGE '...' TYPE 'E'.
      ENDIF.
    ENDFORM.
    DESCRIBE FIELD INTO
    Note
    This statement is for internal use only.
    It cannot be used in application programs.
    Syntax
    DESCRIBE FIELD dobj INTO td.
    Effect
    All characteristics of the field f, its components , sub-components etc. are displayed in the field td (type description). td has to be of the type SYDES_DESC, defined in Type Group SYDES. Because of this, the type group SYDES must be integrated into the ABAP-program with a TYPE-POOLS statement .
    The structure SYDES_DESC has two table-type components TYPES and NAMES:
    In TYPES, the tree structure of the type belonging to f is displayed. The components of a node are stored in the table TYPES in a continuous manner. Beginning and end of the line area that represents the components are stored in TYPES-FROM and TYPES-TO. The reference to the superior node can be found in TYPES-BACK. If no superior resp. subordinate node exists, then this is marked by the value 0 (For the relevance of further components, refer to the following sections).
    The names of components, types etc. are not stored directly in TYPES. Instead, the components TYPES-IDX_... hold an index in the name table NAMES. The value 0 indicates that there is no reference to the name table.
    NAMES contains the possibly fragmented names in the component NAMES-NAME. If a name continues in the following line, this is indicated by an asterisk ('*') in the component NAMES-CONTINUE.
    The type description table (TYPES) not only stores information about the tree structure but also further information about the type of f resp. its components. This includes especially all information that can be determined using the usual additions to DESCRIBE FIELD. In detail, TYPES contains the following columns:
    IDX_NAME
    Component Name
    IDX_USER_TYPE
    Name of a user-defined type, i.e., a type that was defined through its TYPES-statement. Derived types (... TYPE A-B) and structures from the ABAP-Dictionary are not considered to be user-defined types.
    CONTEXT
    For user-defined types only: The context, in which the type is defined. Possible values are defined in the constant SYDES_CONTEXT of the type group SYDES. Please only use these constants to carry out a comparison. In detail, we distinguish between the following type contexts:
    SYDES_CONTEXT-PROGRAM: Program-global type
    SYDES_CONTEXT-FORM   : FORM-local type
    SYDES_CONTEXT-FUNCTION: FUNCTION-local type
    SYDES_CONTEXT-METHOD : METHOD-local type
    IDX_CONTEXT_NAME
    For user-defined types only:
    With a local context: The name of the FORM or FUNCTION, whose type was defined. The name of the associated program is then the first entry in the name table.
    With a global context: The name of the program in which the type was defined.
    IDX_EDIT_MASK
    Conversion routine from the ABAP-Dictionary, is in accordance with the addition EDIT MASK at simple DESCRIBE.
    IDX_HELP_ID
    Help-Id when referencing to fields from the ABAP-Dictionary
    LENGTH
    Internal length, corresponds to the addition LENGTH at simple DESCRIBE
    OUTPUT_LENGTH
    Output length, corresponds to the addition OUTPUT-LENGTH at simple DESCRIBE
    DECIMALS
    Number of decimal digits, corresponds to the addition DECIMALS at simple DESCRIBE
    TYPE
    ABAP-Type, corresponds to the addition TYPE at simple DESCRIBE
    TABLE_KIND
    A table type is stored here for the components which represent an internal table. The same values are returned as with the variant DESCRIBE TABLE itab KIND k. Components which do not represent a table get the return value set to SYDES_KIND-UNDEFINED (see type group SYDES).
    Example
    Example definition of the complex data type EMPLOYEE_STRUC:
    PROGRAM DESCTEST.
    TYPES: BEGIN OF name_struc,
             first  TYPE c LENGTH 20,
             last   TYPE c LENGTH 20,
           END OF name_struc,
           BEGIN OF absence_time_struc,
             day        TYPE d,
             from       TYPE t,
             to         TYPE t,
           END OF absence_time_struc,
           phone_number TYPE n LENGTH 20,
           BEGIN OF employee_struc,
             id         LIKE sbook-customid,
             name       TYPE name_struc,
             BEGIN OF address,
               street  TYPE c LENGTH 30,
               zipcode TYPE n LENGTH 4,
               place   TYPE c LENGTH 30,
             END OF address,
             salary_per_month TYPE p LENGTH 10 DECIMALS 3,
             absent           TYPE STANDARD TABLE OF absence_time_struc
                                   WITH NON-UNIQUE DEFAULT KEY,
             phone            TYPE STANDARD TABLE OF phone_number
                                   WITH NON-UNIQUE DEFAULT KEY,
           END OF employee_struc.
    You can determine the structure of the type EMPLOYEE_STRUC by collecting the type group SYDES as follows:
    TYPE-POOLS: sydes.
    DATA: employee TYPE employee_struc,
          td       TYPE sydes_desc.
    DESCRIBE FIELD employee INTO td.
    The following table shows a few selected columns of the type description table TD-TYPES. For a better overview, the names of the columns IDX_NAME, IDX_UERR_TYPE and IDX_EDIT_MASK have been shortened:
        |FROM| TO |BACK|NAME|UTYP|EMSK|TYPE
    |--||||||--
      1 |  2 |  7 |  0 |  0 |  2 |  0 |  v
      2 |  0 |  0 |  1 |  6 |  0 |  4 |  N
      3 |  8 |  9 |  1 |  7 |  5 |  0 |  u
      4 | 10 | 12 |  1 |  8 |  0 |  0 |  u
      5 |  0 |  0 |  1 |  9 |  0 |  0 |  P
      6 | 13 | 13 |  1 | 11 |  0 |  0 |  h
      7 | 17 | 17 |  1 | 12 |  0 |  0 |  h
      8 |  0 |  0 |  3 | 13 |  0 |  0 |  C
      9 |  0 |  0 |  3 | 14 |  0 |  0 |  C
    10 |  0 |  0 |  4 | 15 |  0 |  0 |  C
    11 |  0 |  0 |  4 | 16 |  0 |  0 |  N
    12 |  0 |  0 |  4 | 17 |  0 |  0 |  C
    13 | 14 | 16 |  6 |  0 | 18 |  0 |  u
    14 |  0 |  0 | 13 | 20 |  0 |  0 |  D
    15 |  0 |  0 | 13 | 21 |  0 |  0 |  T
    16 |  0 |  0 | 13 | 22 |  0 |  0 |  T
    17 |  0 |  0 |  7 |  0 |  0 |  0 |  N
    Please note that the entries in rows 6 and 7 represent internal tables (ABAP-Type h). There is always an entry for the corresponding row type (rows 13 and 17) to an internal table.
    The indices in the rows 5 to 7 refer to entries in the name table TD-NAMES. If you look, e.g., at row 3, you find the corresponding component name in TD-NAMES from row 7 (NAME) onward and the corresponding user type from row 5 (NAME_STRUC) onward.
    In the name table TD-NAMES you find the following entries. Note that the names SALARY_PER_MONTH and ABSENCE_TIME_STRUC are stored in two parts:
        |CONTINUE|NAME                   |CONTINUE|NAME
    |--|     -||--
      1 |        |DESCTEST            12 |        |PHONE
      2 |        |EMPLOYEE_STRUC      13 |        |FIRST
      3 |        |SBOOK-CUSTOMID      14 |        |LAST
      4 |        |==ALPHA             15 |        |STREET
      5 |        |NAME_STRUC          16 |        |ZIPCODE
      6 |        |ID                  17 |        |PLACE
      7 |        |NAME                18 |   *    |ABSENCE_TIME_ST
      8 |        |ADDRESS             19 |        |RUC
      9 |   *    |SALARY_PER_MONT     20 |        |DAY
    10 |        |H                   21 |        |FROM
    11 |        |ABSENT              22 |        |TO

  • How to find number of files in a folder using pl/sql

    please someone guide as to how to find number of files in a folder using pl/sql
    Regards

    The Java option works well.
    -- results table that will contain a file list result
    create global temporary table directory_list
            directory       varchar2(1000),
            filename        varchar2(1000)
    on commit preserve rows
    -- allowing public access to this temp table
    grant select, update, insert, delete on directory_list to public;
    create or replace public synonym directory_list for directory_list;
    -- creating the java proc that does the file listing
    create or replace and compile java source named "ListFiles" as
    import java.io.*;
    import java.sql.*;
    public class ListFiles
            public static void getList(String directory, String filter)
            throws SQLException
                    File path = new File( directory );
                    final String ExpressionFilter =  filter;
                    FilenameFilter fileFilter = new FilenameFilter() {
                            public boolean accept(File dir, String name) {
                                    if(name.equalsIgnoreCase(ExpressionFilter))
                                            return true;
                                    if(name.matches("." + ExpressionFilter))
                                            return true;
                                    return false;
                    String[] list = path.list(fileFilter);
                    String element;
                    for(int i = 0; i < list.length; i++)
                            element = list;
    #sql {
    insert
    into directory_list
    ( directory, filename )
    values
    ( :directory, :element )
    -- creating the PL/SQL wrapper for the java proc
    create or replace procedure ListFiles( cDirectory in varchar2, cFilter in varchar2 )
    as language java
    name 'ListFiles.getList( java.lang.String, java.lang.String )';
    -- punching a hole in the Java VM that allows access to the server's file
    -- systems from inside the Oracle JVM (these also allows executing command
    -- line and external programs)
    -- NOTE: this hole MUST be secured using proper Oracle security (e.g. AUTHID
    -- DEFINER PL/SQL code that is trusted)
    declare
    SCHEMA varchar2(30) := USER;
    begin
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.io.FilePermission',
    '<<ALL FILES>>',
    'execute, read, write, delete'
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.lang.RuntimePermission',
    'writeFileDescriptor',
    dbms_java.grant_permission(
    SCHEMA,
    'SYS:java.lang.RuntimePermission',
    'readFileDescriptor',
    commit;
    end;
    To use:
    SQL> exec ListFiles('/tmp', '*.log' );
    PL/SQL procedure successfully completed.
    SQL> select * from directory_list;
    DIRECTORY FILENAME
    /tmp X11_newfonts.log
    /tmp ipv6agt.crashlog
    /tmp dtappint.log
    /tmp Core.sd-log
    /tmp core_intg.sd-log
    /tmp da.sd-log
    /tmp dhcpclient.log
    /tmp oracle8.sd-log
    /tmp cc.sd-log
    /tmp oms.log
    /tmp OmniBack.sd-log
    /tmp DPISInstall.sd-log
    12 rows selected.
    SQL>

  • How to Identify the Same Characters in 2 Different Strings

    Hi All,
    I am requiring a suggestion on how to identify the same characters in 2 different Strings, for example:
    String str1 = "hello";
    String str2 = "llheo";
    Both Strings contain the same characters, but in a different order, so what would be the best technique to verify t that both Strings indeed contain the same characters?
    I was personally thinking along the lines of using the class, java.util.regex.Pattern?
    Any thoughts would me much appreciated. Thanks

    I would instead sort the characters, and then compare
    the sorted data.
    I'm fealing generous
        private static boolean anagram(String left, String right)
            if (left.length() != right.length())
                return false;
            char[] leftChars = left.toCharArray();
            char[] rightChars = right.toCharArray();
            Arrays.sort(leftChars);
            Arrays.sort(rightChars);
            return Arrays.equals(leftChars, rightChars);
        }

  • How to restrict number of characters for an input field

    Hi All,
    I have an input field.
    The max number of characters for this input field is 10.
    when a user enter more then 10 characters. it should prompt for an error or the input field should not allow to accpet the 11 character.
    how we do this in VC.
    need your helpful answers
    Rgds
    Srinivas

    Hi Srinu
    You could achieve this by configuring error messages under the formula:-
    Select the control properties and in the Input field at the Display tab write the formula
    "IF((@<LEN(text)>10),'appropriate message','Records available')"
    Note :- there is a LEN(text) under text functions in formula tab.
    Regards
    Navneet
    Message was edited by:
            Navneet Giria

  • How to find the 'special characters' window

    Hi,
    Frequently I want to access the 'special characters' window, but when I click on the 'special characters' menu item the window does not appear. Sometimes I later find it on another screen (I use nine screens in Spaces), and sometimes can I see it on another screen using Expose, but when I go there it has disappeared. It seems a very fugitive tool, and in its way displays some cute, personality........ But I would love to know how to find it or to force it to appear on the same screen as the application from which I tried to open it!
    all the best,
    Jeremy Harbinson

    Hi,
    Thanks for the reply.
    I tried what you suggest - in the International section of the System Preferences there is a tab labelled 'input menu' and there is a check box (which is checked) titled 'Show input menu in Menu bar'. Unchecking that removes a national flag from the the menu bar, checking it restores that flag. So far, so good. If a click on the flag, a drop down menu appears with 'Hide character palette' as an item - clicking this changes it state to 'Show character palette' but clicking this (several times) changes nothing else that I can see,
    all the best,
    Jeremy

  • How to find which junk characters are there in the string

    Hi Guys in my employee table ,I have a field name emp_name
    and the data inside one of the record is 'BUSH ';
    after trimming it ... length(trim(emp_name)) ... I expected the length to be 4,but it still returns 5.So I am wondering what that extra characters after H is.
    Can some one tell me how to find it.
    thanks in advance.

    Hmmm. What you describe is not the behaviour I would expect from a CHAR(10) column. I would expect this:
    SQL> CREATE TABLE bt (col1 CHAR(10));
    Table created.
    SQL> INSERT INTO bt VALUES ('BUSH ');
    1 row created.
    SQL> SELECT length(col1) FROM bt;
    LENGTH(COL1)
              10
    SQL> SELECT length(trim(col1)) FROM bt;
    LENGTH(TRIM(COL1))
                     4
    SQL> What version of the database are you using? Also, what does this query give you?
    SELECT ascii(substr(ename, 5,1))
    FROM emp
    WHERE  substr(ename,1,4) = 'BUSH';Cheers, APC

  • How to find number missing

    Hi,
      How to find the missing number(not number range) .Is there any functional module is there for missing nos.
    ex: i have nos. from 50 to 100 & no.79 is missed.
    For this issue if any functional module is there pls let me Know.
    Thanks & Regards
    Venkat

    Not sure about a function, but you could create your own function and use this logic.
    REPORT  zrich_0001.
    TYPES: BEGIN OF ttab,
           number TYPE i,
           END OF ttab.
    DATA: itab TYPE TABLE OF ttab.
    DATA: wa LIKE LINE OF itab.
    DATA: tmp LIKE LINE OF itab.
    DATA: diff TYPE i.
    DATA: rows TYPE i.
    DATA: low_number TYPE i.
    DATA: high_number TYPE i.
    DATA: tmp_number TYPE i.
    * Build an internal table with all the numbers
    wa-number = 50.  APPEND wa TO itab.
    DO 50 TIMES.
      wa-number = wa-number + 1.  APPEND wa TO itab.
    ENDDO.
    * Create some missing numbers in the table
    DELETE itab WHERE number = 63.
    DELETE itab WHERE number = 64.
    DELETE itab WHERE number = 65.
    DELETE itab WHERE number = 79.
    sort itab ASCENDING .
    * find the low value.
    clear wa.
    READ TABLE itab INTO wa INDEX 1.
    IF sy-subrc = 0.
      low_number = wa-number.
    ENDIF.
    * Get the high value
    rows = LINES( itab ).
    clear wa.
    READ TABLE itab INTO wa INDEX rows.
    IF sy-subrc = 0.
      high_number = wa-number.
    ENDIF.
    * Now find the missing numbers.
    tmp_number = low_number.
    DO.
      IF tmp_number = high_number.
        EXIT.
      ENDIF.
      READ TABLE itab INTO wa with key number = tmp_number.
      IF sy-subrc <> 0.
        WRITE:/ tmp_number.
      ENDIF.
      tmp_number = tmp_number + 1.
    ENDDO.
    Regards,
    Rich Heilman

  • How to find number for registering iLife11?

    I've just bought iLife 11 and wants to register. Has to provide a number towards the end of the registration process. I tried the Part no. - the number below the barcode (7 digits) and the number o the barcode but none of them can be approved...
    Any idea on how to find the required number?

    Don't want to insult you but this is a typical Microsoft reply, probably true but totally useless. What the hec is the marketing number on the sticker?
    There is a partno (not accepted), a number under the barcode which seems to consist of four different parts, and a fat-printed code starting off with "AKP". Whichone is the correct one?
    Thanks in advance for your reply.

  • How to find number from text string??

    Hi All,
    Can you tell me how to find/ fetch number from string?
    is there any function module  for this.?
    for example , I have string like "+++++1000000589+++"
    and I need to fetch the invoice no 1000000589 from the above string..then  How to do that? Letters may come first or number may come first and latter text...
    Regards,
    Mrunal

    You can do like this.
    The below mentioned is code separate material
        DO 18 TIMES.
          LV_C = LV_C + 1.
          LV_C1 = LV_C - 1.
          IF  GW_MATNR-MATNR+LV_C1(1) CN '0,1,2,3,4,5,6,7,8,9' .
            IF ( ( LV_MAT EQ SPACE ) ) ."  and ( lv_prefix eq space ) ) .
              LV_PREFIX = 'X'.
              CONCATENATE GW_TEMP-PREFIX GW_MATNR-MATNR+LV_C1(1) INTO
              GW_TEMP-PREFIX.
            ELSE.
              LV_SUFFIX = 'X'.
              CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
              GW_TEMP-SUFFIX.
            ENDIF.
          ELSEIF ( ( LV_SUFFIX EQ SPACE ) ) .
            LV_MAT = 'X'.
            CONCATENATE GW_TEMP-MATNR1 GW_MATNR-MATNR+LV_C1(1) INTO
            GW_TEMP-MATNR1.
          ELSEIF ( ( LV_MAT EQ 'X' ) ) .
            CONCATENATE GW_TEMP-SUFFIX GW_MATNR-MATNR+LV_C1(1) INTO
            GW_TEMP-SUFFIX.
          ENDIF.
        ENDDO.

  • How to find number of users logged into ODI

    Hi Experts,
    I am using ODI 11g in linux environment. I have created 15 users in system manager tab.
    My query is, how to find ODI11g logged in users list
    For Example, out of 15 users, 7 users are accessing ODI, how to fetch 7 users name list.
    Is there any query to find fetch the list
    Can any one please help me out
    Thanks in Advance
    Regards,
    PK
    Edited by: 917775 on Jun 21, 2012 11:52 PM

    Hi Rai,
    Thank you for the response
    I have verified already with v$session table, it seems how database user are login (lie it show the status as Active and InActive in status column) but I want to know the staus for how users are login into ODI.
    I have verified with SNP_USER table also, no uses of the.
    Any help on same
    Thanks in advance
    Regards,
    Phanikanth

  • How to set number of characters in input field ?

    I am creating an input field dynamically (via CL_WD_INPUT_FIELD).
    I am binding the value (via BIND_VALUE) to an attribute with type CHAR30.
    I want to give the possibility to enter a number with 4 digits (0 - 9999).
    Is it possible to restrict the number of characters that can be entered to 4 (although the BIND_VALUE attribute has a type CHAR30, that allows 30)?
    I have tried it via set_length, bind_length but it seems that the length of the BIND_VALUE attribute overrules the length information...

    Hi Moritz,
    AFAIk you have no other option as using a NUM4 here.
    Set Length just sets the lengths of the inputfield according to the current character set ... count of charcters but does not limit the value you may enter
    Cheers
    Sascha

  • How to find missing glyphs / characters

    hi,
    is there a way to find missing glyphs / characters (that are not contained in a font and thus displayed as pinkish rectangles) in a text?
    I thought there might be a metacharacter or a variable of the Text object, but I couldn't find anything.
    thanks,
    w

    Try scripting a preflight check

  • How to find unicode equialent for a dbcs character

    I have one requirement from client to display DBCS ( Chinese, Japanese, etc.., ) characters in their equivalent unicode format. Every DBCS character should be displayed like &#xxx; in XML. In our project we create the XML dynamically. When we get the data initially we get it in DBCS. We need to convert that DBCS data character by character to the corresponding unicode values and put it in the XML that we create.
    My questions are :
    How to find out whether a particular character is a unicode character first ?
    I need your help on how to find the unicode equivalent values for each dbcs character ?

    Hopefully you get that data in some charset. You should not have to deal with low-level character conversion, just read the data into strings using that charset. (You can use the form of InputStreamReader that takes a charset name as the second parameter.) Put the strings into XML and when you write out the XML, the serializer will take care of putting valid and consistent data into the document. (That's assuming you're using a serializer that somebody else wrote and not just plain old Java I/O.)
    Looks to me like the hard part will be getting your client to tell you what charset the data is encoded in.

  • Function in oracle to find number of occurances of a character in a string

    hi,
    is there any function in oracle to find the number of ocurrances of a character in a string ?
    or is there any simple way of doing the same, rather than writting many lines of code as my program is already very complex.
    Maria

    Hi Maria,
    I don't know of such a function in Oracle, but maybe you could use this:
    length(search_string) - length(replace(search_string, character_to_be_found))
    For example: select length('Hello') - length ( replace('Hello', 'l')) from dual;
    Hope this is what you're looking for
    Danny

Maybe you are looking for