Hi Abhishek
You can avaoid this loop inside loop as follow(just an idea). You will have to keep one internal table of same type as ITAB1 which will be filled with custom segments only. A temporary another internal table ITAB2_INDEX will be required ITAB which will contain for material, from index of ITAB1(temporary table) and To index .
so when you
LOOP at IDOC_DATA wher segnam is E1EDP31.
read table ITAB2_INDEX with key MATNR.
if found
insert line of ITAB1 from ITAB2_INDEX-FROM to ITAB2_INDEX-TO to IDOC_DATA.
ENDLOOP