When you edit IDOC - it will create a copy of original IDOC i believe in 33 status . Refer to the IDOC and add the contents back.
if you wanted to do it pragmatically - use FM .
EDI_DOCUMENT_OPEN_FOR_EDIT
EDI_CHANGE_DATA_SEGMENTS
EDI_DOCUMENT_CLOSE_EDIT.