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

To eliminate non-numeric values in a table-field

Hi all,

I have written a select statement to the table ADRC and extracting field values of SORT2(length 20 characters) from that table into internal table.

My problem is to extract only the non-numeric field values from the database table.

Can we incorporate this condition in the select statement.

If not, how to eliminate the non-numeric fields from the internal table.

Can you please send me code for this purpose

Hope you will respond as soon as possible.

Thank you,

Shalem.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 01:04 PM

    hi

    use

    this for internal table in loop.

    loop at itab.

    • Check this logic

    itab-field1 CO '1234567890.'.

    • delete condition

    delete itab.

    endif.

    Hi U can also Check FM : <b>NUMERIC_CHECK</b>

    if it does not take care of Decimal point

    therefore ur actual code will be like this

    <b>loop at itab.
       if  itab-field1 CO '1234567890.'.
           delete itab.
       endif.
    Endloop.
    </b>

    <b>CO (Contains Only):</b>

    c1 contains only characters from the string c2.

    If c1 or c2 is of type C, the comparison takes into account the full length of the field, including blanks at the end.

    comparison.

    If c1 is of type STRING and empty, the result of the comparison is always positive.

    If c2 is of type STRING and empty, the result of the comparison is always negative, unless c1 is also an empty string.

    If the result of the comparison is negative, the field SY-FDPOS contains the offset of the first character in c1 which is not also included in c2.

    If the result of the comparison is positive, the system field SY-FDPOS contains the length of c1.

    The comparison is case-sensitive.

    Examples:

    'ABCDE' CO 'XYZ' is false; SY-FDPOS = 0.

    'ABCDE' CO 'AB' is false; SY-FDPOS = 2.

    'ABCDE' CO 'ABCDE' is true; SY-FDPOS = 5.

    <b>CN (Contains Not only):</b>

    "c1 CN c2" is equivalent to " NOT ( c1 CO c2 )".

    c1 contains not only characters from c2.

    If the result of the comparison is positive, the system field SY-FDPOS contains the offset of the first character in c1 which is not also in c2.

    If the result of the comparison is negative, the system field SY-FDPOS contains the length of c1.

    <b>

    Please mark Helpful Answers & Reward Point

    Hope ur Problem Is Solved.

    Regards

    </b>

    Message was edited by: Manoj Gupta

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 15, 2006 at 01:16 PM

    Hi,

    Try something like this:

    DATA: itab    TYPE TABLE OF adrc,
          w_strg  TYPE string,
          w_type  TYPE dd01v-datatype.
    
    FIELD-SYMBOLS: <fs_row> LIKE LINE OF itab,
                   <fs>     TYPE ANY.
    
    SELECT * FROM adrc INTO TABLE itab.
    
    LOOP AT itab ASSIGNING <fs_row>.
      DO.
        ASSIGN COMPONENT sy-index OF STRUCTURE <fs_row> TO <fs>.
        IF sy-subrc <> 0.
          EXIT.
        ENDIF.
    
        w_strg = <fs>.
        CALL FUNCTION 'NUMERIC_CHECK'
          EXPORTING
            string_in        = w_strg
          IMPORTING
    *      STRING_OUT       =
            htype            = w_type.
    
        IF w_type <> 'NUMC'.
          CLEAR : <fs>.
        ENDIF.
      ENDDO.
    ENDLOOP.

    Best regards,

    Guillaume

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 01:09 PM

    Hi Shalem,

    internal table itab.

    Structure x_itab.

    loop at itab into x_itab.

    if itab-field1 CO '9999'. " any value

    delete x_itab.

    endif.

    endloop.

    Regards,

    Richa

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 01:20 PM

    Hi,

    Try this logic

    loop at itab.

    if itab-field1 co sy-abcde.

    else.

    delete itab.

    endif.

    endloop.

    Regards,

    Amole

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 01:44 PM

    Hi,

    loop at it_adrc.
     if it_adrc-sort2 ca '0123456789'.
    *- If it has both number and characters
      if it_adrc-sort2 ca 'abcdefghijklmnopqrstuvxyz'.
         
        else.
    *- If only numbers
       delete it_adrc.
     endif.
        endif.
    endloop.

    Hope this works.

    Regards,

    Kalpana

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 15, 2006 at 01:45 PM

    hi shalem,

    loop at itab.

    if itab-field1 CA '1234567890.'.

    delete itab.

    endif.

    Endloop.

    hope this helps.

    reward if helpful.

    regards,

    keerthi.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 15, 2006 at 01:52 PM

    loop at itab.

    if itab-field co '1234567890 .'.

    *do not delete.

    else.

    delete itab.

    endif.

    endloop.

    note that '1234567890 .' has a space also after 0 .

    Regards,

    Ravi

    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.