小说网站 搜小说 无限网 烟雨红尘 小说爱好者 免费小说 免费小说网站

Sample Code for Qp_preq_pub.Price_request Api to Simulate an Ask for Promotion Modifier

DECLARE
 p_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
 p_qual_tbl QP_PREQ_GRP.QUAL_TBL_TYPE;
 p_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
 p_LINE_DETAIL_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
 p_LINE_DETAIL_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
 p_LINE_DETAIL_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
 p_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
 p_control_rec QP_PREQ_GRP.CONTROL_RECORD_TYPE;
 x_line_tbl QP_PREQ_GRP.LINE_TBL_TYPE;
 x_line_qual QP_PREQ_GRP.QUAL_TBL_TYPE;
 x_line_attr_tbl QP_PREQ_GRP.LINE_ATTR_TBL_TYPE;
 x_line_detail_tbl QP_PREQ_GRP.LINE_DETAIL_TBL_TYPE;
 x_line_detail_qual_tbl QP_PREQ_GRP.LINE_DETAIL_QUAL_TBL_TYPE;
 x_line_detail_attr_tbl QP_PREQ_GRP.LINE_DETAIL_ATTR_TBL_TYPE;
 x_related_lines_tbl QP_PREQ_GRP.RELATED_LINES_TBL_TYPE;
 x_return_status VARCHAR2(240);
 x_return_status_text VARCHAR2(240);
 qual_rec QP_PREQ_GRP.QUAL_REC_TYPE;
 line_attr_rec QP_PREQ_GRP.LINE_ATTR_REC_TYPE;
 line_rec QP_PREQ_GRP.LINE_REC_TYPE;
 rltd_rec QP_PREQ_GRP.RELATED_LINES_REC_TYPE;
 ldet_rec QP_PREQ_GRP.LINE_DETAIL_REC_TYPE;
 line_detail_attr_rec QP_PREQ_GRP.LINE_DETAIL_ATTR_REC_TYPE;
 line_detail_qual_rec QP_PREQ_GRP.LINE_DETAIL_QUAL_REC_TYPE;
 l_pricing_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;
 l_qualifier_contexts_Tbl QP_Attr_Mapping_PUB.Contexts_Result_Tbl_Type;

 I BINARY_INTEGER;
 l_version VARCHAR2(240);

 --Variables
 l_operation QP_LIST_LINES.ARITHMETIC_OPERATOR%TYPE; --Operation
 l_operand QP_LIST_LINES.OPERAND%TYPE; --Operand
 l_list_line_type_code QP_LIST_LINES.LIST_LINE_TYPE_CODE%TYPE; --List line type
 l_mod_level_code QP_LIST_LINES.MODIFIER_LEVEL_CODE%TYPE; --Modifier level code

BEGIN

DBMS_OUTPUT.ENABLE(10000);

oe_debug_pub.SetDebugLevel(5); -- Set debug level
oe_debug_pub.G_DIR :='/usr/tmp'; -- Directory to store debug file

--Print debug file name
dbms_output.put_line('The File is'|| oe_debug_pub.Set_Debug_Mode('FILE'));

--Initialization
oe_debug_pub.Initialize;
oe_debug_pub.debug_on;
--fnd_global.apps_initialize(1564,21623,660);
mo_global.init('QP');

/*QP_Attr_Mapping_PUB.Build_Contexts(
p_request_type_code => 'ONT',
p_pricing_type => 'L',
x_price_contexts_result_tbl => l_pricing_contexts_Tbl,
x_qual_contexts_result_tbl => l_qualifier_Contexts_Tbl );*/

-- Passing Information to the Pricing Engine
-- Setting up the control record variables
-- Please refer documentation for explanation of each of these settings

---- Control Record
p_control_rec.pricing_event :='LINE';-- 'BATCH';
p_control_rec.calculate_flag := 'Y'; --QP_PREQ_GRP.G_SEARCH_N_CALCULATE;
p_control_rec.simulation_flag := 'N';
p_control_rec.rounding_flag := 'Q';
p_control_Rec.manual_discount_flag := 'Y';
p_control_rec.request_type_code := 'ONT';
p_control_rec.TEMP_TABLE_INSERT_FLAG := 'Y';

-- Request Line (Order Line) Information
 line_rec.request_type_code :='ONT';
 line_rec.line_id :=17157; -- Order Line Id. This can be any thing for this script
 line_rec.line_Index :='1'; -- Request Line Index
 line_rec.line_type_code := 'LINE'; -- LINE or ORDER(Summary Line)
 line_rec.pricing_effective_date := sysdate; -- Pricing as of what date ?
 line_rec.active_date_first := sysdate; -- Can be Ordered Date or Ship Date
 line_rec.active_date_second := sysdate; -- Can be Ordered Date or Ship Date
 line_rec.active_date_first_type := 'NO TYPE'; -- ORD/SHIP
 line_rec.active_date_second_type :='NO TYPE'; -- ORD/SHIP
 line_rec.line_quantity := 1; -- Ordered Quantity
 line_rec.line_uom_code := 'EA'; -- Ordered UOM Code
 line_rec.currency_code := 'USD'; -- Currency Code
 line_rec.price_flag := 'Y'; -- Price Flag can have 'Y' , 'N'(No pricing) , 'P'(Phase)
 p_line_tbl(1) := line_rec;

 --Attach detail attributes


