10-10-2007 8:25 AM
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.
10-10-2007 8:47 AM
Hi,
U declare fields in the int.table with type p decimals 0.
Assign points if useful.
10-10-2007 8:49 AM
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
10-10-2007 8:54 AM
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
10-10-2007 8:54 AM
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.