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

validating flat file

Former Member
0 Likes
539

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.

4 REPLIES 4
Read only

Former Member
0 Likes
503

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.

Read only

Former Member
0 Likes
503

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

Read only

former_member182354
Contributor
0 Likes
503

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

Read only

Former Member
0 Likes
503

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.