ITPub博客

首页 > 数据库 > Oracle > EBS依据API批量完成挑库和发运

EBS依据API批量完成挑库和发运

Oracle 作者:yuanlinok 时间:2015-03-24 10:04:34 0 删除 编辑
EBS依据API批量完成挑库和发运 2014-07-22 11:33:26
      轉載 EBS里面销售订单的发运事务处理过程。
     需求:要求能够模拟系统发运事务处理页面的操作,将销售订单行多行一次性的选中进行挑库,挑库发放,并最终发运确认完成交货。
     方案:因为客户需要批量的完成上述的挑库发放,发运确认的动作,并且是跟第三方系统集成完成,所以只能根据后台API模拟完成。
EBS中针对这个其实提供了很多pub后缀的公共包可以供调用,比如 WSH_PICKING_BATCHES_PUB,WSH_DELIVERY_DETAILS_PUB等,通过打开包体查看,这些包大部分都是EBS标准 webservice的代码,并且一次性只能处理一条记录,即只能处理一行数据,这个与客户需求不符。为了实现客户需求,于是又查询了metalink和 其他的一些资料,得到另外的一些API可供使用。
    试验步骤:
1. 创建了两张SO,然后登记订单,并且针对SO订单做好库存保留,此时SO行对应的delivery_detail_id也产生了;




2.对产生的三行delivery detail进行挑库,用的是如下代码,其中l_delivery_detail_tab是一个table类型的变量,将每行产生的delivery detail id依次赋值给变量,最后将统一产生交货号,从图中可以看出,同一张订单的将产生同一个交货号

