Pages

OracleEBSpro is purely for knowledge sharing and learning purpose, with the main focus on Oracle E-Business Suite Product and other related Oracle Technologies.

I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog.

I share my Oracle knowledge through this blog. All my posts in this blog are based on my experience, reading oracle websites, books, forums and other blogs. I invite people to read and suggest ways to improve this blog.


Monday, November 3, 2014

Reprice an Order Line or Order

Suppose you need to price all lines of an order using pl/sql script, you may use following script. Advantage of using OE_LINE_REPRICE.Reprice_Line procedure:

  1. You will have access to correct value of oe_order_pub.g_line.line_id in QP_CUSTOM.get_custom_price procedure 

CREATE OR REPLACE PROCEDURE skm_reprice_lines
( p_header_id NUMBER
) IS
  l_line_rec      OE_Order_Pub.Line_Rec_Type;
  l_return_status VARCHAR2(10);
  i NUMBER;
  l_msg_data VARCHAR2(250);
  
  CURSOR c_lines IS
     SELECT line_id
       FROM oe_order_lines_all
      WHERE header_id = p_header_id;
BEGIN

  OE_DEBUG_PUB.debug_on();
  OE_DEBUG_PUB.Start_ONT_Debugger('/home/users/smisra','skm1',null);

  DBMS_APPLICATION_INFO.set_client_info('1');

  FOR l_line IN c_lines 
  LOOP
    OE_Line_Util.Query_Row
    ( p_line_id     =>    l_line.line_id
    , x_line_rec    =>    l_line_rec
    );

    DBMS_OUTPUT.put_line('Line Id:' || l_line_rec.line_id);
    DBMS_OUTPUT.put_line('ordered_item:' || l_line_rec.ordered_item);
    OE_LINE_REPRICE.Reprice_Line
    ( p_line_rec         => l_line_rec
    , p_Repricing_date    => 'SYSDATE'
    , p_Repricing_event    => 'LINE'
    , p_Honor_Price_Flag  => 'Y'
    , x_return_status    => l_return_status
    ) ;
  END LOOP;
 
  DBMS_OUTPUT.put_line('Return Message:' || l_return_status);

  IF fnd_msg_pub.count_msg > 0
  THEN
     FOR j in 1..FND_MSG_PUB.count_msg
     LOOP
        FND_MSG_PUB.get
        ( p_msg_index      => j
        , p_encoded       => 'F'
        , p_data          => l_msg_data
        , p_msg_index_out => i
        );
        dbms_output.put_line( 'Error: ' || j || ':' || l_msg_data);
     END LOOP;
  END IF;

OE_DEBUG_PUB.debug_off();
END;
/

References:
http://sanjaimisra.blogspot.com/2008/05/reprice-order-line.html

PROCEDURE reprice_order (p_in_header_id IN NUMBER)
   IS
      v_header_count    NUMBER;
      v_header_list     VARCHAR2 (32000);
      v_line_count      NUMBER;
      v_line_list       VARCHAR2 (32000);
      v_price_level     VARCHAR2 (32000);
      v_return_status   VARCHAR2 (32000);
      v_msg_count       NUMBER;
      v_msg_data        VARCHAR2 (32000);
   BEGIN

      v_header_count := 1;
      v_header_list := TO_CHAR (p_in_header_id);
      v_price_level := 'ORDER';

      BEGIN
         oe_order_adj_pvt.price_action (p_header_count       => v_header_count,
                                        p_header_list        => v_header_list,
                                        p_line_count         => v_line_count,
                                        p_line_list          => v_line_list,
                                        p_price_level        => v_price_level,
                                        x_return_status      => v_return_status,
                                        x_msg_count          => v_msg_count,
                                        x_msg_data           => v_msg_data
                                       );
         COMMIT;

         IF (v_return_status != fnd_api.g_ret_sts_success)
         THEN
            dbms_output.put_line(v_msg_data);
         END IF;
      EXCEPTION
         WHEN OTHERS
         THEN
            dbms_output.put_line(sqlerrm);
      END;
   EXCEPTION
      WHEN OTHERS
      THEN
        dbms_output.put_line(sqlerrm);
   END reprice_order;

References:
http://www.oracleappstoday.com/2014/08/api-to-reprice-order-total-in-oracle-r12.html

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thanks for sharing the useful information I found this blog very informative which will help to learn the subject very easily and for the further information visit
    Oracle Fusion Financials Training

    ReplyDelete