-- Pricing Attributes Passed In
 --Pass inventory item id
 line_attr_rec.LINE_INDEX := 1; -- Attributes for the above line. Attributes are attached with the line index
 line_attr_rec.PRICING_CONTEXT :='ITEM';
 line_attr_rec.PRICING_ATTRIBUTE :='PRICING_ATTRIBUTE1';
 line_attr_rec.PRICING_ATTR_VALUE_FROM := '25006';-- Inventory Item Id
 line_attr_rec.VALIDATED_FLAG :='N';
 p_line_attr_tbl(3):= line_attr_rec;

 --Pass price list id
 qual_rec.LINE_INDEX := 1; -- Attributes for the above line. Attributes are attached with the line index
 qual_rec.QUALIFIER_CONTEXT :='MODLIST';
 qual_rec.QUALIFIER_ATTRIBUTE :='QUALIFIER_ATTRIBUTE4';
 qual_rec.QUALIFIER_ATTR_VALUE_FROM :='6009'; -- Price List Id
 qual_rec.COMPARISON_OPERATOR_CODE := '=';
 qual_rec.VALIDATED_FLAG :='Y';
 p_qual_tbl(1):= qual_rec;
 
 --Modifier Line
 qual_rec.LINE_INDEX := 1; -- Attributes for the above line. Attributes are attached with the line index
 qual_rec.QUALIFIER_CONTEXT :='MODLIST';
 qual_rec.QUALIFIER_ATTRIBUTE :='QUALIFIER_ATTRIBUTE2';
 qual_rec.QUALIFIER_ATTR_VALUE_FROM :='47682'/*'39360'*/; -- Modifier line id
 qual_rec.COMPARISON_OPERATOR_CODE := '=';
 qual_rec.VALIDATED_FLAG :='N';
 p_qual_tbl(2):= qual_rec;
 
-- Actual Call to the Pricing Engine
 QP_PREQ_PUB.PRICE_REQUEST
  (p_line_tbl,
  p_qual_tbl,
  p_line_attr_tbl,
  p_line_detail_tbl,
  p_line_detail_qual_tbl,
  p_line_detail_attr_tbl,
  p_related_lines_tbl,
  p_control_rec,
  x_line_tbl,
  x_line_qual,
  x_line_attr_tbl,
  x_line_detail_tbl,
  x_line_detail_qual_tbl,
  x_line_detail_attr_tbl,
  x_related_lines_tbl,
  x_return_status,
  x_return_status_text);
/*
-- Interpreting Information From the Pricing Engine . Output statements commented. Please uncomment for debugging
*/
-- Return Status Information ..
DBMS_OUTPUT.PUT_LINE('Return Status text '|| x_return_status_text);
DBMS_OUTPUT.PUT_LINE('Return Status '|| x_return_status);

DBMS_OUTPUT.PUT_LINE('+---------Information Returned to Caller---------------------+ ');

DBMS_OUTPUT.PUT_LINE('-------------Request Line Information-------------------');

I := x_line_tbl.FIRST;
IF I IS NOT NULL THEN
 LOOP
  DBMS_OUTPUT.PUT_LINE('Line Index: '||x_line_tbl(I).line_index);
  DBMS_OUTPUT.PUT_LINE('Unit_price: '||x_line_tbl(I).unit_price);
  DBMS_OUTPUT.PUT_LINE('Percent price: '||x_line_tbl(I).percent_price);
  DBMS_OUTPUT.PUT_LINE('Adjusted Unit Price: '||x_line_tbl(I).adjusted_unit_price);
  DBMS_OUTPUT.PUT_LINE('Pricing status code: '||x_line_tbl(I).status_code);
  DBMS_OUTPUT.PUT_LINE('Pricing status text: '||x_line_tbl(I).status_text);
  EXIT WHEN I = x_line_tbl.LAST;
  I := x_line_tbl.NEXT(I);
 END LOOP;
END IF;

DBMS_OUTPUT.PUT_LINE('-----------Pricing Attributes Information-------------');

I := x_line_detail_attr_tbl.FIRST;
IF I IS NOT NULL THEN
 LOOP

  DBMS_OUTPUT.PUT_LINE('Line detail Index '||x_line_detail_attr_tbl(I).line_detail_index);
  DBMS_OUTPUT.PUT_LINE('Context '||x_line_detail_attr_tbl(I).pricing_context);
  DBMS_OUTPUT.PUT_LINE('Attribute '||x_line_detail_attr_tbl(I).pricing_attribute);
  DBMS_OUTPUT.PUT_LINE('Value '||x_line_detail_attr_tbl(I).pricing_attr_value_from);
  DBMS_OUTPUT.PUT_LINE('Status Code '||x_line_detail_attr_tbl(I).status_code);
  DBMS_OUTPUT.PUT_LINE('---------------------------------------------------');

  EXIT WHEN I = x_line_detail_attr_tbl.last;
  I:=x_line_detail_attr_tbl.NEXT(I);

 END LOOP;
