Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Delete decimal values and alphabets in internal table

Former Member
0 Kudos

Hi,

I am having the some values in an internal table like 10 , 10.000 , 10.0001 and 20 20.111 , 20.123 , fgds321 , ghty543 etc.

i want to delete the values which has decimal value and alphabets. The table should contain with values of whole numbers alone.

Can anyone tell how to do this.

regards,

Phyrose.

4 REPLIES 4

Former Member
0 Kudos

Hi,

U declare fields in the int.table with type p decimals 0.

Assign points if useful.

former_member188827
Active Contributor
0 Kudos

data:BEGIN OF it OCCURS 0,

zch(15) TYPE c,

END OF it.

it-zch = '10'.

APPEND it.

it-zch = '10.000'.

APPEND it.

it-zch = '10.0001'.

APPEND it.

it-zch = '20'.APPEND it.

it-zch = '20.111'.APPEND it.

it-zch = '20.123 '.APPEND it.

it-zch = 'fgds321 '.APPEND it.

it-zch = 'ghty543'.APPEND it.

loop at it.

if it-zch ca '.' or it-zch ca 'abcdefghijklmnopqrstuvwxyz'.

DELETE it INDEX sy-tabix.

endif.

ENDLOOP.

loop at it.

WRITE / it-zch.

ENDLOOP.

plz reward points if dis helps

Clemenss
Active Contributor
0 Kudos

Hi camila,

if you are on release 4.7 or later, you can make use of TRY ... ENDTRY construct:

Try conversion of field to an integer number.

if this is successful, convert the field to a floating point (Type f) number.

If both integer and float have the same value (=), the number is ok.

Other wise delete field contents.

Regards,

Clemens

Former Member
0 Kudos

HI,

TRY LIKE THIS,

data:BEGIN OF it OCCURS 0,

zch(15) TYPE c,

END OF it.

it-zch = '10'.

APPEND it.

it-zch = '10.000'.

APPEND it.

it-zch = '10.0001'.

APPEND it.

it-zch = '20'.APPEND it.

it-zch = '20.111'.APPEND it.

it-zch = '20.123 '.APPEND it.

it-zch = 'fgds321 '.APPEND it.

it-zch = 'ghty543'.APPEND it.

loop at it.

if it-zch = '.' or it-zch = 'ABCDEFGHIJKLMNOPuvwxyz'.

DELETE it INDEX sy-tabix.

endif.

ENDLOOP.

loop at it.

WRITE / it-zch.

ENDLOOP.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

SURESH ALURI.