Hi Tang Yan,
When updating a document you need to make sure :
Closing a line + adding a new line in one operation (oOrder.Update) will throw you an error.
This is not supported. You will have this problem also when using the SAP UI.
What you need to do is separate the process in two process :
1. Add the new line. then oOrder.Update();
call back the oOrder object then,
2. Close the original line. then oOrder.Update();
It has to be in the exact order above.
Regards
Edy