Application Development and Automation 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: 
Read only

type checking

Former Member
0 Likes
514

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
489

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.

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
489

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®

Read only

Former Member
0 Likes
489

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

Read only

Former Member
0 Likes
490

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.