使用API进行发运确认并运行Interface Trip Stop

DECLARE

  p_sales_order            NUMBER := 1506764295;
  p_line_number            NUMBER := 1.1;
  p_org_id                 NUMBER := 121;
  l_shipped_quantity       NUMBER := 1;
  p_api_version_number     NUMBER := 1.0;
  init_msg_list            VARCHAR2(200);
  l_commit                 VARCHAR2(30);
  x_msg_details            VARCHAR2(3000);
  x_msg_summary            VARCHAR2(3000);
  x_return_status          VARCHAR2(3);
  x_msg_count              NUMBER;
  x_msg_data               VARCHAR2(3000);
  p_validation_level       NUMBER;
  v_errbuf                 VARCHAR2(2000);
  v_retcode                VARCHAR2(20);
  v_released_status        wsh_delivery_details.released_status%TYPE;
  v_inv_interfaced_flag    wsh_delivery_details.inv_interfaced_flag%TYPE;
  v_oe_interfaced_flag     wsh_delivery_details.oe_interfaced_flag%TYPE;
  v_source_code            wsh_delivery_details.source_code%TYPE;
  v_pending_interface_flag wsh_trip_stops.pending_interface_flag%TYPE;
  l_changed_attributes     wsh_delivery_details_pub.changedattributetabtype;
  l_source_code            VARCHAR2(30) := 'OE';
  -- Parameters for WSH_DELIVERIES_PUB
  p_delivery_name           VARCHAR2(30);
  p_action_code             VARCHAR2(15);
  p_asg_trip_id             NUMBER;
  p_asg_trip_name           VARCHAR2(30);
  p_asg_pickup_stop_id      NUMBER;
  p_asg_pickup_loc_id       NUMBER;
  p_asg_pickup_loc_code     VARCHAR2(30);
  p_asg_pickup_arr_date     DATE;
  p_asg_pickup_dep_date     DATE;
  p_asg_dropoff_stop_id     NUMBER;
  p_asg_dropoff_loc_id      NUMBER;
  p_asg_dropoff_loc_code    VARCHAR2(30);
  p_asg_dropoff_arr_date    DATE;
  p_asg_dropoff_dep_date    DATE;
  p_sc_action_flag          VARCHAR2(10);
  p_sc_intransit_flag       VARCHAR2(10);
  p_sc_close_trip_flag      VARCHAR2(10);
  p_sc_create_bol_flag      VARCHAR2(10);
  p_sc_stage_del_flag       VARCHAR2(10);
  p_sc_trip_ship_method     VARCHAR2(30);
  p_sc_actual_dep_date      VARCHAR2(30);
  p_sc_report_set_id        NUMBER;
  p_sc_report_set_name      VARCHAR2(60);
  p_sc_defer_interface_flag VARCHAR2(60);
  p_sc_send_945_flag        VARCHAR2(60);
  p_sc_rule_id              NUMBER;
  p_sc_rule_name            VARCHAR2(60);
  p_wv_override_flag        VARCHAR2(10);
  p_asg_pickup_stop_seq     NUMBER;
  p_asg_dropoff_stop_seq    NUMBER;
  x_trip_id                 VARCHAR2(30);
  x_trip_name               VARCHAR2(30);
  fail_api EXCEPTION;
  x_debug_file       VARCHAR2(100);
  l_ship_method_code VARCHAR2(100);
  l_user_id          NUMBER;
  l_resp_id          NUMBER;
  l_appl_id          NUMBER;

  CURSOR c_ord_details IS

    SELECT DISTINCT det.source_header_number sales_order
                   ,det.org_id
                   ,det.source_line_number
                   ,det.source_header_id
                   ,det.source_line_id
                   ,det.source_header_type_name
                   ,det.inventory_item_id
                   ,det.requested_quantity
                   ,det.delivery_detail_id
                   ,(SELECT concatenated_segments
                       FROM mtl_system_items_kfv
                      WHERE inventory_item_id = det.inventory_item_id
                        AND organization_id = det.organization_id) ordered_item
                   ,det.organization_id
                   ,det.src_requested_quantity
                   ,det.shipped_quantity
                   ,del.delivery_id
                   ,del.status_code delivery_status_code
                   ,det.released_status pick_release_status
                   ,det.oe_interfaced_flag
                   ,det.inv_interfaced_flag
      FROM wsh_delivery_details     det
          ,wsh_delivery_assignments asn
          ,wsh_new_deliveries       del
     WHERE 1 = 1
       AND det.delivery_detail_id = asn.delivery_detail_id
       AND asn.delivery_id = del.delivery_id(+)
       AND det.source_header_number = p_sales_order
       AND det.source_line_number = p_line_number
       AND det.org_id = p_org_id
       AND shipped_quantity IS NULL
       AND nvl(del.status_code, 'OP') <> 'CL'
       AND det.released_status = 'Y';
  --
  v_user_id      NUMBER;
  v_resp_id      NUMBER;
  v_resp_appl_id NUMBER;
  --  