点击(此处)折叠或打开

  1. DECLARE
  2.   x_return_status VARCHAR2(1);
  3.   x_msg_count NUMBER;
  4.   x_msg_data VARCHAR2(4000);
  5.   l_delivery_detail_tab wsh_util_core.id_tab_type;
  6.   x_del_rows wsh_util_core.id_tab_type;
  7.   v_msg_index_out NUMBER;
  8. BEGIN
  9.   fnd_global.apps_initialize(0, 50787, 660);
  10.   mo_global.set_policy_context(\'S\', 82);
  11.   l_delivery_detail_tab(1) := 520003;
  12.   l_delivery_detail_tab(2) := 520004;
  13.   l_delivery_detail_tab(3) := 520005;
  14.   --l_delivery_detail_tab(4) := 2280578;
  15.   fnd_msg_pub.initialize;
  16.   wsh_delivery_details_pub.autocreate_deliveries(p_api_version_number => 1.0,
  17.                                                  p_init_msg_list => fnd_api.g_false,
  18.                                                  p_commit => fnd_api.g_false,
  19.                                                  x_return_status => x_return_status,
  20.                                                  x_msg_count => x_msg_count,
  21.                                                  x_msg_data => x_msg_data,
  22.                                                  p_line_rows => l_delivery_detail_tab,
  23.                                                  x_del_rows => x_del_rows);
  24.   dbms_output.put_line(x_return_status);

  25.   IF x_del_rows.count() > 0
  26.   THEN
  27.     FOR i IN x_del_rows.first .. x_del_rows.last LOOP
  28.       dbms_output.put_line(x_del_rows(i));
  29.     END LOOP;
  30.   END IF;

  31.   IF x_msg_count > 0
  32.   THEN
  33.     FOR v_index IN 1 .. x_msg_count LOOP
  34.       fnd_msg_pub.get(p_msg_index => v_index,
  35.                       p_encoded => \'F\',
  36.                       p_data => x_msg_data,
  37.                       p_msg_index_out => v_msg_index_out);
  38.       dbms_output.put_line(x_msg_data);
  39.     END LOOP;
  40.   END IF;
  41. END;

3.产生交货号之后,将要进行挑库确认的动作,这其实也是完成物料搬运单等一系列动作的过程,代码如下:
这里出现了一个问题,可能是实例化环境造成的,单纯的调用这个匿名块来完成动作是不行的,将会爆出一个无法启动挑库确认的错误,
我后来尝试将代码写成一个并发程序,同样的代码,在系统中跑一次并发是没有问题的,
具体的是哪个环境实例化变量不对我还在尝试,但是这个不是重要的,因为后面程序完成肯定也是在系统中跑,现在只是自己测试写的匿名块而已。

点击(此处)折叠或打开

  1. DECLARE
  2.   x_return_status VARCHAR2(1);
  3.   x_msg_count NUMBER;
  4.   x_msg_data VARCHAR2(4000);
  5.   l_delivery_detail_tab wsh_util_core.id_tab_type;
  6.   x_del_rows wsh_util_core.id_tab_type;
  7.   v_msg_index_out NUMBER;
  8.   l_action_prms wsh_glbl_var_strct_grp.dd_action_parameters_rec_type;
  9.   l_action_out_rec wsh_glbl_var_strct_grp.dd_action_out_rec_type;
  10. BEGIN
  11.   fnd_global.apps_initialize(0, 50787, 660);
  12.   mo_global.set_policy_context(\'S\', 82);
  13.   l_delivery_detail_tab(1) := 520003;
  14.   l_delivery_detail_tab(2) := 520004;
  15.   l_delivery_detail_tab(3) := 520005;
  16.   -- l_delivery_detail_tab (4) := 2280578;
  17.   l_action_prms.phase := 1;
  18.   l_action_prms.caller := \'WSH_PUB\';
  19.   l_action_prms.action_code := \'PICK-RELEASE\';

  20.   fnd_msg_pub.initialize;
  21.   wsh_interface_grp.delivery_detail_action(p_api_version_number => 1.0,
  22.                                            p_init_msg_list => fnd_api.g_false,
  23.                                            p_commit => fnd_api.g_false,
  24.                                            x_return_status => x_return_status,
  25.                                            x_msg_count => x_msg_count,
  26.                                            x_msg_data => x_msg_data,
  27.                                            p_detail_id_tab => l_delivery_detail_tab,
  28.                                            p_action_prms => l_action_prms,
  29.                                            x_action_out_rec => l_action_out_rec);
  30.   COMMIT;
  31.   dbms_output.put_line(x_return_status);

  32.   IF x_msg_count > 0
  33.   THEN
  34.     FOR v_index IN 1 .. x_msg_count LOOP
  35.       fnd_msg_pub.get(p_msg_index => v_index,
  36.                       p_encoded => \'F\',
  37.                       p_data => x_msg_data,
  38.                       p_msg_index_out => v_msg_index_out);
  39.       dbms_output.put_line(x_msg_data);
  40.     END LOOP;
  41.   END IF;

  42. END;
4.挑库成功后,最后就是进行发运确认的动作,用的代码如下:
变量l_del_rows也是一个table类型的,给它传的值就是前面产生的交货号,
自此,对于一次性处理多行挑库发运的过程就能满足了,
当然这里是分开来完成的,后面需要的就是把这些匿名块都写成procedure或者function,然后一次性的全部完成。

点击(此处)折叠或打开

  1. DECLARE
  2.   x_return_status VARCHAR2(1);
  3.   x_msg_count NUMBER;
  4.   x_msg_data VARCHAR2(4000);
  5.   v_msg_index_out NUMBER;
  6.   l_action_prms wsh_deliveries_grp.action_parameters_rectype;
  7.   l_rec_attr_tab wsh_new_deliveries_pvt.delivery_attr_tbl_type;
  8.   x_dlvy_action_out_rec wsh_deliveries_grp.delivery_action_out_rec_type;
  9.   x_default_para_rectype wsh_deliveries_grp.default_parameters_rectype;
  10.   l_del_rows wsh_util_core.id_tab_type;

  11. BEGIN
  12.   fnd_global.apps_initialize(0, 50787, 660);
  13.   mo_global.set_policy_context(\'S\', 82);

  14.   l_del_rows(1) := 129405;
  15.   l_del_rows(2) := 129406;

  16.   wsh_new_delivery_actions.confirm_delivery(p_del_rows => l_del_rows,
  17.                                             p_action_flag => \'A\',
  18.                                             --S Ship Entered Quantities, Ship Unspecified
  19.                                             --B Ship Entered Quantities, Backorder Unspecified
  20.                                             --T Ship Entered Quantities, Stage Unspecified
  21.                                             --A Ship All
  22.                                             --C Completely Backordered
  23.                                             p_intransit_flag => \'Y\', --\'Y\' for autocreate_trip closes first stop
  24.                                             p_close_flag => \'Y\', --\'Y\' closes autocreated trip and stops
  25.                                             p_stage_del_flag => NULL, --\'Y\' creates a new delivery for the staged lines
  26.                                             p_report_set_id => NULL, --report set for delivery
  27.                                             p_ship_method => NULL, --ship method for autocreated trip
  28.                                             p_actual_dep_date => NULL, --actual departure date for pickup stop on autocreated trip
  29.                                             p_bol_flag => NULL,
  30.                                             p_mc_bol_flag => \'N\',
  31.                                             p_defer_interface_flag => \'Y\', --\'Y\' skip concurrent program submission,bug 1578251
  32.                                             p_send_945_flag => NULL, --\'Y\' trigger outbound shipment advice for delivery with WSH lines
  33.                                             x_return_status => x_return_status);

  34.   COMMIT;
  35.   dbms_output.put_line(x_return_status);
  36. END;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/673037/viewspace-1471443/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2008-07-25

  • 博文量
    9
  • 访问量
    20654