Hi Akky,
I requested the Full code for understanding.
Anyway as per my understanding, i have done the following changes, hope it will work.
DATA: l_flag type i value 0.
LOOP AT idoc_data[] ASSIGNING FIELD-SYMBOL(<ls_idoc_data>)
WHERE docnum EQ idoc_contrl-docnum.
l_flag = 0.
case segmname
when segA
ls_tablefield1 = ls_idocsegfield1,
ls_tablefield2 = ls_idocsegfield2,
ls_tablefield3 = ls_idocsegfield3,
ls_tablefield4 = ls_idocsegfield4,
l_flag = 1.
when segB
ls_tablefield5 = ls_idocsegfield5,
ls_tablefield6 = ls_idocsegfield6,
l_flag = 1.
when segC
ls_tablefield7 = ls_idocsegfield7,
ls_tablefield8 = ls_idocsegfield8,
l_flag = 1.
endcase.
if l_flag = 1.
MODIFY TABLE lt_table FROM ls_table
IF sy-subrc EQ 0.
lv_edi_status = '53'.
ELSE.
lv_edi_status = '51'.
ENDIF.
endif.
endloop.
endloop.
"Sort the internal table by using some key
SORT LT_TABLE BY <FIELD_NAME>.
"Delete the adjacent duplicates
DELETE ADJACENT DUPLICATES FROM LT_TABLE COMPARING <FIELD_NAME>.
"Also delete the empty value
DELETE LT_TABLE WHERE <FIELD_NAME>= ''.
IF lt_table[] IS NOT INITIAL.
MODIFY ztabel FROM TABLE lt_table.
COMMIT WORK.
ENDIF.
If you face the problem still, kindly share the full program with debugger screenshots that will help for better understanding.
Regards
Rajkumar Narasimman