BEGIN
  --
  /* To get the user id details */
  SELECT user_id INTO v_user_id FROM fnd_user WHERE user_name = 'SETUP01';

  /* To get the responsibility and responsibility application id */
  SELECT f.responsibility_id, f.application_id
    INTO v_resp_id, v_resp_appl_id
    FROM fnd_responsibility_tl f
   WHERE f.responsibility_name = '受注管理スーパーユーザー(SC)'
     AND f.language = 'JA';
  --
  fnd_global.apps_initialize(user_id      => v_user_id,
                             resp_id      => v_resp_id,
                             resp_appl_id => v_resp_appl_id);

  dbms_output.put_line(v_user_id || ' ' || v_resp_id || ' ' ||
                       v_resp_appl_id);
  --

  FOR i IN c_ord_details LOOP
    dbms_output.put_line('Initializing the Application for Shipping Transactions');
    -- Mandatory initialization for R12
    mo_global.set_policy_context('S', i.org_id);
    mo_global.init('ONT');
    -- Ship Confirming
    p_delivery_name := to_char(i.delivery_id);

    dbms_output.put_line('Before Shipping, Calling WSH_DELIVERY_DETAILS_PUB API to Update Shipping Attributes');
    dbms_output.put_line('=============================================');
    l_changed_attributes(1).delivery_detail_id := i.delivery_detail_id;
    l_changed_attributes(1).shipped_quantity := l_shipped_quantity;
    wsh_delivery_details_pub.update_shipping_attributes(p_api_version_number => 1.0,
                                                        p_init_msg_list      => init_msg_list,
                                                        p_commit             => l_commit,
                                                        x_return_status      => x_return_status,
                                                        x_msg_count          => x_msg_count,
                                                        x_msg_data           => x_msg_data,
                                                        p_changed_attributes => l_changed_attributes,
                                                        p_source_code        => l_source_code);

    IF (x_return_status <> wsh_util_core.g_ret_sts_success) THEN
      RAISE fail_api;
      dbms_output.put_line('Failed to Update the Shipping Attributes');
    ELSE
      dbms_output.put_line('Successfully Updated the Shipping Attributes');
    END IF;

    BEGIN
      SELECT shipping_method_code
        INTO l_ship_method_code
        FROM oe_order_headers_all
       WHERE order_number = i.sales_order
         AND org_id = i.org_id;
    EXCEPTION
      WHEN OTHERS THEN
        l_ship_method_code := NULL;
    END;

    p_action_code       := 'CONFIRM'; -- The action code for ship confirm
    p_sc_action_flag    := 'S'; -- Ship entered quantity.
    p_sc_intransit_flag := 'N';
    --In transit flag is set to 'Y' closes the pickup stop and sets the delivery in transit.
    p_sc_close_trip_flag      := 'Y'; -- Close the trip after ship confirm
    p_sc_trip_ship_method     := l_ship_method_code; -- The ship method code
    p_sc_defer_interface_flag := 'Y';
    p_sc_stage_del_flag       := 'Y';
    p_sc_create_bol_flag      := 'N';
    p_wv_override_flag        := 'N';

    -- API Call for Ship Confirmation
    dbms_output.put_line('Calling WSH_DELIVERIES_PUB to Perform Ship Confirmation');
    dbms_output.put_line('=============================================');

    wsh_deliveries_pub.delivery_action(p_api_version_number      => 1.0,
                                       p_init_msg_list           => init_msg_list,
                                       x_return_status           => x_return_status,
                                       x_msg_count               => x_msg_count,
                                       x_msg_data                => x_msg_data,
                                       p_action_code             => p_action_code,
                                       p_delivery_id             => i.delivery_id,
                                       p_delivery_name           => p_delivery_name,
                                       p_asg_trip_id             => p_asg_trip_id,
                                       p_asg_trip_name           => p_asg_trip_name,
                                       p_asg_pickup_stop_id      => p_asg_pickup_stop_id,
                                       p_asg_pickup_loc_id       => p_asg_pickup_loc_id,
                                       p_asg_pickup_stop_seq     => p_asg_pickup_stop_seq,
                                       p_asg_pickup_loc_code     => p_asg_pickup_loc_code,
                                       p_asg_pickup_arr_date     => p_asg_pickup_arr_date,
                                       p_asg_pickup_dep_date     => p_asg_pickup_dep_date,
                                       p_asg_dropoff_stop_id     => p_asg_dropoff_stop_id,
                                       p_asg_dropoff_loc_id      => p_asg_dropoff_loc_id,
                                       p_asg_dropoff_stop_seq    => p_asg_dropoff_stop_seq,
                                       p_asg_dropoff_loc_code    => p_asg_dropoff_loc_code,
                                       p_asg_dropoff_arr_date    => p_asg_dropoff_arr_date,
                                       p_asg_dropoff_dep_date    => p_asg_dropoff_dep_date,
                                       p_sc_action_flag          => p_sc_action_flag,
                                       p_sc_intransit_flag       => p_sc_intransit_flag,
                                       p_sc_close_trip_flag      => p_sc_close_trip_flag,
                                       p_sc_create_bol_flag      => p_sc_create_bol_flag,
                                       p_sc_stage_del_flag       => p_sc_stage_del_flag,
                                       p_sc_trip_ship_method     => p_sc_trip_ship_method,
                                       p_sc_actual_dep_date      => p_sc_actual_dep_date,
                                       p_sc_report_set_id        => p_sc_report_set_id,
                                       p_sc_report_set_name      => p_sc_report_set_name,
                                       p_sc_defer_interface_flag => p_sc_defer_interface_flag,
                                       p_sc_send_945_flag        => p_sc_send_945_flag,
                                       p_sc_rule_id              => p_sc_rule_id,
                                       p_sc_rule_name            => p_sc_rule_name,
                                       p_wv_override_flag        => p_wv_override_flag,
                                       x_trip_id                 => x_trip_id,
                                       x_trip_name               => x_trip_name);

    IF (x_return_status <> wsh_util_core.g_ret_sts_success) THEN
      dbms_output.put_line('Ship confirm has not been Completed For SO => ');
      --ROLLBACK;
      RAISE fail_api;
    ELSE
      dbms_output.put_line('Ship confirm Successfully Completed For SO => ');
      --COMMIT;

      dbms_output.put_line('Checking the Delivery Status after delivery action API Call');
      dbms_output.put_line('==========================================');

      SELECT wdd.source_code
            ,wdd.released_status
            ,wdd.inv_interfaced_flag
            ,wdd.oe_interfaced_flag
            ,wts.pending_interface_flag
        INTO v_source_code
            ,v_released_status
            ,v_inv_interfaced_flag
            ,v_oe_interfaced_flag
            ,v_pending_interface_flag
        FROM wsh_trips                wtr
            ,wsh_trip_stops           wts
            ,wsh_delivery_legs        wlg
            ,wsh_new_deliveries       wnd
            ,wsh_delivery_assignments wda
            ,wsh_delivery_details     wdd
       WHERE wtr.trip_id = wts.trip_id
         AND wts.stop_id = wlg.pick_up_stop_id
         AND wts.pending_interface_flag = 'Y'
         AND wdd.inv_interfaced_flag <> 'Y'
         AND wlg.delivery_id = wnd.delivery_id
         AND wnd.delivery_id = wda.delivery_id
         AND wda.delivery_detail_id = wdd.delivery_detail_id
         AND wnd.delivery_id = p_delivery_name
         AND wdd.source_line_id = i.source_line_id;

      IF (v_source_code = 'OE' AND v_released_status = 'C' AND
         v_inv_interfaced_flag <> 'Y' AND v_oe_interfaced_flag <> 'Y' AND
         v_pending_interface_flag = 'Y') THEN

        dbms_output.put_line('The Delivery has been Shipped & the Next Step is - Run Interface');
        dbms_output.put_line('===========================================');
        -- API Call for Submitting Interface Trip Stop

        wsh_ship_confirm_actions.interface_all_wrp(errbuf            => v_errbuf,
                                                   retcode           => v_retcode,
                                                   p_mode            => 'ALL',
                                                   p_stop_id         => NULL,
                                                   p_delivery_id     => p_delivery_name,
                                                   p_log_level       => 0,
                                                   p_batch_id        => NULL,
                                                   p_trip_type       => NULL,
                                                   p_organization_id => i.organization_id,
                                                   p_num_requests    => 1,
                                                   p_stops_per_batch => 1);

      ELSE
        dbms_output.put_line('The Delivery has not Shipped Properly');
      END IF;
    END IF;
  END LOOP;

