ITPub博客

首页 > 数据库 > Oracle > Which responsibility ran the sales order Workflow ?

Which responsibility ran the sales order Workflow ?

原创 Oracle 作者:419088217 时间:2015-02-09 17:39:28 0 删除 编辑
OEOL Workflow , 客制化一个function node ,在function node 里面 call apply hold API, 问题来了apply hold API 会check对于hold name 的职责权限, 那些职责有权限做apply hold和release hold, 很想知道workflow取的环境的值是什么,取的是那个职责。 fnd_global.apps_initialize
我们知道Workflow是后台运行的,通过测试,取的responsibility的值是 create order时候用的职责, 设置hold name 职责权限后,  workflow调用API 可以apply hold。  


fnd_global.apps_initialize (user_id,
                                  resp_id,
                                  fnd_global.resp_appl_id
                                 );


   declare

      v_chr_return_status      VARCHAR2 (10);
      v_num_msg_count          NUMBER;
      v_chr_msg_data           VARCHAR2 (300);
      v_chr_hold_entity_code   oe_hold_sources_all.hold_entity_code%TYPE
                                                                       := 'O';
      v_num_user_id            NUMBER;
      v_num_resp_id            NUMBER;
      v_num_resp_appl_id       NUMBER;
      v_num_line_id            NUMBER;
      v_num_header_id          NUMBER;
      v_num_hold_id            NUMBER;
      rec_header               oe_order_pub.header_rec_type;
      rec_header_val           oe_order_pub.header_val_rec_type;
      tab_header_adj           oe_order_pub.header_adj_tbl_type;
      tab_header_adj_val       oe_order_pub.header_adj_val_tbl_type;
      tab_header_price_att     oe_order_pub.header_price_att_tbl_type;
      tab_header_adj_att       oe_order_pub.header_adj_att_tbl_type;
      tab_header_adj_assoc     oe_order_pub.header_adj_assoc_tbl_type;
      tab_header_scredit       oe_order_pub.header_scredit_tbl_type;
      tab_header_scredit_val   oe_order_pub.header_scredit_val_tbl_type;
      tab_line                 oe_order_pub.line_tbl_type;
      tab_line_val             oe_order_pub.line_val_tbl_type;
      tab_line_adj             oe_order_pub.line_adj_tbl_type;
      tab_line_adj_val         oe_order_pub.line_adj_val_tbl_type;
      tab_line_price_val       oe_order_pub.line_price_att_tbl_type;
      tab_line_adj_att         oe_order_pub.line_adj_att_tbl_type;
      tab_line_adj_assoc       oe_order_pub.line_adj_assoc_tbl_type;
      tab_line_scredit         oe_order_pub.line_scredit_tbl_type;
      tab_line_scredit_val     oe_order_pub.line_scredit_val_tbl_type;
      tab_lot_serial           oe_order_pub.lot_serial_tbl_type;
      tab_lot_serial_val       oe_order_pub.lot_serial_val_tbl_type;
      tab_action_request       oe_order_pub.request_tbl_type;
   BEGIN

      v_num_line_id := TO_NUMBER (319504792);

      -- Get order Header id
      BEGIN
         SELECT ool.header_id
           INTO v_num_header_id
           FROM oe_order_lines ool
          WHERE ool.line_id = v_num_line_id AND ROWNUM < 2;
      EXCEPTION
         WHEN OTHERS
         THEN
--            IF g_num_pg_debug <> 0
--            THEN
--               oe_debug_pub.ADD (   'Error: '
--                                 || 'Error while retrieving Header id ',
--                                 1
--                                );
--            END IF;
       DBMS_OUTPUT.PUT_LINE('error can not find header id '||sqlerrm);
      END;

      BEGIN
         SELECT ohd.hold_id
           INTO v_num_hold_id
           FROM oe_hold_definitions ohd
          WHERE UPPER (ohd.NAME) = UPPER ('Change Order-Scheduling Hold VLVS');
      EXCEPTION
         WHEN OTHERS
         THEN
