Hi Dhivya,
Seems to be the problems is in the below code:
* sort ta_flatfile by matnr.
loop at ta_flatfile INTO wa_flatfile.
MOVE-CORRESPONDING wa_flatfile to wa_flatfile1.
at FIRST.
perform bdc_open_group. "bdc new session
ENDAT.
at NEW matnr.
clear wa_bdcdata.
v_flag = 'X'.
perform bdc_header_insert.
ENDat.
Can you please check in debug mode, whether these control break events are working correctly?
Because, wa_flatfile will have ***** only.