2007 Dec 19 1:21 AM
my flat file
char numc currency
karthi 1233 123,000.0.
i have check give feild give correct format or worg.
urgent .................
when ever u get the data from flat file to internal table..
give a check if condition...
if check is fine append or else put it into a error file.. or write out..
how to write condition?sample code nned please urgent.
2007 Dec 19 2:59 AM
Friend,
use the FM NUMERIC_CHECK
parameters: ch(10).
data: ty type DD01V-DATATYPE.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = ch
IMPORTING
STRING_OUT = ch
HTYPE = ty.
case ty.
when 'NUMC'.
when 'CHAR'.
endcase.
2007 Dec 19 1:32 AM
if char co sy-abcde
else.
" Only character values in field char
endif.
if numc co '0123456789'
else.
" Only numeric values in field numc
endif.
if currency >= 0
else.
" Currency should be > 0
endif.
PS: Please give your queries in detail, so that other members understand easily
a®
2007 Dec 19 2:46 AM
Check the Types as Follows.
>DATA:lr_descrref TYPE REF TO cl_abap_typedescr.
>lr_descrref = cl_abap_typedescr=>describe_by_data( variable ). " this is the variable of >which you want to check the type of
>CASE lr_descrref->type_kind.
>WHEN= 'P'.
> Packed Number
>WHEN 'C'.
> Character
>WHEN OTHERS.
> And so on.
>ENDCASE.
This would be the best way to check types dynamically.
Amandeep
2007 Dec 19 2:59 AM
Friend,
use the FM NUMERIC_CHECK
parameters: ch(10).
data: ty type DD01V-DATATYPE.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
STRING_IN = ch
IMPORTING
STRING_OUT = ch
HTYPE = ty.
case ty.
when 'NUMC'.
when 'CHAR'.
endcase.