--            IF g_num_pg_debug <> 0
--            THEN
--               oe_debug_pub.ADD ('Error: '
--                                 || 'Error while retrieving Hold id ',
--                                 1
--                                );
--            END IF;
          DBMS_OUTPUT.PUT_LINE('error can not find hold '||sqlerrm);
      END;

      IF v_num_line_id IS NOT NULL
      THEN
         tab_action_request (1).request_type := oe_globals.g_apply_hold;
         tab_action_request (1).entity_code := oe_globals.g_entity_line;
         tab_action_request (1).entity_id := v_num_line_id;
         tab_action_request (1).param1 := v_num_hold_id;
         tab_action_request (1).param2 := v_chr_hold_entity_code;
         tab_action_request (1).param3 := v_num_header_id;
         tab_action_request (1).param4 :=
                                'Hold Applied By EMR Bill Only VLVS Workflow';
         tab_action_request (1).date_param1 := NULL;
         ----------------------Calling Process Order API
         oe_order_pub.process_order
                         (p_api_version_number          => 1.0,
                          p_init_msg_list               => fnd_api.g_false,
                          p_return_values               => fnd_api.g_false,
                          p_action_commit               => fnd_api.g_false,
                          x_return_status               => v_chr_return_status,
                          x_msg_count                   => v_num_msg_count,
                          x_msg_data                    => v_chr_msg_data,
                          p_action_request_tbl          => tab_action_request,
                          x_header_rec                  => rec_header,
                          x_header_val_rec              => rec_header_val,
                          x_header_adj_tbl              => tab_header_adj,
                          x_header_adj_val_tbl          => tab_header_adj_val,
                          x_header_price_att_tbl        => tab_header_price_att,
                          x_header_adj_att_tbl          => tab_header_adj_att,
                          x_header_adj_assoc_tbl        => tab_header_adj_assoc,
                          x_header_scredit_tbl          => tab_header_scredit,
                          x_header_scredit_val_tbl      => tab_header_scredit_val,
                          x_line_tbl                    => tab_line,
                          x_line_val_tbl                => tab_line_val,
                          x_line_adj_tbl                => tab_line_adj,
                          x_line_adj_val_tbl            => tab_line_adj_val,
                          x_line_price_att_tbl          => tab_line_price_val,
                          x_line_adj_att_tbl            => tab_line_adj_att,
                          x_line_adj_assoc_tbl          => tab_line_adj_assoc,
                          x_line_scredit_tbl            => tab_line_scredit,
                          x_line_scredit_val_tbl        => tab_line_scredit_val,
                          x_lot_serial_tbl              => tab_lot_serial,
                          x_lot_serial_val_tbl          => tab_lot_serial_val,
                          x_action_request_tbl          => tab_action_request
                         );
      END IF;
   EXCEPTION
      WHEN OTHERS
      THEN
--         IF g_num_pg_debug <> 0
--         THEN
--            oe_debug_pub.ADD ('Error: ' || ' WF Activity: Error' || SQLERRM,
--                              1
--                             );
--         END IF;

    DBMS_OUTPUT.PUT_LINE('error api error '||sqlerrm);
   END ;

OPTION 2:
     rec_hold_source               oe_holds_pvt.hold_source_rec_type;
      v_num_line_rec_apply_hold     NUMBER                            := 0;
      v_num_success_code   CONSTANT NUMBER                            := 0;
      v_num_warning_code   CONSTANT NUMBER                            := 1;
      g_num_error_code     CONSTANT NUMBER                            := 2;
      v_chr_hold_entity_code        VARCHAR2 (3)                      := 'O';
      v_chr_msg_data                VARCHAR2 (2000)                   := NULL;
      v_chr_return_status           VARCHAR2 (30);
      v_num_msg_count               NUMBER                            := 0;
      v_num_msgcntr                 NUMBER;
      v_num_msg_index_out           NUMBER;
   BEGIN
      o_num_ret_status := v_num_success_code;
      fnd_file.put_line (fnd_file.LOG, 'i_num_line_id' || i_num_line_id);
      fnd_file.put_line (fnd_file.LOG, 'i_num_header_id' || i_num_header_id);
      fnd_file.put_line (fnd_file.LOG,
                         'i_chr_hold_apply_comment'
                         || i_chr_hold_apply_comment
                        );
      fnd_file.put_line (fnd_file.LOG, 'i_num_hold_id' || i_num_hold_id);
      --Assign Hold relevant data
      rec_hold_source.line_id := i_num_line_id;
      rec_hold_source.hold_entity_code := v_chr_hold_entity_code;
      rec_hold_source.hold_entity_id := i_num_header_id;
      rec_hold_source.header_id := i_num_header_id;
      rec_hold_source.hold_comment := i_chr_hold_apply_comment;
      rec_hold_source.hold_id := i_num_hold_id;
      rec_hold_source.request_id := g_num_request_id;
      rec_hold_source.program_id := g_num_program_id;
      rec_hold_source.program_application_id := g_num_prog_appl_id;
      rec_hold_source.last_updated_by := g_num_user_id;
      rec_hold_source.last_update_date := g_dte_sys_date;
      rec_hold_source.last_update_login := g_num_login_id;
      fnd_file.put_line (fnd_file.LOG, 'Calling oe_holds_pub.apply_holds');
      oe_msg_pub.RESET;
      -- Call Apply_Holds API
      oe_holds_pub.apply_holds (p_api_version          => 1.0,
                                p_commit               => i_chr_action_commit,
                                p_hold_source_rec      => rec_hold_source,
                                x_msg_count            => v_num_msg_count,
                                x_msg_data             => v_chr_msg_data,
                                x_return_status        => v_chr_return_status
                               );
      fnd_file.put_line (fnd_file.LOG, 'v_num_msg_count' || v_num_msg_count);
      fnd_file.put_line (fnd_file.LOG,
                         'v_chr_return_status' || v_chr_return_status
                        );

      IF v_num_msg_count > 0
      THEN
         v_num_msgcntr := 1;

         WHILE v_num_msgcntr <= v_num_msg_count
         LOOP
            oe_msg_pub.get (p_msg_index          => v_num_msgcntr,
                            p_encoded            => fnd_api.g_false,
                            p_data               => v_chr_msg_data,
                            p_msg_index_out      => v_num_msg_index_out
                           );
            v_num_msgcntr := v_num_msgcntr + 1;
            fnd_file.put_line (fnd_file.LOG,
                               '**v_chr_msg_data - ' || v_chr_msg_data
                              );
         END LOOP;

         o_num_ret_status := g_num_error_code;
      END IF;

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

请登录后发表评论 登录
全部评论

注册时间:2014-12-25

  • 博文量
    63
  • 访问量
    52245