EXCEPTION
  WHEN fail_api THEN

    dbms_output.put_line('==============');
    dbms_output.put_line('Error Details If Any');
    dbms_output.put_line('==============');

    wsh_util_core.get_messages(p_init_msg_list => 'Y',
                               x_summary       => x_msg_summary,
                               x_details       => x_msg_details,
                               x_count         => x_msg_count);

    IF x_msg_count > 1 THEN
      x_msg_data := x_msg_summary || x_msg_details;
      dbms_output.put_line(x_msg_data);
    ELSE
      x_msg_data := x_msg_summary || x_msg_details;
      dbms_output.put_line(x_msg_data);
    END IF;
    --
  --FOR i IN 1 .. x_msg_count LOOP
  --  x_msg_data := oe_msg_pub.get(p_msg_index => i, p_encoded => 'F');
  --  dbms_output.put_line(i || ') ' || x_msg_data);
  --END LOOP;
  --
END;

时间: 2024-10-12 07:40:55

使用API进行发运确认并运行Interface Trip Stop的相关文章

批量发运确认开发 wsh_deliveries_pub.delivery_action

API wsh_deliveries_pub.delivery_action问题点:1.发运确认会调用接口请求,同一个SO对应几个交货号会报出现锁,2.请求会存在延时,报表不能输出正确的结果解决方法:把发运确认API设置为延迟接口,即p_sc_defer_interface_flag为'Y',然后存储过程中直接调用连接停靠站过程. declare --PARAMETER FOR "WSH_DELIVERIES_PUB.Delivery_Action" x_Return_Status V

