ORACLE EBS 销售订单(RMA) 开发接口案例

创建RMA订单

-- create_RMA
DECLARE
  l_iface_rec        ont.oe_headers_iface_all%ROWTYPE;
  l_iface_lines_rec  ont.oe_lines_iface_all%ROWTYPE;
  l_iface_action_rec ont.oe_actions_iface_all%ROWTYPE;
  l_org_id  NUMBER := 85; --OU ID
  l_request_id NUMBER;
BEGIN
  --Header
  l_iface_rec.last_update_date      := SYSDATE;
  l_iface_rec.last_updated_by       := 0;
  l_iface_rec.creation_date         := SYSDATE;
  l_iface_rec.created_by            := 0;
  l_iface_rec.last_update_login     := -1;
  --
  l_iface_rec.orig_sys_document_ref := 'F-WLRMA006';
  --
  l_iface_rec.org_id                := l_org_id;
  l_iface_rec.order_source_id       := 2; --Online, see ont.oe_order_sources
  l_iface_rec.operation_code          := 'INSERT';
  l_iface_rec.order_type_id           := 1076;  -- ZJ_NX_HTH_JXS_FG_ORD 订单类型
  l_iface_rec.sold_to_org_id          := 523233;  -- 商贸上海
  l_iface_rec.booked_flag             := 'Y';

  INSERT INTO ont.oe_headers_iface_all
  VALUES l_iface_rec;

  --Line                 
  l_iface_lines_rec.last_update_date      := SYSDATE;
  l_iface_lines_rec.last_updated_by       := 0;
  l_iface_lines_rec.creation_date         := SYSDATE;
  l_iface_lines_rec.created_by            := 0;
  l_iface_lines_rec.last_update_login     := -1;
  --
  l_iface_lines_rec.orig_sys_document_ref := l_iface_rec.orig_sys_document_ref;
  l_iface_lines_rec.orig_sys_line_ref     := 'F-ZFRMA006-1';
  --
  l_iface_lines_rec.org_id                := l_iface_rec.org_id;
  l_iface_lines_rec.order_source_id       := l_iface_rec.order_source_id;
  l_iface_lines_rec.operation_code       := 'INSERT';
  l_iface_lines_rec.inventory_item_id    := 2655053;  -- 物料Code 1A01223901
  l_iface_lines_rec.ordered_quantity     := 1;
  --
  l_iface_lines_rec.return_context :=  'ORDER';
  l_iface_lines_rec.return_attribute1 := 10956502;
  l_iface_lines_rec.return_attribute2 := 21007844;
  l_iface_lines_rec.return_reason_code := 'WRONG PRODUCT'; 
   
  INSERT INTO ont.oe_lines_iface_all
  VALUES l_iface_lines_rec;
  
   -- import
  fnd_global.apps_initialize(user_id      => 13560,
                             resp_id      => 50584,
                             resp_appl_id => 660);

   l_request_id := fnd_request.submit_request(application => 'ONT',
                                             program     => 'OEOIMP',
                                             argument1   => 85,  -- P_Operating_Unit
                                             argument2   => NULL,  -- P_Order_Source
                                             argument3 => 'F-ZFRMA006', -- P_Orig_Sys_Document_Ref
                                             argument4 => NULL,  --P_Operation_Code
                                             argument5 => NULL, -- P_Validate_Only
                                             argument6 => NULL, -- P_Debug_Level
                                             argument7 => 1,  --P_Num_Instances
                                             argument8 => NULL,  -- P_Sold_To_Org_Id
                                             argument9 => NULL -- P_Sold_To_Org
                                             );  
  COMMIT;
  dbms_output.put_line('RACUST request id: ' || l_request_id);  
END;

查看RMA单据是否已生成

SELECT T.FLOW_STATUS_CODE, T.* from oe_order_headers_all t WHERE t.orig_sys_document_ref = 'F-ZFRMA006';

创建已输入状态的RMA订单

-- create_RMA (entered)
DECLARE
  l_iface_rec        ont.oe_headers_iface_all%ROWTYPE;
  l_iface_lines_rec  ont.oe_lines_iface_all%ROWTYPE;
  l_iface_action_rec ont.oe_actions_iface_all%ROWTYPE;

  l_org_id  NUMBER := 85; --OU ID
  l_request_id NUMBER;
