使用SQL關閉訂單頭

訂單的關閉是自動的,在所有行工作流結束(Close或者Cancel)後0.5天,訂單頭也將在Workflow Background Process的推動下關閉。

還有另外一種說法:you can wait until month-end and the “Order Flow – Generic” workflow will close it for you.

所以造成了很多時候訂單行已經關閉了,但訂單頭還是處於Booked狀態,這個時候如果你想Close訂單頭,你可以手動運行Workflow Background Process來關閉訂單,也可以使用腳本來close Order Header.

腳本一:

  1. begin  
  2. fnd_global.apps_initialize(:USER_ID, :RESP_ID, :RESP_APPL_ID);  
  3. end;  
  4. /  
  5.   
  6. /*If Work Flow exist for Order header then use the script below. This will close the Order  
  7. After running this script run "Workflow Background Process" */  
  8. begin  
  9. wf_engine.completeactivity  
  10. (  
  11. 'OEOH'--item_type  
  12. '9999999'--item_key = header_id .... pass the HEADER_ID of the order you want to close  
  13. 'CLOSE_WAIT_FOR_L'-- apps.wf_process_activities.activity_name where instance_id= apps.wf_item_activity_statuses.process_activity  
  14. null  
  15. );  
  16. end;  
  17. /  
  18. Commit;  
  19.   
  20. ====================  
  21. /*If Work Flow does NOT exist for Order then use the script below .  
  22. After running this script run "Workflow Background Process" */  
  23.   
  24. declare  
  25. l_return_status VARCHAR2(240);  
  26. l_msg_count NUMBER;  
  27. l_msg_data VARCHAR2(240);  
  28. l_header_id NUMBER := 99999999; --pass the HEADER_ID of the order you want to close  
  29. begin  
  30. OE_ORDER_CLOSE_UTIL.Close_Order  
  31. ( p_api_version_number => 1.0  
  32. , p_header_id => l_header_id  
  33. , x_return_status => l_return_status  
  34. , x_msg_count => l_msg_count  
  35. , x_msg_data => l_msg_data  
  36. );  
  37. dbms_output.put_line('status = ' l_return_status);  
  38. end;  
  39. /  
  40. Commit;  
  41.   
  42. /* After running this script run "Workflow Background Process" */  
  43. **********************************************************************  
  44. **********************************************************************  
腳本二:你要確保訂單行都被關閉了的情況用這個腳本
  1. Select HEADER_ID, OPEN_FLAG, FLOW_STATUS_CODE  
  2. from apps.oe_order_lines_all  
  3. where org_id=:org_id and header_id =:HEADER_ID; --pass the ORG_ID and HEADER_ID of the order you want to close  
  4.   
  5. update apps.oe_order_headers_all  
  6. set open_flag = 'N' , FLOW_STATUS_CODE= 'CLOSED'  
  7. where org_id=:org_id and header_id =:HEADER_ID; --pass the ORG_ID and HEADER_ID of the order you want to close  
  8.   
  9. Commit;  

轉自:http://blog.csdn.net/pan_tian/article/details/7696961

======EOF======

發佈了15 篇原創文章 · 獲贊 6 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章