How to delete IDoc Segment

Hi Experts,

Please advice me. I've a requirement to delete Idoc segment and also it sub-segment E1EDP01. The user requirement as below:


1. User would like to reject the material in the 1st line item of the standard order (VA02) due to customer would like to change to other material number and set a reason for rejection under the "Reason for rejection" for the 1st line item.

2. User than enter another material number in the 2nd line item of the same standard order (VA02) without deleting the 1st line item.

3. After entering the material number, the user will click Extras->Output->Header->Edit.

4. Choose an output type and set the medium "EDI"

5. Click "Further Data" and choose the "Dispatch time" to 4. Click back and save

6. Therefore an EDI will be generated. To view the IDoc number, go back to the sales order and click on the "Processing Log"

7. Go to transaction WE02 and enter the idoc number.

Expected Result:

1. If there is an reason for rejection maintain in either 1 of the line item material in a standard order, the segment and its sub-segment for E1EDP01 must be deleted for the respective line item.

My Blocking point:

1. May i know how to delete an idoc segment and its sub-segment in abap? I've also researched in the internet but i could find any function module which is able to delete the segment and its sub-segment of the IDoc.

Please advice me as I'm very new to IDoc. Thanks so much.