END IF;

DBMS_OUTPUT.PUT_LINE('-----------Qualifier Attributes Information-------------');

I := x_line_detail_qual_tbl.FIRST;
IF I IS NOT NULL THEN
 LOOP
  DBMS_OUTPUT.PUT_LINE('Line Detail Index '||x_line_detail_qual_tbl(I).line_detail_index);
  DBMS_OUTPUT.PUT_LINE('Context '||x_line_detail_qual_tbl(I).qualifier_context);
  DBMS_OUTPUT.PUT_LINE('Attribute '||x_line_detail_qual_tbl(I).qualifier_attribute);
  DBMS_OUTPUT.PUT_LINE('Value '||x_line_detail_qual_tbl(I).qualifier_attr_value_from);
  DBMS_OUTPUT.PUT_LINE('Status Code '||x_line_detail_qual_tbl(I).status_code);
  DBMS_OUTPUT.PUT_LINE('---------------------------------------------------');

  EXIT WHEN I = x_line_detail_qual_tbl.last;
  I:=x_line_detail_qual_tbl.NEXT(I);

 END LOOP;
END IF;

I := x_line_detail_tbl.FIRST;

DBMS_OUTPUT.PUT_LINE('------------Price List/Discount Information------------');

IF I IS NOT NULL THEN
 LOOP
  DBMS_OUTPUT.PUT_LINE('Line Index: '||x_line_detail_tbl(I).line_index);
  DBMS_OUTPUT.PUT_LINE('Line Detail Index: '||x_line_detail_tbl(I).line_detail_index);
  DBMS_OUTPUT.PUT_LINE('Line Detail Type:'||x_line_detail_tbl(I).line_detail_type_code);
  DBMS_OUTPUT.PUT_LINE('List Header Id: '||x_line_detail_tbl(I).list_header_id);
  DBMS_OUTPUT.PUT_LINE('List Line Id: '||x_line_detail_tbl(I).list_line_id);
  DBMS_OUTPUT.PUT_LINE('List Line Type Code: '||x_line_detail_tbl(I).list_line_type_code);
  DBMS_OUTPUT.PUT_LINE('Adjustment Amount : '||x_line_detail_tbl(I).adjustment_amount);
  DBMS_OUTPUT.PUT_LINE('Line Quantity : '||x_line_detail_tbl(I).line_quantity);
  DBMS_OUTPUT.PUT_LINE('Operand Calculation Code: '||x_line_detail_tbl(I).Operand_calculation_code);
  DBMS_OUTPUT.PUT_LINE('Operand value: '||x_line_detail_tbl(I).operand_value);
  DBMS_OUTPUT.PUT_LINE('Automatic Flag: '||x_line_detail_tbl(I).automatic_flag);
  DBMS_OUTPUT.PUT_LINE('Override Flag: '||x_line_detail_tbl(I).override_flag);
  DBMS_OUTPUT.PUT_LINE('status_code: '||x_line_detail_tbl(I).status_code);
  DBMS_OUTPUT.PUT_LINE('status text: '||x_line_detail_tbl(I).status_text);
  DBMS_OUTPUT.PUT_LINE('-------------------------------------------');
  EXIT WHEN I = x_line_detail_tbl.LAST;
  I := x_line_detail_tbl.NEXT(I);
 END LOOP;
END IF;

DBMS_OUTPUT.PUT_LINE('--------------Related Lines Information for Price Breaks/Service Items---------------');

I := x_related_lines_tbl.FIRST;
IF I IS NOT NULL THEN
 LOOP
  DBMS_OUTPUT.PUT_LINE('Line Index :'||x_related_lines_tbl(I).line_index);
  DBMS_OUTPUT.PUT_LINE('Line Detail Index: '||x_related_lines_tbl(I).LINE_DETAIL_INDEX);
  DBMS_OUTPUT.PUT_LINE('Relationship Type Code: '||x_related_lines_tbl(I).relationship_type_code);
  DBMS_OUTPUT.PUT_LINE('Related Line Index: '||x_related_lines_tbl(I).RELATED_LINE_INDEX);
  DBMS_OUTPUT.PUT_LINE('Related Line Detail Index: '||x_related_lines_tbl(I).related_line_detail_index);
  DBMS_OUTPUT.PUT_LINE('Status Code: '|| x_related_lines_tbl(I).STATUS_CODE);
  EXIT WHEN I = x_related_lines_tbl.LAST;
  I := x_related_lines_tbl.NEXT(I);
 END LOOP;
END IF;

END;
 

posted on 2014-11-19 21:42  王小航  阅读(487)  评论(0编辑  收藏  举报

导航