OM批量发运确认开发

问题:1.发运确认会调用接口请求,同一个SO对应几个交货号会报出现锁,2.请求会存在延时,报表不能输出正确的结果解决方法:把发运确认API设置为延迟接口,即p_sc_defer_interface_flag为‘Y’,直接调用连接停靠站存储过程wsh_ship_confirm_actions.interface_all DECLARE  --PARAMETER FOR "WSH_DELIVERIES_PUB.Delivery_Action"  p_api_version_number  

转:Oracle EBS订单的流程(Order-&gt;AR)

目录(?)[-] 基本流程 创建订单 Pick Release Pick Confirm Ship Confirm Deliveries Interface Trip Stop - SRS Workflow background Process AutoInvoice Closing the Order OrderShipping Transactions Status Summary 基本流程 创建订单 路径:Order Management > Orders,Returns > Sales

java 11 移除的一些其他内容,更简化的编译运行程序,Unicode 10,移除了不太使用的JavaEE模块和CORBA技术,废除Nashorn javascript引擎,不建议使用Pack200 相关api

移除的一些其他内容 移除项 移除了com.sun.awt.AWTUtilities 移除了sun.misc.Unsafe.defineClass, 使用java.lang.invoke.MethodHandles.Lookup.defineClass来替代 移除了Thread.destroy()以及 Thread.stop(Throwable)方法 移除了sun.nio.ch.disableSystemWideOverlappingFileLockCheck.sun.locale.formata

