‎2008 Jul 10 10:44 AM
Hi folks,
I need to validate my flat file.It contain 5 fields. I have to check whether each coloumn is filled data with valid data types. For example, 'country' field should have a numbers in it. And the 'Rate' field should not have the characters in it, if that field contains any characters it should be caught as a error record.. Please suggest me how to solve this...Thanks in advance..
Shyam.
‎2008 Jul 10 10:58 AM
Not sure what is your scenario ... but u can upload the data into an itab and then loop the itab and check the field contents whether they are numeric or char using FM like NUMERIC_CHECK .
Below is the samle output from NUMERIC_CHECK
Input : output :
11 type - Num
1.1 type - char
1 1 type - char
1*1 type - char
Just check out with your all possible inputs is SE37 .
So based on FM output you can raise error message.
You can also try moving the values to a NUM data type field but it may go short dump.
RB.
‎2008 Jul 10 11:08 AM
Hi Shyam,
it_tab1 consists of entries of your flat file.
Validate your entries in itab1, Invalid entries are moved into it_err. (Which consists of all your Invalid entries).
Regards,
Sai
‎2008 Jul 10 11:09 AM
Hi Shyam,
Use upload function module to get that data into an internal table. Then perform all your validation on the entries inthe Internal table.
Raghav
‎2008 Jul 10 11:18 AM
If you want to validate any character field, you can use the system variable SY-ABCDE(Constant: Alphabet (A,B,C,...)).
suppose you flat file's data is into the internal table I_TAB and you have work area of same type WA_TAB. Now use below piece of code....
loop at i_tab into wa_tab.
if wa_tab-country ca sy-abcde.
message 'Invalid Country' type 'E'.
endif.
endloop.
i think this code will work.
please reward if it is helpful.