DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_PRICE_HELPER

Source


1 PACKAGE BODY PO_PRICE_HELPER AS
2 -- $Header: PO_PRICE_HELPER.plb 120.5.12020000.2 2013/03/15 21:28:45 pla ship $
3 
4 ---------------------------------------------------------------------------
5 -- Modules for debugging.
6 ---------------------------------------------------------------------------
7 
8 -- The module base for this package.
9   D_PACKAGE_BASE CONSTANT VARCHAR2(50) :=
10     PO_LOG.get_package_base('PO_PRICE_HELPER');
11 
12 -- The module base for the subprogram.
13   D_no_dists_reserved CONSTANT VARCHAR2(100) :=
14     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'no_dists_reserved');
15 
16 -- The module base for the subprogram.
17   D_accruals_allow_update CONSTANT VARCHAR2(100) :=
18     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'accruals_allow_update');
19 
20 -- The module base for the subprogram.
21   D_no_timecards_exist CONSTANT VARCHAR2(100) :=
22     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'no_timecards_exist');
23 
24 -- The module base for the subprogram.
25   D_no_pending_receipts CONSTANT VARCHAR2(100) :=
26     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'no_pending_receipts');
27 
28 -- The module base for the subprogram.
29   D_retro_account_allows_update CONSTANT VARCHAR2(100) :=
30     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'retro_account_allows_update');
31 
32 -- The module base for the subprogram.
33   D_warn_amt_based_notif_ctrls CONSTANT VARCHAR2(100) :=
34     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'warn_amt_based_notif_ctrls');
35 
36 -- The module base for the subprogram.
37   D_attempt_line_price_update CONSTANT VARCHAR2(100) :=
38     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'attempt_line_price_update');
39 
40 -- The module base for the subprogram.
41   D_check_system_allows_update CONSTANT VARCHAR2(100) :=
42     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'check_system_allows_update');
43 
44 -- The module base for the subprogram.
45   D_attempt_man_mod_pricing CONSTANT VARCHAR2(100) :=
46     PO_LOG.get_subprogram_base(D_PACKAGE_BASE, 'attempt_man_mod_pricing');
47 
48 ---------------------------------------------------------------------------
49 -- Constants.
50 ---------------------------------------------------------------------------
51 
52   c_result_type_rank_WARNING CONSTANT NUMBER :=
53     PO_VALIDATIONS.result_type_rank(PO_VALIDATIONS.c_result_type_warning);
54 
55   c_ENTITY_TYPE_LINE CONSTANT VARCHAR2(30) := PO_VALIDATIONS.c_ENTITY_TYPE_LINE;
56 
57   c_UNIT_PRICE CONSTANT VARCHAR2(30) := 'UNIT_PRICE';
58 
59 -- PO_HEADERS_ALL.type_lookup_code
60   c_STANDARD CONSTANT VARCHAR2(10) := 'STANDARD';
61 
62 -- PO_LINES_ALL.order_type_lookup_code
63   c_RATE CONSTANT VARCHAR2(5) := 'RATE';
64 
65 -- RCV_TRANSACTIONS_INTERFACE.transaction_status_code
66   c_PENDING CONSTANT VARCHAR2(10) := 'PENDING';
67 
68 -- Retroactive update mode
69   c_ALL_RELEASES CONSTANT VARCHAR2(30) := 'ALL_RELEASES';
70 
71 -- PO_HEADERS_ALL.authorization_status
72   c_INCOMPLETE CONSTANT VARCHAR2(30) := 'INCOMPLETE';
73 
74 -- PO_LINES_ALL.price_break_lookup_code
75   c_NON_CUMULATIVE CONSTANT VARCHAR2(30) := 'NON CUMULATIVE';
76 
77 -------------------------------------------------------------------------------
78 --Start of Comments
79 --Pre-reqs: None.
80 --Modifies: PO_VALIDATION_RESULTS, sequences.
81 --Locks: None.
82 --Function:
83 --  Determines if a line's price is allowed to be updated.
84 --Parameters:
85 --IN:
86 --p_po_line_id
87 --  Identifies the line that should be checked.
88 --p_draft_id
89 --  Further identifies the line.
90  -- <Bug 13503748 : Encumbrance ER : Parameter to
91  -- identify if the amount on the distributions of the line has been changed
92  -- p_amount_changed_flag
93 
94 --OUT:
95 --x_system_allows_update
96 --  Indicates whether or not a price change is allowed.
97 --    'Y' - price change is allowed.
98 --    'N' - price change is not allowed.
99 --  VARCHAR2(1)
100 --End of Comments
101 -------------------------------------------------------------------------------
102   PROCEDURE check_system_allows_update(
103      p_po_line_id IN NUMBER
104    , p_price_break_lookup_code IN VARCHAR2
105    , p_amount_changed_flag IN VARCHAR2  DEFAULT NULL  -- bug#13503748
106    , x_system_allows_update OUT NOCOPY VARCHAR2)
107   IS
108     d_mod CONSTANT VARCHAR2(100) := D_check_system_allows_update;
109     d_position NUMBER := 0;
110 
111     l_line_id_tbl PO_TBL_NUMBER;
112     l_price_break_lookup_code_tbl PO_TBL_VARCHAR30;
113     l_result_set_id NUMBER;
114     l_result_type VARCHAR2(30);
115     l_results PO_VALIDATION_RESULTS_TYPE;
116 
117     l_amount_changed_flag_tbl PO_TBL_VARCHAR1; --<Bug 13503748 :Encumbrance ER>--
118 
119   BEGIN
120     IF PO_LOG.d_proc THEN
121       PO_LOG.proc_begin(d_mod, 'p_po_line_id', p_po_line_id);
122       PO_LOG.proc_begin(d_mod, 'p_price_break_lookup_code', p_price_break_lookup_code);
123       PO_LOG.proc_begin(d_mod, 'p_amount_changed_flag', p_amount_changed_flag); --<Bug 13503748 :Encumbrance ER>--
124     END IF;
125 
126     d_position := 1;
127     l_line_id_tbl := PO_TBL_NUMBER(p_po_line_id);
128     l_price_break_lookup_code_tbl := PO_TBL_VARCHAR30(p_price_break_lookup_code);
129 
130     l_amount_changed_flag_tbl := PO_TBL_VARCHAR1(p_amount_changed_flag); --<Bug 13503748 :Encumbrance ER>--
131 
132     d_position := 100;
133     IF PO_LOG.d_stmt THEN
134       PO_LOG.stmt(d_mod, d_position, 'l_line_id_tbl', l_line_id_tbl);
135     END IF;
136 
137     PO_VALIDATIONS.validate_unit_price_change(
138        p_line_id_tbl => l_line_id_tbl
139      , p_price_break_lookup_code_tbl => l_price_break_lookup_code_tbl
140      , p_amount_changed_flag_tbl => l_amount_changed_flag_tbl  --<Bug 13503748 :Encumbrance ER>--
141      , p_stopping_result_type => PO_VALIDATIONS.c_result_type_FAILURE
142      , x_result_type => l_result_type
143      , x_result_set_id => l_result_set_id
144      , x_results => l_results);
145 
146     d_position := 200;
147     IF PO_LOG.d_stmt THEN
148       PO_LOG.stmt(d_mod, d_position, 'l_result_set_id', l_result_set_id);
149       PO_LOG.stmt(d_mod, d_position, 'l_result_type', l_result_type);
150     END IF;
151 
152     IF (PO_VALIDATIONS.result_type_rank(l_result_type) >=
153         c_result_type_rank_WARNING)
154       THEN
155       x_system_allows_update := 'Y';
156     ELSE
157       x_system_allows_update := 'N';
158     END IF;
159 
160     d_position := 300;
161     IF PO_LOG.d_proc THEN
162       PO_LOG.proc_end(d_mod, 'x_system_allows_update', x_system_allows_update);
163     END IF;
164 
165   EXCEPTION
166     WHEN OTHERS THEN
167       IF PO_LOG.d_exc THEN
168         PO_LOG.exc(d_mod, d_position, NULL);
169       END IF;
170       RAISE;
171   END check_system_allows_update;
172 
173 
174 -------------------------------------------------------------------------------
175 --Start of Comments
176 --Pre-reqs: None.
177 --Modifies: PO_VALIDATION_RESULTS, sequences.
178 --Locks: None.
179 --Function:
180 --  Verifies that the line's price is allowed to be updated
181 --  and calls the Pricing API to get a new price.
182 --Parameters:
183 --  See the parameter descriptions for PO_SOURCING_SV2.get_break_price.
184 --OUT:
185 --x_system_allows_update
186 --  Indicates whether or not a price change is allowed.
187 --    'Y' - price change is allowed.
188 --    'N' - price change is not allowed.
189 --  VARCHAR2(1)
190 --End of Comments
191 -------------------------------------------------------------------------------
192   PROCEDURE attempt_line_price_update(
193      p_order_quantity IN NUMBER
194    , p_ship_to_org IN NUMBER
195    , p_ship_to_loc IN NUMBER
196    , p_po_line_id IN NUMBER
197    , p_need_by_date IN DATE
198    , p_line_location_id IN NUMBER
199    , p_contract_id IN NUMBER
200    , p_org_id IN NUMBER
201    , p_supplier_id IN NUMBER
202    , p_supplier_site_id IN NUMBER
203    , p_creation_date IN DATE
204    , p_order_header_id IN NUMBER
205    , p_order_line_id IN NUMBER
206    , p_line_type_id IN NUMBER
207    , p_item_revision IN VARCHAR2
208    , p_item_id IN NUMBER
209    , p_category_id IN NUMBER
210    , p_supplier_item_num IN VARCHAR2
211    , p_uom IN VARCHAR2
212    , p_in_price IN NUMBER
213    , p_currency_code IN VARCHAR2
214    , p_price_break_lookup_code IN VARCHAR2
215    --<Enhanced Pricing Start>
216    , p_draft_id IN NUMBER DEFAULT NULL
217    , p_src_flag IN VARCHAR2 DEFAULT NULL
218    , p_doc_sub_type IN VARCHAR2 DEFAULT NULL
219    --<Enhanced Pricing End>
220    -- <Bug : 13503748 Encumbrance ER : Parameter to identify if the amount on the distributions of the line has been changed
221     ,p_amount_changed_flag IN VARCHAR2 DEFAULT NULL
222 
223    , x_base_unit_price OUT NOCOPY NUMBER
224    , x_price_break_id OUT NOCOPY NUMBER
225    , x_price OUT NOCOPY NUMBER
226    , x_return_status OUT NOCOPY VARCHAR2
227    , x_from_advanced_pricing OUT NOCOPY VARCHAR2
228    , x_system_allows_update OUT NOCOPY VARCHAR2)
229   IS
230     d_mod CONSTANT VARCHAR2(100) := D_attempt_line_price_update;
231     d_position NUMBER := 0;
232   BEGIN
233 
234     IF PO_LOG.d_proc THEN
235       PO_LOG.proc_begin(d_mod, 'p_order_quantity', p_order_quantity);
236       PO_LOG.proc_begin(d_mod, 'p_ship_to_org', p_ship_to_org);
237       PO_LOG.proc_begin(d_mod, 'p_ship_to_loc', p_ship_to_loc);
238       PO_LOG.proc_begin(d_mod, 'p_po_line_id', p_po_line_id);
239       PO_LOG.proc_begin(d_mod, 'p_need_by_date', p_need_by_date);
240       PO_LOG.proc_begin(d_mod, 'p_line_location_id', p_line_location_id);
241       PO_LOG.proc_begin(d_mod, 'p_contract_id', p_contract_id);
242       PO_LOG.proc_begin(d_mod, 'p_org_id', p_org_id);
243       PO_LOG.proc_begin(d_mod, 'p_supplier_id', p_supplier_id);
244       PO_LOG.proc_begin(d_mod, 'p_supplier_site_id', p_supplier_site_id);
245       PO_LOG.proc_begin(d_mod, 'p_creation_date', p_creation_date);
246       PO_LOG.proc_begin(d_mod, 'p_order_header_id', p_order_header_id);
247       PO_LOG.proc_begin(d_mod, 'p_order_line_id', p_order_line_id);
248       PO_LOG.proc_begin(d_mod, 'p_line_type_id', p_line_type_id);
249       PO_LOG.proc_begin(d_mod, 'p_item_revision', p_item_revision);
250       PO_LOG.proc_begin(d_mod, 'p_item_id', p_item_id);
251       PO_LOG.proc_begin(d_mod, 'p_category_id', p_category_id);
252       PO_LOG.proc_begin(d_mod, 'p_supplier_item_num', p_supplier_item_num);
253       PO_LOG.proc_begin(d_mod, 'p_uom', p_uom);
254       PO_LOG.proc_begin(d_mod, 'p_in_price', p_in_price);
255       PO_LOG.proc_begin(d_mod, 'p_currency_code', p_currency_code);
256       --<Enhanced Pricing Start>
257       PO_LOG.proc_begin(d_mod, 'p_draft_id', p_draft_id);
258       PO_LOG.proc_begin(d_mod, 'p_src_flag', p_src_flag);
259       PO_LOG.proc_begin(d_mod, 'p_doc_sub_type', p_doc_sub_type);
260       --<Enhanced Pricing End>
261       PO_LOG.proc_begin(d_mod, 'p_amount_changed_flag', p_amount_changed_flag);  -- <Bug : 13503748 Encumbrance ER >--
262     END IF;
263 
264     d_position := 1;
265     check_system_allows_update(
266                                  p_po_line_id => p_order_line_id
267                                , p_price_break_lookup_code => p_price_break_lookup_code
268                                 -- <Bug : Encumbrance ER : 13503748: Parameter to identify if the amount on
269                                 -- the distributions of the line has been changed
270                                , p_amount_changed_flag  => p_amount_changed_flag
271                                , x_system_allows_update => x_system_allows_update
272                                );
273 
274     d_position := 90;
275     IF PO_LOG.d_stmt THEN
276       PO_LOG.stmt(d_mod, d_position, 'x_system_allows_update', x_system_allows_update);
277     END IF;
278 
279     IF (x_system_allows_update = 'Y') THEN
280       d_position := 100;
281       PO_SOURCING2_SV.get_break_price(
282          p_api_version => 1.0
283        , p_order_quantity => p_order_quantity
284        , p_ship_to_org => p_ship_to_org
285        , p_ship_to_loc => p_ship_to_loc
286        , p_po_line_id => p_po_line_id
287        , p_cum_flag => FALSE
288        , p_need_by_date => TRUNC(p_need_by_date)
289        , p_line_location_id => p_line_location_id
290        , p_contract_id => p_contract_id
291        , p_org_id => p_org_id
292        , p_supplier_id => p_supplier_id
293        , p_supplier_site_id => p_supplier_site_id
294        , p_creation_date => p_creation_date
295        , p_order_header_id => p_order_header_id
296        , p_order_line_id => p_order_line_id
297        , p_line_type_id => p_line_type_id
298        , p_item_revision => p_item_revision
299        , p_item_id => p_item_id
300        , p_category_id => p_category_id
301        , p_supplier_item_num => p_supplier_item_num
302        , p_uom => p_uom
303        , p_in_price => p_in_price
304        , p_currency_code => p_currency_code
305        --<Enhanced Pricing Start>
306        , p_draft_id => p_draft_id
307        , p_src_flag => p_src_flag
308        , p_doc_sub_type => p_doc_sub_type
309        --<Enhanced Pricing End>
310        , x_base_unit_price => x_base_unit_price
311        , x_price_break_id => x_price_break_id
312        , x_price => x_price
313        , x_return_status => x_return_status
314        , x_from_advanced_pricing => x_from_advanced_pricing);
315     END IF;
316 
317     IF PO_LOG.d_proc THEN
318       PO_LOG.proc_end(d_mod, 'x_base_unit_price', x_base_unit_price);
319       PO_LOG.proc_end(d_mod, 'x_price_break_id', x_price_break_id);
320       PO_LOG.proc_end(d_mod, 'x_price', x_price);
321       PO_LOG.proc_end(d_mod, 'x_return_status', x_return_status);
322       PO_LOG.proc_end(d_mod, 'x_from_advanced_pricing', x_from_advanced_pricing);
323       PO_LOG.proc_end(d_mod, 'x_system_allows_update', x_system_allows_update);
324     END IF;
325 
326   EXCEPTION
327     WHEN OTHERS THEN
328       IF PO_LOG.d_exc THEN
329         PO_LOG.exc(d_mod, d_position, NULL);
330       END IF;
331       RAISE;
332   END attempt_line_price_update;
333 
334 
335 -------------------------------------------------------------------------------
336 --Start of Comments
337 --Pre-reqs: None.
338 --Modifies: PO_VALIDATION_RESULTS, sequences.
339 --Locks: None.
340 --Function:
341 --  Inserts a row into PO_VALIDATION_RESULTS for any of the specified
342 --  lines that have a reserved distribution.
343 --Parameters:
344 --IN:
345 --p_line_id_tbl
346 --  Identifies the lines that should be checked.
347 --p_draft_id_tbl
348 --  Used to insert messages into PO_VALIDATION_RESULTS.
349 --p_amount_changed_flag_tbl
350 -- <Bug : Encumbrance ER : 13503748: Parameter to identify if the amount
351 -- on the distributions of the line has been changed
352 --IN OUT:
353 --x_result_set_id
354 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
355 --  If this is NULL, it will be retrieved from the sequence.
356 --OUT:
357 --x_result_type
358 --  Indicates whether or not any error results were produced.
359 --    c_result_type_FAILURE - results were produced.
360 --    c_result_type_SUCCESS - no errors.
361 --  VARCHAR2(30)
362 --End of Comments
363 -------------------------------------------------------------------------------
364   PROCEDURE no_dists_reserved(
365      p_line_id_tbl IN PO_TBL_NUMBER
366    , p_amt_changed_flag_tbl IN PO_TBL_VARCHAR1
367    , x_result_set_id IN OUT NOCOPY NUMBER
368    , x_result_type OUT NOCOPY VARCHAR2)
369   IS
370     d_mod CONSTANT VARCHAR2(100) := D_no_dists_reserved;
371     d_position NUMBER := 0;
372     l_is_clm_po VARCHAR2(1) := 'N'; -- Bug#10397036
373   BEGIN
374 
375     IF PO_LOG.d_proc THEN
376       PO_LOG.proc_begin(d_mod, 'p_line_id_tbl', p_line_id_tbl);
377       PO_LOG.proc_begin(d_mod, 'p_amt_changed_flag_tbl', p_amt_changed_flag_tbl); -- <Bug13503748 : Encumbrance ER >--
378       PO_LOG.proc_begin(d_mod, 'x_result_set_id', x_result_set_id);
379     END IF;
380 
381     d_position := 1;
382     IF (x_result_set_id IS NULL) THEN
383       x_result_set_id := PO_VALIDATIONS.next_result_set_id();
384     END IF;
385 
386     d_position := 100;
387     /* Bug#10397036 : Unable to change Price in Modification */
388     x_result_type := PO_VALIDATIONS.c_result_type_SUCCESS;
389 
390     FOR i IN 1 .. p_line_id_tbl.Count LOOP
391       l_is_clm_po := PO_CLM_INTG_GRP.Is_clm_po(p_po_line_id => p_line_id_tbl(i));
392 
393       IF Nvl(l_is_clm_po,'N') = 'N' THEN
394         INSERT INTO PO_VALIDATION_RESULTS_GT
395         (result_set_id
396         , entity_type
397         , entity_id
398         , column_name
399         , message_name
400         )
401         SELECT
402           x_result_set_id
403         , c_ENTITY_TYPE_LINE
404         , p_line_id_tbl(i)
405         , c_UNIT_PRICE
406         , NULL -- TODO: Get message from PM.
407         FROM
408           PO_LINES_ALL LINE
409         , PO_HEADERS_ALL HEADER
410         WHERE
411             LINE.po_line_id = p_line_id_tbl(i)
412         AND HEADER.po_header_id = LINE.po_header_id
413         AND HEADER.type_lookup_code = c_STANDARD
414         AND LINE.order_type_lookup_code <> c_RATE
415         AND EXISTS
416           (SELECT NULL
417             FROM PO_DISTRIBUTIONS_ALL DIST
418             WHERE
419                 DIST.po_line_id = LINE.po_line_id
420             AND DIST.encumbered_flag = 'Y'
421           )
422     AND NVL(p_amt_changed_flag_tbl(i),'N') = 'N'; -- <Bug 13503748: Encumbrance ER >--
423 
424         d_position := 200;
425         IF (SQL%ROWCOUNT > 0) THEN
426           x_result_type := PO_VALIDATIONS.c_result_type_FAILURE;
427         END IF;
428       END IF;
429     END LOOP;
430 
431     d_position := 300;
432 
433     IF PO_LOG.d_proc THEN
434       PO_LOG.proc_end(d_mod, 'x_result_set_id', x_result_set_id);
435       PO_LOG.proc_end(d_mod, 'x_result_type', x_result_type);
436     END IF;
437 
438   EXCEPTION
439     WHEN OTHERS THEN
440       IF PO_LOG.d_exc THEN
441         PO_LOG.exc(d_mod, d_position, NULL);
442       END IF;
443       RAISE;
444   END no_dists_reserved;
445 
446 
447 -------------------------------------------------------------------------------
448 --Start of Comments
449 --Pre-reqs: None.
450 --Modifies: PO_VALIDATION_RESULTS, sequences.
451 --Locks: None.
452 --Function:
453 --  Inserts a row into PO_VALIDATION_RESULTS for each of the lines specified
454 --  whose accrued status should prevent an update to the price.
455 --  An example of an error is that some quantity has been billed and
456 --  retroactive price updates are not allowed.
457 --Parameters:
458 --IN:
459 --p_line_id_tbl
460 --  Identifies the lines that should be checked.
461 --p_draft_id_tbl
462 --  Used to insert messages into PO_VALIDATION_RESULTS.
463 --IN OUT:
464 --x_result_set_id
465 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
466 --  If this is NULL, it will be retrieved from the sequence.
467 --OUT:
468 --x_result_type
469 --  Indicates whether or not any error results were produced.
470 --    c_result_type_FAILURE - results were produced.
471 --    c_result_type_SUCCESS - no errors.
472 --  VARCHAR2(30)
473 --End of Comments
474 -------------------------------------------------------------------------------
475   PROCEDURE accruals_allow_update(
476      p_line_id_tbl IN PO_TBL_NUMBER
477    , x_results IN OUT NOCOPY PO_VALIDATION_RESULTS_TYPE
478    , x_result_type OUT NOCOPY VARCHAR2)
479   IS
480     d_mod CONSTANT VARCHAR2(100) := D_accruals_allow_update;
481     d_position NUMBER := 0;
482     d_stmt CONSTANT BOOLEAN := PO_LOG.d_stmt;
483 
484     l_results_count NUMBER;
485     l_data_key NUMBER;
486     l_line_id_tbl PO_TBL_NUMBER;
487     l_expense_accrual_code_tbl PO_TBL_VARCHAR4000;
488     l_header_id_tbl PO_TBL_NUMBER;
489     l_type_lookup_code_tbl PO_TBL_VARCHAR4000;
490 
491     l_quantity_received NUMBER;
492     l_quantity_billed NUMBER;
493     l_encumbered_flag VARCHAR2(1);
494     l_prevent_price_update_flag VARCHAR2(1);
495     l_online_req_flag VARCHAR2(1);
496     l_quantity_released NUMBER;
497     l_amount_released NUMBER;
498   BEGIN
499 
500     IF PO_LOG.d_proc THEN
501       PO_LOG.proc_begin(d_mod, 'p_line_id_tbl', p_line_id_tbl);
502     END IF;
503 
504     d_position := 1;
505     IF (x_results IS NULL) THEN
506       x_results := PO_VALIDATION_RESULTS_TYPE.new_instance();
507     END IF;
508 
509     l_results_count := x_results.result_type.COUNT;
510 
511 
512     d_position := 10;
513     l_data_key := PO_CORE_S.get_session_gt_nextval();
514 
515     FORALL i IN 1 .. p_line_id_tbl.COUNT
516     INSERT INTO PO_SESSION_GT
517     (key
518     , num1
519     )
520     VALUES
521     (l_data_key
522     , p_line_id_tbl(i)
523     )
524     ;
525 
526     d_position := 20;
527     SELECT
528       LINE.po_line_id
529     , HEADER.po_header_id
530     , HEADER.type_lookup_code
531     , PARAMS.expense_accrual_code
532     BULK COLLECT INTO
533       l_line_id_tbl
534     , l_header_id_tbl
535     , l_type_lookup_code_tbl
536     , l_expense_accrual_code_tbl
537     FROM
538       PO_SESSION_GT SES
539     , PO_LINES_ALL LINE
540     , PO_HEADERS_ALL HEADER
541     , PO_SYSTEM_PARAMETERS_ALL PARAMS
542     WHERE
543         SES.key = l_data_key
544     AND LINE.po_line_id = SES.num1
545     AND HEADER.po_header_id = LINE.po_header_id
546     AND HEADER.type_lookup_code = c_STANDARD
547     AND PARAMS.org_id = HEADER.org_id
548     ;
549 
550     d_position := 100;
551     IF PO_LOG.d_stmt THEN
552       PO_LOG.stmt_session_gt(d_mod, d_position, l_data_key);
553       PO_LOG.stmt(d_mod, d_position, 'l_line_id_tbl', l_line_id_tbl);
554       PO_LOG.stmt(d_mod, d_position, 'l_header_id_tbl', l_header_id_tbl);
555       PO_LOG.stmt(d_mod, d_position, 'l_type_lookup_code_tbl', l_type_lookup_code_tbl);
556       PO_LOG.stmt(d_mod, d_position, 'l_expense_accrual_code_tbl', l_expense_accrual_code_tbl);
557     END IF;
558 
559     FOR i IN 1 .. l_line_id_tbl.COUNT LOOP
560 
561   -- The prevent_price_udpate_flag should start as N,
562   -- and an error will only be reported if it becomed Y.
563       l_prevent_price_update_flag := 'N';
564 
565       d_position := 200;
566       PO_LINES_SV4.get_ship_quantity_info(
567          x_po_line_id => l_line_id_tbl(i)
568        , x_expense_accrual_code => l_expense_accrual_code_tbl(i)
569        , x_po_header_id => l_header_id_tbl(i)
570        , x_type_lookup_code => l_type_lookup_code_tbl(i)
571        , x_quantity_received => l_quantity_received
572        , x_quantity_billed => l_quantity_billed
573        , x_encumbered_flag => l_encumbered_flag
574        , x_prevent_price_update_flag => l_prevent_price_update_flag
575        , x_online_req_flag => l_online_req_flag
576        , x_quantity_released => l_quantity_released
577        , x_amount_released => l_amount_released);
578 
579       d_position := 300;
580       IF d_stmt THEN
581         PO_LOG.stmt(d_mod, d_position, 'l_prevent_price_update_flag', l_prevent_price_update_flag);
582       END IF;
583 
584       IF (l_prevent_price_update_flag = 'Y') THEN
585         d_position := 400;
586         x_results.add_result(
587            p_entity_type => c_ENTITY_TYPE_LINE
588          , p_entity_id => l_line_id_tbl(i)
589          , p_column_name => c_UNIT_PRICE
590          , p_message_name => NULL); -- TODO: need message from PM.
591 
592         d_position := 450;
593       END IF;
594 
595     END LOOP;
596 
597     IF (l_results_count < x_results.result_type.COUNT) THEN
598       x_result_type := PO_VALIDATIONS.c_result_type_FAILURE;
599     ELSE
600       x_result_type := PO_VALIDATIONS.c_result_type_SUCCESS;
601     END IF;
602 
603     IF PO_LOG.d_proc THEN
604       PO_LOG.proc_end(d_mod, 'x_result_type', x_result_type);
605     END IF;
606 
607   EXCEPTION
608     WHEN OTHERS THEN
609       IF PO_LOG.d_exc THEN
610         PO_LOG.exc(d_mod, d_position, NULL);
611       END IF;
612       RAISE;
613   END accruals_allow_update;
614 
615 
616 -------------------------------------------------------------------------------
617 --Start of Comments
618 --Pre-reqs: None.
619 --Modifies: PO_VALIDATION_RESULTS, sequences.
620 --Locks: None.
621 --Function:
622 --  Inserts a row into PO_VALIDATION_RESULTS for any of the specified
623 --  lines for which there are submitted or approved timecards.
624 --Parameters:
625 --IN:
626 --p_line_id_tbl
627 --  Identifies the lines that should be checked.
628 --p_draft_id_tbl
629 --  Used to insert messages into PO_VALIDATION_RESULTS.
630 --IN OUT:
631 --x_result_set_id
632 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
633 --  If this is NULL, it will be retrieved from the sequence.
634 --OUT:
635 --x_result_type
636 --  Indicates whether or not any error results were produced.
637 --    c_result_type_FAILURE - results were produced.
638 --    c_result_type_SUCCESS - no errors.
639 --  VARCHAR2(30)
640 --End of Comments
641 -------------------------------------------------------------------------------
642   PROCEDURE no_timecards_exist(
643      p_line_id_tbl IN PO_TBL_NUMBER
644    , x_results IN OUT NOCOPY PO_VALIDATION_RESULTS_TYPE
645    , x_result_type OUT NOCOPY VARCHAR2)
646   IS
647   BEGIN
648     PO_VALIDATION_HELPER.no_timecards_exist(
649        p_calling_module => D_no_timecards_exist
650      , p_line_id_tbl => p_line_id_tbl
651      , p_start_date_tbl => NULL
652      , p_expiration_date_tbl => NULL
653      , p_column_name => c_UNIT_PRICE
654      , p_message_name => PO_MESSAGE_S.PO_CHNG_OTL_NO_PRICE_CHANGE
655      , x_results => x_results
656      , x_result_type => x_result_type);
657   END no_timecards_exist;
658 
659 
660 -------------------------------------------------------------------------------
661 --Start of Comments
662 --Pre-reqs: None.
663 --Modifies: PO_VALIDATION_RESULTS, sequences.
664 --Locks: None.
665 --Function:
666 --  Inserts a row into PO_VALIDATION_RESULTS for any of the specified
667 --  lines for which there are pending receipts.
668 --Parameters:
669 --IN:
670 --p_line_id_tbl
671 --  Identifies the lines that should be checked.
672 --p_draft_id_tbl
673 --  Used to insert messages into PO_VALIDATION_RESULTS.
674 --IN OUT:
675 --x_result_set_id
676 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
677 --  If this is NULL, it will be retrieved from the sequence.
678 --OUT:
679 --x_result_type
680 --  Indicates whether or not any error results were produced.
681 --    c_result_type_FAILURE - results were produced.
682 --    c_result_type_SUCCESS - no errors.
683 --  VARCHAR2(30)
684 --End of Comments
685 -------------------------------------------------------------------------------
686   PROCEDURE no_pending_receipts(
687      p_line_id_tbl IN PO_TBL_NUMBER
688    , x_result_set_id IN OUT NOCOPY NUMBER
689    , x_result_type OUT NOCOPY VARCHAR2)
690   IS
691     d_mod CONSTANT VARCHAR2(100) := D_no_pending_receipts;
692     d_position NUMBER := 0;
693   BEGIN
694 
695     IF PO_LOG.d_proc THEN
696       PO_LOG.proc_begin(d_mod, 'p_line_id_tbl', p_line_id_tbl);
697       PO_LOG.proc_begin(d_mod, 'x_result_set_id', x_result_set_id);
698     END IF;
699 
700     d_position := 1;
701     IF (x_result_set_id IS NULL) THEN
702       x_result_set_id := PO_VALIDATIONS.next_result_set_id();
703     END IF;
704 
705     d_position := 100;
706     FORALL i IN 1 .. p_line_id_tbl.COUNT
707     INSERT INTO PO_VALIDATION_RESULTS_GT
708     (result_set_id
709     , entity_type
710     , entity_id
711     , column_name
712     , message_name
713     )
714     SELECT
715       x_result_set_id
716     , c_ENTITY_TYPE_LINE
717     , p_line_id_tbl(i)
718     , c_UNIT_PRICE
719     , PO_MESSAGE_S.PO_RCV_TRANSACTION_PENDING
720     FROM DUAL
721     WHERE EXISTS
722       (SELECT null
723         FROM
724           RCV_TRANSACTIONS_INTERFACE RTI
725         , PO_LINE_LOCATIONS_ALL POLL
726         WHERE
727             RTI.po_line_location_id = POLL.line_location_id
728         AND POLL.po_line_id = p_line_id_tbl(i)
729         AND RTI.transaction_status_code = c_PENDING
730       )
731     ;
732 
733     d_position := 200;
734     IF (SQL%ROWCOUNT > 0) THEN
735       x_result_type := PO_VALIDATIONS.c_result_type_FAILURE;
736     ELSE
737       x_result_type := PO_VALIDATIONS.c_result_type_SUCCESS;
738     END IF;
739 
740     IF PO_LOG.d_proc THEN
741       PO_LOG.proc_end(d_mod, 'x_result_set_id', x_result_set_id);
742       PO_LOG.proc_end(d_mod, 'x_result_type', x_result_type);
743     END IF;
744 
745   EXCEPTION
746     WHEN OTHERS THEN
747       IF PO_LOG.d_exc THEN
748         PO_LOG.exc(d_mod, d_position, NULL);
749       END IF;
750       RAISE;
751   END no_pending_receipts;
752 
753 
754 -------------------------------------------------------------------------------
755 --Start of Comments
756 --Pre-reqs: None.
757 --Modifies: PO_VALIDATION_RESULTS, sequences.
758 --Locks: None.
759 --Function:
760 --  Inserts a row into PO_VALIDATION_RESULTS for any of the specified
761 --  lines for which the retroactive account setup is not valid.
762 --Parameters:
763 --IN:
764 --p_line_id_tbl
765 --  Identifies the lines that should be checked.
766 --p_draft_id_tbl
767 --  Used to insert messages into PO_VALIDATION_RESULTS.
768 --IN OUT:
769 --x_result_set_id
770 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
771 --  If this is NULL, it will be retrieved from the sequence.
772 --OUT:
773 --x_result_type
774 --  Indicates whether or not any error results were produced.
775 --    c_result_type_FAILURE - results were produced.
776 --    c_result_type_SUCCESS - no errors.
777 --  VARCHAR2(30)
778 --End of Comments
779 -------------------------------------------------------------------------------
780   PROCEDURE retro_account_allows_update(
781      p_line_id_tbl IN PO_TBL_NUMBER
782    , p_price_break_lookup_code_tbl IN PO_TBL_VARCHAR30
783    , x_results IN OUT NOCOPY PO_VALIDATION_RESULTS_TYPE
784    , x_result_type OUT NOCOPY VARCHAR2)
785   IS
786     d_mod CONSTANT VARCHAR2(100) := D_retro_account_allows_update;
787     d_position NUMBER := 0;
788     d_stmt CONSTANT BOOLEAN := PO_LOG.d_stmt;
789 
790     l_results_count NUMBER;
791     l_data_key NUMBER;
792 
793     l_line_id_tbl PO_TBL_NUMBER;
794     l_price_break_lookup_code_tbl PO_TBL_VARCHAR4000;
795 
796     l_line_id NUMBER;
797     l_price_break_lookup_code VARCHAR2(4000);
798 
799     l_retroactive_update_mode VARCHAR2(30);
800     l_account_valid VARCHAR2(1);
801   BEGIN
802     IF PO_LOG.d_proc THEN
803       PO_LOG.proc_begin(d_mod, 'p_line_id_tbl', p_line_id_tbl);
804       PO_LOG.proc_begin(d_mod, 'p_price_break_lookup_code_tbl', p_price_break_lookup_code_tbl);
805     END IF;
806 
807     d_position := 1;
808     IF (x_results IS NULL) THEN
809       x_results := PO_VALIDATION_RESULTS_TYPE.new_instance();
810     END IF;
811 
812     l_results_count := x_results.result_type.COUNT;
813 
814     d_position := 50;
815     l_retroactive_update_mode := PO_RETROACTIVE_PRICING_PVT.get_retro_mode();
816 
817     d_position := 90;
818     IF d_stmt THEN
819       PO_LOG.stmt(d_mod, d_position, 'l_retroactive_update_mode', l_retroactive_update_mode);
820     END IF;
821 
822     IF (l_retroactive_update_mode = c_ALL_RELEASES) THEN
823       d_position := 100;
824       l_data_key := PO_CORE_S.get_session_gt_nextval();
825 
826       FORALL i IN 1 .. p_line_id_tbl.COUNT
827       INSERT INTO PO_SESSION_GT
828       (key
829       , num1
830       , char1
831       )
832       VALUES
833       (l_data_key
834       , p_line_id_tbl(i)
835       , p_price_break_lookup_code_tbl(i)
836       )
837       ;
838 
839       d_position := 110;
840       SELECT
841         SES.num1
842       , SES.char1
843       BULK COLLECT INTO
844         l_line_id_tbl
845       , l_price_break_lookup_code_tbl
846       FROM
847         PO_SESSION_GT SES
848       , PO_LINES_ALL LINE
849       , PO_HEADERS_ALL HEADER
850       WHERE
851           SES.key = l_data_key
852       AND LINE.po_line_id = SES.num1
853       AND HEADER.po_header_id = LINE.po_header_id
854       AND HEADER.type_lookup_code = c_STANDARD
855       AND HEADER.authorization_status <> c_INCOMPLETE
856       AND (SES.char1 IS NULL OR SES.char1 = c_NON_CUMULATIVE)
857       ;
858 
859       d_position := 120;
860       IF PO_LOG.d_stmt THEN
861         PO_LOG.stmt_session_gt(d_mod, d_position, l_data_key);
862         PO_LOG.stmt(d_mod, d_position, 'l_line_id_tbl', l_line_id_tbl);
863         PO_LOG.stmt(d_mod, d_position, 'l_price_break_lookup_code', l_price_break_lookup_code);
864       END IF;
865 
866       FOR i IN 1 .. l_line_id_tbl.COUNT LOOP
867         d_position := 200;
868         l_line_id := l_line_id_tbl(i);
869         l_price_break_lookup_code := l_price_break_lookup_code_tbl(i);
870 
871         IF d_stmt THEN
872           PO_LOG.stmt(d_mod, d_position,'iteration '|| i ||' l_line_id', l_line_id);
873         END IF;
874 
875         l_account_valid :=
876         PO_RETROACTIVE_PRICING_PVT.is_adjustment_account_valid(
877                                                                p_std_po_price_change => 'Y'
878                                                                , p_po_line_id => l_line_id
879                                                                , p_po_line_loc_id => NULL
880                                                                );
881 
882         d_position := 250;
883         IF d_stmt THEN
884           PO_LOG.stmt(d_mod, d_position, 'l_account_valid', l_account_valid);
885         END IF;
886 
887         IF (l_account_valid = 'N') THEN
888           d_position := 300;
889           x_results.add_result(
890                                p_entity_type => c_ENTITY_TYPE_LINE
891                                , p_entity_id => l_line_id
892                                , p_message_name => PO_MESSAGE_S.PO_CHNG_OTL_NO_PRICE_CHANGE
893                                , p_column_name => c_UNIT_PRICE
894                                );
895 
896           d_position := 350;
897         END IF;
898 
899       END LOOP;
900 
901     END IF;
902 
903     IF (l_results_count < x_results.result_type.COUNT) THEN
904       x_result_type := PO_VALIDATIONS.c_result_type_FAILURE;
905     ELSE
906       x_result_type := PO_VALIDATIONS.c_result_type_SUCCESS;
907     END IF;
908 
909     IF PO_LOG.d_proc THEN
910       PO_LOG.proc_end(d_mod, 'x_result_type', x_result_type);
911     END IF;
912 
913   EXCEPTION
914     WHEN OTHERS THEN
915       IF PO_LOG.d_exc THEN
916         PO_LOG.exc(d_mod, d_position, NULL);
917       END IF;
918       RAISE;
919   END retro_account_allows_update;
920 
921 
922 -------------------------------------------------------------------------------
923 --Start of Comments
924 --Pre-reqs: None.
925 --Modifies: PO_VALIDATION_RESULTS, sequences.
926 --Locks: None.
927 --Function:
928 --  Inserts a row into PO_VALIDATION_RESULTS for any of the specified
929 --  lines for which amount based notification controls exist.
930 --Parameters:
931 --IN:
932 --p_line_id_tbl
933 --  Identifies the lines that should be checked.
934 --p_draft_id_tbl
935 --  Used to insert messages into PO_VALIDATION_RESULTS.
936 --IN OUT:
937 --x_result_set_id
938 --  The identifier into PO_VALIDATION_RESULTS for the results produced.
939 --  If this is NULL, it will be retrieved from the sequence.
940 --OUT:
941 --x_result_type
942 --  Indicates whether or not any error results were produced.
943 --    c_result_type_WARNING - results were produced.
944 --    c_result_type_SUCCESS - no errors.
945 --  VARCHAR2(30)
946 --End of Comments
947 -------------------------------------------------------------------------------
948   PROCEDURE warn_amt_based_notif_ctrls(
949      p_line_id_tbl IN PO_TBL_NUMBER
950    , x_result_set_id IN OUT NOCOPY NUMBER
951    , x_result_type OUT NOCOPY VARCHAR2)
952   IS
953   BEGIN
954     PO_VALIDATION_HELPER.amount_notif_ctrl_warning(
955        p_calling_module => D_warn_amt_based_notif_ctrls
956      , p_line_id_tbl => p_line_id_tbl
957      , p_quantity_tbl => NULL
958      , p_column_name => c_UNIT_PRICE
959      , p_message_name => PO_MESSAGE_S.PO_PO_NFC_PRICE_CHANGE
960      , x_result_set_id => x_result_set_id
961      , x_result_type => x_result_type);
962   END warn_amt_based_notif_ctrls;
963 
964 --<Enhanced Pricing Start>
965 -------------------------------------------------------------------------------
966 --Start of Comments
967 --attempt_man_mod_pricing
968 -------------------------------------------------------------------------------
969 
970   PROCEDURE attempt_man_mod_pricing(
971      p_order_quantity IN NUMBER
972    , p_ship_to_org IN NUMBER
973    , p_ship_to_loc IN NUMBER
974    , p_po_line_id IN NUMBER
975    , p_need_by_date IN DATE
976    , p_line_location_id IN NUMBER
977    , p_contract_id IN NUMBER
978    , p_org_id IN NUMBER
979    , p_supplier_id IN NUMBER
980    , p_supplier_site_id IN NUMBER
981    , p_creation_date IN DATE
982    , p_order_header_id IN NUMBER
983    , p_order_line_id IN NUMBER
984    , p_line_type_id IN NUMBER
985    , p_item_revision IN VARCHAR2
986    , p_item_id IN NUMBER
987    , p_category_id IN NUMBER
988    , p_supplier_item_num IN VARCHAR2
989    , p_uom IN VARCHAR2
990    , p_in_price IN NUMBER
991    , p_currency_code IN VARCHAR2
992    , p_price_break_lookup_code IN VARCHAR2
993    --<Enhanced Pricing Start: Parameters to identify calls with or without source docuemnt and document type (standard or blanket)>
994    , p_src_flag IN VARCHAR2 DEFAULT NULL
995    , p_doc_sub_type IN VARCHAR2 DEFAULT NULL
996    --<Enhanced Pricing End>
997    , x_return_status OUT NOCOPY VARCHAR2
998    , x_system_allows_update OUT NOCOPY VARCHAR2)
999   IS
1000     d_mod CONSTANT VARCHAR2(100) := D_attempt_man_mod_pricing;
1001     d_position NUMBER := 0;
1002 
1003     l_doc_sub_type VARCHAR2(30);
1004     l_source_document_type PO_HEADERS.type_lookup_code%TYPE;
1005     l_source_document_header_id PO_LINES.po_header_id%TYPE;
1006     l_pricing_date PO_LINE_LOCATIONS.need_by_date%TYPE;
1007     l_rate PO_HEADERS.rate%TYPE;
1008     l_rate_type PO_HEADERS.rate_type%TYPE;
1009 
1010     l_return_status VARCHAR2(1);
1011   BEGIN
1012     -- Initialize OUT parameters
1013     x_return_status := FND_API.G_RET_STS_SUCCESS;
1014     x_system_allows_update := 'N';
1015 
1016     IF PO_LOG.d_proc THEN
1017       PO_LOG.proc_begin(d_mod, 'p_order_quantity', p_order_quantity);
1018       PO_LOG.proc_begin(d_mod, 'p_ship_to_org', p_ship_to_org);
1019       PO_LOG.proc_begin(d_mod, 'p_ship_to_loc', p_ship_to_loc);
1020       PO_LOG.proc_begin(d_mod, 'p_po_line_id', p_po_line_id);
1021       PO_LOG.proc_begin(d_mod, 'p_need_by_date', p_need_by_date);
1022       PO_LOG.proc_begin(d_mod, 'p_line_location_id', p_line_location_id);
1023       PO_LOG.proc_begin(d_mod, 'p_contract_id', p_contract_id);
1024       PO_LOG.proc_begin(d_mod, 'p_org_id', p_org_id);
1025       PO_LOG.proc_begin(d_mod, 'p_supplier_id', p_supplier_id);
1026       PO_LOG.proc_begin(d_mod, 'p_supplier_site_id', p_supplier_site_id);
1027       PO_LOG.proc_begin(d_mod, 'p_creation_date', p_creation_date);
1028       PO_LOG.proc_begin(d_mod, 'p_order_header_id', p_order_header_id);
1029       PO_LOG.proc_begin(d_mod, 'p_order_line_id', p_order_line_id);
1030       PO_LOG.proc_begin(d_mod, 'p_line_type_id', p_line_type_id);
1031       PO_LOG.proc_begin(d_mod, 'p_item_revision', p_item_revision);
1032       PO_LOG.proc_begin(d_mod, 'p_item_id', p_item_id);
1033       PO_LOG.proc_begin(d_mod, 'p_category_id', p_category_id);
1034       PO_LOG.proc_begin(d_mod, 'p_supplier_item_num', p_supplier_item_num);
1035       PO_LOG.proc_begin(d_mod, 'p_uom', p_uom);
1036       PO_LOG.proc_begin(d_mod, 'p_in_price', p_in_price);
1037       PO_LOG.proc_begin(d_mod, 'p_currency_code', p_currency_code);
1038       PO_LOG.proc_begin(d_mod, 'p_src_flag', p_src_flag);
1039       PO_LOG.proc_begin(d_mod, 'p_doc_sub_type', p_doc_sub_type);
1040     END IF;
1041 
1042     d_position := 1;
1043     check_system_allows_update( p_po_line_id              => p_order_line_id
1044                               , p_price_break_lookup_code => p_price_break_lookup_code
1045                               , x_system_allows_update    => x_system_allows_update
1046                               );
1047 
1048     d_position := 100;
1049     IF PO_LOG.d_stmt THEN
1050       PO_LOG.stmt(d_mod, d_position, 'x_system_allows_update', x_system_allows_update);
1051     END IF;
1052 
1053     IF (x_system_allows_update = 'Y') THEN
1054       d_position := 120;
1055       --Initialize Document Sub Type
1056       IF (p_doc_sub_type IS NOT NULL) THEN
1057         l_doc_sub_type := p_doc_sub_type;
1058       ELSE
1059         l_doc_sub_type := 'PO';
1060       END IF;
1061 
1062       IF PO_LOG.d_stmt THEN
1063         PO_LOG.stmt(d_mod, d_position, 'l_doc_sub_type', l_doc_sub_type);
1064       END IF;
1065 
1066       d_position := 140;
1067       IF PO_LOG.d_stmt THEN
1068         PO_LOG.stmt(d_mod, d_position, 'Get source document header id and type');
1069       END IF;
1070 
1071       IF (p_po_line_id IS NOT NULL) THEN
1072         SELECT ph.type_lookup_code,
1073                pl.po_header_id
1074         INTO   l_source_document_type,
1075              l_source_document_header_id
1076         FROM po_headers_all ph,
1077              po_lines_all pl
1078         WHERE ph.po_header_id = pl.po_header_id
1079         AND pl.po_line_id = p_po_line_id;
1080       ELSIF (p_contract_id IS NOT NULL) THEN
1081         SELECT ph.type_lookup_code,
1082                ph.po_header_id
1083         INTO   l_source_document_type,
1084                l_source_document_header_id
1085         FROM po_headers_all ph
1086         WHERE ph.po_header_id = p_contract_id;
1087       ELSE
1088         l_source_document_type := NULL;
1089         l_source_document_header_id := NULL;
1090       END IF;
1091 
1092       l_pricing_date := NVL(p_need_by_date, SYSDATE);
1093 
1094       IF (PO_ADVANCED_PRICE_PVT.is_valid_qp_line_type(p_line_type_id)) THEN
1095         l_rate_type := NULL;
1096         l_rate := NULL;
1097         d_position := 160;
1098         IF PO_LOG.d_stmt THEN
1099           PO_LOG.stmt(d_mod, d_position, 'Call pricing to retrieve manual modifiers');
1100         END IF;
1101 
1102         PO_ADVANCED_PRICE_PVT.call_pricing_manual_modifier(
1103             p_org_id => p_org_id
1104           , p_supplier_id => p_supplier_id
1105           , p_supplier_site_id => p_supplier_site_id
1106           , p_creation_date => p_creation_date
1107           , p_order_type => l_doc_sub_type
1108           , p_ship_to_location_id => p_ship_to_loc
1109           , p_ship_to_org_id => p_ship_to_org
1110           , p_order_header_id => p_order_header_id
1111           , p_order_line_id => p_order_line_id
1112           , p_item_revision => p_item_revision
1113           , p_item_id => p_item_id
1114           , p_category_id => p_category_id
1115           , p_supplier_item_num => p_supplier_item_num
1116           , p_agreement_type => l_source_document_type
1117           , p_agreement_id => l_source_document_header_id
1118           , p_agreement_line_id => p_po_line_id
1119           , p_rate => l_rate
1120           , p_rate_type => l_rate_type
1121           , p_currency_code => p_currency_code
1122           , p_need_by_date => l_pricing_date
1123           , p_quantity => p_order_quantity
1124           , p_uom => p_uom
1125           , p_unit_price => p_in_price
1126           , x_return_status => l_return_status );
1127 
1128         IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
1129           app_exception.raise_exception;
1130         END IF; /* IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) */
1131 
1132         x_return_status := l_return_status;
1133 
1134         d_position := 180;
1135         IF PO_LOG.d_stmt THEN
1136           PO_LOG.stmt(d_mod, d_position, 'x_return_status', x_return_status);
1137         END IF;
1138       ELSE
1139         d_position := 200;
1140         IF PO_LOG.d_stmt THEN
1141           PO_LOG.stmt(d_mod, d_position, 'Not a valid price type to call Advanced Pricing API(NSD - No Source Document)');
1142         END IF;
1143       END IF; /*IF (PO_ADVANCED_PRICE_PVT.is_valid_qp_line_type(p_line_type_id))*/
1144     END IF;
1145     IF PO_LOG.d_proc THEN
1146       PO_LOG.proc_end(d_mod, 'x_return_status', x_return_status);
1147       PO_LOG.proc_end(d_mod, 'x_system_allows_update', x_system_allows_update);
1148     END IF;
1149   EXCEPTION
1150     WHEN OTHERS THEN
1151       IF PO_LOG.d_exc THEN
1152         PO_LOG.exc(d_mod, d_position, NULL);
1153       END IF;
1154       RAISE;
1155   END attempt_man_mod_pricing;
1156 
1157 END PO_PRICE_HELPER;