OM模块功能&amp;API详解

(一)销售订单概述 1.1   与车间模块关系 当使用ATO类型订单时,订单管理模块会直接在车间模块中产生任务 1.2   与库存模块关系 在销售订单中使用的物料,单位等信息均来自库存模块,在订单执行过程中,按订单保留及销售发运等功能也会对库存模块起作用 1.3   与应收模块关系 销售完成后,订单管理模块会在应收接口中产生INVOICE信息,影响应收模块中销售订单对应的应收INVOICE处理操作 1.4   与采购模块关系 在直发流程,背对背等销售流程中,订单模块会在采购模块中产生对应的采购需

所有标准API

序号 系统版本 模块 应用场景 类型 API/接口 参数规格 样例代码 备注 登记者 登记时间 关键字 1 12.1.3 AP 付款核销 API ap_pay_invoice_pkg.ap_pay_invoice 赵杨 2013/3/30 付款/核销 2 12.1.3 AP 应付发票审批 API ap_approval_pkg.approval 赵杨 2013/3/30 发票/审批 3 12.1.3 AP 预付款核销 API ap_prepay_pkg.apply_prepay_fr_prepa

(转)Java API设计清单

转自: 伯乐在线 Java API设计清单 英文原文 TheAmiableAPI 在设计Java API的时候总是有很多不同的规范和考量.与任何复杂的事物一样,这项工作往往就是在考验我们思考的缜密程度.就像飞行员起飞前的检查清单,这张清单将帮助软件设计者在设计Java API的过程中回忆起那些明确的或者不明确的规范.本文也可以看作为“API设计指南”这篇文章的附录. 我们还准备了一些前后比对的例子来展示这个列表如何帮助你理清设计需求,找出错误,识别糟糕的设计实践以及如何寻找改进的时机. 这个清单

EBS 第一个项目 学习总结 ---- 发运模块

EBS 组织架构: (一)业务组(BG) (二)法律实体(LE) (三)业务实体(OU) (四)库存组织(INV) (五)公司成本中心(Cost Center) (六)HR组织 (七)多组织接入控制 Sale Order 销售订单  的  Ship Confirm 发运功能模块: 在做状态变化时候要记得对WHO字段进行状态的修改. 必要表的信息: oe_order_headers_all 订单头信息表 oe_order_lines_all --header_id=oe_order_headers

C# API 大全

C:\ProgramFiles\MicrosoftVisual Studio .NET\ FrameworkSDK\Samples\ Technologies\ Interop\PlatformInvoke\ WinAPIs\CS目录下有大量的调用API的例子. 一.调用格式 using System.Runtime.InteropServices; //引用此名称空间,简化后面的代码 //使用DllImportAttribute特性来引入api函数,注意声明的是空方法,即方法体为空. [Dll