KSK k
Solution is already suggested by Santosh & Eduardo in their respective post. Please refer their post.
You need to add logic in FM module to restrict execution of segment E1EDP01 in the IDoc. To restrict the same (logic already mention by TW)
if item category relevant for free of goods
or/add
if item level net price = 0
FYI. Generally, you don't use/develop custom develop program for EDI, instead of program RSNASTED & FORM routine EDI_PROCESSING.
Thanks, JP