BEGIN
  --Header
  l_iface_rec.last_update_date      := SYSDATE;
  l_iface_rec.last_updated_by       := 0;
  l_iface_rec.creation_date         := SYSDATE;
  l_iface_rec.created_by            := 0;
  l_iface_rec.last_update_login     := -1;
  --
  l_iface_rec.orig_sys_document_ref := 'F-ZFRMA007';
  --
  l_iface_rec.org_id                := l_org_id;
  l_iface_rec.order_source_id       := 2; --Online, see ont.oe_order_sources
  l_iface_rec.operation_code          := 'INSERT';
  l_iface_rec.order_type_id           := 1076;  -- ZJ_NX_HTH_JXS_FG_ORD
  l_iface_rec.sold_to_org_id          := 523233;  -- 商贸上海
  l_iface_rec.booked_flag             := 'N';  -- 

  INSERT INTO ont.oe_headers_iface_all
  VALUES l_iface_rec;

  --Line                 
  l_iface_lines_rec.last_update_date      := SYSDATE;
  l_iface_lines_rec.last_updated_by       := 0;
  l_iface_lines_rec.creation_date         := SYSDATE;
  l_iface_lines_rec.created_by            := 0;
  l_iface_lines_rec.last_update_login     := -1;
  --
  l_iface_lines_rec.orig_sys_document_ref := l_iface_rec.orig_sys_document_ref;
  l_iface_lines_rec.orig_sys_line_ref     := 'F-ZFRMA007-1';
  --
  l_iface_lines_rec.org_id                := l_iface_rec.org_id;
  l_iface_lines_rec.order_source_id       := l_iface_rec.order_source_id;
  l_iface_lines_rec.operation_code       := 'INSERT';
  l_iface_lines_rec.inventory_item_id    := 2655053;  -- 1A01223901
  l_iface_lines_rec.ordered_quantity     := 1;
  --
  l_iface_lines_rec.return_context :=  'ORDER';
  l_iface_lines_rec.return_attribute1 := 10956502;
  l_iface_lines_rec.return_attribute2 := 21007844;
  l_iface_lines_rec.return_reason_code := 'WRONG PRODUCT'; 
   
  INSERT INTO ont.oe_lines_iface_all
  VALUES l_iface_lines_rec;
  
   -- import
  fnd_global.apps_initialize(user_id      => 13560,
                             resp_id      => 50584,
                             resp_appl_id => 660);

  l_request_id := fnd_request.submit_request(application => 'ONT',
                                             program     => 'OEOIMP',
                                             argument1   => 85,  
                                             argument2   => NULL, 
                                             argument3 => 'F-ZFRMA007', 
                                             argument4 => NULL,  
                                             argument5 => NULL, 
                                             argument6 => NULL, 
                                             argument7 => 1,  
                                             argument8 => NULL, 
                                             argument9 => NULL                        );
  COMMIT;
  dbms_output.put_line('RACUST request id: ' || l_request_id);  
END;

查看

SELECT T.FLOW_STATUS_CODE, T.* from oe_order_headers_all t WHERE t.orig_sys_document_ref = 'F-ZFRMA007';

将已输入变为已登记的RMA订单

DECLARE
  l_iface_rec        ont.oe_headers_iface_all%ROWTYPE;
  l_iface_lines_rec  ont.oe_lines_iface_all%ROWTYPE;
  l_iface_action_rec ont.oe_actions_iface_all%ROWTYPE;

  l_org_id     NUMBER := 85; --OU ID
  l_request_id NUMBER;
BEGIN
  
  --Header
  l_iface_rec.last_update_date      := SYSDATE;
  l_iface_rec.last_updated_by       := 0;
  l_iface_rec.creation_date         := SYSDATE;
  l_iface_rec.created_by            := 0;
  l_iface_rec.last_update_login     := -1;
  --
  l_iface_rec.orig_sys_document_ref := 'F-ZFRMA007';
  --
  l_iface_rec.org_id                := l_org_id;
  l_iface_rec.order_source_id       := 2; --Online, see ont.oe_order_sources
  l_iface_rec.operation_code          := 'UPDATE'; 

  INSERT INTO ont.oe_headers_iface_all
  VALUES l_iface_rec;
  
  -- action
  l_iface_action_rec.order_source_id       := 2;
  l_iface_action_rec.orig_sys_document_ref := 'F-ZFRMA007';
  l_iface_action_rec.org_id                := 85;
  l_iface_action_rec.operation_code        := 'BOOK_ORDER';
  
  INSERT INTO oe_actions_iface_all VALUES l_iface_action_rec;
  
  -- import
  fnd_global.apps_initialize(user_id      => 13560,
                             resp_id      => 50584,
                             resp_appl_id => 660);

  l_request_id := fnd_request.submit_request(application => 'ONT',
                                             program     => 'OEOIMP',
                                             argument1   => 85, 
                                             argument2   => NULL, 
                                             argument3   => 'F-ZFRMA007', 
                                             argument4   => NULL, 
                                             argument5   => NULL, 
                                             argument6   => NULL, 
                                             argument7   => 1, 
                                             argument8   => NULL, 
                                             argument9   => NULL                                              );
  COMMIT;
  dbms_output.put_line('RACUST request id: ' || l_request_id);
END;

查看

SELECT T.FLOW_STATUS_CODE, T.* from oe_order_headers_all t WHERE t.orig_sys_document_ref = 'F-ZFRMA007';

你可能感兴趣的:(Oracle,EBS)