[Home] [Help]
PACKAGE BODY: APPS.JMF_SHIKYU_RPT_CFR_PVT
Source
1 PACKAGE BODY JMF_SHIKYU_RPT_CFR_PVT AS
2 --$Header: JMFVCFRB.pls 120.40.12020000.2 2012/07/04 07:20:23 ntungare ship $
3 --+===========================================================================+
4 --| Copyright (c) 2005 Oracle Corporation |
5 --| Redwood Shores, California, USA |
6 --| All rights reserved. |
7 --+===========================================================================+
8 --| |
9 --| FILENAME : JMFVCFRB.pls |
10 --| |
11 --| DESCRIPTION: Body file of the package for creating temporary |
12 --| data for SHIKYU Confirmation Report. |
13 --| |
14 --| FUNCTION/PROCEDURE: cfr_before_report_trigger |
15 --| get_onhand_components |
16 --| get_rpt_confirmation_data |
17 --| get_unallocated_components |
18 --| get_unallocated_rep_po |
19 --| get_rep_po_residual_unalloc |
20 --| set_rep_po_residual_unalloc |
21 --| set_rcv_transaction_unalloc |
22 --| get_unconsumed_components |
23 --| get_unconsumed_sub_po |
24 --| get_unconsumed_rep_po |
25 --| get_sub_po_residual_unconsume |
26 --| set_sub_po_residual_unconsume |
27 --| set_rcv_transaction_unconsume |
28 --| validate_cfr_mid_temp |
29 --| add_data_to_cfr_temp |
30 --| rpt_get_crude_data |
31 --| rpt_get_Comp_Estimated_data |
32 --| rpt_get_SubPO_data |
33 --| rpt_get_UnReceived_data |
34 --| rpt_get_Received_data |
35 --| rpt_get_Int_data |
36 --| rpt_debug_show_mid_data |
37 --| rpt_debug_show_temp_data |
38 --| |
39 --| HISTORY: |
40 --| 15-APR-2005 shu Created. |
41 --| 10-OCT-2005 shu Added some output information for debug |
42 --| 11-OCT-2005 shu Modified subcontracting_component column |
43 --| select criteria. |
44 --| 13-OCT-2005 shu Modified source code to avoid the warning |
45 --| message. added debug output code |
46 --| 18-NOV-2005 shu added code for setting request completed with |
47 --| warning if SHIKYU profile is disable |
48 --| 05-DEC-2005 shu Fixed some no data issue due to null columns |
49 --| 07-DEC-2005 shu added procedures rpt_get_xxx for report data |
50 --| 21-DEC-2005 shu tuning SQLperformance in get_onhand_components|
51 --| 16-JAN-2006 shu using FND_LOG.STRING for logging standard |
52 --| 19-JAN-2006 shu changed parameter p_currency_conversion_date |
53 --| from date to varchar2; |
54 --| added rpt_debug_show_mid_data procedure |
55 --| added rpt_debug_show_temp_data procedure |
56 --| 26-JAN-2006 shu fix bug #4997302 for report UOM conversion |
57 --| 08-FEB-2006 shu fix bug #4997302 for date conversion and |
58 --| reversed Price/Cost conversion |
59 --| 14-FEB-2006 shu fix bug #4997302 for the item cost column |
60 --| 13-MAR-2006 amy remove commented code |
61 --| 19-MAY-2006 amy updated procedure cfr_before_report_trigger to fix bug #5212686 |
62 --| 24-MAY-2006 amy updated procedure get_onhand_components to fix sqlid#17703607 in bug #5212686 |
63 --| 22-JUNE-2006 amy updated procedure rpt_get_Comp_Estimated_data and rpt_get_Int_data |
64 --| to fix bug #5231233 |
65 --| 26-JUNE-2006 amy updated procedure get_unconsumed_sub_po AND get_unconsumed_rep_po |
66 --| to fix potensial issue,which occurs when same onhand components are found in different tp organization |
67 --| 28-JUNE-2006 amy updated procedure get_unallocated_rep_po |
68 --| to fix potensial issue that some unallocated repPO are lost in the report |
69 --| this issue was found when fixed bug #5232863 |
70 --| 28-JUNE-2006 amy updated procedure rpt_get_crude_data to fix project_number related issue |
71 --| 19-JUNE-2006 amy updated to fix bug 5391412 |
72 --| Updated procedure rpt_get_SubPO_data to get all received subPOs(partial or fully) |
73 --| instead of get those subPOs causing onhand Qty |
74 --| Renamed original procedure rpt_get_SubPO_data as rpt_get_SubPO_data_Onhand for future use |
75 --| instead of get those subPOs causing onhand Qty |
76 --| Added global variable g_ou_id to pass ou infro to procedure rpt_get_SubPO_data |
77 --| Added global variable CFR_EXT_SUBPO_AFT_ONHAND to identify original subpo data in rpt_temp table |
78 --| 28-JUNE-2006 amy updated procedure rpt_get_SubPO_data to fix bug 5415777 |
79 --| 07-SEP-2006 amy updated procedure rpt_get_crude_data to fix bug 5510828(get project id for table sub not from rcv transactions) |
80 --| updated procedure rpt_get_Comp_Estimated_data to fix bug 5510828(insert project_num/task_num information into rpt temp data(100) |
81 --| updated procedure rpt_get_SubPo_data to fix bug 5510828(insert project_num/task_num information into rpt temp data(110) |
82 --| 18-SEP-2006 amy updated procedure get_unallocated_components to fix bug 5509464(get vendor_id/vendor_site_id from repleninshment po information in receiving transaction query) |
83 --| updated procedure get_unallocated_rep_po to fix bug 5509464(updated sql query criteria to cover the cases when having some rep POs have corresponding rep SOs |
84 --| but are not allocated to a subcontracting po. |
85 --| updated procedure rpt_get_crude_data to fix bug 5509464(updated sql query criteria to cover the cases when having some rep POs have corresponding rep SOs |
86 --| but are not allocated to a subcontracting po. |
87 --| 28-SEP-2006 amy updated procedure get_unallocated_components
88 --| get_unallocated_rep_po |
89 --| set_rep_po_residual_unalloc |
90 --| set_rcv_transaction_unalloc |
91 --| set_sub_po_residual_unconsume |
92 --| set_rcv_transaction_unconsume |
93 --| to fix potential issue of operations between null numbers |
94 --| 17-NOV-2006 amy updated procedure cfr_before_report_trigger, |
95 --| add_data_to_cfr_temp and |
96 --| rpt_get_UnReceived_data to fix bug 5583680 |
97 --| 20-NOV-2006 amy updated procedure rpt_get_Comp_Estimated_data |
98 --| and rpt_get_Int_data to fix bug 5665445. |
99 --| The issue was mainly due to the duplicated |
100 --| conversions of the onhand qty from the |
101 --| Secondary UOM, which caused the resulting |
102 --| onhand qty to be much smaller than the actual |
103 --| onhand qty. |
104 --| 21-NOV-2006 vchu continued bug fix for bug 5583680: |
105 --| modified the query in rpt_get_Received_data |
106 --| to correctly fetched the replenishments |
107 --| received in past xx days. Also, replaced |
108 --| usages of shipping_quantity_uom column of the |
109 --| oe_order_lines_all table by the |
110 --| order_quantity_uom, since this is the correct |
111 --| uom accompanying the shipped_quantity. |
112 --| 21-NOV-2006 vchu bug fix for 5665334: Changed the signature |
113 --| of cfr_before_report_trigger to pass in the |
114 --| ID of the FROM and TO OEM Organization, |
115 --| instead of the name. Also added a new helper |
116 --| procedure to get the name of an Inventory |
117 --| organization given the ID. This procedure is |
118 --| called in cfr_before_report_trigger in order |
119 --| to get the name of the TO and FROM |
120 --| Organization in the current session language. |
121 --| 08-DEC-2006 amy bug fix for 5702139: Updated procedure |
122 --| get_unallocated_rep_po to pass correct uom |
123 --| jmf_shikyu_allocations.uom to parameter p_current_uom_code |
124 --| when call function get_item_primary_quantity |
125 --| to convert allocated quantity |
126 --| 11-DEC-2006 amy bug fix for 5702139: Updated procedure |
127 --| get_unallocated_rep_po again to pass primary |
128 --| uom to parameter p_current_uom_code when |
129 --| the replenishment PO is never allocated to a |
130 --| subcontracting PO |
131 --| 04-OCT-2007 kdevadas 12.1 Buy/Sell Subcontracting changes |
132 --| Reference - GBL_BuySell_TDD.doc |
133 --| Reference - GBL_BuySell_FDD.doc |
134 --| 16-NOV-2007 kdevadas Bug 6630087 - Removed the standard cost check|
135 --| as Buy/Sell subcontracting supports non-std |
136 --| OEM orgs as well |
137 --+===========================================================================+
138
139 --=============================================
140 -- CONSTANTS
141 --=============================================
142 G_MODULE_PREFIX CONSTANT VARCHAR2(50) := 'jmf.plsql.' || G_PKG_NAME || '.';
143
144 --=============================================
145 -- GLOBAL VARIABLES
146 --=============================================
147
148 g_fnd_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'), 'N');
149 --Amy add for fixing bug 5391412 start
150 g_ou_id NUMBER:=0;
151 --Amy add for fixing bug 5391412 end
152
153 --The report region for confirmation report
154 CFR_CRUDE_DATA CONSTANT NUMBER := 10;
155 CFR_EXT_COMPONENT CONSTANT NUMBER := 100;
156 CFR_EXT_SUBCONTRACT_PO CONSTANT NUMBER := 110;
157 CFR_EXT_UN_RCV CONSTANT NUMBER := 120;
158 CFR_EXT_RCV_IN_DAYS CONSTANT NUMBER := 130;
159 --Amy add for fixing bug 5391412 start
160 CFR_EXT_SUBPO_AFT_ONHAND CONSTANT NUMBER := 140;
161 --Amy add for fixing bug 5391412 end
162 CFR_INT_COMPONENT CONSTANT NUMBER := 200;
163
164 --the constant for temporary table rowtype identify for confirmation report
165 CFR_TMP_ONHAND_ROW CONSTANT NUMBER := 10; --The onhand information
166 CFR_TMP_REP_PO_UNALLOCATED_ROW CONSTANT NUMBER := 20; --The replenishment purchase order unallocated info
167 CFR_TMP_REP_PO_UNCONSUMED_ROW CONSTANT NUMBER := 30; --The replenishment purchase order unconsumed info
168 CFR_TMP_SUB_PO_UNCONSUMED_ROW CONSTANT NUMBER := 40; --The subcontracting purchase order info
169 CFR_TMP_RCV_ROW CONSTANT NUMBER := 50; --The receive transactions info
170
171 --the constant for temporary table get_rcv_flag for confirmation report
172 CFR_REP_PO_GET_RCV_FLAG CONSTANT VARCHAR2(1) := 'Y'; --this rep_po line has been used for get_rcv_transactions
173 CFR_SUB_PO_GET_REP_FLAG CONSTANT VARCHAR2(1) := 'Y'; --this sub_po line has been used for get_replenishment po
174
175 -- Bug 5665334
176 --========================================================================
177 -- PROCEDURE : get_organization_name PUBLIC
178 -- PARAMETERS: p_organization_id Inventory Organization ID
179 -- : x_organization_name Organization Name to be returned
180 -- COMMENT : The procedure returns the name of an Inventory Organization
181 -- if the input ID parameter was valid.
182 --========================================================================
183 PROCEDURE get_organization_name
184 ( p_organization_id IN NUMBER
185 , x_organization_name OUT NOCOPY VARCHAR2
186 )
187 IS
188 BEGIN
189
190 x_organization_name := NULL;
191
192 IF p_organization_id IS NOT NULL
193 THEN
194 SELECT name
195 INTO x_organization_name
196 FROM hr_all_organization_units_tl haoutl
197 WHERE haoutl.organization_id = p_organization_id
198 AND haoutl.LANGUAGE = USERENV('LANG');
199 END IF;
200
201 EXCEPTION
202 WHEN NO_DATA_FOUND THEN
203 x_organization_name := NULL;
204
205 WHEN OTHERS THEN
206 x_organization_name := NULL;
207
208 END get_organization_name;
209
210 --========================================================================
211 -- PROCEDURE : cfr_before_report_trigger PUBLIC
212 -- PARAMETERS: p_rpt_mode the report mode: External/Internal report
213 -- : p_ou_id Operating unit id
214 -- : p_supplier_name_from the supplier name from
215 -- : p_supplier_name_to the supplier name to
216 -- : p_supplier_site_code_from the supplier site code from
217 -- : p_supplier_site_code_to the supplier site code to
218 -- : p_oem_inv_org_name_from oem inventory org name from
219 -- : p_oem_inv_org_name_to oem inventory org name to
220 -- : p_item_number_from item number from
221 -- : p_item_number_to item number to
222 -- : p_days_received received after the days ago
223 -- : p_sort_by By Supplier/Site or By Item,
224 -- the External report can use only by Supplier/Site
225 -- : p_currency_conversion_type the currency conversion type
226 -- : p_currency_conversion_date the currency conversion date
227 -- COMMENT : this procedure will be called in the before report trigger,
228 -- all the other needed procedures will be called in this procedure
229 -- PRE-COND :
230 -- EXCEPTIONS:
231 --========================================================================
232 PROCEDURE cfr_before_report_trigger
233 (
234 p_rpt_mode IN VARCHAR2
235 ,p_ou_id IN NUMBER
236 ,p_supplier_name_from IN VARCHAR2
237 ,p_supplier_site_code_from IN VARCHAR2
238 ,p_supplier_name_to IN VARCHAR2
239 ,p_supplier_site_code_to IN VARCHAR2
240 -- Bug 5665334
241 ,p_oem_inv_org_id_from IN NUMBER
242 ,p_oem_inv_org_id_to IN NUMBER
243 ,p_item_number_from IN VARCHAR2
244 ,p_item_number_to IN VARCHAR2
245 ,p_days_received IN NUMBER
246 ,p_sort_by IN VARCHAR2
247 ,p_currency_conversion_type IN VARCHAR2
248 ,p_currency_conversion_date IN VARCHAR2 --from Report parameter, use VARCHAR2 not DATE
249 ,p_functional_currency IN VARCHAR2
250 ) IS
251
252 l_api_name CONSTANT VARCHAR2(30) := 'cfr_before_report_trigger';
253 l_currency_conversion_date DATE;
254 --for checking SHIKYU enable profile.
255 l_jmf_shk_not_enabled VARCHAR2(240);
256 l_conc_succ BOOLEAN;
257 l_functional_currency gl_ledgers.currency_code%TYPE;
258
259 -- Bug 5665334
260 l_oem_inv_org_name_from hr_all_organization_units_tl.name%TYPE := NULL;
261 l_oem_inv_org_name_to hr_all_organization_units_tl.name%TYPE := NULL;
262
263 BEGIN
264
265 --Amy add for fixing bug 5391412 start
266 -- set g_ou_id for rpt_get_subPO_data procedure.
267 g_ou_id := p_ou_id;
268 --Amy add for fixing bug 5391412 end
269
270 -- Bug 5665334: Get the name of the OEM Organization From and Organization To
271 get_organization_name
272 ( p_organization_id => p_oem_inv_org_id_from
273 , x_organization_name => l_oem_inv_org_name_from
274 );
275 get_organization_name
276 ( p_organization_id => p_oem_inv_org_id_to
277 , x_organization_name => l_oem_inv_org_name_to
278 );
279
280 -- **** for debug information in readonly UT environment.--- begin ****
281 JMF_SHIKYU_RPT_UTIL.debug_output
282 (
283 p_output_to => 'FND_LOG.STRING'
284 ,p_api_name => G_MODULE_PREFIX || l_api_name || '.begin'
285 ,p_message => 'CVS Version(v 2.26 2006/02/14):' ||
286 ',p_rpt_mode:' || p_rpt_mode ||
287 ',p_ou_id :' || g_ou_id ||
288 ',p_supplier_name_from:' || p_supplier_name_from ||
289 ',p_supplier_site_code_from:' || p_supplier_site_code_from ||
290 ',p_supplier_name_to :' || p_supplier_name_to ||
291 ',p_supplier_site_code_to:' || p_supplier_site_code_to ||
292 ',p_oem_inv_org_id_from:' || p_oem_inv_org_id_from ||
293 ',l_oem_inv_org_name_from:' || l_oem_inv_org_name_from ||
294 ',p_oem_inv_org_id_to:' || p_oem_inv_org_id_to ||
295 ',l_oem_inv_org_name_to:' || l_oem_inv_org_name_to ||
296 ',p_item_number_from:' || p_item_number_from ||
297 ',p_item_number_to:' || p_item_number_to ||
298 ',p_days_received:' || p_days_received ||
299 ',p_sort_by:' || p_sort_by ||
300 ',p_currency_conversion_type:' || p_currency_conversion_type ||
301 ',p_currency_conversion_date:' || p_currency_conversion_date ||
302 ',p_functional_currency:' || p_functional_currency
303 );
304 -- **** for debug information in readonly UT environment.--- end ****
305
306 /*IF p_currency_conversion_date IS NULL */
307 /* the input date format like 30-DEC-2005 in the parameter form
308 Use fnd_date.canonical_to_date rather than use to_date, as some date formate issue.
309 */
310 IF p_currency_conversion_date IS NULL
311 THEN
312 l_currency_conversion_date := SYSDATE;
313 ELSE
314 l_currency_conversion_date := fnd_date.canonical_to_date(p_currency_conversion_date);
315 END IF;
316
317 l_functional_currency := p_functional_currency;
318 IF (p_functional_currency IS NULL)
319 THEN
320 SELECT gl_ledgers.currency_code
321 INTO l_functional_currency
322 FROM gl_ledgers gl_ledgers
323 WHERE gl_ledgers.ledger_id =
324 /* (SELECT DISTINCT xllv.ledger_id
325 FROM xle_le_ou_ledger_v xllv
326 WHERE xllv.operating_unit_id = p_ou_id
327 );*/
328 (select set_of_books_id from hr_operating_units
329 where organization_id = p_ou_id);
330 END IF;
331 -- **** for debug information in readonly UT environment.--- begin ****
332 JMF_SHIKYU_RPT_UTIL.debug_output
333 (
334 p_output_to => 'FND_LOG.STRING'
335 ,p_api_name => G_MODULE_PREFIX || l_api_name
336 ,p_message => 'l_functional_currency:' || l_functional_currency ||
337 ',l_currency_conversion_date:' || l_currency_conversion_date
338 );
339 -- **** for debug information in readonly UT environment.--- end ****
340
341 IF g_fnd_debug = 'Y' AND
342 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
343 THEN
344 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
345 , g_module_prefix || l_api_name || '.begin'
346 , NULL);
347 END IF;
348
349 --check if the SHIKYU enable profile is set to Yes. if no then return one error and stop.
350 IF (NVL(FND_PROFILE.VALUE('JMF_SHK_CHARGE_BASED_ENABLED'), 'N') = 'N')
351 THEN
352 FND_MESSAGE.SET_NAME('JMF', 'JMF_SHK_NOT_ENABLE');
353 l_jmf_shk_not_enabled := FND_MESSAGE.GET;
354
355 fnd_file.PUT_LINE(fnd_file.output, l_jmf_shk_not_enabled);
356
357 l_conc_succ := fnd_concurrent.set_completion_status(status => 'WARNING'
358 ,message => l_jmf_shk_not_enabled);
359
360 IF g_fnd_debug = 'Y' AND
361 FND_LOG.LEVEL_ERROR >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
362 THEN
363 IF l_conc_succ
364 THEN
365 fnd_log.STRING( FND_LOG.LEVEL_ERROR
366 ,g_module_prefix || l_api_name || '.Warning'
367 ,l_jmf_shk_not_enabled);
368 END IF;
369 END IF;
370
371 RETURN;
372 END IF;
373
374 --clear old data if any
375 DELETE FROM JMF_SHIKYU_CFR_MID_TEMP;
376 DELETE FROM JMF_SHIKYU_CFR_RPT_TEMP;
377 COMMIT;
378
379 -- Valid parameter validation;
380 -- if all parameters are valid then continue; otherwise raise an error message in log;
381 --get the on hand components information,with inv_org,item_id
382 -- **** for debug information in readonly UT environment.--- begin ****
383 JMF_SHIKYU_RPT_UTIL.debug_output
384 (
385 p_output_to => 'FND_LOG.STRING'
386 ,p_api_name => G_MODULE_PREFIX || l_api_name
387 ,p_message => 'begin, p_rpt_mode:' || p_rpt_mode || ',p_ou_id:' || p_ou_id
388 );
389 -- **** for debug information in readonly UT environment.--- end ****
390 get_onhand_components(p_onhand_row_type => CFR_TMP_ONHAND_ROW --p_onhand_row_type
391 ,p_ou_id => p_ou_id
392 ,p_supplier_name_from => p_supplier_name_from
393 ,p_supplier_site_code_from => p_supplier_site_code_from
394 ,p_supplier_name_to => p_supplier_name_to
395 ,p_supplier_site_code_to => p_supplier_site_code_to
396 ,p_oem_inv_org_name_from => l_oem_inv_org_name_from -- Bug 5665334
397 ,p_oem_inv_org_name_to => l_oem_inv_org_name_to -- Bug 5665334
398 ,p_item_number_from => p_item_number_from
399 ,p_item_number_to => p_item_number_to);
400
401 -- for each record in the onhand information (inv_org, item), get the confirmation data
402 -- **** for debug information in readonly UT environment.--- begin ****
403 JMF_SHIKYU_RPT_UTIL.debug_output
404 (
405 p_output_to => 'FND_LOG.STRING'
406 ,p_api_name => G_MODULE_PREFIX || l_api_name
407 ,p_message => 'begin, p_rpt_mode:' || p_rpt_mode || ',p_ou_id:' || p_ou_id
408 );
409 -- **** for debug information in readonly UT environment.--- end ****
410 get_rpt_confirmation_data(p_onhand_row_type => CFR_TMP_ONHAND_ROW --p_onhand_row_type
411 ,p_rep_po_unalloc_row_type => CFR_TMP_REP_PO_UNALLOCATED_ROW --p_rep_po_unalloc_row_type
412 ,p_rep_po_unconsumed_row_type => CFR_TMP_REP_PO_UNCONSUMED_ROW --p_rep_po_unconsumed_row_type
413 ,p_sub_po_unconsumed_row_type => CFR_TMP_SUB_PO_UNCONSUMED_ROW --p_sub_po_unconsumed_row_type
414 ,p_rcv_transaction_row_type => CFR_TMP_RCV_ROW --p_rcv_transaction_row_type
415 ,p_ou_id => p_ou_id
416 ,p_days_received => p_days_received
417 ,p_currency_conversion_type => p_currency_conversion_type
418 ,p_currency_conversion_date => l_currency_conversion_date);
419
420
421 -- create some data in the mid_temp table to make the data consistent
422 validate_cfr_mid_temp(p_rcv_row_type => CFR_TMP_RCV_ROW);
423
424 -- add the find data to temporary table for report, with the UOM Currency conversion
425 -- **** for debug information in readonly UT environment.--- begin ****
426 JMF_SHIKYU_RPT_UTIL.debug_output
427 (
428 p_output_to => 'FND_LOG.STRING'
429 ,p_api_name => G_MODULE_PREFIX || l_api_name
430 ,p_message => 'begin, p_rpt_mode:' || p_rpt_mode || ',p_ou_id:' || p_ou_id
431 );
432 -- **** for debug information in readonly UT environment.--- end ****
433 add_data_to_cfr_temp(p_rcv_row_type => CFR_TMP_RCV_ROW --p_rcv_row_type
434 ,p_rpt_mode => p_rpt_mode
435 ,p_days_received => p_days_received
436 ,p_currency_conversion_type => p_currency_conversion_type
437 ,p_currency_conversion_date => l_currency_conversion_date
438 ,p_functional_currency => l_functional_currency
439 -- Amy added to fix bug 5583680 start
440 ,p_supplier_name_from => p_supplier_name_from
441 ,p_supplier_site_code_from => p_supplier_site_code_from
442 ,p_supplier_name_to => p_supplier_name_to
443 ,p_supplier_site_code_to => p_supplier_site_code_to
444 ,p_oem_inv_org_name_from => l_oem_inv_org_name_from -- Bug 5665334
445 ,p_oem_inv_org_name_to => l_oem_inv_org_name_to -- Bug 5665334
446 -- Amy added to fix bug 5583680 end
447 );
448
449 -- **** for debug information in readonly UT environment.--- begin ****
450 JMF_SHIKYU_RPT_UTIL.debug_output
451 (
452 p_output_to => 'FND_LOG.STRING'
453 ,p_api_name => G_MODULE_PREFIX || l_api_name
454 ,p_message => 'end, p_rpt_mode:' || p_rpt_mode || ',p_ou_id:' || p_ou_id
455 );
456 -- **** for debug information in readonly UT environment.--- end ****
457
458 COMMIT;
459
460 --print the data in mid temp table for debug.
461 rpt_debug_show_mid_data(
462 p_row_type => NULL
463 ,p_output_to => 'FND_LOG.STRING'
464 );
465 rpt_debug_show_temp_data
466 (
467 p_rpt_data_type => NULL
468 ,p_output_to => 'FND_LOG.STRING'
469 );
470
471 EXCEPTION
472 WHEN NO_DATA_FOUND THEN
473 --Set message name;
474 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
475 fnd_msg_pub.Add;
476
477 IF g_fnd_debug = 'Y' AND
478 FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
479 THEN
480 FND_LOG.STRING( FND_LOG.LEVEL_EXCEPTION
481 , G_MODULE_PREFIX || l_api_name || '.no_data'
482 , 'JMF_SHK_RPT_NO_DATA');
483 END IF;
484
485 WHEN OTHERS THEN
486 IF g_fnd_debug = 'Y' AND
487 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
488 THEN
489 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
490 , G_MODULE_PREFIX || l_api_name || '.exception'
491 , 'EXCEPTION:WHEN OTHERS THEN');
492 END IF;
493
494 ROLLBACK;
495
496 END cfr_before_report_trigger;
497
498 --========================================================================
499 -- PROCEDURE : cfr_get_onhand_components PUBLIC
500 -- PARAMETERS: p_onhand_row_type row type id to identify the
501 -- onhand components information
502 -- : p_ou_id Operating unit id
503 -- : p_supplier_name_from the supplier name from
504 -- : p_supplier_site_code_from the supplier site code from
505 -- : p_supplier_name_to the supplier name to
506 -- : p_supplier_site_code_to the supplier site code to
507 -- : p_oem_inv_org_name_from oem inventory org name from
508 -- : p_oem_inv_org_name_to oem inventory org name to
509 -- : p_item_number_from item id from
510 -- : p_item_number_to item id to
511 -- COMMENT : It is used to get all the onhand compoents primary UOM quantity;
512 -- (reference to the condition:''Operating Unit, 'from OEM INV organization' ,'to OEM INV organization',
513 -- 'From supplier','From site','To supplier','To site','From Item','To item')
514 -- PRE-COND :
515 -- EXCEPTIONS:
516 --========================================================================
517 PROCEDURE get_onhand_components
518 (
519 p_onhand_row_type IN NUMBER
520 ,p_ou_id IN NUMBER
521 ,p_supplier_name_from IN VARCHAR2
522 ,p_supplier_site_code_from IN VARCHAR2
523 ,p_supplier_name_to IN VARCHAR2
524 ,p_supplier_site_code_to IN VARCHAR2
525 ,p_oem_inv_org_name_from IN VARCHAR2
526 ,p_oem_inv_org_name_to IN VARCHAR2
527 ,p_item_number_from IN VARCHAR2
528 ,p_item_number_to IN VARCHAR2
529 ) IS
530
531 -- cursor for the OEM inventory organization,to get the org_id,org_code,org_name
532 -- refer to the org_name from and to condition
533 CURSOR l_cur_get_oem_inv_org_info
534 (lp_ou_id hr_all_organization_units.organization_id%TYPE
535 , lp_oem_inv_org_name_from hr_all_organization_units_vl.NAME%TYPE
536 , lp_oem_inv_org_name_to hr_all_organization_units_vl.NAME%TYPE
537 ) IS
538 SELECT mp.organization_id
539 ,mp.organization_code
540 ,haoutl.NAME
541 FROM mtl_parameters mp
542 ,hr_organization_information hoi
543 ,hr_all_organization_units haou
544 ,HR_ALL_ORGANIZATION_UNITS_TL haoutl
545 WHERE mp.organization_id = hoi.organization_id
546 AND haou.organization_id = hoi.organization_id
547 AND haou.organization_id = haoutl.organization_id
548 AND NVL(mp.trading_partner_org_flag,'N') = 'N'
549 AND hoi.org_information_context = 'Accounting Information'
550 AND hoi.org_information3 = to_char(lp_ou_id) -- bug 14108256
551 AND haoutl.NAME >= NVL(lp_oem_inv_org_name_from
552 ,haoutl.NAME)
553 AND haoutl.NAME <= NVL(lp_oem_inv_org_name_to
554 ,haoutl.NAME)
555 AND haoutl.LANGUAGE = USERENV('LANG');
556
557 l_oem_inv_org_id mtl_parameters.organization_id%TYPE;
558 l_oem_inv_org_code mtl_parameters.organization_code%TYPE;
559 l_oem_inv_org_name hr_all_organization_units_vl.NAME%TYPE;
560
561 -- need to be cleared, how to know the restriction from the oem_inv_org and supplier/site
562 -- cursor for geting tp_inv_org_id using the specific oem_inv_org_id, supplier/site
563 CURSOR l_cur_get_tp_inv_org_info
564 ( lp_oem_inv_org_id mtl_interorg_parameters.from_organization_id%TYPE
565 , lp_supplier_name_from po_vendors.vendor_name%TYPE
566 , lp_supplier_name_to po_vendors.vendor_name%TYPE
567 , lp_supplier_site_code_from po_vendor_sites_all.vendor_site_code%TYPE
568 , lp_supplier_site_code_to po_vendor_sites_all.vendor_site_code%TYPE
569 )
570 IS
571 SELECT mip.to_organization_id --tp_org_id
572 ,mp.organization_code --tp_org_code
573 ,pv.vendor_id --supplier_id
574 ,pvs.vendor_site_id --supplier_site_id
575 FROM mtl_interorg_parameters mip
576 ,po_vendors pv
577 ,po_vendor_sites_all pvs
578 ,hr_organization_information hoi
579 ,mtl_parameters mp
580 WHERE mip.from_organization_id = lp_oem_inv_org_id
581 --AND mip.shikyu_enabled_flag = 'Y'
582 AND mip.subcontracting_type in ('B','C') -- 12.1 Buy/Sell Subcontracting Changes
583 AND mp.trading_partner_org_flag = 'Y' --hide for test as there is not data for this column!!!
584 AND hoi.org_information_context = 'Customer/Supplier Association' --to identify the flexfield
585 AND hoi.org_information3 = pv.vendor_id --(Application : Human Resources,Descriptive Flexfield Segment Title: Org Developer DF.)
586 AND hoi.org_information4 = pvs.vendor_site_id
587 AND mip.to_organization_id = hoi.organization_id
588 AND mip.to_organization_id = mp.organization_id
589 AND ((pv.vendor_name IS NULL) OR
590 ((pv.vendor_name >= NVL(lp_supplier_name_from
591 ,pv.vendor_name)) AND
592 (pv.vendor_name <= NVL(lp_supplier_name_to
593 ,pv.vendor_name))))
594 AND ((pvs.vendor_site_code IS NULL) OR
595 (pvs.vendor_site_code >=
596 NVL(lp_supplier_site_code_from
597 ,pvs.vendor_site_code)) AND
598 (pvs.vendor_site_code <=
599 NVL(lp_supplier_site_code_to
600 ,pvs.vendor_site_code)));
601
602 l_tp_inv_org_id mtl_parameters.organization_id%TYPE;
603 l_tp_inv_org_code mtl_parameters.organization_code%TYPE;
604 l_supplier_id po_vendors.vendor_id%TYPE;
605 l_supplier_site_id po_vendor_sites_all.vendor_site_id%TYPE;
606
607 l_api_name CONSTANT VARCHAR2(30) := 'get_onhand_components';
608
609 BEGIN
610
611 IF g_fnd_debug = 'Y' AND
612 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
613 THEN
614 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
615 , g_module_prefix || l_api_name || '.begin'
616 , NULL);
617 END IF;
618 -- **** for debug information in readonly UT environment.--- begin ****
619 JMF_SHIKYU_RPT_UTIL.debug_output
620 (
621 p_output_to => 'FND_LOG.STRING'
622 ,p_api_name => G_MODULE_PREFIX || l_api_name
623 ,p_message => 'begin:' ||
624 ',p_onhand_row_type:' || p_onhand_row_type ||
625 ',p_ou_id :' || p_ou_id ||
626 ',p_supplier_name_from:' || p_supplier_name_from ||
627 ',p_supplier_site_code_from:' || p_supplier_site_code_from ||
628 ',p_supplier_name_to :' || p_supplier_name_to ||
629 ',p_supplier_site_code_to:' || p_supplier_site_code_to ||
630 ',p_oem_inv_org_name_from:' || p_oem_inv_org_name_from ||
631 ',p_oem_inv_org_name_to:' || p_oem_inv_org_name_to ||
632 ',p_item_number_from:' || p_item_number_from ||
633 ',p_item_number_to:' || p_item_number_to
634 );
635 -- **** for debug information in readonly UT environment.--- end ****
636
637 -- Valid parameter validation;
638 -- if all parameters are valid then continue; otherwise raise an error message in log;
639
640 --get the oem_inv_org information, then for each oem_inv_org, find the TP inv_org
641 OPEN l_cur_get_oem_inv_org_info(p_ou_id
642 ,p_oem_inv_org_name_from
643 ,p_oem_inv_org_name_to);
644 LOOP
645 --find the oem organizations
646 FETCH l_cur_get_oem_inv_org_info
647 INTO l_oem_inv_org_id, l_oem_inv_org_code, l_oem_inv_org_name;
648
649 EXIT WHEN l_cur_get_oem_inv_org_info%NOTFOUND; -- no more oem organiztions
650 -- **** for debug information in readonly UT environment.--- begin ****
651 JMF_SHIKYU_RPT_UTIL.debug_output
652 (
653 p_output_to => 'FND_LOG.STRING'
654 ,p_api_name => G_MODULE_PREFIX || l_api_name
655 ,p_message => ',l_oem_inv_org_id:' || l_oem_inv_org_id ||
656 ',l_oem_inv_org_code :' || l_oem_inv_org_code ||
657 ',l_oem_inv_org_name:' || l_oem_inv_org_name
658 );
659 -- **** for debug information in readonly UT environment.--- end ****
660
661 --process for this oem_inv_org
662 --find the tp_inv_orgs that belongs to the oem_inv_org and supplier/sites
663 OPEN l_cur_get_tp_inv_org_info(l_oem_inv_org_id
664 ,p_supplier_name_from
665 ,p_supplier_name_to
666 ,p_supplier_site_code_from
667 ,p_supplier_site_code_to);
668 LOOP
669 --find the tp organizations
670 FETCH l_cur_get_tp_inv_org_info
671 INTO l_tp_inv_org_id, l_tp_inv_org_code, l_supplier_id, l_supplier_site_id;
672
673 EXIT WHEN l_cur_get_tp_inv_org_info%NOTFOUND; -- no more tp organiztions
674 -- **** for debug information in readonly UT environment.--- begin ****
675 JMF_SHIKYU_RPT_UTIL.debug_output
676 (
677 p_output_to => 'FND_LOG.STRING'
678 ,p_api_name => G_MODULE_PREFIX || l_api_name
679 ,p_message => ',l_tp_inv_org_id:' || l_tp_inv_org_id ||
680 ',l_tp_inv_org_code :' || l_tp_inv_org_code ||
681 ',l_supplier_id:' || l_supplier_id ||
682 ',l_supplier_site_id' || l_supplier_site_id
683 );
684 -- **** for debug information in readonly UT environment.--- end ****
685
686 -- get the onhand quantity for each TP inv org items.
687 -- for the specified tp_inv_org_id, find the items
688 -- insert the data into the mid temp table,
689 --???using the get_item_number function to get the flexfield values, or using segment1 for hardcoding?
690 INSERT INTO jmf_shikyu_cfr_mid_temp
691 (row_type --onhand row type
692 ,oem_inv_org_id --oem_inv_org_id
693 ,supplier_id --supplier_id
694 ,site_id --site_id
695 ,tp_inv_org_id --tp_inv_org_id
696 ,item_id --item_id
697 ,primary_unconsumed_quantity --onhand primary uom quantity
698 ,project_id --project_id
699 ,task_id --task_id
700 )
701 SELECT p_onhand_row_type
702 ,l_oem_inv_org_id
703 ,l_supplier_id
704 ,l_supplier_site_id
705 ,onhand.organization_id
706 ,onhand.inventory_item_id
707 ,SUM(onhand.transaction_quantity) primary_uom_qty
708 ,onhand.project_id
709 ,onhand.task_id
710 FROM MTL_ONHAND_QUANTITIES onhand
711 ,MTL_SYSTEM_ITEMS_B_KFV item_f -- the latest view for the item flexfield
712 WHERE onhand.organization_id = l_tp_inv_org_id
713 AND onhand.organization_id = item_f.organization_id
714 AND onhand.inventory_item_id = item_f.inventory_item_id
715 AND item_f.subcontracting_component IS NOT NULL --= 'Y'
716 /* AND item_f.concatenated_segments >=
717 NVL(p_item_number_from, item_f.concatenated_segments)
718 AND item_f.concatenated_segments <=
719 NVL(p_item_number_to, item_f.concatenated_segments)*/
720 AND (p_item_number_from IS NULL
721 OR item_f.concatenated_segments >= p_item_number_from)
722 AND (p_item_number_to IS NULL
723 OR item_f.concatenated_segments <= p_item_number_to)
724 GROUP BY onhand.organization_id
725 ,onhand.inventory_item_id
726 ,onhand.project_id
727 ,onhand.task_id;
728 END LOOP; --end loop of finding the tp organizations
729 CLOSE l_cur_get_tp_inv_org_info;
730
731 END LOOP; --end loop of finding the oem organizations
732 CLOSE l_cur_get_oem_inv_org_info;
733
734 COMMIT; -- for debug on UT ?????
735 --print the data in mid temp table for debug.
736 rpt_debug_show_mid_data(
737 p_row_type => p_onhand_row_type
738 ,p_output_to => 'FND_LOG.STRING'
739 );
740 EXCEPTION
741 WHEN NO_DATA_FOUND THEN
742 --Set message name;
743 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
744 fnd_msg_pub.Add;
745 -- **** for debug information in readonly UT environment.--- begin ****
746 JMF_SHIKYU_RPT_UTIL.debug_output
747 (
748 p_output_to => 'FND_LOG.STRING'
749 ,p_api_name => G_MODULE_PREFIX || l_api_name
750 ,p_message => 'NO_DATA_FOUND'
751 );
752 -- **** for debug information in readonly UT environment.--- end ****
753
754 WHEN OTHERS THEN
755 -- raise log message;
756
757 IF g_fnd_debug = 'Y' AND
758 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
759 THEN
760 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
761 , G_MODULE_PREFIX || l_api_name || '.exception'
762 , NULL);
763 END IF;
764 -- **** for debug information in readonly UT environment.--- begin ****
765 JMF_SHIKYU_RPT_UTIL.debug_output
766 (
767 p_output_to => 'FND_LOG.STRING'
768 ,p_api_name => G_MODULE_PREFIX || l_api_name
769 ,p_message => 'OTHERS'
770 );
771 -- **** for debug information in readonly UT environment.--- end ****
772
773 END get_onhand_components;
774
775 --========================================================================
776 -- PROCEDURE : get_rpt_confirmation_data PUBLIC
777 -- PARAMETERS: p_onhand_row_type row type id to identify the
778 -- onhand components information
779 -- : p_rep_po_unalloc_row_type replenishment po unalloc row in mid-temp table
780 -- : p_rep_po_unconsumed_row_type replenishment po unconsume row in mid-temp table
781 -- : p_sub_po_unconsumed_row_type subcontract po unconsume row in mid-temp table
782 -- : p_days_received received after the days ago
783 -- : p_sort_by By Supplier/Site or By Item, the External report can use only by Supplier/Site
784 -- : p_currency_conversion_type the currency conversion type
785 -- : p_currency_conversion_date the currency conversion date
786 -- COMMENT : for each line in the on hand data in the jmf_shikyu_cfr_mid_temp table,
787 -- this procedure is used to get the possilbe rcv_transaction data information
788 -- for those onhand SHIKYU components based on LIFO received date.
789 -- first the unallocated qty,then the allocated but unconsumed qty.
790 -- PRE-COND :
791 -- EXCEPTIONS:
792 --========================================================================
793 PROCEDURE get_rpt_confirmation_data
794 (
795 p_onhand_row_type IN NUMBER
796 ,p_rep_po_unalloc_row_type IN NUMBER
797 ,p_rep_po_unconsumed_row_type IN NUMBER
798 ,p_sub_po_unconsumed_row_type IN NUMBER
799 ,p_rcv_transaction_row_type IN NUMBER
800 ,p_ou_id IN NUMBER
801 ,p_days_received IN NUMBER
802 ,p_currency_conversion_type IN VARCHAR2
803 ,p_currency_conversion_date IN DATE
804 ) IS
805 l_api_name CONSTANT VARCHAR2(30) := 'get_rpt_confirmation_data';
806
807 l_supplier_id jmf_shikyu_cfr_mid_temp.supplier_id%TYPE;
808 l_supplier_site_id jmf_shikyu_cfr_mid_temp.site_id%TYPE;
809 l_oem_inv_org_id jmf_shikyu_cfr_mid_temp.oem_inv_org_id%TYPE;
810 l_tp_inv_org_id jmf_shikyu_cfr_mid_temp.tp_inv_org_id%TYPE;
811 l_item_id jmf_shikyu_cfr_mid_temp.item_id%TYPE;
812 l_project_id jmf_shikyu_cfr_mid_temp.project_id%TYPE;
813 l_task_id jmf_shikyu_cfr_mid_temp.task_id%TYPE;
814 l_onhand_quantity jmf_shikyu_cfr_mid_temp.primary_unconsumed_quantity%TYPE;
815 -- get on hand components information
816 CURSOR l_cur_get_onhand_components IS
817 SELECT supplier_id
818 ,site_id
819 ,oem_inv_org_id
820 ,tp_inv_org_id
821 ,item_id
822 ,project_id
823 ,task_id
824 ,primary_unconsumed_quantity
825 FROM jmf_shikyu_cfr_mid_temp
826 WHERE row_type = p_onhand_row_type;
827
828 BEGIN
829 IF g_fnd_debug = 'Y' AND
830 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
831 THEN
832 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
833 , g_module_prefix || l_api_name || '.begin'
834 , NULL);
835 END IF;
836 -- **** for debug information in readonly UT environment.--- begin ****
837 JMF_SHIKYU_RPT_UTIL.debug_output
838 (
839 p_output_to => 'FND_LOG.STRING'
840 ,p_api_name => G_MODULE_PREFIX || l_api_name
841 ,p_message => 'begin:' ||
842 ',p_onhand_row_type:' || p_onhand_row_type ||
843 ',p_rep_po_unalloc_row_type :' || p_rep_po_unalloc_row_type ||
844 ',p_rep_po_unconsumed_row_type:' || p_rep_po_unconsumed_row_type ||
845 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
846 ',p_rcv_transaction_row_type :' || p_rcv_transaction_row_type ||
847 ',p_ou_id:' || p_ou_id ||
848 ',p_days_received:' || p_days_received ||
849 ',p_currency_conversion_type:' || p_currency_conversion_type ||
850 ',p_currency_conversion_date:' || p_currency_conversion_date
851 );
852 -- **** for debug information in readonly UT environment.--- end ****
853
854 -- Valid parameter validation;
855 -- if all parameters are valid then continue; otherwise raise an error message in log;
856 OPEN l_cur_get_onhand_components;
857 LOOP
858 --find unallocated and allocated but unconsumed rcv_transactions for the inv_org,item.
859 FETCH l_cur_get_onhand_components
860 INTO l_supplier_id, l_supplier_site_id, l_oem_inv_org_id, l_tp_inv_org_id, l_item_id, l_project_id, l_task_id, l_onhand_quantity;
861
862 EXIT WHEN l_cur_get_onhand_components%NOTFOUND;
863 -- **** for debug information in readonly UT environment.--- begin ****
864 JMF_SHIKYU_RPT_UTIL.debug_output
865 (
866 p_output_to => 'FND_LOG.STRING'
867 ,p_api_name => G_MODULE_PREFIX || l_api_name
868 ,p_message => ',l_supplier_id:' || l_supplier_id ||
869 ',l_supplier_site_id :' || l_supplier_site_id ||
870 ',l_oem_inv_org_id:' || l_oem_inv_org_id ||
871 ',l_tp_inv_org_id:' || l_tp_inv_org_id ||
872 ',l_item_id :' || l_item_id ||
873 ',l_project_id:' || l_project_id ||
874 ',l_task_id:' || l_task_id ||
875 ',l_onhand_quantity:' || l_onhand_quantity
876 );
877 -- **** for debug information in readonly UT environment.--- end ****
878
879 --get the unallocated rcv_transactions
880 get_unallocated_components(p_rep_po_unalloc_row_type => p_rep_po_unalloc_row_type
881 ,p_rcv_transaction_row_type => p_rcv_transaction_row_type
882 ,p_ou_id => p_ou_id
883 ,p_supplier_id => l_supplier_id
884 ,p_supplier_site_id => l_supplier_site_id
885 ,p_oem_inv_org_id => l_oem_inv_org_id
886 ,p_tp_inv_org_id => l_tp_inv_org_id
887 ,p_item_id => l_item_id
888 ,p_project_id => l_project_id
889 ,p_task_id => l_task_id
890 ,x_need_to_find_pri_qty => l_onhand_quantity);
891
892 --get the allocated but unconsumed rcv_transactions
893 IF l_onhand_quantity > 0
894 THEN
895 get_unconsumed_components(p_sub_po_unconsumed_row_type => p_sub_po_unconsumed_row_type
896 ,p_rep_po_unconsumed_row_type => p_rep_po_unconsumed_row_type
897 ,p_rcv_transaction_row_type => p_rcv_transaction_row_type
898 ,p_ou_id => p_ou_id
899 ,p_supplier_id => l_supplier_id
900 ,p_supplier_site_id => l_supplier_site_id
901 ,p_oem_inv_org_id => l_oem_inv_org_id
902 ,p_tp_inv_org_id => l_tp_inv_org_id
903 ,p_item_id => l_item_id
904 ,p_project_id => l_project_id
905 ,p_task_id => l_task_id
906 ,x_need_to_find_pri_qty => l_onhand_quantity);
907 END IF;
908
909 -- record the l_onhand_quantity to column primary_unallocated_quantity
910 UPDATE jmf_shikyu_cfr_mid_temp
911 SET primary_unallocated_quantity = l_onhand_quantity
912 WHERE row_type = p_onhand_row_type
913 AND supplier_id = l_supplier_id
914 AND site_id = l_supplier_site_id
915 AND oem_inv_org_id = l_oem_inv_org_id
916 AND tp_inv_org_id = l_tp_inv_org_id
917 AND item_id = l_item_id
918 AND ((project_id IS NULL) OR (project_id = l_project_id))
919 AND ((task_id IS NULL) OR (task_id = l_task_id));
920
921 IF l_onhand_quantity > 0
922 THEN
923 -- the found onhand quantity has no matched rcv_transactions
924 -- **** for debug information in readonly UT environment.--- begin ****
925 JMF_SHIKYU_RPT_UTIL.debug_output
926 (
927 p_output_to => 'FND_LOG.STRING'
928 ,p_api_name => G_MODULE_PREFIX || l_api_name
929 ,p_message => '** onhand quantity :' || l_onhand_quantity ||', has no matched rcv_transactions'
930 );
931 -- **** for debug information in readonly UT environment.--- end ****
932 END IF;
933
934 END LOOP; -- end of find the onhand information
935 CLOSE l_cur_get_onhand_components;
936
937 COMMIT; -- for debug on UT ?????
938 IF g_fnd_debug = 'Y' AND
939 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
940 THEN
941 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
942 , g_module_prefix || l_api_name || '.end'
943 , NULL);
944 END IF;
945 EXCEPTION
946 WHEN NO_DATA_FOUND THEN
947 -- raise log message;
948 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
949 fnd_msg_pub.Add;
950
951 WHEN OTHERS THEN
952
953 IF g_fnd_debug = 'Y' AND
954 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
955 THEN
956 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
957 , G_MODULE_PREFIX || l_api_name || '.execption'
958 , NULL);
959 END IF;
960 -- **** for debug information in readonly UT environment.--- begin ****
961 JMF_SHIKYU_RPT_UTIL.debug_output
962 (
963 p_output_to => 'FND_LOG.STRING'
964 ,p_api_name => G_MODULE_PREFIX || l_api_name
965 ,p_message => 'WHEN OTHERS THEN'
966 );
967 -- **** for debug information in readonly UT environment.--- end ****
968
969 END get_rpt_confirmation_data;
970
971 --========================================================================
972 -- PROCEDURE : get_unallocated_components PUBLIC
973 -- PARAMETERS: p_rep_po_unalloc_row_type row type id to identify the
974 -- unallocated components information
975 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
976 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
977 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
978 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
979 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
980 -- : p_item_id the item_id got from the onhand info from mid temp table
981 -- : x_need_to_find_pri_qty the need to find quantity under primary UOM
982 -- COMMENT : for each line in the on hand data in the jmf_shikyu_cfr_mid_temp table,
983 -- this procedure is used to get the possilbe unallocated rcv_transaction data information
984 -- for those onhand SHIKYU components based on LIFO received date.
985 -- PRE-COND :
986 -- EXCEPTIONS:
987 --========================================================================
988 PROCEDURE get_unallocated_components
989 (
990 p_rep_po_unalloc_row_type IN NUMBER
991 ,p_rcv_transaction_row_type IN NUMBER
992 ,p_ou_id IN NUMBER
993 ,p_supplier_id IN NUMBER
994 ,p_supplier_site_id IN NUMBER
995 ,p_oem_inv_org_id IN NUMBER
996 ,p_tp_inv_org_id IN NUMBER
997 ,p_item_id IN NUMBER
998 ,p_project_id IN NUMBER
999 ,p_task_id IN NUMBER
1000 ,x_need_to_find_pri_qty IN OUT NOCOPY NUMBER
1001 ) IS
1002 l_api_name CONSTANT VARCHAR2(30) := 'get_unallocated_components';
1003
1004 -- get rcv_transaction information, rcv_transaction_id, rcv_unprocessed_qty
1005 -- decrease the rcv quantity processed and logged in the jmf_shikyu_cfr_mid_temp table.
1006 CURSOR l_cur_get_rcv_transaction_info IS
1007 SELECT rt.transaction_id
1008 -- Updated to fix potential issue of operations between null numbers
1009 -- ,rt.primary_quantity -
1010 ,NVL(rt.primary_quantity,0) -
1011 NVL((SELECT SUM(NVL(jscmt_rcv.primary_unallocated_quantity
1012 ,0) + NVL(jscmt_rcv.primary_unconsumed_quantity
1013 ,0))
1014 FROM jmf_shikyu_cfr_mid_temp jscmt_rcv
1015 WHERE jscmt_rcv.row_type = 40
1016 AND jscmt_rcv.shikyu_id = rt.transaction_id)
1017 ,0)
1018 --Added to fix bug 5509464 start
1019 ,pha.vendor_id --p_supplier_id
1020 ,pha.vendor_site_id --p_supplier_site_id
1021 --Added to fix bug 5509464 end
1022 FROM jmf_shikyu_cfr_mid_temp mid
1023 ,po_line_locations_all pll
1024 ,rcv_transactions rt
1025 --Added to fix bug 5509464 start
1026 ,po_headers_all pha
1027 --Added to fix bug 5509464 end
1028 WHERE mid.row_type = p_rep_po_unalloc_row_type
1029 AND NVL(mid.get_rcv_flag
1030 ,'N') <> CFR_REP_PO_GET_RCV_FLAG --if the rep_po line have done get rcv process, the get_rcv_flag will be set to 1
1031 AND mid.shikyu_id = pll.line_location_id
1032 AND rt.transaction_type = 'RECEIVE'
1033 AND pll.line_location_id = rt.po_line_location_id
1034 --Added to fix bug 5509464 start
1035 AND pha.po_header_id=pll.po_header_id
1036 --Added to fix bug 5509464 end
1037 ORDER BY rt.transaction_date;
1038
1039 l_rcv_transaction_id rcv_transactions.transaction_id%TYPE; --for cursor
1040 l_rcv_unprocessed_primary_qty rcv_transactions.primary_quantity%TYPE; --for cursor
1041 --Added to fix bug 5509464 start
1042 l_supplier_id po_headers_all.vendor_id%TYPE; --for cursor
1043 l_supplier_site_id po_headers_all.vendor_site_id%TYPE; --for cursor
1044 --Added to fix bug 5509464 end
1045
1046 l_rep_po_residual_pri rcv_transactions.primary_quantity%TYPE;
1047 l_rcv_unallocated_pri rcv_transactions.primary_quantity%TYPE;
1048
1049 BEGIN
1050 IF g_fnd_debug = 'Y' AND
1051 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1052 THEN
1053 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1054 , g_module_prefix || l_api_name || '.begin'
1055 , NULL);
1056 END IF;
1057 -- **** for debug information in readonly UT environment.--- begin ****
1058 JMF_SHIKYU_RPT_UTIL.debug_output
1059 (
1060 p_output_to => 'FND_LOG.STRING'
1061 ,p_api_name => G_MODULE_PREFIX || l_api_name
1062 ,p_message => 'begin:' ||
1063 ',p_rep_po_unalloc_row_type :' || p_rep_po_unalloc_row_type ||
1064 ',p_rcv_transaction_row_type :' || p_rcv_transaction_row_type ||
1065 ',p_ou_id :' || p_ou_id ||
1066 ',p_supplier_id:' || p_supplier_id ||
1067 ',p_supplier_site_id:' || p_supplier_site_id ||
1068 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1069 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1070 ',p_item_id:' || p_item_id ||
1071 ',p_project_id:' || p_project_id ||
1072 ',p_task_id:' || p_task_id
1073 );
1074 -- **** for debug information in readonly UT environment.--- end ****
1075
1076 -- Valid parameter validation;
1077 -- if all parameters are valid then continue; otherwise raise an error message in log;
1078
1079 --step1:find all the replenishment PO with oem_inv_org,supplier/site,tp_inv_org,item that have unallocated components
1080 get_unallocated_rep_po(p_rep_po_unalloc_row_type => p_rep_po_unalloc_row_type
1081 ,p_ou_id => p_ou_id
1082 ,p_supplier_id => p_supplier_id
1083 ,p_supplier_site_id => p_supplier_site_id
1084 ,p_oem_inv_org_id => p_oem_inv_org_id
1085 ,p_tp_inv_org_id => p_tp_inv_org_id
1086 ,p_item_id => p_item_id
1087 ,p_project_id => p_project_id
1088 ,p_task_id => p_task_id);
1089 --step2:find all the received transactions for the all replenishment PO above, based on LIFO receive date
1090 --
1091 OPEN l_cur_get_rcv_transaction_info;
1092 LOOP
1093 --begin rcv_transaction information
1094 EXIT WHEN x_need_to_find_pri_qty <= 0;
1095
1096 FETCH l_cur_get_rcv_transaction_info
1097 --Updated to fix bug 5509464 start
1098 --INTO l_rcv_transaction_id, l_rcv_unprocessed_primary_qty;
1099 INTO l_rcv_transaction_id, l_rcv_unprocessed_primary_qty,l_supplier_id,l_supplier_site_id;
1100 --Updated to fix bug 5509464 end
1101
1102 EXIT WHEN l_cur_get_rcv_transaction_info%NOTFOUND;
1103 -- **** for debug information in readonly UT environment.--- begin ****
1104 JMF_SHIKYU_RPT_UTIL.debug_output
1105 (
1106 p_output_to => 'FND_LOG.STRING'
1107 ,p_api_name => G_MODULE_PREFIX || l_api_name
1108 ,p_message => 'begin:' ||
1109 ',x_need_to_find_pri_qty :' || x_need_to_find_pri_qty ||
1110 ',l_rcv_transaction_id :' || l_rcv_transaction_id ||
1111 ',l_rcv_unprocessed_primary_qty :' || l_rcv_unprocessed_primary_qty
1112 );
1113 -- **** for debug information in readonly UT environment.--- end ****
1114
1115 --step3:find the possible onhand components(for the unallocated )
1116 l_rep_po_residual_pri := get_rep_po_residual_unalloc(p_rep_po_unalloc_row_type => p_rep_po_unalloc_row_type
1117 ,p_ou_id => p_ou_id
1118 ,p_rcv_transaction_id => l_rcv_transaction_id
1119 --Updated to fix bug 5509464 start
1120 --,p_supplier_id => p_supplier_id
1121 --,p_supplier_site_id => p_supplier_site_id
1122 ,p_supplier_id => l_supplier_id
1123 ,p_supplier_site_id => l_supplier_site_id
1124 --Updated to fix bug 5509464 end
1125 ,p_oem_inv_org_id => p_oem_inv_org_id
1126 ,p_tp_inv_org_id => p_tp_inv_org_id
1127 ,p_item_id => p_item_id
1128 ,p_project_id => p_project_id
1129 ,p_task_id => p_task_id); --the quantity for primary uom
1130
1131 IF l_rep_po_residual_pri > 0
1132 THEN
1133 --the possilbe unallocated rcv_transactions primary quantity
1134 l_rcv_unallocated_pri := jmf_shikyu_rpt_util.get_min3(p_number1 => l_rcv_unprocessed_primary_qty
1135 ,p_number2 => l_rep_po_residual_pri
1136 ,p_number3 => x_need_to_find_pri_qty);
1137
1138 --insert data to rcv_temp marking the processed rcv_transaction,
1139 set_rcv_transaction_unalloc(p_rcv_row_type => p_rcv_transaction_row_type
1140 ,p_ou_id => p_ou_id
1141 ,p_rcv_transaction_id => l_rcv_transaction_id
1142 ,p_rcv_unallocated_pri => l_rcv_unallocated_pri
1143 --Updated to fix bug 5509464 start
1144 ,p_supplier_id => p_supplier_id
1145 ,p_supplier_site_id => p_supplier_site_id
1146 --,l_supplier_id => p_supplier_id
1147 --,l_supplier_site_id => p_supplier_site_id
1148 --Updated to fix bug 5509464 end
1149 ,p_oem_inv_org_id => p_oem_inv_org_id
1150 ,p_tp_inv_org_id => p_tp_inv_org_id
1151 ,p_item_id => p_item_id
1152 ,p_project_id => p_project_id
1153 ,p_task_id => p_task_id);
1154
1155 --the residual unallocated quantity for primary quantity
1156 --update replenishment po residual quantity information
1157 set_rep_po_residual_unalloc(p_rep_po_unalloc_row_type => p_rep_po_unalloc_row_type
1158 ,p_rcv_transaction_row_type => p_rcv_transaction_row_type
1159 ,p_ou_id => p_ou_id
1160 ,p_rcv_transaction_id => l_rcv_transaction_id
1161 --Updated to fix bug 5509464 start
1162 --,p_supplier_id => p_supplier_id
1163 --,p_supplier_site_id => p_supplier_site_id
1164 ,p_supplier_id => l_supplier_id
1165 ,p_supplier_site_id => l_supplier_site_id
1166 --Updated to fix bug 5509464 end
1167 ,p_oem_inv_org_id => p_oem_inv_org_id
1168 ,p_tp_inv_org_id => p_tp_inv_org_id
1169 ,p_item_id => p_item_id
1170 ,p_project_id => p_project_id
1171 ,p_task_id => p_task_id
1172 ,p_new_rep_po_unallocated_pri => l_rcv_unallocated_pri);
1173 --update the need to find primary quantity
1174 x_need_to_find_pri_qty := x_need_to_find_pri_qty -
1175 l_rcv_unallocated_pri;
1176
1177 END IF;
1178
1179 END LOOP; -- end of find the rcv_transaction information
1180 CLOSE l_cur_get_rcv_transaction_info;
1181
1182 --step4:update the get_rcv_flags for the rep_po lines, move to above, need the sucess status
1183 COMMIT; -- for debug on UT ?????
1184 IF g_fnd_debug = 'Y' AND
1185 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1186 THEN
1187 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1188 , g_module_prefix || l_api_name || '.end'
1189 , NULL);
1190 END IF;
1191 EXCEPTION
1192 WHEN NO_DATA_FOUND THEN
1193 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
1194 fnd_msg_pub.Add;
1195 WHEN OTHERS THEN
1196 IF g_fnd_debug = 'Y' AND
1197 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1198 THEN
1199 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
1200 , G_MODULE_PREFIX || l_api_name || '.exception'
1201 , NULL);
1202 END IF;
1203 -- **** for debug information in readonly UT environment.--- begin ****
1204 JMF_SHIKYU_RPT_UTIL.debug_output
1205 (
1206 p_output_to => 'FND_LOG.STRING'
1207 ,p_api_name => G_MODULE_PREFIX || l_api_name
1208 ,p_message => 'WHEN OTHERS THEN'
1209 );
1210 -- **** for debug information in readonly UT environment.--- end ****
1211
1212 END get_unallocated_components;
1213
1214 --========================================================================
1215 -- PROCEDURE : get_unallocated_rep_po PUBLIC ,get_unallocated_replenishment_po
1216 -- PARAMETERS: p_rep_po_unalloc_row_type row type id to identify the
1217 -- unallocated components information
1218 -- : p_ou_id the operating unit id
1219 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
1220 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
1221 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
1222 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
1223 -- : p_item_id the item_id got from the onhand info from mid temp table
1224 -- COMMENT : find the replenishment purchase order that have unallocated receipts for the item
1225 -- and insert the result to mid temp table
1226 -- PRE-COND :
1227 -- EXCEPTIONS:
1228 --========================================================================
1229 PROCEDURE get_unallocated_rep_po
1230 (
1231 p_rep_po_unalloc_row_type IN NUMBER
1232 ,p_ou_id IN NUMBER
1233 ,p_supplier_id IN NUMBER
1234 ,p_supplier_site_id IN NUMBER
1235 ,p_oem_inv_org_id IN NUMBER
1236 ,p_tp_inv_org_id IN NUMBER
1237 ,p_item_id IN NUMBER
1238 ,p_project_id IN NUMBER
1239 ,p_task_id IN NUMBER
1240 ) IS
1241 l_api_name CONSTANT VARCHAR2(30) := 'get_unallocated_rep_po';
1242
1243 BEGIN
1244 IF g_fnd_debug = 'Y' AND
1245 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1246 THEN
1247 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1248 , g_module_prefix || l_api_name || '.begin'
1249 , NULL);
1250 END IF;
1251 -- **** for debug information in readonly UT environment.--- begin ****
1252 JMF_SHIKYU_RPT_UTIL.debug_output
1253 (
1254 p_output_to => 'FND_LOG.STRING'
1255 ,p_api_name => G_MODULE_PREFIX || l_api_name
1256 ,p_message => 'begin:' ||
1257 ',p_rep_po_unalloc_row_type:' || p_rep_po_unalloc_row_type ||
1258 ',p_ou_id :' || p_ou_id ||
1259 ',p_supplier_id:' || p_supplier_id ||
1260 ',p_supplier_site_id:' || p_supplier_site_id ||
1261 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1262 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1263 ',p_item_id:' || p_item_id ||
1264 ',p_project_id:' || p_project_id ||
1265 ',p_task_id:' || p_task_id
1266 );
1267 -- **** for debug information in readonly UT environment.--- end ****
1268
1269 -- Valid parameter validation;
1270 -- if all parameters are valid then continue; otherwise raise an error message in log;
1271
1272 -- the allocated quantity for one po line_location_id, change the UOM in po and shikyu allocation to primary UOM
1273 -- only insert the rep_po that not in mid temp table, if in the table already, keep the data.
1274 INSERT INTO jmf_shikyu_cfr_mid_temp
1275 (row_type
1276 ,shikyu_id
1277 ,uom
1278 ,primary_uom
1279 ,primary_unallocated_quantity
1280 ,supplier_id
1281 ,site_id
1282 ,oem_inv_org_id
1283 ,tp_inv_org_id
1284 ,item_id)
1285 SELECT p_rep_po_unalloc_row_type
1286 ,plla.line_location_id
1287 ,uom_tl.uom_code
1288 ,JMF_SHIKYU_RPT_UTIL.get_item_primary_uom_code(p_tp_inv_org_id
1289 ,p_item_id)
1290 ,JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(p_tp_inv_org_id
1291 ,pla.item_id
1292 ,uom_tl.uom_code
1293 -- Updated to fix potential issue of operations between null numbers
1294 -- ,plla.quantity_received) -
1295 ,NVL(plla.quantity_received,0)) -
1296 (SELECT SUM(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(jsr.tp_organization_id
1297 ,jsr.shikyu_component_id
1298 -- fix bug 5702139
1299 -- ,uom_tl_s.uom_code
1300 ,decode(jsa.allocated_quantity
1301 ,null
1302 ,uom_tl_s.uom_code
1303 ,jsa.uom)
1304 --Updated to fix bug 5509464 start
1305 --,jsa.allocated_quantity)) pll_allocated
1306 ,nvl(jsa.allocated_quantity,0))) pll_allocated
1307 --Updated to fix bug 5509464 end
1308 FROM jmf_shikyu_allocations jsa
1309 ,jmf_shikyu_replenishments jsr
1310 ,MTL_UNITS_OF_MEASURE_TL uom_tl_s
1311 --Updated to fix bug 5509464 start
1312 --WHERE jsa.replenishment_so_line_id = jsr.replenishment_so_line_id
1313 -- AND jsa.shikyu_component_id = jsr.shikyu_component_id
1314 WHERE jsa.replenishment_so_line_id(+) = jsr.replenishment_so_line_id
1315 AND jsa.shikyu_component_id(+) = jsr.shikyu_component_id
1316 --Updated to fix bug 5509464 end
1317 AND jsr.replenishment_po_shipment_id = plla.line_location_id
1318 AND plla.po_line_id = pla.po_line_id
1319 AND uom_tl_s.LANGUAGE = USERENV('LANG')
1320 -- fix bug 5702139
1321 -- AND pla.unit_meas_lookup_code = uom_tl_s.unit_of_measure
1322 AND po_uom_s.get_primary_uom(pla.item_id,p_tp_inv_org_id,null) = uom_tl_s.unit_of_measure -- primary UOM
1323 AND jsr.shikyu_component_id = p_item_id) residual_unallocated_pri
1324 ,pha.vendor_id --p_supplier_id
1325 ,pha.vendor_site_id --p_supplier_site_id
1326 ,p_oem_inv_org_id
1327 ,p_tp_inv_org_id
1328 ,p_item_id
1329 FROM po_headers_all pha
1330 ,po_lines_all pla
1331 ,po_line_locations_all plla
1332 ,MTL_UNITS_OF_MEASURE_TL uom_tl
1333 ,HR_ORGANIZATION_INFORMATION hoi -- Add this table to get information of oem
1334 WHERE pla.po_header_id = pha.po_header_id
1335 AND plla.po_line_id = pla.po_line_id
1336 AND pla.unit_meas_lookup_code = uom_tl.unit_of_measure
1337 AND uom_tl.LANGUAGE = USERENV('LANG')
1338 AND pha.org_id = p_ou_id
1339 AND hoi.ORGANIZATION_ID = p_oem_inv_org_id
1340 AND hoi.org_information_context = 'Customer/Supplier Association' --to identify the flexfield
1341 AND ((pha.vendor_id = hoi.org_information3) OR -- when org_information_context is set to be 'Customer/Supplier Association',this identify the supplier_id of org
1342 (pha.vendor_id IS NULL AND hoi.org_information3 IS NULL))
1343 AND ((pha.vendor_site_id = hoi.org_information4) OR -- when org_information_context is set to be 'Customer/Supplier Association',this identify the supplier_site_id of org
1344 (pha.vendor_site_id IS NULL AND hoi.org_information4 IS NULL))
1345 AND pla.item_id = p_item_id
1346 AND plla.line_location_id NOT IN
1347 (SELECT jscmt.shikyu_id
1348 FROM jmf_shikyu_cfr_mid_temp jscmt
1349 WHERE jscmt.row_type = p_rep_po_unalloc_row_type
1350 AND jscmt.item_id = p_item_id
1351 AND jscmt.oem_inv_org_id = p_oem_inv_org_id
1352 AND jscmt.tp_inv_org_id = p_tp_inv_org_id
1353 AND jscmt.supplier_id = p_supplier_id
1354 AND jscmt.site_id = p_supplier_site_id)
1355 --updated to fix bug 5232863 start
1356 -- AND JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(pha.org_id
1357 AND JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(p_tp_inv_org_id
1358 ,pla.item_id
1359 ,uom_tl.uom_code
1360 -- Updated to fix potential issue of operations between null numbers
1361 -- ,plla.quantity_received) >
1362 ,NVL(plla.quantity_received,0)) >
1363 -- (SELECT SUM(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(jsr.tp_organization_id
1364 (SELECT SUM(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(p_tp_inv_org_id
1365 --updated to fix bug 5232863 end
1366 ,jsr.shikyu_component_id
1367 -- fix bug 5702139
1368 -- ,uom_tl_s.uom_code
1369 ,decode(jsa.allocated_quantity
1370 ,null
1371 ,uom_tl_s.uom_code
1372 ,jsa.uom)
1373 --Updated to fix bug 5509464 start
1374 --,jsa.allocated_quantity)) pll_allocated
1375 ,nvl(jsa.allocated_quantity,0))) pll_allocated
1376 --Updated to fix bug 5509464 end
1377 FROM jmf_shikyu_allocations jsa
1378 ,jmf_shikyu_replenishments jsr
1379 ,MTL_UNITS_OF_MEASURE_TL uom_tl_s
1380 --Updated to fix bug 5509464 start
1381 --WHERE jsa.replenishment_so_line_id = jsr.replenishment_so_line_id
1382 -- AND jsa.shikyu_component_id = jsr.shikyu_component_id
1383 WHERE jsa.replenishment_so_line_id(+) = jsr.replenishment_so_line_id
1384 AND jsa.shikyu_component_id(+) = jsr.shikyu_component_id
1385 --Updated to fix bug 5509464 end
1386 AND jsr.replenishment_po_shipment_id = plla.line_location_id
1387 AND plla.po_line_id = pla.po_line_id
1388 -- fix bug 5702139
1389 -- AND pla.unit_meas_lookup_code = uom_tl_s.unit_of_measure
1390 AND po_uom_s.get_primary_uom(pla.item_id,p_tp_inv_org_id,null) = uom_tl_s.unit_of_measure -- primary UOM
1391 AND jsr.shikyu_component_id = p_item_id);
1392
1393 --update the residual_unallocated(quantity) column under UOM.
1394 UPDATE jmf_shikyu_cfr_mid_temp
1395 SET quantity = NVL(primary_unallocated_quantity,0) *
1396 JMF_SHIKYU_RPT_UTIL.po_uom_convert_p(primary_uom
1397 ,uom
1398 ,item_id)
1399 WHERE row_type = p_rep_po_unalloc_row_type
1400 AND quantity IS NULL --only for those do not get the primary uom
1401 AND supplier_id = p_supplier_id
1402 AND site_id = p_supplier_site_id
1403 AND oem_inv_org_id = p_oem_inv_org_id
1404 AND tp_inv_org_id = p_tp_inv_org_id
1405 AND item_id = p_item_id;
1406 COMMIT; -- for debug on UT ?????
1407
1408 --print the data in mid temp table for debug.
1409 rpt_debug_show_mid_data(
1410 p_row_type => p_rep_po_unalloc_row_type
1411 ,p_output_to => 'FND_LOG.STRING'
1412 );
1413 IF g_fnd_debug = 'Y' AND
1414 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1415 THEN
1416 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1417 , g_module_prefix || l_api_name || '.end'
1418 , NULL);
1419 END IF;
1420 EXCEPTION
1421 WHEN NO_DATA_FOUND THEN
1422 -- raise log message;
1423 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
1424 fnd_msg_pub.Add;
1425
1426 WHEN OTHERS THEN
1427
1428 IF g_fnd_debug = 'Y' AND
1429 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1430 THEN
1431 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
1432 , G_MODULE_PREFIX || l_api_name || '.execption'
1433 , NULL);
1434 END IF;
1435 -- **** for debug information in readonly UT environment.--- begin ****
1436 JMF_SHIKYU_RPT_UTIL.debug_output
1437 (
1438 p_output_to => 'FND_LOG.STRING'
1439 ,p_api_name => G_MODULE_PREFIX || l_api_name
1440 ,p_message => 'WHEN OTHERS THEN'
1441 );
1442 -- **** for debug information in readonly UT environment.--- end ****
1443
1444 END get_unallocated_rep_po;
1445
1446 --========================================================================
1447 -- FUNCTION : get_rep_po_residual_unalloc PUBLIC ,get_replenishment_po_unallocated quantity for primary uom
1448 -- PARAMETERS: p_rep_po_unalloc_row_type row type id to identify the
1449 -- unallocated components information
1450 -- : p_rcv_transaction_id row type id to identify the rcv_transaction data
1451 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
1452 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
1453 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
1454 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
1455 -- : p_item_id the item_id got from the onhand info from mid temp table
1456 -- COMMENT : find the replenishment purchase order residual unallocated quantity for primary uom
1457 -- PRE-COND :
1458 -- EXCEPTIONS:
1459 --========================================================================
1460 FUNCTION get_rep_po_residual_unalloc
1461 (
1462 p_rep_po_unalloc_row_type IN NUMBER
1463 ,p_ou_id IN NUMBER
1464 ,p_rcv_transaction_id IN NUMBER
1465 ,p_supplier_id IN NUMBER
1466 ,p_supplier_site_id IN NUMBER
1467 ,p_oem_inv_org_id IN NUMBER
1468 ,p_tp_inv_org_id IN NUMBER
1469 ,p_item_id IN NUMBER
1470 ,p_project_id IN NUMBER
1471 ,p_task_id IN NUMBER
1472 ) RETURN NUMBER IS
1473 l_api_name CONSTANT VARCHAR2(30) := 'get_rep_po_residual_unalloc';
1474
1475 l_rep_po_unallocated_pri rcv_transactions.primary_quantity%TYPE;
1476 BEGIN
1477 -- **** for debug information in readonly UT environment.--- begin ****
1478 JMF_SHIKYU_RPT_UTIL.debug_output
1479 (
1480 p_output_to => 'FND_LOG.STRING'
1481 ,p_api_name => G_MODULE_PREFIX || l_api_name
1482 ,p_message => 'begin:' ||
1483 ',p_rep_po_unalloc_row_type:' || p_rep_po_unalloc_row_type ||
1484 ',p_ou_id :' || p_ou_id ||
1485 ',p_rcv_transaction_id' || p_rcv_transaction_id ||
1486 ',p_supplier_id:' || p_supplier_id ||
1487 ',p_supplier_site_id:' || p_supplier_site_id ||
1488 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1489 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1490 ',p_item_id:' || p_item_id ||
1491 ',p_project_id:' || p_project_id ||
1492 ',p_task_id:' || p_task_id
1493 );
1494 -- **** for debug information in readonly UT environment.--- end ****
1495
1496 IF g_fnd_debug = 'Y' AND
1497 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1498 THEN
1499 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1500 , g_module_prefix || l_api_name || '.begin'
1501 , NULL);
1502 END IF;
1503
1504 -- Valid parameter validation;
1505 -- if all parameters are valid then continue; otherwise raise an error message in log;
1506 SELECT cfr_mid.primary_unallocated_quantity
1507 INTO l_rep_po_unallocated_pri
1508 FROM jmf_shikyu_cfr_mid_temp cfr_mid
1509 ,po_line_locations_all poloc
1510 ,rcv_transactions rcv
1511 WHERE rcv.transaction_type = 'RECEIVE'
1512 AND poloc.line_location_id = rcv.po_line_location_id
1513 AND cfr_mid.shikyu_id = poloc.line_location_id
1514 AND rcv.transaction_id = P_rcv_transaction_id
1515 AND cfr_mid.supplier_id = p_supplier_id
1516 AND cfr_mid.site_id = p_supplier_site_id
1517 AND cfr_mid.oem_inv_org_id = p_oem_inv_org_id
1518 AND cfr_mid.tp_inv_org_id = p_tp_inv_org_id
1519 AND cfr_mid.item_id = p_item_id
1520 AND cfr_mid.row_type = p_rep_po_unalloc_row_type
1521 AND rownum = 1;
1522 COMMIT; -- for debug on UT ?????
1523 --print the data in mid temp table for debug.
1524 rpt_debug_show_mid_data(
1525 p_row_type => p_rep_po_unalloc_row_type
1526 ,p_output_to => 'FND_LOG.STRING'
1527 );
1528
1529 IF g_fnd_debug = 'Y' AND
1530 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1531 THEN
1532 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1533 , g_module_prefix || l_api_name || '.end'
1534 , NULL);
1535 END IF;
1536 RETURN l_rep_po_unallocated_pri;
1537
1538 EXCEPTION
1539 WHEN NO_DATA_FOUND THEN
1540 -- raise log message;
1541 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
1542 fnd_msg_pub.Add;
1543 l_rep_po_unallocated_pri := 0;
1544 RETURN l_rep_po_unallocated_pri;
1545
1546 WHEN OTHERS THEN
1547 IF g_fnd_debug = 'Y' AND
1548 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1549 THEN
1550 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
1551 , G_MODULE_PREFIX || l_api_name || '.execption'
1552 , NULL);
1553 END IF;
1554 -- **** for debug information in readonly UT environment.--- begin ****
1555 JMF_SHIKYU_RPT_UTIL.debug_output
1556 (
1557 p_output_to => 'FND_LOG.STRING'
1558 ,p_api_name => G_MODULE_PREFIX || l_api_name
1559 ,p_message => 'Exception: ' || SQLERRM
1560 );
1561 -- **** for debug information in readonly UT environment.--- end ****
1562 l_rep_po_unallocated_pri := 0;
1563 RETURN l_rep_po_unallocated_pri;
1564
1565 END get_rep_po_residual_unalloc;
1566
1567 --========================================================================
1568 -- PROCEDURE : set_rep_po_residual_unalloc PUBLIC ,set_replenishment_po_unallocated quantity for primary uom
1569 -- PARAMETERS: p_rep_po_unalloc_row_type row type id to identify the
1570 -- unallocated components information
1571 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
1572 -- : p_rep_po_id row type id to identify the rcv_transaction data
1573 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
1574 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
1575 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
1576 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
1577 -- : p_item_id the item_id got from the onhand info from mid temp table
1578 -- COMMENT : find the replenishment purchase order residual unallocated quantity for primary uom
1579 -- PRE-COND :
1580 -- EXCEPTIONS:
1581 --========================================================================
1582 PROCEDURE set_rep_po_residual_unalloc
1583 (
1584 p_rep_po_unalloc_row_type IN NUMBER
1585 ,p_rcv_transaction_row_type IN NUMBER
1586 ,p_ou_id IN NUMBER
1587 ,p_rcv_transaction_id IN NUMBER
1588 ,p_supplier_id IN NUMBER
1589 ,p_supplier_site_id IN NUMBER
1590 ,p_oem_inv_org_id IN NUMBER
1591 ,p_tp_inv_org_id IN NUMBER
1592 ,p_item_id IN NUMBER
1593 ,p_project_id IN NUMBER
1594 ,p_task_id IN NUMBER
1595 ,p_new_rep_po_unallocated_pri IN NUMBER
1596 ) IS
1597 l_api_name CONSTANT VARCHAR2(30) := 'set_rep_po_residual_unalloc';
1598
1599 BEGIN
1600 -- **** for debug information in readonly UT environment.--- begin ****
1601 JMF_SHIKYU_RPT_UTIL.debug_output
1602 (
1603 p_output_to => 'FND_LOG.STRING'
1604 ,p_api_name => G_MODULE_PREFIX || l_api_name
1605 ,p_message => 'begin:' ||
1606 ',p_rep_po_unalloc_row_type:' || p_rep_po_unalloc_row_type ||
1607 ',p_rcv_transaction_row_type:' || p_rcv_transaction_row_type ||
1608 ',p_ou_id :' || p_ou_id ||
1609 ',p_rcv_transaction_id' || p_rcv_transaction_id ||
1610 ',p_supplier_id:' || p_supplier_id ||
1611 ',p_supplier_site_id:' || p_supplier_site_id ||
1612 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1613 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1614 ',p_item_id:' || p_item_id ||
1615 ',p_new_rep_po_unallocated_pri:' || p_new_rep_po_unallocated_pri ||
1616 ',p_project_id:' || p_project_id ||
1617 ',p_task_id:' || p_task_id
1618 );
1619 -- **** for debug information in readonly UT environment.--- end ****
1620
1621 IF g_fnd_debug = 'Y' AND
1622 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1623 THEN
1624 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1625 , g_module_prefix || l_api_name || '.begin'
1626 , NULL);
1627 END IF;
1628
1629 -- Valid parameter validation;
1630 -- if all parameters are valid then continue; otherwise raise an error message in log;
1631 UPDATE jmf_shikyu_cfr_mid_temp
1632 -- Updated to fix potential issue of operations between null numbers
1633 --SET quantity = quantity -
1634 -- (quantity *
1635 SET quantity = NVL(quantity,0) -
1636 (NVL(quantity,0) *
1637 p_new_rep_po_unallocated_pri /
1638 primary_unallocated_quantity) --residual_unallocated for the UOM
1639 -- Updated to fix potential issue of operations between null numbers
1640 -- ,primary_unallocated_quantity = primary_unallocated_quantity -
1641 ,primary_unallocated_quantity = NVL(primary_unallocated_quantity,0) -
1642 p_new_rep_po_unallocated_pri --residual_unallocated for the primary UOM
1643 WHERE row_type = p_rep_po_unalloc_row_type
1644 AND supplier_id = p_supplier_id
1645 AND site_id = p_supplier_site_id
1646 AND oem_inv_org_id = p_oem_inv_org_id
1647 AND tp_inv_org_id = p_tp_inv_org_id
1648 AND item_id = p_item_id
1649 AND shikyu_id =
1650 (SELECT rcv.po_line_location_id
1651 FROM rcv_transactions rcv
1652 WHERE rcv.transaction_id = p_rcv_transaction_id
1653 AND rcv.transaction_type = 'RECEIVE');
1654
1655 /*
1656 TODO: owner="sunwa" created="2005-11-27"
1657 text="how to deal with if the quantity less then 0"
1658 */
1659 COMMIT; -- for debug on UT ?????
1660 --print the data in mid temp table for debug.
1661 rpt_debug_show_mid_data(
1662 p_row_type => p_rep_po_unalloc_row_type
1663 ,p_output_to => 'FND_LOG.STRING'
1664 );
1665 IF g_fnd_debug = 'Y' AND
1666 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1667 THEN
1668 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1669 , g_module_prefix || l_api_name || '.end'
1670 , NULL);
1671 END IF;
1672 EXCEPTION
1673 WHEN NO_DATA_FOUND THEN
1674 -- raise log message;
1675 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
1676 fnd_msg_pub.Add;
1677
1678 WHEN OTHERS THEN
1679 IF g_fnd_debug = 'Y' AND
1680 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1681 THEN
1682 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
1683 , G_MODULE_PREFIX || l_api_name || '.execption'
1684 , NULL);
1685 END IF;
1686 -- **** for debug information in readonly UT environment.--- begin ****
1687 JMF_SHIKYU_RPT_UTIL.debug_output
1688 (
1689 p_output_to => 'FND_LOG.STRING'
1690 ,p_api_name => G_MODULE_PREFIX || l_api_name
1691 ,p_message => 'WHEN OTHERS THEN'
1692 );
1693 -- **** for debug information in readonly UT environment.--- end ****
1694
1695 END set_rep_po_residual_unalloc;
1696
1697 --========================================================================
1698 -- PROCEDURE : set_rcv_transaction_unalloc PUBLIC ,get_replenishment_po_unallocated quantity for primary uom
1699 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
1700 -- : p_rcv_transaction_id row type id to identify the rcv_transaction data
1701 -- : p_rcv_unallocated_pri the rcv unallocated quantity for primary uom
1702 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
1703 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
1704 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
1705 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
1706 -- : p_item_id the item_id got from the onhand info from mid temp table
1707 -- COMMENT : update the replenishment po receive transaction unallocated information for primary uom
1708 -- PRE-COND :
1709 -- EXCEPTIONS:
1710 --========================================================================
1711 PROCEDURE set_rcv_transaction_unalloc
1712 (
1713 p_rcv_row_type IN NUMBER
1714 ,p_ou_id IN NUMBER
1715 ,p_rcv_transaction_id IN NUMBER
1716 ,p_rcv_unallocated_pri IN NUMBER
1717 ,p_supplier_id IN NUMBER
1718 ,p_supplier_site_id IN NUMBER
1719 ,p_oem_inv_org_id IN NUMBER
1720 ,p_tp_inv_org_id IN NUMBER
1721 ,p_item_id IN NUMBER
1722 ,p_project_id IN NUMBER
1723 ,p_task_id IN NUMBER
1724 ) IS
1725 l_api_name CONSTANT VARCHAR2(30) := 'set_rcv_transaction_unalloc';
1726
1727 l_jmf_cfr_mid_temp_rcv_rows NUMBER;
1728 BEGIN
1729 -- **** for debug information in readonly UT environment.--- begin ****
1730 JMF_SHIKYU_RPT_UTIL.debug_output
1731 (
1732 p_output_to => 'FND_LOG.STRING'
1733 ,p_api_name => G_MODULE_PREFIX || l_api_name
1734 ,p_message => 'begin:' ||
1735 ',p_rcv_row_type:' || p_rcv_row_type ||
1736 ',p_ou_id :' || p_ou_id ||
1737 ',p_rcv_transaction_id' || p_rcv_transaction_id ||
1738 ',p_supplier_id:' || p_supplier_id ||
1739 ',p_supplier_site_id:' || p_supplier_site_id ||
1740 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1741 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1742 ',p_item_id:' || p_item_id ||
1743 ',p_rcv_unallocated_pri:' || p_rcv_unallocated_pri ||
1744 ',p_project_id:' || p_project_id ||
1745 ',p_task_id:' || p_task_id
1746 );
1747 -- **** for debug information in readonly UT environment.--- end ****
1748
1749 IF g_fnd_debug = 'Y' AND
1750 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1751 THEN
1752 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1753 , g_module_prefix || l_api_name || '.begin'
1754 , NULL);
1755 END IF;
1756
1757 -- Valid parameter validation;
1758 -- if all parameters are valid then continue; otherwise raise an error message in log;
1759 --????
1760 SELECT COUNT(*)
1761 INTO l_jmf_cfr_mid_temp_rcv_rows
1762 FROM jmf_shikyu_cfr_mid_temp
1763 WHERE row_type = p_rcv_row_type
1764 AND shikyu_id = p_rcv_transaction_id;
1765 --find if there is a rcv_transaction line exist
1766 IF l_jmf_cfr_mid_temp_rcv_rows = 1 --Found one row
1767 THEN
1768 --update if exist
1769 UPDATE jmf_shikyu_cfr_mid_temp
1770 -- Updated to fix potential issue of operations between null numbers
1771 -- SET primary_unallocated_quantity = primary_unallocated_quantity +
1772 SET primary_unallocated_quantity = NVL(primary_unallocated_quantity,0) +
1773 p_rcv_unallocated_pri
1774 WHERE row_type = p_rcv_row_type
1775 AND shikyu_id = p_rcv_transaction_id;
1776 ELSE
1777 --NOTFOUND
1778 --add if not exist
1779 INSERT INTO jmf_shikyu_cfr_mid_temp
1780 (row_type
1781 ,shikyu_id
1782 ,primary_unallocated_quantity
1783 ,oem_inv_org_id
1784 ,tp_inv_org_id
1785 ,item_id
1786 ,supplier_id
1787 ,site_id)
1788 VALUES
1789 (p_rcv_row_type
1790 ,p_rcv_transaction_id
1791 ,p_rcv_unallocated_pri
1792 ,p_oem_inv_org_id
1793 ,p_tp_inv_org_id
1794 ,p_item_id
1795 ,p_supplier_id
1796 ,p_supplier_site_id);
1797 END IF;
1798 COMMIT; -- for debug on UT ?????
1799 --print the data in mid temp table for debug.
1800 rpt_debug_show_mid_data(
1801 p_row_type => p_rcv_row_type
1802 ,p_output_to => 'FND_LOG.STRING'
1803 );
1804 IF g_fnd_debug = 'Y' AND
1805 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1806 THEN
1807 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1808 , g_module_prefix || l_api_name || '.end'
1809 , NULL);
1810 END IF;
1811 EXCEPTION
1812 WHEN NO_DATA_FOUND THEN
1813 -- raise log message;
1814 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
1815 fnd_msg_pub.Add;
1816
1817 WHEN OTHERS THEN
1818 IF g_fnd_debug = 'Y' AND
1819 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1820 THEN
1821 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
1822 , G_MODULE_PREFIX || l_api_name || '.execption'
1823 , NULL);
1824 END IF;
1825 -- **** for debug information in readonly UT environment.--- begin ****
1826 JMF_SHIKYU_RPT_UTIL.debug_output
1827 (
1828 p_output_to => 'FND_LOG.STRING'
1829 ,p_api_name => G_MODULE_PREFIX || l_api_name
1830 ,p_message => 'WHEN OTHERS THEN'
1831 );
1832 -- **** for debug information in readonly UT environment.--- end ****
1833
1834 END set_rcv_transaction_unalloc;
1835
1836 --========================================================================
1837 -- PROCEDURE : get_unconsumed_components PUBLIC
1838 -- PARAMETERS: p_sub_po_unconsumed_row_type row type id to identify the
1839 -- unallocated components information
1840 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
1841 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
1842 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
1843 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
1844 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
1845 -- : p_item_id the item_id got from the onhand info from mid temp table
1846 -- : x_need_to_find_pri_qty the need to find quantity under primary UOM
1847 -- COMMENT : for each line in the on hand data in the jmf_shikyu_cfr_mid_temp table,
1848 -- this procedure is used to get the possilbe allocated but unconsumed rcv_transaction data information
1849 -- for those onhand SHIKYU components based on LIFO received date.
1850 -- PRE-COND :
1851 -- EXCEPTIONS:
1852 --========================================================================
1853 PROCEDURE get_unconsumed_components
1854 (
1855 p_sub_po_unconsumed_row_type IN NUMBER
1856 ,p_rep_po_unconsumed_row_type IN NUMBER
1857 ,p_rcv_transaction_row_type IN NUMBER
1858 ,p_ou_id IN NUMBER
1859 ,p_supplier_id IN NUMBER
1860 ,p_supplier_site_id IN NUMBER
1861 ,p_oem_inv_org_id IN NUMBER
1862 ,p_tp_inv_org_id IN NUMBER
1863 ,p_item_id IN NUMBER
1864 ,p_project_id IN NUMBER
1865 ,p_task_id IN NUMBER
1866 ,x_need_to_find_pri_qty IN OUT NOCOPY NUMBER
1867 ) IS
1868 l_api_name CONSTANT VARCHAR2(30) := 'get_unconsumed_components';
1869
1870 -- get rcv_transaction information, rcv_transaction_id, rcv_unprocessed_qty, from subcontract order, via the replenishment po
1871 /*
1872 TODO: owner="sunwa" created="2005-11-30"
1873 text="how about RepPO received quantity < allocated? can this be happen?"
1874 */
1875 CURSOR l_cur_get_rcv_transaction_info IS
1876 SELECT rt.transaction_id
1877 ,rt.primary_quantity -
1878 NVL((SELECT SUM(NVL(mid_s.primary_unallocated_quantity
1879 ,0) + NVL(mid_s.primary_unconsumed_quantity
1880 ,0))
1881 FROM jmf_shikyu_cfr_mid_temp mid_s
1882 WHERE mid_s.row_type = p_rcv_transaction_row_type
1883 AND mid_s.shikyu_id = rt.transaction_id)
1884 ,0)
1885 FROM jmf_shikyu_allocations alloc
1886 ,jmf_shikyu_replenishments jsr
1887 ,jmf_shikyu_cfr_mid_temp mid
1888 ,rcv_transactions rt
1889 WHERE mid.row_type = p_sub_po_unconsumed_row_type
1890 AND NVL(mid.get_rep_flag
1891 ,'N') <> CFR_REP_PO_GET_RCV_FLAG --if the rep_po line have done get rcv process, the get_rcv_flag will be set to 1
1892 AND mid.shikyu_id = alloc.subcontract_po_shipment_id
1893 AND mid.item_id = alloc.shikyu_component_id
1894 AND alloc.replenishment_so_line_id = jsr.replenishment_so_line_id
1895 AND jsr.replenishment_po_shipment_id = rt.po_line_location_id
1896 AND rt.transaction_type = 'RECEIVE'
1897 AND jsr.oem_organization_id = p_oem_inv_org_id
1898 AND jsr.tp_organization_id = p_tp_inv_org_id
1899 AND jsr.tp_supplier_id = p_supplier_id
1900 AND jsr.tp_supplier_site_id = p_supplier_site_id
1901 AND jsr.shikyu_component_id = p_item_id
1902 ORDER BY rt.transaction_date;
1903
1904 l_rcv_transaction_id rcv_transactions.transaction_id%TYPE; --for cursor
1905 l_rcv_unprocessed_primary_qty rcv_transactions.primary_quantity%TYPE; --for cursor
1906
1907 l_sub_po_residual_pri rcv_transactions.primary_quantity%TYPE;
1908 l_rcv_unconsumed_pri rcv_transactions.primary_quantity%TYPE;
1909
1910 BEGIN
1911 -- **** for debug information in readonly UT environment.--- begin ****
1912 JMF_SHIKYU_RPT_UTIL.debug_output
1913 (
1914 p_output_to => 'FND_LOG.STRING'
1915 ,p_api_name => G_MODULE_PREFIX || l_api_name
1916 ,p_message => 'begin:' ||
1917 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
1918 ',p_rep_po_unconsumed_row_type:' || p_rep_po_unconsumed_row_type ||
1919 ',p_rcv_transaction_row_type:' || p_rcv_transaction_row_type ||
1920 ',p_ou_id :' || p_ou_id ||
1921 ',p_supplier_id:' || p_supplier_id ||
1922 ',p_supplier_site_id:' || p_supplier_site_id ||
1923 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
1924 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
1925 ',p_item_id:' || p_item_id ||
1926 ',x_need_to_find_pri_qty:' || x_need_to_find_pri_qty ||
1927 ',p_project_id:' || p_project_id ||
1928 ',p_task_id:' || p_task_id
1929 );
1930 -- **** for debug information in readonly UT environment.--- end ****
1931
1932 IF g_fnd_debug = 'Y' AND
1933 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
1934 THEN
1935 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
1936 , g_module_prefix || l_api_name || '.begin'
1937 , NULL);
1938 END IF;
1939
1940 -- Valid parameter validation;
1941 -- if all parameters are valid then continue; otherwise raise an error message in log;
1942 --step1:find all the subcontracting PO that not fully received(with oem_inv_org,supplier/site,tp_inv_org,item)
1943 get_unconsumed_sub_po(p_sub_po_unconsumed_row_type => p_sub_po_unconsumed_row_type
1944 ,p_ou_id => p_ou_id
1945 ,p_supplier_id => p_supplier_id
1946 ,p_supplier_site_id => p_supplier_site_id
1947 ,p_oem_inv_org_id => p_oem_inv_org_id
1948 ,p_tp_inv_org_id => p_tp_inv_org_id
1949 ,p_item_id => p_item_id
1950 ,p_project_id => p_project_id
1951 ,p_task_id => p_task_id);
1952 --step2:find all the replenishment po received transactions for the all subcontract PO above, based on LIFO receive date
1953 --
1954 OPEN l_cur_get_rcv_transaction_info;
1955 LOOP
1956 --begin rcv_transaction information
1957 EXIT WHEN x_need_to_find_pri_qty <= 0;
1958
1959 FETCH l_cur_get_rcv_transaction_info
1960 INTO l_rcv_transaction_id, l_rcv_unprocessed_primary_qty;
1961
1962 EXIT WHEN l_cur_get_rcv_transaction_info%NOTFOUND;
1963 -- **** for debug information in readonly UT environment.--- begin ****
1964 JMF_SHIKYU_RPT_UTIL.debug_output
1965 (
1966 p_output_to => 'FND_LOG.STRING'
1967 ,p_api_name => G_MODULE_PREFIX || l_api_name
1968 ,p_message => 'begin:' ||
1969 ',x_need_to_find_pri_qty:' || x_need_to_find_pri_qty ||
1970 ',l_rcv_transaction_id:' || l_rcv_transaction_id ||
1971 ',l_rcv_unprocessed_primary_qty:' || l_rcv_unprocessed_primary_qty
1972 );
1973 -- **** for debug information in readonly UT environment.--- end ****
1974
1975 --step3:find the possible onhand components(for the unconsumed )
1976 l_sub_po_residual_pri := get_sub_po_residual_unconsume(p_sub_po_unconsumed_row_type => p_sub_po_unconsumed_row_type
1977 ,p_ou_id => p_ou_id
1978 ,p_rcv_transaction_id => l_rcv_transaction_id
1979 ,p_supplier_id => p_supplier_id
1980 ,p_supplier_site_id => p_supplier_site_id
1981 ,p_oem_inv_org_id => p_oem_inv_org_id
1982 ,p_tp_inv_org_id => p_tp_inv_org_id
1983 ,p_item_id => p_item_id
1984 ,p_project_id => p_project_id
1985 ,p_task_id => p_task_id); --the quantity for primary uom
1986
1987 IF l_sub_po_residual_pri > 0
1988 THEN
1989 --the possilbe unconsumed rcv_transactions primary quantity
1990 l_rcv_unconsumed_pri := jmf_shikyu_rpt_util.get_min3(p_number1 => l_rcv_unprocessed_primary_qty
1991 ,p_number2 => l_sub_po_residual_pri
1992 ,p_number3 => x_need_to_find_pri_qty);
1993
1994 --insert data to rcv_temp marking the processed rcv_transaction,
1995 set_rcv_transaction_unconsume(p_rcv_row_type => p_rcv_transaction_row_type
1996 ,p_ou_id => p_ou_id
1997 ,p_rcv_transaction_id => l_rcv_transaction_id
1998 ,p_rcv_unconsumed_pri => l_rcv_unconsumed_pri
1999 ,p_supplier_id => p_supplier_id
2000 ,p_supplier_site_id => p_supplier_site_id
2001 ,p_oem_inv_org_id => p_oem_inv_org_id
2002 ,p_tp_inv_org_id => p_tp_inv_org_id
2003 ,p_item_id => p_item_id
2004 ,p_project_id => p_project_id
2005 ,p_task_id => p_task_id);
2006
2007 --the residual unconsumed quantity for primary quantity
2008 --update replenishment po residual unconsumed quantity information
2009 set_sub_po_residual_unconsume(p_sub_po_unconsumed_row_type => p_sub_po_unconsumed_row_type
2010 ,p_rcv_transaction_row_type => p_rcv_transaction_row_type
2011 ,p_ou_id => p_ou_id
2012 ,p_rcv_transaction_id => l_rcv_transaction_id
2013 ,p_supplier_id => p_supplier_id
2014 ,p_supplier_site_id => p_supplier_site_id
2015 ,p_oem_inv_org_id => p_oem_inv_org_id
2016 ,p_tp_inv_org_id => p_tp_inv_org_id
2017 ,p_item_id => p_item_id
2018 ,p_project_id => p_project_id
2019 ,p_task_id => p_task_id
2020 ,p_new_consumed_pri => l_rcv_unconsumed_pri);
2021 --update the need to find primary quantity
2022 x_need_to_find_pri_qty := x_need_to_find_pri_qty - l_rcv_unconsumed_pri;
2023
2024 END IF;
2025
2026 END LOOP; -- end of find the rcv_transaction information
2027 CLOSE l_cur_get_rcv_transaction_info;
2028
2029 --step4:update the get_rcv_flags for the rep_po lines
2030 COMMIT; -- for debug on UT ?????
2031 IF g_fnd_debug = 'Y' AND
2032 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2033 THEN
2034 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2035 , g_module_prefix || l_api_name || '.end'
2036 , NULL);
2037 END IF;
2038 EXCEPTION
2039 WHEN NO_DATA_FOUND THEN
2040 -- raise log message;
2041 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2042 fnd_msg_pub.Add;
2043
2044 WHEN OTHERS THEN
2045 IF g_fnd_debug = 'Y' AND
2046 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2047 THEN
2048 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2049 , G_MODULE_PREFIX || l_api_name || '.execption'
2050 , NULL);
2051 END IF;
2052 -- **** for debug information in readonly UT environment.--- begin ****
2053 JMF_SHIKYU_RPT_UTIL.debug_output
2054 (
2055 p_output_to => 'FND_LOG.STRING'
2056 ,p_api_name => G_MODULE_PREFIX || l_api_name
2057 ,p_message => 'WHEN OTHERS THEN'
2058 );
2059 -- **** for debug information in readonly UT environment.--- end ****
2060
2061 END get_unconsumed_components;
2062
2063 --========================================================================
2064 -- PROCEDURE : get_unconsumed_sub_po PUBLIC ,unconsumed_subcontracting_po
2065 -- PARAMETERS: p_sub_po_unconsumed_row_type row type id to identify the
2066 -- unallocated components information
2067 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
2068 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
2069 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
2070 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
2071 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
2072 -- : p_item_id the item_id got from the onhand info from mid temp table
2073 -- COMMENT : find the subcontracting purchase order that not fully received
2074 -- PRE-COND :
2075 -- EXCEPTIONS:
2076 --========================================================================
2077 PROCEDURE get_unconsumed_sub_po
2078 (
2079 p_sub_po_unconsumed_row_type IN NUMBER
2080 ,p_ou_id IN NUMBER
2081 ,p_supplier_id IN NUMBER
2082 ,p_supplier_site_id IN NUMBER
2083 ,p_oem_inv_org_id IN NUMBER
2084 ,p_tp_inv_org_id IN NUMBER
2085 ,p_item_id IN NUMBER
2086 ,p_project_id IN NUMBER
2087 ,p_task_id IN NUMBER
2088 ) IS
2089 l_api_name CONSTANT VARCHAR2(30) := 'get_unconsumed_sub_po';
2090
2091 BEGIN
2092 -- **** for debug information in readonly UT environment.--- begin ****
2093 JMF_SHIKYU_RPT_UTIL.debug_output
2094 (
2095 p_output_to => 'FND_LOG.STRING'
2096 ,p_api_name => G_MODULE_PREFIX || l_api_name
2097 ,p_message => 'begin:' ||
2098 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
2099 ',p_ou_id :' || p_ou_id ||
2100 ',p_supplier_id:' || p_supplier_id ||
2101 ',p_supplier_site_id:' || p_supplier_site_id ||
2102 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
2103 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
2104 ',p_item_id:' || p_item_id ||
2105 ',p_project_id:' || p_project_id ||
2106 ',p_task_id:' || p_task_id
2107 );
2108 -- **** for debug information in readonly UT environment.--- end ****
2109
2110 IF g_fnd_debug = 'Y' AND
2111 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2112 THEN
2113 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2114 , g_module_prefix || l_api_name || '.begin'
2115 , NULL);
2116 END IF;
2117
2118 -- Valid parameter validation;
2119 -- if all parameters are valid then continue; otherwise raise an error message in log;
2120 --the subcontract orders that not fully received
2121
2122 -- insert only the new SubPO info
2123 INSERT INTO jmf_shikyu_cfr_mid_temp
2124 (row_type
2125 ,shikyu_id
2126 ,uom
2127 ,primary_uom
2128 ,primary_unconsumed_quantity
2129 ,supplier_id
2130 ,site_id
2131 ,oem_inv_org_id
2132 ,tp_inv_org_id
2133 ,item_id)
2134 SELECT p_sub_po_unconsumed_row_type
2135 ,sub_po.subcontract_po_shipment_id
2136 ,comp.uom
2137 ,JMF_SHIKYU_RPT_UTIL.get_item_primary_uom_code(sub_po.tp_organization_id
2138 ,comp.shikyu_component_id)
2139 ,((SELECT NVL(SUM(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(sub_po.tp_organization_id
2140 ,jsa_a.shikyu_component_id
2141 ,jsa_a.uom
2142 ,NVL(jsa_a.allocated_quantity
2143 ,0)))
2144 ,0)
2145 FROM jmf_shikyu_allocations jsa_a
2146 WHERE jsa_a.subcontract_po_shipment_id =
2147 comp.subcontract_po_shipment_id
2148 AND jsa_a.shikyu_component_id = comp.shikyu_component_id) -
2149 wip_req.quantity_issued
2150 ) primary_possible_unconsumed
2151 ,ph.vendor_id
2152 ,ph.vendor_site_id
2153 ,sub_po.oem_organization_id
2154 ,sub_po.tp_organization_id
2155 ,comp.shikyu_component_id
2156 FROM po_line_locations_all pll
2157 ,jmf_subcontract_orders sub_po
2158 ,po_headers_all ph
2159 ,jmf_shikyu_components comp
2160 ,wip_requirement_operations wip_req
2161 WHERE pll.line_location_id = sub_po.subcontract_po_shipment_id
2162 AND pll.quantity > pll.quantity_received --this can be ignore if allow the allocated qty larger than ordered qty
2163 AND sub_po.oem_organization_id = p_oem_inv_org_id
2164 AND sub_po.tp_organization_id = p_tp_inv_org_id
2165 AND pll.po_header_id = ph.po_header_id
2166 AND ((ph.org_id IS NULL) OR (ph.org_id = p_ou_id))
2167 AND ph.vendor_id = p_supplier_id
2168 AND ph.vendor_site_id = p_supplier_site_id
2169 AND sub_po.wip_entity_id = wip_req.wip_entity_id
2170 AND sub_po.subcontract_po_shipment_id =
2171 comp.subcontract_po_shipment_id
2172 AND comp.shikyu_component_id = wip_req.inventory_item_id
2173 AND comp.shikyu_component_id = p_item_id
2174 AND sub_po.tp_organization_id = wip_req.organization_id
2175 AND wip_req.repetitive_schedule_id IS NULL
2176 AND wip_req.operation_seq_num = 1
2177 --This may cause issue when same components are found in different tp organization,the onhand component are found
2178 -- secondly,will be lost in them mid_temp table.That means in the report will lose some datas which should be displayed.
2179 -- updated to fix this potensial issue.
2180 /* AND NOT ((comp.subcontract_po_shipment_id IN
2181 (SELECT jscmt_s.shikyu_id
2182 FROM jmf_shikyu_cfr_mid_temp jscmt_s
2183 WHERE jscmt_s.row_type = p_sub_po_unconsumed_row_type)) AND
2184 (comp.shikyu_component_id IN
2185 (SELECT jscmt_i.item_id
2186 FROM jmf_shikyu_cfr_mid_temp jscmt_i
2187 WHERE jscmt_i.row_type = p_sub_po_unconsumed_row_type)))*/
2188 AND NOT (comp.subcontract_po_shipment_id IN
2189 (SELECT jscmt_s.shikyu_id
2190 FROM jmf_shikyu_cfr_mid_temp jscmt_s
2191 WHERE jscmt_s.row_type = p_sub_po_unconsumed_row_type
2192 AND jscmt_s.item_id = p_item_id))
2193 ;
2194
2195 --update the primary UOM, primary_residual_unallocated
2196 UPDATE jmf_shikyu_cfr_mid_temp
2197 SET quantity = NVL(primary_unconsumed_quantity,0) *
2198 JMF_SHIKYU_RPT_UTIL.po_uom_convert_p(primary_uom
2199 ,uom
2200 ,item_id)
2201 WHERE row_type = p_sub_po_unconsumed_row_type
2202 AND quantity IS NULL --only for those do not get the quantity of uom
2203 AND supplier_id = p_supplier_id
2204 AND site_id = p_supplier_site_id
2205 AND oem_inv_org_id = p_oem_inv_org_id
2206 AND tp_inv_org_id = p_tp_inv_org_id
2207 AND item_id = p_item_id;
2208 COMMIT; -- for debug on UT ?????
2209 --print the data in mid temp table for debug.
2210 rpt_debug_show_mid_data(
2211 p_row_type => p_sub_po_unconsumed_row_type
2212 ,p_output_to => 'FND_LOG.STRING'
2213 );
2214 IF g_fnd_debug = 'Y' AND
2215 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2216 THEN
2217 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2218 , g_module_prefix || l_api_name || '.end'
2219 , NULL);
2220 END IF;
2221 EXCEPTION
2222 WHEN NO_DATA_FOUND THEN
2223 -- raise log message;
2224 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2225 fnd_msg_pub.Add;
2226
2227 WHEN OTHERS THEN
2228 IF g_fnd_debug = 'Y' AND
2229 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2230 THEN
2231 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2232 , G_MODULE_PREFIX || l_api_name || '.execption'
2233 , NULL);
2234 END IF;
2235 -- **** for debug information in readonly UT environment.--- begin ****
2236 JMF_SHIKYU_RPT_UTIL.debug_output
2237 (
2238 p_output_to => 'FND_LOG.STRING'
2239 ,p_api_name => G_MODULE_PREFIX || l_api_name
2240 ,p_message => 'WHEN OTHERS THEN'
2241 );
2242 -- **** for debug information in readonly UT environment.--- end ****
2243
2244 END get_unconsumed_sub_po;
2245
2246 --========================================================================
2247 -- PROCEDURE : get_unconsumed_rep_po PUBLIC ,get_unconsumed_replenishment_po
2248 -- PARAMETERS: p_rep_po_unconsume_row_type row type id to identify the
2249 -- unconsumed components information
2250 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
2251 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
2252 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
2253 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
2254 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
2255 -- : p_item_id the item_id got from the onhand info from mid temp table
2256 -- COMMENT : find the replenishment purchase order that have unallocated receipts for the item
2257 -- and insert the result to mid temp table
2258 -- PRE-COND :
2259 -- EXCEPTIONS:
2260 --========================================================================
2261 PROCEDURE get_unconsumed_rep_po
2262 (
2263 p_sub_po_unconsumed_row_type IN NUMBER
2264 ,p_rep_po_unconsumed_row_type IN NUMBER
2265 ,p_ou_id IN NUMBER
2266 ,p_supplier_id IN NUMBER
2267 ,p_supplier_site_id IN NUMBER
2268 ,p_oem_inv_org_id IN NUMBER
2269 ,p_tp_inv_org_id IN NUMBER
2270 ,p_item_id IN NUMBER
2271 ,p_project_id IN NUMBER
2272 ,p_task_id IN NUMBER
2273 ) IS
2274 l_api_name CONSTANT VARCHAR2(30) := 'get_unconsumed_rep_po';
2275
2276 BEGIN
2277 -- **** for debug information in readonly UT environment.--- begin ****
2278 JMF_SHIKYU_RPT_UTIL.debug_output
2279 (
2280 p_output_to => 'FND_LOG.STRING'
2281 ,p_api_name => G_MODULE_PREFIX || l_api_name
2282 ,p_message => 'begin:' ||
2283 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
2284 ',p_rep_po_unconsumed_row_type:' || p_rep_po_unconsumed_row_type ||
2285 ',p_ou_id :' || p_ou_id ||
2286 ',p_supplier_id:' || p_supplier_id ||
2287 ',p_supplier_site_id:' || p_supplier_site_id ||
2288 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
2289 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
2290 ',p_item_id:' || p_item_id ||
2291 ',p_project_id:' || p_project_id ||
2292 ',p_task_id:' || p_task_id
2293 );
2294 -- **** for debug information in readonly UT environment.--- end ****
2295
2296 IF g_fnd_debug = 'Y' AND
2297 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2298 THEN
2299 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2300 , g_module_prefix || l_api_name || '.begin'
2301 , NULL);
2302 END IF;
2303
2304 -- Valid parameter validation;
2305 -- if all parameters are valid then continue; otherwise raise an error message in log;
2306
2307 -- the allocated quantity for one po line_location_id, assume that the UOM are the same in po and shikyu allocation
2308 -- need to add the supplier/site oem tp org and item restriction????.
2309 -- update 2005-11-30
2310 INSERT INTO jmf_shikyu_cfr_mid_temp
2311 (row_type
2312 ,shikyu_id
2313 ,uom
2314 ,primary_uom
2315 ,primary_unconsumed_quantity
2316 ,supplier_id
2317 ,site_id
2318 ,oem_inv_org_id
2319 ,tp_inv_org_id
2320 ,item_id)
2321 SELECT p_rep_po_unconsumed_row_type
2322 ,jsr.replenishment_po_shipment_id
2323 ,alloc.uom
2324 ,JMF_SHIKYU_RPT_UTIL.get_item_primary_uom_code(jsr.oem_organization_id
2325 ,alloc.shikyu_component_id)
2326 ,JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(jsr.oem_organization_id
2327 ,alloc.shikyu_component_id
2328 ,alloc.uom
2329 ,alloc.allocated_quantity) -
2330 NVL(wro.quantity_issued
2331 ,0)
2332 ,jsr.tp_supplier_id
2333 ,jsr.tp_supplier_site_id
2334 ,jsr.oem_organization_id
2335 ,jsr.tp_organization_id
2336 ,alloc.shikyu_component_id
2337 FROM jmf_shikyu_allocations alloc
2338 ,jmf_shikyu_replenishments jsr
2339 ,jmf_shikyu_cfr_mid_temp mid
2340 ,jmf_subcontract_orders jso
2341 ,wip_requirement_operations wro
2342 WHERE mid.row_type = p_sub_po_unconsumed_row_type
2343 AND NVL(mid.get_rep_flag
2344 ,'N') <> CFR_SUB_PO_GET_REP_FLAG
2345 AND mid.shikyu_id = alloc.subcontract_po_shipment_id
2346 AND mid.item_id = alloc.shikyu_component_id
2347 AND alloc.replenishment_so_line_id = jsr.replenishment_so_line_id
2348 AND jsr.oem_organization_id = p_oem_inv_org_id
2349 AND jsr.tp_organization_id = p_tp_inv_org_id
2350 AND jsr.tp_supplier_id = p_supplier_id
2351 AND jsr.tp_supplier_site_id = p_supplier_site_id
2352 AND alloc.shikyu_component_id = p_item_id
2353 AND alloc.subcontract_po_shipment_id =
2354 jso.subcontract_po_shipment_id
2355 AND jso.wip_entity_id = wro.wip_entity_id(+)
2356 AND jso.tp_organization_id = wro.organization_id(+)
2357 AND ((wro.operation_seq_num IS NULL) OR
2358 (wro.operation_seq_num = 1))
2359 AND wro.repetitive_schedule_id IS NULL
2360 AND alloc.shikyu_component_id = wro.inventory_item_id
2361 --This may cause issue when same components are found in different tp organization,the onhand component are found
2362 -- secondly,will be lost in them mid_temp table.That means in the report will lose some datas which should be displayed.
2363 -- updated to fix this potensial issue.
2364 /* AND NOT
2365 ((jsr.replenishment_po_shipment_id IN
2366 (SELECT jscmt_s.shikyu_id
2367 FROM jmf_shikyu_cfr_mid_temp jscmt_s
2368 WHERE jscmt_s.row_type = p_rep_po_unconsumed_row_type)) AND
2369 (alloc.shikyu_component_id IN
2370 (SELECT jscmt_i.item_id
2371 FROM jmf_shikyu_cfr_mid_temp jscmt_i
2372 WHERE jscmt_i.row_type = p_rep_po_unconsumed_row_type)));
2373 */ AND NOT (jsr.replenishment_po_shipment_id IN
2374 (SELECT jscmt_s.shikyu_id
2375 FROM jmf_shikyu_cfr_mid_temp jscmt_s
2376 WHERE jscmt_s.row_type = p_rep_po_unconsumed_row_type
2377 AND jscmt_s.item_id = p_item_id));
2378
2379 --update the primary UOM, primary_residual_unallocated
2380 UPDATE jmf_shikyu_cfr_mid_temp
2381 SET quantity = NVL(primary_unconsumed_quantity,0) *
2382 JMF_SHIKYU_RPT_UTIL.po_uom_convert_p(primary_uom
2383 ,uom
2384 ,item_id)
2385 WHERE row_type = p_rep_po_unconsumed_row_type
2386 AND quantity IS NULL --only for those do not get the quantity of uom
2387 AND supplier_id = p_supplier_id
2388 AND site_id = p_supplier_site_id
2389 AND oem_inv_org_id = p_oem_inv_org_id
2390 AND tp_inv_org_id = p_tp_inv_org_id
2391 AND item_id = p_item_id;
2392
2393 COMMIT; -- for debug on UT ?????
2394 --print the data in mid temp table for debug.
2395 rpt_debug_show_mid_data(
2396 p_row_type => p_rep_po_unconsumed_row_type
2397 ,p_output_to => 'FND_LOG.STRING'
2398 );
2399 IF g_fnd_debug = 'Y' AND
2400 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2401 THEN
2402 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2403 , g_module_prefix || l_api_name || '.end'
2404 , NULL);
2405 END IF;
2406 EXCEPTION
2407 WHEN NO_DATA_FOUND THEN
2408 -- raise log message;
2409 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2410 fnd_msg_pub.Add;
2411
2412 WHEN OTHERS THEN
2413 IF g_fnd_debug = 'Y' AND
2414 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2415 THEN
2416 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2417 , G_MODULE_PREFIX || l_api_name || '.execption'
2418 , NULL);
2419 END IF;
2420 -- **** for debug information in readonly UT environment.--- begin ****
2421 JMF_SHIKYU_RPT_UTIL.debug_output
2422 (
2423 p_output_to => 'FND_LOG.STRING'
2424 ,p_api_name => G_MODULE_PREFIX || l_api_name
2425 ,p_message => 'WHEN OTHERS THEN'
2426 );
2427 -- **** for debug information in readonly UT environment.--- end ****
2428
2429 END get_unconsumed_rep_po;
2430
2431 --========================================================================
2432 -- FUNCTION : get_sub_po_residual_unconsume PUBLIC ,get_replenishment_po_unallocated quantity for primary uom
2433 -- PARAMETERS: p_sub_po_unconsumed_row_type row type id to identify the
2434 -- unallocated components information
2435 -- : p_rcv_transaction_id row type id to identify the rcv_transaction data
2436 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
2437 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
2438 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
2439 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
2440 -- : p_item_id the item_id got from the onhand info from mid temp table
2441 -- COMMENT : find the subcontract order residual unconsumed quantity for primary uom
2442 -- PRE-COND :
2443 -- EXCEPTIONS:
2444 --========================================================================
2445 FUNCTION get_sub_po_residual_unconsume
2446 (
2447 p_sub_po_unconsumed_row_type IN NUMBER
2448 ,p_ou_id IN NUMBER
2449 ,p_rcv_transaction_id IN NUMBER
2450 ,p_supplier_id IN NUMBER
2451 ,p_supplier_site_id IN NUMBER
2452 ,p_oem_inv_org_id IN NUMBER
2453 ,p_tp_inv_org_id IN NUMBER
2454 ,p_item_id IN NUMBER
2455 ,p_project_id IN NUMBER
2456 ,p_task_id IN NUMBER
2457 ) RETURN NUMBER IS
2458 l_api_name CONSTANT VARCHAR2(30) := 'get_sub_po_residual_unconsume';
2459
2460 l_sub_po_residual_pri rcv_transactions.primary_quantity%TYPE;
2461 BEGIN
2462 -- **** for debug information in readonly UT environment.--- begin ****
2463 JMF_SHIKYU_RPT_UTIL.debug_output
2464 (
2465 p_output_to => 'FND_LOG.STRING'
2466 ,p_api_name => G_MODULE_PREFIX || l_api_name
2467 ,p_message => 'begin:' ||
2468 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
2469 ',p_rcv_transaction_id:' || p_rcv_transaction_id ||
2470 ',p_ou_id :' || p_ou_id ||
2471 ',p_supplier_id:' || p_supplier_id ||
2472 ',p_supplier_site_id:' || p_supplier_site_id ||
2473 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
2474 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
2475 ',p_item_id:' || p_item_id ||
2476 ',p_project_id:' || p_project_id ||
2477 ',p_task_id:' || p_task_id
2478 );
2479 -- **** for debug information in readonly UT environment.--- end ****
2480
2481 IF g_fnd_debug = 'Y' AND
2482 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2483 THEN
2484 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2485 , g_module_prefix || l_api_name || '.begin'
2486 , NULL);
2487 END IF;
2488
2489 -- Valid parameter validation;
2490 -- if all parameters are valid then continue; otherwise raise an error message in log;
2491 SELECT SUM(NVL(cfr_mid.primary_unconsumed_quantity
2492 ,0))
2493 INTO l_sub_po_residual_pri
2494 FROM jmf_shikyu_cfr_mid_temp cfr_mid
2495 ,rcv_transactions rcv
2496 ,jmf_shikyu_allocations alloc
2497 ,jmf_shikyu_replenishments jsr
2498 WHERE rcv.transaction_id = P_rcv_transaction_id
2499 AND rcv.transaction_type = 'RECEIVE'
2500 AND cfr_mid.row_type = p_sub_po_unconsumed_row_type
2501 AND cfr_mid.supplier_id = p_supplier_id
2502 AND cfr_mid.site_id = p_supplier_site_id
2503 AND cfr_mid.oem_inv_org_id = p_oem_inv_org_id
2504 AND cfr_mid.tp_inv_org_id = p_tp_inv_org_id
2505 AND cfr_mid.item_id = p_item_id
2506 AND cfr_mid.shikyu_id = alloc.subcontract_po_shipment_id
2507 AND cfr_mid.item_id = alloc.shikyu_component_id
2508 AND alloc.replenishment_so_line_id = jsr.replenishment_so_line_id
2509 AND jsr.replenishment_po_shipment_id = rcv.po_line_location_id;
2510 IF g_fnd_debug = 'Y' AND
2511 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2512 THEN
2513 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2514 , g_module_prefix || l_api_name || '.end'
2515 , NULL);
2516 END IF;
2517 RETURN l_sub_po_residual_pri;
2518 EXCEPTION
2519 WHEN NO_DATA_FOUND THEN
2520 -- raise log message;
2521 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2522 fnd_msg_pub.Add;
2523 RETURN 0;
2524
2525 WHEN OTHERS THEN
2526 IF g_fnd_debug = 'Y' AND
2527 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2528 THEN
2529 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2530 , G_MODULE_PREFIX || l_api_name || '.execption'
2531 , NULL);
2532 END IF;
2533 RETURN -1;
2534 -- **** for debug information in readonly UT environment.--- begin ****
2535 JMF_SHIKYU_RPT_UTIL.debug_output
2536 (
2537 p_output_to => 'FND_LOG.STRING'
2538 ,p_api_name => G_MODULE_PREFIX || l_api_name
2539 ,p_message => 'WHEN OTHERS THEN'
2540 );
2541 -- **** for debug information in readonly UT environment.--- end ****
2542
2543 END get_sub_po_residual_unconsume;
2544
2545 --========================================================================
2546 -- PROCEDURE : set_sub_po_residual_unconsume PUBLIC ,set_replenishment_po_unallocated quantity for primary uom
2547 -- PARAMETERS: p_sub_po_unconsumed_row_type row type id to identify the
2548 -- unconsumed components information
2549 -- : p_rcv_transaction_row_type row type id to identify the rcv_transaction data
2550 -- : p_rep_po_id row type id to identify the rcv_transaction data
2551 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
2552 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
2553 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
2554 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
2555 -- : p_item_id the item_id got from the onhand info from mid temp table
2556 -- : p_new_consumed_pri the new consumed primary quantity that need to update in the temp table
2557 -- COMMENT : find the subcontract order residual unaconsumed quantity for primary uom
2558 -- PRE-COND :
2559 -- EXCEPTIONS:
2560 --========================================================================
2561 PROCEDURE set_sub_po_residual_unconsume
2562 (
2563 p_sub_po_unconsumed_row_type IN NUMBER
2564 ,p_rcv_transaction_row_type IN NUMBER
2565 ,p_ou_id IN NUMBER
2566 ,p_rcv_transaction_id IN NUMBER
2567 ,p_supplier_id IN NUMBER
2568 ,p_supplier_site_id IN NUMBER
2569 ,p_oem_inv_org_id IN NUMBER
2570 ,p_tp_inv_org_id IN NUMBER
2571 ,p_item_id IN NUMBER
2572 ,p_project_id IN NUMBER
2573 ,p_task_id IN NUMBER
2574 ,p_new_consumed_pri IN NUMBER
2575 ) IS
2576 l_api_name CONSTANT VARCHAR2(30) := 'set_sub_po_residual_unconsume';
2577
2578 CURSOR lcur_sub_po_temp_info IS
2579 SELECT cfr_mid.shikyu_id
2580 ,cfr_mid.primary_unconsumed_quantity
2581 FROM jmf_shikyu_cfr_mid_temp cfr_mid
2582 ,rcv_transactions rcv
2583 ,jmf_shikyu_allocations alloc
2584 ,jmf_shikyu_replenishments jsr
2585 WHERE rcv.transaction_id = p_rcv_transaction_id
2586 AND rcv.transaction_type = 'RECEIVE'
2587 AND cfr_mid.row_type = p_sub_po_unconsumed_row_type
2588 AND cfr_mid.supplier_id = p_supplier_id
2589 AND cfr_mid.site_id = p_supplier_site_id
2590 AND cfr_mid.oem_inv_org_id = p_oem_inv_org_id
2591 AND cfr_mid.tp_inv_org_id = p_tp_inv_org_id
2592 AND cfr_mid.item_id = p_item_id
2593 AND cfr_mid.shikyu_id = alloc.subcontract_po_shipment_id
2594 AND cfr_mid.item_id = alloc.shikyu_component_id
2595 AND alloc.replenishment_so_line_id = jsr.replenishment_so_line_id
2596 AND jsr.replenishment_po_shipment_id = rcv.po_line_location_id
2597 AND cfr_mid.primary_unconsumed_quantity > 0
2598 ORDER BY cfr_mid.shikyu_id DESC;
2599
2600 l_sub_po_id jmf_shikyu_cfr_mid_temp.shikyu_id%TYPE;
2601 l_residual_old_consumed_pri jmf_shikyu_cfr_mid_temp.primary_unconsumed_quantity%TYPE;
2602 l_residual_new_consumed_pri jmf_shikyu_cfr_mid_temp.primary_unconsumed_quantity%TYPE;
2603 l_cur_sub_po_consumed_pri jmf_shikyu_cfr_mid_temp.primary_unconsumed_quantity%TYPE;
2604 BEGIN
2605 -- **** for debug information in readonly UT environment.--- begin ****
2606 JMF_SHIKYU_RPT_UTIL.debug_output
2607 (
2608 p_output_to => 'FND_LOG.STRING'
2609 ,p_api_name => G_MODULE_PREFIX || l_api_name
2610 ,p_message => 'begin:' ||
2611 ',p_sub_po_unconsumed_row_type:' || p_sub_po_unconsumed_row_type ||
2612 ',p_rcv_transaction_row_type:' || p_rcv_transaction_row_type ||
2613 ',p_rcv_transaction_id:' || p_rcv_transaction_id ||
2614 ',p_ou_id :' || p_ou_id ||
2615 ',p_supplier_id:' || p_supplier_id ||
2616 ',p_supplier_site_id:' || p_supplier_site_id ||
2617 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
2618 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
2619 ',p_item_id:' || p_item_id ||
2620 ',p_new_consumed_pri:' || p_new_consumed_pri ||
2621 ',p_project_id:' || p_project_id ||
2622 ',p_task_id:' || p_task_id
2623 );
2624 -- **** for debug information in readonly UT environment.--- end ****
2625
2626 IF g_fnd_debug = 'Y' AND
2627 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2628 THEN
2629 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2630 , g_module_prefix || l_api_name || '.begin'
2631 , NULL);
2632 END IF;
2633
2634 -- Valid parameter validation;
2635 -- if all parameters are valid then continue; otherwise raise an error message in log;
2636 --????
2637 l_residual_new_consumed_pri := p_new_consumed_pri;
2638 OPEN lcur_sub_po_temp_info;
2639 LOOP
2640 --begin process updating the unconsumed qty for the found subcontract order in the mid temp table
2641 EXIT WHEN l_residual_new_consumed_pri <= 0;
2642
2643 FETCH lcur_sub_po_temp_info
2644 INTO l_sub_po_id, l_residual_old_consumed_pri;
2645
2646 EXIT WHEN lcur_sub_po_temp_info%NOTFOUND;
2647
2648 -- **** for debug information in readonly UT environment.--- begin ****
2649 JMF_SHIKYU_RPT_UTIL.debug_output
2650 (
2651 p_output_to => 'FND_LOG.STRING'
2652 ,p_api_name => G_MODULE_PREFIX || l_api_name
2653 ,p_message => 'begin:' ||
2654 ',l_residual_new_consumed_pri:' || l_residual_new_consumed_pri ||
2655 ',l_sub_po_id:' || l_sub_po_id ||
2656 ',l_residual_old_consumed_pri:' || l_residual_old_consumed_pri
2657 );
2658 -- **** for debug information in readonly UT environment.--- end ****
2659
2660 l_cur_sub_po_consumed_pri := jmf_shikyu_rpt_util.get_min2(l_residual_old_consumed_pri
2661 ,l_residual_new_consumed_pri);
2662 UPDATE jmf_shikyu_cfr_mid_temp
2663 -- Updated to fix potential issue of operations between null numbers
2664 -- SET quantity = quantity -
2665 -- (quantity * l_cur_sub_po_consumed_pri /
2666 SET quantity = NVL(quantity,0) -
2667 ( NVL(quantity,0) * l_cur_sub_po_consumed_pri /
2668 primary_unconsumed_quantity) --possible unconsumed for UOM
2669 ,primary_unconsumed_quantity = NVL(primary_unconsumed_quantity,0) -
2670 l_cur_sub_po_consumed_pri --possible unconsumed for primary UOM
2671 WHERE row_type = p_sub_po_unconsumed_row_type
2672 AND shikyu_id = l_sub_po_id
2673 AND oem_inv_org_id = p_oem_inv_org_id
2674 AND tp_inv_org_id = p_tp_inv_org_id
2675 AND item_id = p_item_id;
2676
2677 l_residual_new_consumed_pri := l_residual_new_consumed_pri -
2678 l_cur_sub_po_consumed_pri;
2679
2680 END LOOP; --end process updating the unconsumed qty for the found subcontract order in the mid temp table
2681 CLOSE lcur_sub_po_temp_info;
2682
2683 /*
2684 TODO: owner="sunwa" created="2005-11-30"
2685 text="how about if the l_residual_new_consumed_pri still lager then 0 "
2686 */
2687 -- if l_residual_new_consumed_pri > 0 then ---
2688 COMMIT; -- for debug on UT ?????
2689 rpt_debug_show_mid_data(
2690 p_row_type => p_sub_po_unconsumed_row_type
2691 ,p_output_to => 'FND_LOG.STRING'
2692 );
2693 IF g_fnd_debug = 'Y' AND
2694 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2695 THEN
2696 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2697 , g_module_prefix || l_api_name || '.end'
2698 , NULL);
2699 END IF;
2700 EXCEPTION
2701 WHEN NO_DATA_FOUND THEN
2702 -- raise log message;
2703 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2704 fnd_msg_pub.Add;
2705
2706 WHEN OTHERS THEN
2707 IF g_fnd_debug = 'Y' AND
2708 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2709 THEN
2710 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2711 , G_MODULE_PREFIX || l_api_name || '.execption'
2712 , NULL);
2713 END IF;
2714 -- **** for debug information in readonly UT environment.--- begin ****
2715 JMF_SHIKYU_RPT_UTIL.debug_output
2716 (
2717 p_output_to => 'FND_LOG.STRING'
2718 ,p_api_name => G_MODULE_PREFIX || l_api_name
2719 ,p_message => 'WHEN OTHERS THEN'
2720 );
2721 -- **** for debug information in readonly UT environment.--- end ****
2722
2723 END set_sub_po_residual_unconsume;
2724
2725 --========================================================================
2726 -- PROCEDURE : set_rcv_transaction_unconsume PUBLIC ,get_replenishment_po_unconsumed quantity for primary uom
2727 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
2728 -- : p_rcv_transaction_id row type id to identify the rcv_transaction data
2729 -- : p_rcv_unallocated_pri the rcv unallocated quantity for primary uom
2730 -- : p_supplier_id the supplier id got from the onhand info from mid temp table
2731 -- : p_supplier_site_id the supplier site id got from the onhand info from mid temp table
2732 -- : p_oem_inv_org_id the oem_inv_org_id got from the onhand info from mid temp table
2733 -- : p_tp_inv_org_id the tp_inv_org_id got from the onhand info from mid temp table
2734 -- : p_item_id the item_id got from the onhand info from mid temp table
2735 -- COMMENT : update the replenishment po receive transaction unconsumed information for primary uom
2736 -- old_unconsumed = old_unconsumed + p_rcv_unconsumed_pri
2737 -- PRE-COND :
2738 -- EXCEPTIONS:
2739 --========================================================================
2740 PROCEDURE set_rcv_transaction_unconsume
2741 (
2742 p_rcv_row_type IN NUMBER
2743 ,p_ou_id IN NUMBER
2744 ,p_rcv_transaction_id IN NUMBER
2745 ,p_rcv_unconsumed_pri IN NUMBER
2746 ,p_supplier_id IN NUMBER
2747 ,p_supplier_site_id IN NUMBER
2748 ,p_oem_inv_org_id IN NUMBER
2749 ,p_tp_inv_org_id IN NUMBER
2750 ,p_item_id IN NUMBER
2751 ,p_project_id IN NUMBER
2752 ,p_task_id IN NUMBER
2753 ) IS
2754 l_api_name CONSTANT VARCHAR2(30) := 'set_rcv_transaction_unconsume';
2755
2756 l_jmf_cfr_mid_temp_rcv_rows NUMBER;
2757 BEGIN
2758 -- **** for debug information in readonly UT environment.--- begin ****
2759 JMF_SHIKYU_RPT_UTIL.debug_output
2760 (
2761 p_output_to => 'FND_LOG.STRING'
2762 ,p_api_name => G_MODULE_PREFIX || l_api_name
2763 ,p_message => 'begin:' ||
2764 ',p_rcv_row_type:' || p_rcv_row_type ||
2765 ',p_rcv_transaction_id:' || p_rcv_transaction_id ||
2766 ',p_ou_id :' || p_ou_id ||
2767 ',p_supplier_id:' || p_supplier_id ||
2768 ',p_supplier_site_id:' || p_supplier_site_id ||
2769 ',p_oem_inv_org_id :' || p_oem_inv_org_id ||
2770 ',p_tp_inv_org_id:' || p_tp_inv_org_id ||
2771 ',p_item_id:' || p_item_id ||
2772 ',p_rcv_unconsumed_pri:' || p_rcv_unconsumed_pri ||
2773 ',p_project_id:' || p_project_id ||
2774 ',p_task_id:' || p_task_id
2775 );
2776 -- **** for debug information in readonly UT environment.--- end ****
2777
2778 IF g_fnd_debug = 'Y' AND
2779 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2780 THEN
2781 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2782 , g_module_prefix || l_api_name || '.begin'
2783 , NULL);
2784 END IF;
2785
2786 -- Valid parameter validation;
2787 -- if all parameters are valid then continue; otherwise raise an error message in log;
2788 SELECT COUNT(*)
2789 INTO l_jmf_cfr_mid_temp_rcv_rows
2790 FROM jmf_shikyu_cfr_mid_temp
2791 WHERE row_type = p_rcv_row_type
2792 AND shikyu_id = p_rcv_transaction_id;
2793 --find if there is a rcv_transaction line exist
2794 IF l_jmf_cfr_mid_temp_rcv_rows = 1 --Found one row
2795 THEN
2796 --update if exist
2797 UPDATE jmf_shikyu_cfr_mid_temp
2798 -- Updated to fix potential issue of operations between null numbers
2799 -- SET primary_unconsumed_quantity = primary_unconsumed_quantity +
2800 SET primary_unconsumed_quantity = NVL(primary_unconsumed_quantity,0) +
2801 p_rcv_unconsumed_pri
2802 WHERE row_type = p_rcv_row_type
2803 AND shikyu_id = p_rcv_transaction_id;
2804 ELSE
2805 --NOTFOUND
2806 --add if not exist
2807 INSERT INTO jmf_shikyu_cfr_mid_temp
2808 (row_type
2809 ,shikyu_id
2810 ,primary_unconsumed_quantity
2811 ,oem_inv_org_id
2812 ,tp_inv_org_id
2813 ,item_id
2814 ,supplier_id
2815 ,site_id)
2816 VALUES
2817 (p_rcv_row_type
2818 ,p_rcv_transaction_id
2819 ,p_rcv_unconsumed_pri
2820 ,p_oem_inv_org_id
2821 ,p_tp_inv_org_id
2822 ,p_item_id
2823 ,p_supplier_id
2824 ,p_supplier_site_id);
2825 END IF; --IF l_jmf_cfr_mid_temp_rcv_rows = 1
2826 COMMIT; -- for debug on UT ?????
2827 rpt_debug_show_mid_data(
2828 p_row_type => p_rcv_row_type
2829 ,p_output_to => 'FND_LOG.STRING'
2830 );
2831 IF g_fnd_debug = 'Y' AND
2832 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2833 THEN
2834 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2835 , g_module_prefix || l_api_name || '.end'
2836 , NULL);
2837 END IF;
2838 EXCEPTION
2839 WHEN NO_DATA_FOUND THEN
2840 -- raise log message;
2841 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2842 fnd_msg_pub.Add;
2843
2844 WHEN OTHERS THEN
2845
2846 IF g_fnd_debug = 'Y' AND
2847 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2848 THEN
2849 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2850 , G_MODULE_PREFIX || l_api_name || '.execption'
2851 , NULL);
2852 END IF;
2853 -- **** for debug information in readonly UT environment.--- begin ****
2854 JMF_SHIKYU_RPT_UTIL.debug_output
2855 (
2856 p_output_to => 'FND_LOG.STRING'
2857 ,p_api_name => G_MODULE_PREFIX || l_api_name
2858 ,p_message => 'WHEN OTHERS THEN'
2859 );
2860 -- **** for debug information in readonly UT environment.--- end ****
2861
2862 END set_rcv_transaction_unconsume;
2863
2864 --========================================================================
2865 -- PROCEDURE : validate_cfr_mid_temp PUBLIC ,validate the data in mid temp table, do UOM and Currency conversion
2866 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
2867 -- COMMENT : this include UOM and Currency conversion and data check
2868 -- PRE-COND :
2869 -- EXCEPTIONS:
2870 --========================================================================
2871 PROCEDURE validate_cfr_mid_temp(p_rcv_row_type IN NUMBER)
2872 IS
2873 l_api_name CONSTANT VARCHAR2(30) := 'validate_cfr_mid_temp';
2874
2875 BEGIN
2876 -- **** for debug information in readonly UT environment.--- begin ****
2877 JMF_SHIKYU_RPT_UTIL.debug_output
2878 (
2879 p_output_to => 'FND_LOG.STRING'
2880 ,p_api_name => G_MODULE_PREFIX || l_api_name
2881 ,p_message => 'begin:' ||
2882 ',p_rcv_row_type:' || p_rcv_row_type
2883 );
2884 -- **** for debug information in readonly UT environment.--- end ****
2885
2886 IF g_fnd_debug = 'Y' AND
2887 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2888 THEN
2889 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2890 , g_module_prefix || l_api_name || '.begin'
2891 , 'p_rcv_row_type:' || p_rcv_row_type);
2892 END IF;
2893
2894 -- fill the uom, primary_uom column for CFR_TMP_RCV_ROW rows
2895 UPDATE jmf_shikyu_cfr_mid_temp jscmt
2896 SET jscmt.uom = (SELECT rt.unit_of_measure
2897 FROM rcv_transactions rt
2898 WHERE jscmt.row_type = CFR_TMP_RCV_ROW
2899 AND rt.transaction_id = jscmt.shikyu_id)
2900 ,jscmt.primary_uom = (SELECT rt.primary_unit_of_measure
2901 FROM rcv_transactions rt
2902 WHERE jscmt.row_type = CFR_TMP_RCV_ROW
2903 AND rt.transaction_id = jscmt.shikyu_id)
2904 WHERE jscmt.row_type = CFR_TMP_RCV_ROW;
2905 -- update the quantity column for CFR_TMP_RCV_ROW rows
2906 -- quantity of UOM =
2907 UPDATE jmf_shikyu_cfr_mid_temp
2908 SET quantity = (NVL(primary_unallocated_quantity
2909 ,0) + NVL(primary_unconsumed_quantity
2910 ,0)) *
2911 JMF_SHIKYU_RPT_UTIL.po_uom_convert_p(JMF_SHIKYU_RPT_UTIL.uom_to_code(primary_uom)
2912 ,JMF_SHIKYU_RPT_UTIL.uom_to_code(uom)
2913 ,item_id)
2914 WHERE row_type = CFR_TMP_RCV_ROW;
2915 COMMIT; -- for debug on UT ?????
2916 rpt_debug_show_mid_data(
2917 p_row_type => CFR_TMP_RCV_ROW
2918 ,p_output_to => 'FND_LOG.STRING'
2919 );
2920 IF g_fnd_debug = 'Y' AND
2921 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2922 THEN
2923 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2924 , g_module_prefix || l_api_name || '.end'
2925 , NULL);
2926 END IF;
2927 EXCEPTION
2928 WHEN NO_DATA_FOUND THEN
2929 -- raise log message;
2930 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
2931 fnd_msg_pub.Add;
2932
2933 WHEN OTHERS THEN
2934 IF g_fnd_debug = 'Y' AND
2935 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2936 THEN
2937 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
2938 , G_MODULE_PREFIX || l_api_name || '.execption'
2939 , NULL);
2940 END IF;
2941 -- **** for debug information in readonly UT environment.--- begin ****
2942 JMF_SHIKYU_RPT_UTIL.debug_output
2943 (
2944 p_output_to => 'FND_LOG.STRING'
2945 ,p_api_name => G_MODULE_PREFIX || l_api_name
2946 ,p_message => 'WHEN OTHERS THEN'
2947 );
2948 -- **** for debug information in readonly UT environment.--- end ****
2949
2950 END validate_cfr_mid_temp;
2951
2952 --========================================================================
2953 -- PROCEDURE : add_data_to_cfr_temp PUBLIC ,process the mid_temp data and add to temp talbe for report builder
2954 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
2955 -- COMMENT : and data merge to temp talbe for report builder
2956 -- PRE-COND :
2957 -- EXCEPTIONS:
2958 --========================================================================
2959 PROCEDURE add_data_to_cfr_temp
2960 (
2961 p_rcv_row_type IN NUMBER
2962 ,p_rpt_mode IN VARCHAR2
2963 ,p_days_received IN NUMBER
2964 ,p_currency_conversion_type IN VARCHAR2
2965 ,p_currency_conversion_date IN DATE
2966 ,p_functional_currency IN VARCHAR2
2967 -- Amy added to fix bug 5583680 start
2968 ,p_supplier_name_from IN VARCHAR2
2969 ,p_supplier_site_code_from IN VARCHAR2
2970 ,p_supplier_name_to IN VARCHAR2
2971 ,p_supplier_site_code_to IN VARCHAR2
2972 ,p_oem_inv_org_name_from IN VARCHAR2
2973 ,p_oem_inv_org_name_to IN VARCHAR2
2974 -- Amy added to fix bug 5583680 end
2975 ) IS
2976 l_api_name CONSTANT VARCHAR2(30) := 'add_data_to_cfr_temp';
2977 l_p_currency_conversion_date DATE;
2978 BEGIN
2979 -- **** for debug information in readonly UT environment.--- begin ****
2980 JMF_SHIKYU_RPT_UTIL.debug_output
2981 (
2982 p_output_to => 'FND_LOG.STRING'
2983 ,p_api_name => G_MODULE_PREFIX || l_api_name
2984 ,p_message => 'begin:' ||
2985 ',p_rcv_row_type:' || p_rcv_row_type ||
2986 ',p_rpt_mode:' || p_rpt_mode ||
2987 ',p_days_received:' || p_days_received ||
2988 ',p_currency_conversion_type:' || p_currency_conversion_type ||
2989 ',p_currency_conversion_date:' || p_currency_conversion_date ||
2990 ',p_functional_currency:' || p_functional_currency
2991 );
2992 -- **** for debug information in readonly UT environment.--- end ****
2993
2994 IF g_fnd_debug = 'Y' AND
2995 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
2996 THEN
2997 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
2998 , g_module_prefix || l_api_name || '.begin'
2999 , NULL);
3000 END IF;
3001
3002 IF p_currency_conversion_date IS NULL
3003 THEN
3004 l_p_currency_conversion_date := SYSDATE;
3005 ELSE
3006 l_p_currency_conversion_date := p_currency_conversion_date;
3007 END IF;
3008 -- **** for debug information in readonly UT environment.--- begin ****
3009 JMF_SHIKYU_RPT_UTIL.debug_output
3010 (
3011 p_output_to => 'FND_LOG.STRING'
3012 ,p_api_name => G_MODULE_PREFIX || l_api_name
3013 ,p_message => 'begin:' ||
3014 ',l_p_currency_conversion_date:' || l_p_currency_conversion_date
3015 );
3016 -- **** for debug information in readonly UT environment.--- end ****
3017
3018
3019 --step1: get crude data: add the data for standard po, using po_lines_all
3020 rpt_get_crude_data(p_rpt_mode => p_rpt_mode
3021 ,p_currency_conversion_type => p_currency_conversion_type
3022 ,p_currency_conversion_date => l_p_currency_conversion_date
3023 ,p_functional_currency => p_functional_currency);
3024
3025 -- get the summary estinated qty for SHIKYU_component region in the report
3026 rpt_get_Comp_Estimated_data(p_rpt_mode => p_rpt_mode);
3027
3028 -- get the distinct SubPO info for SHIKYU_component accordingly in the report
3029 rpt_get_SubPO_data(p_rpt_mode => p_rpt_mode
3030 --Amy add for fixing bug 5391412 start
3031 ,p_ou_id => g_ou_id
3032 ,p_days_received => p_days_received);
3033 --Amy add for fixing bug 5391412 end
3034
3035 -- get the data for Un-received Replenishments
3036 -- Amy updated to fix bug 5583680 start
3037 -- rpt_get_UnReceived_data(p_rpt_mode => p_rpt_mode);
3038 rpt_get_UnReceived_data(p_rpt_mode => p_rpt_mode
3039 ,p_supplier_name_from => p_supplier_name_from
3040 ,p_supplier_site_code_from => p_supplier_site_code_from
3041 ,p_supplier_name_to => p_supplier_name_to
3042 ,p_supplier_site_code_to => p_supplier_site_code_to
3043 ,p_oem_inv_org_name_from => p_oem_inv_org_name_from
3044 ,p_oem_inv_org_name_to => p_oem_inv_org_name_to);
3045 -- Amy updated to fix bug 5583680 end
3046
3047 -- get the data for Un-received Replenishments
3048 rpt_get_Received_data( p_rpt_mode => p_rpt_mode
3049 ,p_days_received => p_days_received);
3050
3051 -- get data for internal report
3052 rpt_get_Int_data(p_rpt_mode => p_rpt_mode);
3053
3054 IF g_fnd_debug = 'Y' AND
3055 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3056 THEN
3057 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
3058 , g_module_prefix || l_api_name || '.end'
3059 , NULL);
3060 END IF;
3061 EXCEPTION
3062
3063 WHEN NO_DATA_FOUND THEN
3064 -- raise log message;
3065 FND_MESSAGE.set_name('JMF', 'JMF_SHK_RPT_NO_DATA');
3066 fnd_msg_pub.Add;
3067
3068 WHEN OTHERS THEN
3069 IF g_fnd_debug = 'Y' AND
3070 FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3071 THEN
3072 FND_LOG.STRING( FND_LOG.LEVEL_UNEXPECTED
3073 , G_MODULE_PREFIX || l_api_name || '.execption'
3074 , SQLERRM);
3075 END IF;
3076 -- **** for debug information in readonly UT environment.--- begin ****
3077 JMF_SHIKYU_RPT_UTIL.debug_output
3078 (
3079 p_output_to => 'FND_LOG.STRING'
3080 ,p_api_name => G_MODULE_PREFIX || l_api_name
3081 ,p_message => 'WHEN OTHERS THEN:' || SQLERRM
3082 );
3083 -- **** for debug information in readonly UT environment.--- end ****
3084
3085 END add_data_to_cfr_temp;
3086
3087 --========================================================================
3088 -- PROCEDURE : rpt_get_crude_data PUBLIC ,
3089 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
3090 -- COMMENT : get the crude data into jmf_shikyu_cfr_rpt_temp with
3091 -- RPT_DATA_TYPE = CFR_CRUDE_DATA
3092 -- PRE-COND :
3093 -- EXCEPTIONS:
3094 --========================================================================
3095 PROCEDURE rpt_get_crude_data(
3096 p_rpt_mode IN VARCHAR2
3097 ,p_currency_conversion_type IN VARCHAR2
3098 ,p_currency_conversion_date IN DATE
3099 ,p_functional_currency IN VARCHAR2
3100 ) IS
3101 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_data';
3102
3103 BEGIN
3104 -- **** for debug information in readonly UT environment.--- begin ****
3105 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3106 ,p_api_name => G_MODULE_PREFIX || l_api_name
3107 ,p_message => 'begin:');
3108 -- **** for debug information in readonly UT environment.--- end ****
3109
3110 IF g_fnd_debug = 'Y'
3111 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3112 THEN
3113 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
3114 ,g_module_prefix || l_api_name
3115 ,'.begin');
3116 END IF;
3117
3118 -- insert the onhand items that with SubContracting Order.
3119 INSERT INTO jmf_shikyu_cfr_rpt_temp
3120 (rpt_mode
3121 ,TRANSACTION_ID
3122 ,RPT_DATA_TYPE
3123 ,oem_inv_org_id
3124 ,oem_inv_org_code
3125 ,supplier_id
3126 ,supplier_name
3127 ,site_id
3128 ,site_code
3129 ,site_address
3130 ,contact_id
3131 ,contact_name
3132 ,tp_inv_org_id
3133 ,tp_inv_org_code
3134 ,item_id
3135 ,item_number
3136 ,item_description
3137 ,currency_code
3138 ,functional_currency
3139 ,shikyu_price
3140 ,item_cost --the cost based on UOM after conversion from Pri_Uom
3141 ,value1 --the item qty in Pri Uom
3142 ,value2 --the item price in Pri UOM and Pri Currency
3143 ,value3 --the item cost in Pri UOM and Pri Currency, from cst_item_costs table
3144 ,project_id
3145 ,project_num
3146 ,task_id
3147 ,task_num
3148 ,uom
3149 ,ESTIMATED_QTY
3150 ,primary_uom
3151 ,REP_SO_HEADER_ID
3152 ,REP_SO_NUMBER
3153 ,REP_SO_VERSION_NUMBER
3154 ,REP_SO_LINE_ID
3155 ,REP_SO_LINE
3156 ,SHIPPED_DATE
3157 ,EXPECTED_RCV_DATE --the Rep PO need by date
3158 ,REP_PO_HEADER_ID
3159 ,REP_PO_NUMBER
3160 ,REP_PO_REVISION_NUM
3161 ,REP_PO_RELEASE_ID
3162 ,REP_PO_RELEASE_NUM
3163 ,REP_PO_LINE_ID
3164 ,REP_PO_LINE
3165 ,REP_PO_LINE_LOCATION_ID
3166 ,REP_PO_SHIPMENT
3167 ,REP_PO_DISTRIBUTION_ID
3168 ,SUBPO_HEADER_ID
3169 ,SUBPO_NUMBER
3170 ,SUBPO_LINE_ID
3171 ,SUBPO_LINE_NUM
3172 ,SUBPO_RELEASE_ID
3173 ,SUBPO_RELEASE_NUM
3174 ,SUBPO_SHIPMENT_ID
3175 ,SUBPO_SHIPMENT_NUM)
3176 SELECT p_rpt_mode rpt_mode
3177 ,cfr_mid.shikyu_id TRANSACTION_ID
3178 ,CFR_CRUDE_DATA RPT_DATA_TYPE
3179 ,cfr_mid.oem_inv_org_id oem_inv_org_id
3180 ,mp_oem.organization_code oem_org_code
3181 ,cfr_mid.supplier_id supplier_id
3182 ,pv.vendor_name supplier_name
3183 ,cfr_mid.site_id site_id
3184 ,pvs.vendor_site_code site_code
3185 ,pvs.address_line1 || ',' || pvs.address_line2 || ',' ||
3186 pvs.address_line3 site_address
3187 ,ph.vendor_contact_id contact_id
3188 ,pvc.prefix || ' ' || pvc.first_name || ',' || pvc.middle_name || ',' ||
3189 pvc.middle_name || ',' || pvc.last_name contact_name
3190 ,cfr_mid.tp_inv_org_id tp_inv_org_id
3191 ,mp_tp.organization_code tp_inv_org_code
3192 ,cfr_mid.item_id item_id
3193 ,JMF_SHIKYU_RPT_UTIL.get_item_number(cfr_mid.tp_inv_org_id
3194 ,cfr_mid.item_id) item_number
3195 ,item_v.description item_description
3196 ,ooha.transactional_curr_code currency_code --or jmf_shikyu_components.Currency ,not ph.currency_code
3197 ,p_functional_currency functional_currency
3198 ,oola.unit_selling_price po_unit_price --not pl.unit_price
3199 ,JMF_SHIKYU_RPT_UTIL.convert_amount(ooha.transactional_curr_code
3200 ,p_functional_currency
3201 --Amy update for fixing currency conversing issue start
3202 --when paramter p_currency_conversion_date and p_currency_conversion_type are not specified,
3203 -- use sysdate and conversion_type in so as default value.
3204 --,p_currency_conversion_date
3205 --,p_currency_conversion_type
3206 ,decode(p_currency_conversion_date,null,sysdate,p_currency_conversion_date)
3207 ,decode(p_currency_conversion_type,null,ooha.CONVERSION_TYPE_CODE,p_currency_conversion_type)
3208 --Amy update for fixing currency conversing issue end
3209 ,NVL(cic.item_cost
3210 ,0) *
3211 PO_UOM_S.po_uom_convert_p(cfr_mid.primary_uom
3212 ,cfr_mid.uom
3213 ,cfr_mid.item_id)) item_cost --the cost based on UOM after conversion from Pri_Uom
3214 ,(cfr_mid.quantity *
3215 PO_UOM_S.po_uom_convert_p(cfr_mid.uom
3216 ,cfr_mid.primary_uom
3217 ,cfr_mid.item_id)) value1 --item qty in Primary
3218 ,JMF_SHIKYU_RPT_UTIL.convert_amount(ooha.transactional_curr_code
3219 ,p_functional_currency
3220 --Amy update for fixing currency conversing issue start
3221 --when paramter p_currency_conversion_date and p_currency_conversion_type are not specified,
3222 -- use sysdate and conversion_type in so as default value.
3223 --,p_currency_conversion_date
3224 --,p_currency_conversion_type
3225 ,decode(p_currency_conversion_date,null,sysdate,p_currency_conversion_date)
3226 ,decode(p_currency_conversion_type,null,ooha.CONVERSION_TYPE_CODE,p_currency_conversion_type)
3227 --Amy update for fixing currency conversing issue end
3228 ,oola.unit_selling_price *
3229 PO_UOM_S.po_uom_convert_p(cfr_mid.uom
3230 ,cfr_mid.primary_uom
3231 ,cfr_mid.item_id)) value2 --the item price in Pri UOM and Pri Currency
3232 ,NVL(cic.item_cost
3233 ,0) value3 --Standard_Item_Cost in Pri UOM and Pri Currency
3234 --updated to fix project_id related issue start
3235 --,rcv.project_id project_id
3236 ,sub.project_id project_id
3237 --updated to fix project_id related issue start
3238 --updated to fix project_number related issue start
3239 --,prj.segment1 project_number
3240 ,NVL((SELECT DISTINCT segment1 AS project_number
3241 FROM pa_projects_all
3242 WHERE pa_projects_all.project_id(+) = sub.project_id),
3243 (SELECT DISTINCT project_number
3244 FROM pjm_seiban_numbers
3245 WHERE pjm_seiban_numbers.project_id(+) = sub.project_id)) project_number
3246 --updated to fix project_number related issue end
3247 --updated to fix project_id related issue start
3248 --,rcv.task_id task_id
3249 ,sub.task_id task_id
3250 --updated to fix project_id related issue start
3251 ,task.task_number task_number
3252 ,cfr_mid.uom --should jmf_shikyu_components.uom,need rcv.unit_of_measure to conversion?
3253 ,cfr_mid.quantity --the SHIKYU component quantity find in rcv for unallocated + unconsumed
3254 ,cfr_mid.primary_uom --rcv.primary_unit_of_measure
3255 ,oola.header_id RepSO_header_id
3256 ,ooha.order_number REP_SO_NUMBER
3257 ,ooha.version_number RepSO_Version_number
3258 ,oola.line_id RepSO_line_id
3259 ,oola.line_number REP_SO_LINE
3260 ,oola.actual_shipment_date SHIPPED_DATE
3261 ,poloc.need_by_date --,EXPECTED_RCV_DATE
3262 ,rcv.po_header_id RepPO_header_id
3263 ,ph.segment1 REP_PO_NUMBER
3264 ,rcv.po_revision_num RepPO_Revision_num
3265 ,rcv.po_release_id RepPO_Release_id
3266 ,pra.release_num REP_PO_RELEASE
3267 ,rcv.po_line_id RepPO_Line_id
3268 ,pl.line_num REP_PO_LINE
3269 ,rcv.po_line_location_id RepPO_line_location_id
3270 ,poloc.shipment_num REP_PO_SHIPMENT
3271 ,rcv.po_distribution_id RepPO_distribution_id
3272 ,pha_s.po_header_id SubPO_header_id
3273 ,pha_s.segment1 SubPO_Number
3274 ,pla_s.po_line_id SubPO_line_id
3275 ,pla_s.line_num SubPO_Line_num
3276 ,pra_s.po_release_id SubPO_release_id
3277 ,pra_s.release_num SubPO_release_Num
3278 ,plla_s.line_location_id SubPO_shipment_id
3279 ,plla_s.shipment_num SubPO_shipment_num
3280 FROM jmf_shikyu_cfr_mid_temp cfr_mid
3281 ,jmf_subcontract_orders sub
3282 ,po_line_locations_all poloc
3283 ,rcv_transactions rcv
3284 ,mtl_parameters mp_oem
3285 ,mtl_parameters mp_tp
3286 ,po_vendors pv
3287 ,po_vendor_sites_all pvs
3288 ,po_headers_all ph
3289 ,po_vendor_contacts pvc
3290 ,mtl_system_items_vl item_v
3291 ,po_lines_all pl
3292 ,pa_projects_all prj
3293 ,pa_tasks task
3294 ,po_releases_all pra
3295 ,jmf_shikyu_replenishments jsr
3296 ,oe_order_lines_all oola
3297 ,oe_order_headers_all ooha
3298 ,jmf_shikyu_allocations jsa
3299 ,po_line_locations_all plla_s
3300 ,po_headers_all pha_s
3301 ,po_lines_all pla_s
3302 ,po_releases_all pra_s
3303 ,cst_item_costs cic
3304 WHERE cfr_mid.row_type = CFR_TMP_RCV_ROW
3305 AND cfr_mid.oem_inv_org_id = mp_oem.organization_id
3306 AND cfr_mid.tp_inv_org_id = mp_tp.organization_id
3307 AND cfr_mid.supplier_id = pv.vendor_id(+)
3308 AND cfr_mid.site_id = pvs.vendor_site_id(+)
3309 AND cfr_mid.shikyu_id = rcv.transaction_id
3310 AND rcv.transaction_type = 'RECEIVE'
3311 AND rcv.po_header_id = ph.po_header_id
3312 AND ph.vendor_contact_id = pvc.vendor_contact_id(+)
3313 AND cfr_mid.tp_inv_org_id = item_v.organization_id
3314 AND cfr_mid.item_id = item_v.inventory_item_id
3315 AND rcv.po_line_location_id = poloc.line_location_id
3316 AND pl.po_line_id = poloc.po_line_id
3317 AND rcv.project_id = prj.project_id(+)
3318 AND rcv.task_id = task.task_id(+)
3319 AND poloc.po_release_id = pra.po_release_id(+)
3320 AND poloc.line_location_id = jsr.replenishment_po_shipment_id
3321 AND jsr.replenishment_so_line_id = oola.line_id
3322 AND oola.header_id = ooha.header_id
3323 --Updated to fix bug 5509464 start
3324 /* AND jsa.replenishment_so_line_id = jsr.replenishment_so_line_id
3325 AND jsa.subcontract_po_shipment_id = plla_s.line_location_id
3326 AND sub.subcontract_po_shipment_id = plla_s.line_location_id
3327 AND plla_s.po_header_id = pha_s.po_header_id
3328 AND plla_s.po_line_id = pla_s.po_line_id*/
3329 AND jsa.replenishment_so_line_id(+) = jsr.replenishment_so_line_id
3330 AND jsa.subcontract_po_shipment_id = plla_s.line_location_id(+)
3331 AND plla_s.line_location_id = sub.subcontract_po_shipment_id(+)
3332 AND plla_s.po_header_id = pha_s.po_header_id(+)
3333 AND plla_s.po_line_id = pla_s.po_line_id(+)
3334 --Updated to fix bug 5509464 end
3335 AND plla_s.po_release_id = pra_s.po_release_id(+)
3336 AND oola.inventory_item_id = cic.inventory_item_id(+)
3337 AND oola.ship_from_org_id = cic.organization_id(+)
3338 /* Bug 6630087 - Start */
3339 /*Standard Cost check no longer required
3340 as Buy/Sell Subcontracting is supported for non-standard cost
3341 OEM organizations as well.
3342 Note : The confirmation report will display data for both
3343 Chargeable Subcontracting and Buy/Sell enabled OEM orgs depending
3344 on the parameters chosen in the report */
3345 -- AND cic.cost_type_id = 1; --frozen cost/ standard cost
3346 /* Bug 6630087 - End */
3347 --Bugfix 14267758: The sql displays records for all cost types if we do
3348 --not specify a condition on cost_type_id.
3349 AND cic.cost_type_id = mp_oem.primary_cost_method;
3350
3351 -- should insert the onhand items that without SubContracting Order.
3352 --or it will lose the onhand items
3353 /*
3354 TODO: owner="sunwa" category="Fix" priority="1 - High" created="2006-1-26"
3355 text="should insert the onhand items that without SubContracting Order."
3356 */
3357
3358 COMMIT; -- for debug on UT ?????
3359 IF g_fnd_debug = 'Y' AND
3360 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3361 THEN
3362 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
3363 , g_module_prefix || l_api_name || '.end'
3364 , NULL);
3365 END IF;
3366 EXCEPTION
3367 WHEN NO_DATA_FOUND THEN
3368 -- raise log message;
3369 NULL;
3370
3371 WHEN OTHERS THEN
3372 IF g_fnd_debug = 'Y'
3373 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3374 THEN
3375 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
3376 ,G_MODULE_PREFIX || l_api_name || '.execption'
3377 ,NULL);
3378 END IF;
3379 -- **** for debug information in readonly UT environment.--- begin ****
3380 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3381 ,p_api_name => G_MODULE_PREFIX || l_api_name
3382 ,p_message => 'WHEN OTHERS THEN');
3383 -- **** for debug information in readonly UT environment.--- end ****
3384
3385 END rpt_get_crude_data;
3386
3387 --========================================================================
3388 -- PROCEDURE : rpt_get_Comp_Estimated_data PUBLIC ,
3389 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
3390 -- COMMENT : get the Component Estimated data into jmf_shikyu_cfr_rpt_temp with
3391 -- RPT_DATA_TYPE = CFR_EXT_COMPONENT
3392 -- PRE-COND :
3393 -- EXCEPTIONS:
3394 --========================================================================
3395 PROCEDURE rpt_get_Comp_Estimated_data(p_rpt_mode IN VARCHAR2) IS
3396 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_Comp_Estimated_data';
3397
3398 BEGIN
3399 -- **** for debug information in readonly UT environment.--- begin ****
3400 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3401 ,p_api_name => G_MODULE_PREFIX || l_api_name
3402 ,p_message => 'begin:');
3403 -- **** for debug information in readonly UT environment.--- end ****
3404
3405 IF g_fnd_debug = 'Y'
3406 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3407 THEN
3408 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
3409 ,g_module_prefix || l_api_name
3410 ,'.begin');
3411 END IF;
3412
3413 INSERT INTO JMF_SHIKYU_CFR_RPT_TEMP
3414 (rpt_mode
3415 ,RPT_DATA_TYPE
3416 ,oem_inv_org_id
3417 ,supplier_id
3418 ,site_id
3419 ,contact_id
3420 ,tp_inv_org_id
3421 ,item_id
3422 ,shikyu_price
3423 ,currency_code
3424 ,uom
3425 ,project_id
3426 --added to fix project_number related issue start
3427 ,project_num
3428 --added to fix project_number related issue end
3429 ,task_id
3430 --added to fix project_number related issue start
3431 ,task_num
3432 --added to fix project_number related issue end
3433 ,primary_uom
3434 ,ESTIMATED_QTY)
3435 --value SUM(temp.estimated_qty) are supposed to onhand_quantity at item/price level,but got incorrect quantity.
3436 --got incorrect onhand quantity due to use inapposite group.
3437 --updated select statement to add transaction_id into group by to get correct onhand quantity.
3438 /*
3439 TODO: owner="amy" category="Fix" priority="2 - Severe Loss of Service" created="2006-6-22"
3440 text="--updated for fix bug 5231233 Begin"
3441 */
3442 /* SELECT p_rpt_mode RPT_MODE --temp.rpt_mode
3443 ,CFR_EXT_COMPONENT RPT_DATA_TYPE
3444 ,temp.oem_inv_org_id shikyu_oem_inv_org_id
3445 ,temp.supplier_id shikyu_supplier_id
3446 ,temp.site_id shikyu_site_id
3447 ,temp.contact_id
3448 ,temp.tp_inv_org_id shikyu_tp_inv_org_id
3449 ,temp.item_id shikyu_item_id
3450 ,temp.shikyu_price shikyu_price
3451 ,temp.currency_code shikyu_currency
3452 ,temp.uom shikyu_uom
3453 ,temp.project_id
3454 ,temp.task_id
3455 ,temp.primary_uom shikyu_primary_uom
3456 ,SUM(temp.estimated_qty) shikyu_estimated_qty
3457 FROM JMF_SHIKYU_CFR_RPT_TEMP temp
3458 WHERE temp.rpt_DATA_TYPE = CFR_CRUDE_DATA
3459 GROUP BY temp.rpt_mode
3460 ,temp.oem_inv_org_id
3461 ,temp.supplier_id
3462 ,temp.site_id
3463 ,temp.contact_id
3464 ,temp.tp_inv_org_id
3465 ,temp.item_id
3466 ,temp.shikyu_price
3467 ,temp.currency_code
3468 ,temp.uom
3469 ,temp.project_id
3470 ,temp.task_id
3471 ,temp.primary_uom;
3472 */
3473 SELECT p_rpt_mode RPT_MODE --temp.rpt_mode
3474 ,CFR_EXT_COMPONENT RPT_DATA_TYPE
3475 ,temp.oem_inv_org_id shikyu_oem_inv_org_id
3476 ,temp.supplier_id shikyu_supplier_id
3477 ,temp.site_id shikyu_site_id
3478 ,temp.contact_id
3479 ,temp.tp_inv_org_id shikyu_tp_inv_org_id
3480 ,temp.item_id shikyu_item_id
3481 ,temp.shikyu_price shikyu_price
3482 ,temp.currency_code shikyu_currency
3483 ,temp.uom shikyu_uom
3484 ,temp.project_id
3485 --added to fix project_number related issue start
3486 ,temp.project_num
3487 --added to fix project_number related issue end
3488 ,temp.task_id
3489 --added to fix project_number related issue start
3490 ,temp.task_num
3491 --added to fix project_number related issue end
3492 ,temp.primary_uom shikyu_primary_uom
3493 ,SUM(temp.estimated_qty) shikyu_estimated_qty
3494 FROM (SELECT rpt_temp.rpt_mode rpt_mode
3495 ,rpt_temp.oem_inv_org_id oem_inv_org_id
3496 ,rpt_temp.supplier_id supplier_id
3497 ,rpt_temp.site_id site_id
3498 ,rpt_temp.contact_id contact_id
3499 ,rpt_temp.tp_inv_org_id tp_inv_org_id
3500 ,rpt_temp.item_id item_id
3501 ,rpt_temp.shikyu_price shikyu_price
3502 ,rpt_temp.currency_code currency_code
3503 ,rpt_temp.uom uom
3504 ,rpt_temp.project_id project_id
3505 --added to fix project_number related issue start
3506 ,rpt_temp.project_num project_num
3507 --added to fix project_number related issue end
3508 ,rpt_temp.task_id task_id
3509 --added to fix project_number related issue start
3510 ,rpt_temp.task_num task_num
3511 --added to fix project_number related issue end
3512 ,rpt_temp.primary_uom primary_uom
3513 ,rpt_temp.estimated_qty
3514 ,rpt_temp.transaction_id transaction_id
3515 FROM JMF_SHIKYU_CFR_RPT_TEMP rpt_temp
3516 WHERE rpt_temp.rpt_DATA_TYPE = CFR_CRUDE_DATA
3517 GROUP BY rpt_temp.rpt_mode
3518 ,rpt_temp.oem_inv_org_id
3519 ,rpt_temp.supplier_id
3520 ,rpt_temp.site_id
3521 ,rpt_temp.contact_id
3522 ,rpt_temp.tp_inv_org_id
3523 ,rpt_temp.item_id
3524 ,rpt_temp.shikyu_price
3525 ,rpt_temp.currency_code
3526 ,rpt_temp.uom
3527 ,rpt_temp.project_id
3528 --added to fix project_number related issue start
3529 ,rpt_temp.project_num
3530 --added to fix project_number related issue end
3531 ,rpt_temp.task_id
3532 --added to fix project_number related issue start
3533 ,rpt_temp.task_num
3534 --added to fix project_number related issue end
3535 ,rpt_temp.primary_uom
3536 ,rpt_temp.estimated_qty
3537 ,rpt_temp.transaction_id) temp
3538 GROUP BY temp.rpt_mode
3539 ,temp.oem_inv_org_id
3540 ,temp.supplier_id
3541 ,temp.site_id
3542 ,temp.contact_id
3543 ,temp.tp_inv_org_id
3544 ,temp.item_id
3545 ,temp.shikyu_price
3546 ,temp.currency_code
3547 ,temp.uom
3548 ,temp.project_id
3549 --added to fix project_number related issue start
3550 ,temp.project_num
3551 --added to fix project_number related issue end
3552 ,temp.task_id
3553 --added to fix project_number related issue start
3554 ,temp.task_num
3555 --added to fix project_number related issue end
3556 ,temp.primary_uom;
3557 --updated for fix bug #5231233 End
3558
3559 --seems the SUM(temp.estimated_qty) is not the onhand quantity.
3560 --add for fix bug 4997302 Begin
3561 --update the onhand quantity to the ESTIMATED_QTY column, assume the same price and cost, need track
3562 /*
3563 TODO: owner="sunwa" category="Fix" priority="1 - High" created="2006-1-26"
3564 text="--add for fix bug 4997302 Begin"
3565 */
3566 -- As the SUM(temp.estimated_qty) is correct by fixing bug #5231233,sql statement below should be updated
3567 /*
3568 TODO: owner="amy" category="Fix" priority="2 - Severe Loss of Service" created="2006-6-22"
3569 text="--updated for fix bug 5231233 Begin"
3570 */
3571
3572 -- Deleted Update to fix bug 5665445 for incorrect onhand Qty in Secondary UOM case
3573 /* UPDATE JMF_SHIKYU_CFR_RPT_TEMP jscrt
3574 SET jscrt.estimated_qty = PO_UOM_S.po_uom_convert_p(jscrt.primary_uom
3575 ,jscrt.uom
3576 ,jscrt.item_id) *jscrt.ESTIMATED_QTY,
3577 (SELECT jscmt.primary_unconsumed_quantity
3578 FROM jmf_shikyu_cfr_mid_temp jscmt
3579 WHERE jscmt.row_type = CFR_TMP_ONHAND_ROW --10
3580 AND jscmt.tp_inv_org_id =
3581 jscrt.tp_inv_org_id
3582 AND jscmt.item_id = jscrt.item_id),
3583 jscrt.value1 = (SELECT jscmt.primary_unconsumed_quantity
3584 FROM jmf_shikyu_cfr_mid_temp jscmt
3585 WHERE jscmt.row_type = CFR_TMP_ONHAND_ROW --10
3586 AND jscmt.tp_inv_org_id =
3587 jscrt.tp_inv_org_id
3588 AND jscmt.item_id = jscrt.item_id)
3589 jscrt.value1 = jscrt.ESTIMATED_QTY
3590 --updated for fix bug 5231233 End
3591 WHERE jscrt.rpt_data_type = CFR_EXT_COMPONENT; --should not CFR_INT_COMPONENT;
3592 --add for fix bug 4997302 End
3593 */
3594
3595 -- update the SHIKYU_components item number, desc, type info
3596 UPDATE JMF_SHIKYU_CFR_RPT_TEMP temp
3597 SET temp.item_number = (SELECT msibk.concatenated_segments
3598 FROM MTL_SYSTEM_ITEMS_B_KFV msibk
3599 WHERE temp.tp_inv_org_id =
3600 msibk.organization_id
3601 AND temp.item_id =
3602 msibk.inventory_item_id)
3603 ,temp.item_description = (SELECT msibk.description
3604 FROM MTL_SYSTEM_ITEMS_B_KFV msibk
3605 WHERE temp.tp_inv_org_id =
3606 msibk.organization_id
3607 AND temp.item_id =
3608 msibk.inventory_item_id)
3609 ,temp.replenishment_type = (SELECT flv.meaning
3610 FROM fnd_lookup_values flv
3611 ,MTL_SYSTEM_ITEMS_B_KFV msibk
3612 WHERE flv.LANGUAGE = USERENV('LANG')
3613 AND flv.lookup_type =
3614 'JMF_SHK_ITEM_REPLEN_TYPE'
3615 AND msibk.subcontracting_component =
3616 flv.lookup_code
3617 AND temp.tp_inv_org_id =
3618 msibk.organization_id
3619 AND temp.item_id =
3620 msibk.inventory_item_id)
3621 WHERE temp.rpt_DATA_TYPE = CFR_EXT_COMPONENT;
3622 COMMIT; -- for debug on UT ?????
3623 IF g_fnd_debug = 'Y' AND
3624 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3625 THEN
3626 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
3627 , g_module_prefix || l_api_name || '.end'
3628 , NULL);
3629 END IF;
3630 EXCEPTION
3631 WHEN NO_DATA_FOUND THEN
3632 -- raise log message;
3633 NULL;
3634
3635 WHEN OTHERS THEN
3636 IF g_fnd_debug = 'Y'
3637 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3638 THEN
3639 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
3640 ,G_MODULE_PREFIX || l_api_name || '.execption'
3641 ,NULL);
3642 END IF;
3643 -- **** for debug information in readonly UT environment.--- begin ****
3644 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3645 ,p_api_name => G_MODULE_PREFIX || l_api_name
3646 ,p_message => 'WHEN OTHERS THEN');
3647 -- **** for debug information in readonly UT environment.--- end ****
3648
3649 END rpt_get_Comp_Estimated_data;
3650
3651 --========================================================================
3652 -- PROCEDURE : rpt_get_SubPO_data PUBLIC ,
3653 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
3654 -- p_ou_id ou_id to identify period infor
3655 -- p_days_received user entered parameter to determine period
3656 -- COMMENT : get the SubPO info for the component data into jmf_shikyu_cfr_rpt_temp with
3657 -- RPT_DATA_TYPE = CFR_EXT_SUBCONTRACT_PO
3658 -- PRE-COND :
3659 -- EXCEPTIONS:
3660 --========================================================================
3661 PROCEDURE rpt_get_SubPO_data(p_rpt_mode IN VARCHAR2,p_ou_id IN NUMBER,p_days_received IN NUMBER) IS
3662 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_SubPO_data';
3663
3664 BEGIN
3665 -- **** for debug information in readonly UT environment.--- begin ****
3666 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3667 ,p_api_name => G_MODULE_PREFIX || l_api_name
3668 ,p_message => 'begin:');
3669 -- **** for debug information in readonly UT environment.--- end ****
3670
3671 IF g_fnd_debug = 'Y'
3672 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3673 THEN
3674 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
3675 ,g_module_prefix || l_api_name
3676 ,'.begin');
3677 END IF;
3678
3679 INSERT INTO JMF_SHIKYU_CFR_RPT_TEMP
3680 (RPT_MODE
3681 ,RPT_DATA_TYPE
3682 ,oem_inv_org_id
3683 ,supplier_id
3684 ,site_id
3685 ,tp_inv_org_id
3686 ,item_id
3687 ,shikyu_price
3688 ,currency_code
3689 ,uom
3690 ,project_id
3691 --added to fix project_number related issue start
3692 ,project_num
3693 --added to fix project_number related issue end
3694 ,task_id
3695 --added to fix project_number related issue start
3696 ,task_num
3697 --added to fix project_number related issue end
3698 ,primary_uom
3699 ,subpo_header_id
3700 ,subpo_number
3701 ,subpo_line_num
3702 ,subpo_release_num
3703 ,subpo_shipment_num
3704 ,OSA_ITEM_ID
3705 ,OSA_ITEM_NUMBER
3706 ,OSA_ITEM_DESCRIPTION
3707 ,REQUESTED_COMP_QTY
3708 ,ISSUED_COMP_QTY)
3709 SELECT DISTINCT p_rpt_mode RPT_MODE --temp.rpt_mode
3710 ,CFR_EXT_SUBCONTRACT_PO RPT_DATA_TYPE
3711 ,cfr_mid_item_group.oem_inv_org_id oem_inv_org_id
3712 ,cfr_mid_item_group.supplier_id supplier_id
3713 ,cfr_mid_item_group.site_id site_id
3714 ,cfr_mid_item_group.tp_inv_org_id tp_inv_org_id
3715 ,cfr_mid_item_group.item_id item_id
3716 ,oola.unit_selling_price po_unit_price --not pl.unit_price
3717 ,ooha.transactional_curr_code currency_code --or jmf_shikyu_components.Currency ,not ph.currency_code
3718 ,cfr_mid_item_group.uom --should jmf_shikyu_components.uom,need rcv.unit_of_measure to conversion?
3719 ,jso.project_id project_id
3720 --Added to fix project_number related issue start
3721 ,NVL((SELECT DISTINCT segment1 AS project_number
3722 FROM pa_projects_all
3723 WHERE pa_projects_all.project_id(+) = jso.project_id),
3724 (SELECT DISTINCT project_number
3725 FROM pjm_seiban_numbers
3726 WHERE pjm_seiban_numbers.project_id(+) = jso.project_id)) project_number
3727 --Added to fix project_number related issue end
3728 ,jso.task_id task_id
3729 --Added to get task number start
3730 ,task.task_number task_number
3731 --Added to get task number end
3732 ,cfr_mid_item_group.primary_uom --rcv.primary_unit_of_measure
3733 ,pha_s.po_header_id SubPO_header_id
3734 ,pha_s.segment1 SubPO_Number
3735 ,pla_s.line_num SubPO_Line_num
3736 ,pra_s.release_num SubPO_release_Num
3737 ,plla_s.shipment_num SubPO_shipment_NUm
3738 ,jso.osa_item_id
3739 ,msibk.concatenated_segments
3740 ,msibk.description
3741 ,wro.required_quantity
3742 ,wro.quantity_issued
3743 FROM jmf_subcontract_orders jso
3744 ,jmf_shikyu_components jsc
3745 ,(select DISTINCT cfr_mid_temp.oem_inv_org_id oem_inv_org_id
3746 ,cfr_mid_temp.supplier_id supplier_id
3747 ,cfr_mid_temp.site_id site_id
3748 ,cfr_mid_temp.tp_inv_org_id tp_inv_org_id
3749 ,cfr_mid_temp.item_id item_id
3750 ,cfr_mid_temp.uom
3751 ,cfr_mid_temp.primary_uom
3752 from jmf_shikyu_cfr_mid_temp cfr_mid_temp
3753 where cfr_mid_temp.row_type = CFR_TMP_RCV_ROW) cfr_mid_item_group
3754 ,jmf_shikyu_replenishments jsr
3755 ,jmf_shikyu_allocations jsa
3756 ,oe_order_lines_all oola
3757 ,oe_order_headers_all ooha
3758 ,po_line_locations_all plla_s
3759 ,po_headers_all pha_s
3760 ,po_lines_all pla_s
3761 ,po_releases_all pra_s
3762 ,wip_requirement_operations wro
3763 ,MTL_SYSTEM_ITEMS_B_KFV msibk
3764 ,rcv_transactions rt
3765 --Added to get task start
3766 ,pa_tasks task
3767 --Added to get task end
3768 WHERE jsc.SHIKYU_COMPONENT_ID = cfr_mid_item_group.item_id
3769 AND jsc.OEM_ORGANIZATION_ID = cfr_mid_item_group.oem_inv_org_id
3770 AND jsc.UOM = JMF_SHIKYU_RPT_UTIL.uom_to_code(cfr_mid_item_group.uom)
3771 AND jsc.PRIMARY_UOM = JMF_SHIKYU_RPT_UTIL.uom_to_code(cfr_mid_item_group.primary_uom)
3772 AND jso.TP_ORGANIZATION_ID = cfr_mid_item_group.tp_inv_org_id
3773 AND jso.OEM_ORGANIZATION_ID = cfr_mid_item_group.oem_inv_org_id
3774 AND jso.SUBCONTRACT_PO_SHIPMENT_ID = jsc.SUBCONTRACT_PO_SHIPMENT_ID
3775 AND jsc.SUBCONTRACT_PO_SHIPMENT_ID = jsa.SUBCONTRACT_PO_SHIPMENT_ID
3776 AND jsc.SHIKYU_COMPONENT_ID = jsa.SHIKYU_COMPONENT_ID
3777 AND jsa.REPLENISHMENT_SO_LINE_ID = jsr.REPLENISHMENT_SO_LINE_ID
3778 AND jsr.REPLENISHMENT_SO_LINE_ID = oola.LINE_ID
3779 AND oola.HEADER_ID = ooha.HEADER_ID
3780 AND plla_s.LINE_LOCATION_ID = jsa.SUBCONTRACT_PO_SHIPMENT_ID
3781 AND pla_s.PO_LINE_ID=plla_s.PO_LINE_ID
3782 AND pla_s.PO_HEADER_ID=plla_s.PO_HEADER_ID
3783 AND pha_s.PO_HEADER_ID=pla_s.PO_HEADER_ID
3784 AND plla_s.po_release_id = pra_s.po_release_id(+)
3785 AND jso.osa_item_id = msibk.inventory_item_id
3786 AND jso.tp_organization_id = wro.organization_id
3787 AND jso.wip_entity_id = wro.wip_entity_id
3788 AND jso.interlock_status = 'C' --added to fix bug 5415777
3789 AND wro.operation_seq_num = 1
3790 AND wro.repetitive_schedule_id IS NULL
3791 AND cfr_mid_item_group.item_id = wro.inventory_item_id
3792 AND plla_s.QUANTITY_RECEIVED>0
3793 and plla_s.LINE_LOCATION_ID = rt.PO_LINE_LOCATION_ID
3794 and rt.transaction_date < sysdate+1--period to date
3795 and rt.transaction_date >= sysdate-p_days_received --period from date
3796 --Added to get task start
3797 AND jso.task_id = task.task_id(+)
3798 --Added to get task end
3799 ;
3800
3801 COMMIT; -- for debug on UT ?????
3802
3803 IF g_fnd_debug = 'Y' AND
3804 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3805 THEN
3806 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
3807 , g_module_prefix || l_api_name || '.end'
3808 , NULL);
3809 END IF;
3810 EXCEPTION
3811 WHEN NO_DATA_FOUND THEN
3812 -- raise log message;
3813 NULL;
3814
3815 WHEN OTHERS THEN
3816 IF g_fnd_debug = 'Y'
3817 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3818 THEN
3819 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
3820 ,G_MODULE_PREFIX || l_api_name || '.execption'
3821 ,NULL);
3822 END IF;
3823 -- **** for debug information in readonly UT environment.--- begin ****
3824 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3825 ,p_api_name => G_MODULE_PREFIX || l_api_name
3826 ,p_message => 'WHEN OTHERS THEN');
3827 -- **** for debug information in readonly UT environment.--- end ****
3828
3829 END rpt_get_SubPO_data;
3830
3831 --========================================================================
3832 -- PROCEDURE : rpt_get_UnReceived_data PUBLIC ,
3833 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
3834 -- COMMENT : get the SubPO info for the component data into jmf_shikyu_cfr_rpt_temp with
3835 -- RPT_DATA_TYPE = CFR_EXT_UN_RCV
3836 -- PRE-COND :
3837 -- EXCEPTIONS: do not consider the SO return, and RepSO with RepPO is one to one.
3838 --========================================================================
3839 PROCEDURE rpt_get_UnReceived_data
3840 (
3841 p_rpt_mode IN VARCHAR2
3842 -- Amy added to fix bug 5583680 start
3843 ,p_supplier_name_from IN VARCHAR2
3844 ,p_supplier_site_code_from IN VARCHAR2
3845 ,p_supplier_name_to IN VARCHAR2
3846 ,p_supplier_site_code_to IN VARCHAR2
3847 ,p_oem_inv_org_name_from IN VARCHAR2
3848 ,p_oem_inv_org_name_to IN VARCHAR2) IS
3849 -- Amy added to fix bug 5583680 end
3850
3851 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_UnReceived_data';
3852
3853 BEGIN
3854 -- **** for debug information in readonly UT environment.--- begin ****
3855 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
3856 ,p_api_name => G_MODULE_PREFIX || l_api_name
3857 ,p_message => 'begin:');
3858 -- **** for debug information in readonly UT environment.--- end ****
3859
3860 IF g_fnd_debug = 'Y'
3861 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3862 THEN
3863 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
3864 ,g_module_prefix || l_api_name
3865 ,'.begin');
3866 END IF;
3867
3868 INSERT INTO JMF_SHIKYU_CFR_RPT_TEMP
3869 (rpt_mode
3870 ,rpt_data_type
3871 ,Oem_Inv_Org_Id
3872 ,Tp_Inv_Org_Id
3873 ,Supplier_Id
3874 ,Site_Id
3875 ,rep_so_header_id
3876 ,rep_so_number
3877 ,rep_so_line_id
3878 ,rep_so_line
3879 ,rep_po_header_id
3880 ,rep_po_number
3881 ,rep_po_line_id
3882 ,rep_po_line
3883 ,rep_po_line_location_id
3884 ,rep_po_shipment
3885 ,rep_po_release_id
3886 ,rep_po_release_num
3887 ,item_id
3888 ,item_number
3889 ,estimated_qty
3890 ,uom
3891 ,shipped_date
3892 ,expected_rcv_date)
3893 SELECT p_rpt_mode rpt_mode
3894 ,CFR_EXT_UN_RCV rpt_data_type
3895 ,jsr.oem_organization_id -- = oola.ship_from_org_id
3896 ,jsr.tp_organization_id -- = plla.ship_to_organization_id
3897 ,hoi.org_information3 -- the tp org 's supplier = SubPO supplier
3898 ,hoi.org_information4 -- the tp org 's supplier site = SubPO site
3899 ,ooha.header_id rep_so_header_id
3900 ,ooha.order_number rep_so_number
3901 ,oola.line_id rep_so_line_id
3902 ,oola.line_number rep_so_line
3903 ,pha.po_header_id rep_po_header_id
3904 ,pha.segment1 rep_po_number
3905 ,pla.po_line_id rep_po_line_id
3906 ,pla.line_num rep_po_line
3907 ,plla.line_location_id rep_po_line_location_id
3908 ,plla.shipment_num rep_po_shipment
3909 ,pra.po_release_id rep_po_release_id
3910 ,pra.release_num rep_po_release_num
3911 ,oola.inventory_item_id item_id --jsr.shikyu_component_id
3912 ,oola.ordered_item item_number
3913 ,oola.shipped_quantity estimated_qty
3914 ,oola.order_quantity_uom uom
3915 ,oola.actual_shipment_date shipped_date
3916 ,NVL(plla.need_by_date
3917 ,plla.promised_date) expected_rcv_date
3918 FROM oe_order_lines_all oola
3919 ,oe_order_headers_all ooha
3920 ,po_line_locations_all plla
3921 ,po_lines_all pla
3922 ,po_releases_all pra
3923 ,po_headers_all pha
3924 ,jmf_shikyu_replenishments jsr
3925 ,hr_organization_information hoi
3926 -- Amy added to fix bug 5583680 start
3927 ,hr_all_organization_units_tl oem_haoutl
3928 ,hr_organization_information tp_hoi
3929 ,po_vendors pv
3930 ,po_vendor_sites_all pvs
3931 -- Amy added to fix bug 5583680 end
3932 WHERE oola.header_id = ooha.header_id
3933 AND plla.po_line_id = pla.po_line_id
3934 AND plla.po_header_id = pha.po_header_id
3935 AND plla.po_release_id = pra.po_release_id(+)
3936 AND oola.line_id = jsr.replenishment_so_line_id
3937 AND plla.line_location_id = jsr.replenishment_po_shipment_id
3938 AND jsr.tp_organization_id = hoi.organization_id
3939 AND hoi.org_information_context = 'Customer/Supplier Association'
3940 -- Amy updated to fix bug 5583680 start
3941 /*AND (SELECT COUNT(*)
3942 FROM JMF_SHIKYU_CFR_RPT_TEMP jscrt
3943 WHERE jscrt.rpt_data_type = CFR_EXT_COMPONENT
3944 AND jscrt.oem_inv_org_id = jsr.oem_organization_id
3945 AND jscrt.tp_inv_org_id = jsr.tp_organization_id) > 0
3946 AND JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(oola.sold_from_org_id
3947 ,oola.inventory_item_id
3948 ,oola.order_quantity_uom
3949 ,NVL(oola.shipped_quantity
3950 ,0)) >
3951 JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(plla.ship_to_organization_id
3952 ,pla.item_id
3953 ,JMF_SHIKYU_RPT_UTIL.uom_to_code(pla.unit_meas_lookup_code)
3954 ,NVL(plla.quantity_received
3955 ,0));*/
3956 AND jsr.oem_organization_id = oem_haoutl.organization_id
3957 AND oem_haoutl.NAME >= NVL(p_oem_inv_org_name_from
3958 ,oem_haoutl.NAME)
3959 AND oem_haoutl.NAME <= NVL(p_oem_inv_org_name_to
3960 ,oem_haoutl.NAME)
3961 AND oem_haoutl.LANGUAGE = USERENV('LANG')
3962 AND jsr.tp_organization_id = tp_hoi.organization_id
3963 AND tp_hoi.org_information_context = 'Customer/Supplier Association'
3964 AND tp_hoi.org_information3 = pv.vendor_id
3965 AND tp_hoi.org_information4 = pvs.vendor_site_id
3966 AND pv.vendor_name >= NVL(p_supplier_name_from, pv.vendor_name)
3967 AND pv.vendor_name <= NVL(p_supplier_name_to, pv.vendor_name)
3968 AND pvs.vendor_site_code >= NVL(p_supplier_site_code_from, pvs.vendor_site_code)
3969 AND pvs.vendor_site_code <= NVL(p_supplier_site_code_to, pvs.vendor_site_code)
3970 AND NVL(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(jsr.oem_organization_id
3971 ,oola.inventory_item_id
3972 ,oola.order_quantity_uom
3973 ,NVL(oola.shipped_quantity
3974 ,0)),0) >
3975 NVL(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(plla.ship_to_organization_id
3976 ,pla.item_id
3977 ,JMF_SHIKYU_RPT_UTIL.uom_to_code(pla.unit_meas_lookup_code)
3978 ,NVL(plla.quantity_received
3979 ,0)),0);
3980 -- Amy updated to fix bug 5583680 end
3981 COMMIT; -- for debug on UT ?????
3982 IF g_fnd_debug = 'Y' AND
3983 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3984 THEN
3985 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
3986 , g_module_prefix || l_api_name || '.end'
3987 , NULL);
3988 END IF;
3989 EXCEPTION
3990 WHEN NO_DATA_FOUND THEN
3991 -- raise log message;
3992 NULL;
3993
3994 WHEN OTHERS THEN
3995 IF g_fnd_debug = 'Y'
3996 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
3997 THEN
3998 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
3999 ,G_MODULE_PREFIX || l_api_name || '.execption'
4000 ,NULL);
4001 END IF;
4002 -- **** for debug information in readonly UT environment.--- begin ****
4003 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4004 ,p_api_name => G_MODULE_PREFIX || l_api_name
4005 ,p_message => 'WHEN OTHERS THEN');
4006 -- **** for debug information in readonly UT environment.--- end ****
4007
4008 END rpt_get_UnReceived_data;
4009
4010 --========================================================================
4011 -- PROCEDURE : rpt_get_Received_data PUBLIC ,
4012 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
4013 -- COMMENT : get the received data in days into jmf_shikyu_cfr_rpt_temp with
4014 -- RPT_DATA_TYPE = CFR_EXT_RCV_IN_DAYS
4015 -- PRE-COND :
4016 -- EXCEPTIONS: do not consider the SO return, and RepSO with RepPO is one to one.
4017 --========================================================================
4018 PROCEDURE rpt_get_Received_data(
4019 p_rpt_mode IN VARCHAR2
4020 ,p_days_received IN NUMBER
4021 ) IS
4022 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_Received_data';
4023
4024 BEGIN
4025 -- **** for debug information in readonly UT environment.--- begin ****
4026 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4027 ,p_api_name => G_MODULE_PREFIX || l_api_name
4028 ,p_message => 'begin:');
4029 -- **** for debug information in readonly UT environment.--- end ****
4030
4031 IF g_fnd_debug = 'Y'
4032 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4033 THEN
4034 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
4035 ,g_module_prefix || l_api_name
4036 ,'.begin');
4037 END IF;
4038
4039 -- data that Shipped = received and exptected rcv date is in p_days_received
4040 INSERT INTO JMF_SHIKYU_CFR_RPT_TEMP
4041 (rpt_mode
4042 ,rpt_data_type
4043 ,Oem_Inv_Org_Id
4044 ,Tp_Inv_Org_Id
4045 ,Supplier_Id
4046 ,Site_Id
4047 ,rep_so_header_id
4048 ,rep_so_number
4049 ,rep_so_line_id
4050 ,rep_so_line
4051 ,rep_po_header_id
4052 ,rep_po_number
4053 ,rep_po_line_id
4054 ,rep_po_line
4055 ,rep_po_line_location_id
4056 ,rep_po_shipment
4057 ,rep_po_release_id
4058 ,rep_po_release_num
4059 ,item_id
4060 ,item_number
4061 ,estimated_qty
4062 ,uom
4063 ,shipped_date
4064 ,expected_rcv_date)
4065 SELECT p_rpt_mode rpt_mode
4066 ,CFR_EXT_RCV_IN_DAYS rpt_data_type
4067 ,jsr.oem_organization_id -- = oola.ship_from_org_id
4068 ,jsr.tp_organization_id -- = plla.ship_to_organization_id
4069 ,hoi.org_information3 -- the tp org 's supplier = SubPO supplier
4070 ,hoi.org_information4 -- the tp org 's supplier site = SubPO site
4071 ,ooha.header_id rep_so_header_id
4072 ,ooha.order_number rep_so_number
4073 ,oola.line_id rep_so_line_id
4074 ,oola.line_number rep_so_line
4075 ,pha.po_header_id rep_po_header_id
4076 ,pha.segment1 rep_po_number
4077 ,pla.po_line_id rep_po_line_id
4078 ,pla.line_num rep_po_line
4079 ,plla.line_location_id rep_po_line_location_id
4080 ,plla.shipment_num rep_po_shipment
4081 ,pra.po_release_id rep_po_release_id
4082 ,pra.release_num rep_po_release_num
4083 ,oola.inventory_item_id item_id --jsr.shikyu_component_id
4084 ,oola.ordered_item item_number
4085 ,oola.shipped_quantity estimated_qty
4086 ,oola.order_quantity_uom uom
4087 ,oola.actual_shipment_date shipped_date
4088 ,NVL(plla.need_by_date
4089 ,plla.promised_date) expected_rcv_date
4090 FROM oe_order_lines_all oola
4091 ,oe_order_headers_all ooha
4092 ,po_line_locations_all plla
4093 ,po_lines_all pla
4094 ,po_releases_all pra
4095 ,po_headers_all pha
4096 ,jmf_shikyu_replenishments jsr
4097 ,hr_organization_information hoi
4098 WHERE oola.header_id = ooha.header_id
4099 AND plla.po_line_id = pla.po_line_id
4100 AND plla.po_header_id = pha.po_header_id
4101 AND plla.po_release_id = pra.po_release_id(+)
4102 AND oola.line_id = jsr.replenishment_so_line_id
4103 AND plla.line_location_id = jsr.replenishment_po_shipment_id
4104 AND jsr.tp_organization_id = hoi.organization_id
4105 AND hoi.org_information_context = 'Customer/Supplier Association'
4106 AND (SELECT COUNT(*)
4107 FROM JMF_SHIKYU_CFR_RPT_TEMP jscrt
4108 WHERE jscrt.rpt_data_type = CFR_EXT_COMPONENT
4109 AND jscrt.oem_inv_org_id = jsr.oem_organization_id
4110 AND jscrt.tp_inv_org_id = jsr.tp_organization_id) > 0
4111 AND (SYSDATE - NVL(plla.need_by_date
4112 ,plla.promised_date)) <= p_days_received
4113 -- Bug 5583680: Fixed data issue for the Received Replenishments in
4114 -- Past xx Days section
4115 AND NVL(oola.shipped_quantity,0) > 0
4116 AND NVL(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(jsr.oem_organization_id
4117 ,oola.inventory_item_id
4118 ,oola.order_quantity_uom
4119 ,NVL(oola.shipped_quantity
4120 ,0)),0) =
4121 NVL(JMF_SHIKYU_RPT_UTIL.get_item_primary_quantity(plla.ship_to_organization_id
4122 ,pla.item_id
4123 ,JMF_SHIKYU_RPT_UTIL.uom_to_code(pla.unit_meas_lookup_code)
4124 ,NVL(plla.quantity_received
4125 ,0)),0);
4126 COMMIT; -- for debug on UT ?????
4127 IF g_fnd_debug = 'Y' AND
4128 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4129 THEN
4130 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
4131 , g_module_prefix || l_api_name || '.end'
4132 , NULL);
4133 END IF;
4134 EXCEPTION
4135 WHEN NO_DATA_FOUND THEN
4136 -- raise log message;
4137 NULL;
4138
4139 WHEN OTHERS THEN
4140 IF g_fnd_debug = 'Y'
4141 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4142 THEN
4143 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
4144 ,G_MODULE_PREFIX || l_api_name || '.execption'
4145 ,NULL);
4146 END IF;
4147 -- **** for debug information in readonly UT environment.--- begin ****
4148 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4149 ,p_api_name => G_MODULE_PREFIX || l_api_name
4150 ,p_message => 'WHEN OTHERS THEN');
4151 -- **** for debug information in readonly UT environment.--- end ****
4152
4153 END rpt_get_Received_data;
4154
4155 --========================================================================
4156 -- PROCEDURE : rpt_get_Int_data PUBLIC ,
4157 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
4158 -- COMMENT : get the Component data into jmf_shikyu_cfr_rpt_temp with
4159 -- RPT_DATA_TYPE = CFR_INT_COMPONENT
4160 -- PRE-COND :
4161 -- EXCEPTIONS:
4162 --========================================================================
4163 PROCEDURE rpt_get_Int_data(p_rpt_mode IN VARCHAR2) IS
4164 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_Int_data';
4165
4166 BEGIN
4167 -- **** for debug information in readonly UT environment.--- begin ****
4168 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4169 ,p_api_name => G_MODULE_PREFIX || l_api_name
4170 ,p_message => 'begin:');
4171 -- **** for debug information in readonly UT environment.--- end ****
4172
4173 IF g_fnd_debug = 'Y'
4174 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4175 THEN
4176 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
4177 ,g_module_prefix || l_api_name
4178 ,'.begin');
4179 END IF;
4180
4181 -- get the data for internal report
4182 INSERT INTO jmf_shikyu_cfr_rpt_temp
4183 (rpt_mode
4184 ,rpt_data_type
4185 ,oem_inv_org_id
4186 ,oem_inv_org_code
4187 ,oem_inv_org_name
4188 ,oem_inv_org_address
4189 ,supplier_id
4190 ,supplier_name
4191 ,site_id
4192 ,site_code
4193 ,site_address
4194 ,tp_inv_org_id
4195 ,tp_inv_org_code
4196 ,project_id
4197 ,project_num
4198 ,task_id
4199 ,task_num
4200 ,item_id
4201 ,item_number
4202 ,item_description
4203 ,estimated_qty
4204 ,primary_uom
4205 ,shikyu_price
4206 ,currency_code
4207 ,uom
4208 ,item_cost
4209 ,functional_currency
4210 ,value1 --Qty in Primary UOM
4211 ,value2 --SHIKYU Price in Pri UOM and Pri Currency
4212 ,value3) --SHIKYU Cost in Pri UOM and Pri Currency
4213 --value SUM(temp.estimated_qty) are supposed to onhand_quantity at item/price level,but got incorrect quantity.
4214 --got incorrect onhand quantity due to use inapposite group.
4215 --updated select statement to add transaction_id into group by to get correct onhand quantity.
4216 /*
4217 TODO: owner="amy" category="Fix" priority="2 - Severe Loss of Service" created="2006-6-22"
4218 text="--updated for fix bug 5231233 Begin"
4219 */
4220 /* SELECT p_rpt_mode rpt_mode
4221 ,CFR_INT_COMPONENT rpt_data_type
4222 ,jscrt.oem_inv_org_id Iss_oem_inv_org_id
4223 ,jscrt.oem_inv_org_code Iss_oem_inv_org_code
4224 ,haou.name Iss_oem_inv_org_name
4225 ,jscrt.oem_inv_org_address Iss_oem_inv_org_address
4226 ,jscrt.supplier_id Iss_supplier_id
4227 ,jscrt.supplier_name Iss_supplier_name
4228 ,jscrt.site_id Iss_site_id
4229 ,jscrt.site_code Iss_site_code
4230 ,jscrt.site_address Iss_site_address
4231 ,jscrt.tp_inv_org_id Iss_tp_inv_org_id
4232 ,jscrt.tp_inv_org_code Iss_tp_inv_org_code
4233 ,jscrt.project_id Iss_project_id
4234 ,jscrt.project_num Iss_project_num
4235 ,jscrt.task_id Iss_task_id
4236 ,jscrt.task_num Iss_task_num
4237 ,jscrt.item_id Iss_item_id
4238 ,jscrt.item_number Iss_item_number
4239 ,jscrt.item_description Iss_item_description
4240 ,SUM(jscrt.estimated_qty) Iss_estimated_qty_Sum
4241 ,jscrt.primary_uom Iss_primary_uom
4242 ,jscrt.shikyu_price Iss_shikyu_price
4243 ,jscrt.currency_code Iss_currency_code
4244 ,jscrt.uom Iss_uom
4245 ,jscrt.item_cost Iss_item_cost
4246 ,jscrt.functional_currency Iss_functional_currency
4247 ,SUM(jscrt.value1) Iss_estimated_qty_Sum_Pri
4248 ,jscrt.value2 Iss_SHIKYU_Price_PriU
4249 ,jscrt.value3 Iss_SHIKYU_Cost_PriU
4250 FROM jmf_shikyu_cfr_rpt_temp jscrt
4251 ,HR_ALL_ORGANIZATION_UNITS haou
4252 WHERE jscrt.oem_inv_org_id = haou.organization_id
4253 AND jscrt.rpt_data_type = CFR_CRUDE_DATA
4254 GROUP BY jscrt.oem_inv_org_id
4255 ,jscrt.oem_inv_org_code
4256 ,haou.name
4257 ,jscrt.oem_inv_org_address
4258 ,jscrt.supplier_id
4259 ,jscrt.supplier_name
4260 ,jscrt.site_id
4261 ,jscrt.site_code
4262 ,jscrt.site_address
4263 ,jscrt.tp_inv_org_id
4264 ,jscrt.tp_inv_org_code
4265 ,jscrt.project_id
4266 ,jscrt.project_num
4267 ,jscrt.task_id
4268 ,jscrt.task_num
4269 ,jscrt.item_id
4270 ,jscrt.item_number
4271 ,jscrt.item_description
4272 ,jscrt.primary_uom
4273 ,jscrt.shikyu_price
4274 ,jscrt.currency_code
4275 ,jscrt.uom
4276 ,jscrt.item_cost
4277 ,jscrt.functional_currency
4278 ,jscrt.value2
4279 ,jscrt.value3
4280 ;
4281 */
4282 SELECT rpt_temp.rpt_mode
4283 ,rpt_temp.rpt_data_type
4284 ,rpt_temp.oem_inv_org_id Iss_oem_inv_org_id
4285 ,rpt_temp.oem_inv_org_code Iss_oem_inv_org_code
4286 ,rpt_temp.oem_inv_org_name Iss_oem_inv_org_name
4287 ,rpt_temp.oem_inv_org_address Iss_oem_inv_org_address
4288 ,rpt_temp.supplier_id Iss_supplier_id
4289 ,rpt_temp.supplier_name Iss_supplier_name
4290 ,rpt_temp.site_id Iss_site_id
4291 ,rpt_temp.site_code Iss_site_code
4292 ,rpt_temp.site_address Iss_site_address
4293 ,rpt_temp.tp_inv_org_id Iss_tp_inv_org_id
4294 ,rpt_temp.tp_inv_org_code Iss_tp_inv_org_code
4295 ,rpt_temp.project_id Iss_project_id
4296 ,rpt_temp.project_num Iss_project_num
4297 ,rpt_temp.task_id Iss_task_id
4298 ,rpt_temp.task_num Iss_task_num
4299 ,rpt_temp.item_id Iss_item_id
4300 ,rpt_temp.item_number Iss_item_number
4301 ,rpt_temp.item_description Iss_item_description
4302 ,SUM(rpt_temp.estimated_qty) Iss_estimated_qty_Sum
4303 ,rpt_temp.primary_uom Iss_primary_uom
4304 ,rpt_temp.shikyu_price Iss_shikyu_price
4305 ,rpt_temp.currency_code Iss_currency_code
4306 ,rpt_temp.uom Iss_uom
4307 ,rpt_temp.item_cost Iss_item_cost
4308 ,rpt_temp.functional_currency Iss_functional_currency
4309 ,SUM(rpt_temp.value1) Iss_estimated_qty_Sum_Pri
4310 ,rpt_temp.value2 Iss_SHIKYU_Price_PriU
4311 ,rpt_temp.value3 Iss_SHIKYU_Cost_PriU
4312 FROM (
4313 SELECT p_rpt_mode rpt_mode
4314 ,CFR_INT_COMPONENT rpt_data_type
4315 ,jscrt.oem_inv_org_id oem_inv_org_id
4316 ,jscrt.oem_inv_org_code oem_inv_org_code
4317 ,haou.name oem_inv_org_name
4318 ,jscrt.oem_inv_org_address oem_inv_org_address
4319 ,jscrt.supplier_id supplier_id
4320 ,jscrt.supplier_name supplier_name
4321 ,jscrt.site_id site_id
4322 ,jscrt.site_code site_code
4323 ,jscrt.site_address site_address
4324 ,jscrt.tp_inv_org_id tp_inv_org_id
4325 ,jscrt.tp_inv_org_code tp_inv_org_code
4326 ,jscrt.project_id project_id
4327 ,jscrt.project_num project_num
4328 ,jscrt.task_id task_id
4329 ,jscrt.task_num task_num
4330 ,jscrt.item_id item_id
4331 ,jscrt.item_number item_number
4332 ,jscrt.item_description item_description
4333 ,jscrt.estimated_qty estimated_qty
4334 ,jscrt.primary_uom primary_uom
4335 ,jscrt.shikyu_price shikyu_price
4336 ,jscrt.currency_code currency_code
4337 ,jscrt.uom uom
4338 ,jscrt.item_cost item_cost
4339 ,jscrt.functional_currency functional_currency
4340 ,jscrt.value1 value1
4341 ,jscrt.value2 value2
4342 ,jscrt.value3 value3
4343 ,jscrt.transaction_id transaction_id
4344 FROM jmf_shikyu_cfr_rpt_temp jscrt
4345 ,HR_ALL_ORGANIZATION_UNITS_TL haou
4346 WHERE jscrt.oem_inv_org_id = haou.organization_id
4347 AND jscrt.rpt_data_type = CFR_CRUDE_DATA
4348 AND haou.language = USERENV('LANG')
4349 GROUP BY jscrt.rpt_mode
4350 ,jscrt.oem_inv_org_id
4351 ,jscrt.oem_inv_org_code
4352 ,haou.name
4353 ,jscrt.oem_inv_org_address
4354 ,jscrt.supplier_id
4355 ,jscrt.supplier_name
4356 ,jscrt.site_id
4357 ,jscrt.site_code
4358 ,jscrt.site_address
4359 ,jscrt.tp_inv_org_id
4360 ,jscrt.tp_inv_org_code
4361 ,jscrt.project_id
4362 ,jscrt.project_num
4363 ,jscrt.task_id
4364 ,jscrt.task_num
4365 ,jscrt.item_id
4366 ,jscrt.item_number
4367 ,jscrt.item_description
4368 ,jscrt.primary_uom
4369 ,jscrt.shikyu_price
4370 ,jscrt.currency_code
4371 ,jscrt.uom
4372 ,jscrt.item_cost
4373 ,jscrt.functional_currency
4374 ,jscrt.value2
4375 ,jscrt.value3
4376 ,jscrt.transaction_id
4377 ,jscrt.estimated_qty
4378 ,jscrt.value1
4379 ) rpt_temp
4380 GROUP BY rpt_temp.rpt_mode
4381 ,rpt_temp.rpt_data_type
4382 ,rpt_temp.oem_inv_org_id
4383 ,rpt_temp.oem_inv_org_code
4384 ,rpt_temp.oem_inv_org_name
4385 ,rpt_temp.oem_inv_org_address
4386 ,rpt_temp.supplier_id
4387 ,rpt_temp.supplier_name
4388 ,rpt_temp.site_id
4389 ,rpt_temp.site_code
4390 ,rpt_temp.site_address
4391 ,rpt_temp.tp_inv_org_id
4392 ,rpt_temp.tp_inv_org_code
4393 ,rpt_temp.project_id
4394 ,rpt_temp.project_num
4395 ,rpt_temp.task_id
4396 ,rpt_temp.task_num
4397 ,rpt_temp.item_id
4398 ,rpt_temp.item_number
4399 ,rpt_temp.item_description
4400 ,rpt_temp.primary_uom
4401 ,rpt_temp.shikyu_price
4402 ,rpt_temp.currency_code
4403 ,rpt_temp.uom
4404 ,rpt_temp.item_cost
4405 ,rpt_temp.functional_currency
4406 ,rpt_temp.value2
4407 ,rpt_temp.value3;
4408 --updated for fix bug #5231233 End
4409
4410 --seems the SUM(temp.estimated_qty) is not the onhand quantity.
4411 --add for fix bug 4997302 Begin
4412 --update the onhand quantity to the ESTIMATED_QTY column, assume the same price and cost, need track
4413 /*
4414 TODO: owner="sunwa" created="2006-1-26"
4415 text="--add for fix bug 4997302 Begin Internal"
4416 */
4417 -- modify the onhand quantity, for
4418 -- As the SUM(temp.estimated_qty) is correct by fixing bug #5231233,sql statement below should be updated
4419 /*
4420 TODO: owner="amy" category="Fix" priority="2 - Severe Loss of Service" created="2006-6-22"
4421 text="--updated for fix bug 5231233 Begin Internal"
4422 */
4423
4424 -- Deleted Update to fix bug 5665445 for incorrect onhand Qty in Secondary UOM case
4425 /* UPDATE JMF_SHIKYU_CFR_RPT_TEMP jscrt
4426 SET jscrt.estimated_qty = PO_UOM_S.po_uom_convert_p(jscrt.primary_uom
4427 ,jscrt.uom
4428 ,jscrt.item_id) *jscrt.ESTIMATED_QTY,
4429 (SELECT jscmt.primary_unconsumed_quantity
4430 FROM jmf_shikyu_cfr_mid_temp jscmt
4431 WHERE jscmt.row_type = CFR_TMP_ONHAND_ROW --10
4432 AND jscmt.tp_inv_org_id =
4433 jscrt.tp_inv_org_id
4434 AND jscmt.item_id = jscrt.item_id),
4435 jscrt.value1 = (SELECT jscmt.primary_unconsumed_quantity
4436 FROM jmf_shikyu_cfr_mid_temp jscmt
4437 WHERE jscmt.row_type = CFR_TMP_ONHAND_ROW --10
4438 AND jscmt.tp_inv_org_id =
4439 jscrt.tp_inv_org_id
4440 AND jscmt.item_id = jscrt.item_id)
4441 jscrt.value1 = jscrt.ESTIMATED_QTY
4442 --updated for fix bug 5231233 End Internal
4443 WHERE jscrt.rpt_data_type = CFR_INT_COMPONENT;
4444 -- modify the cost and price
4445 */
4446 --add for fix bug 4997302 Begin
4447
4448 COMMIT; -- for debug on UT ?????
4449 IF g_fnd_debug = 'Y' AND
4450 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4451 THEN
4452 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
4453 , g_module_prefix || l_api_name || '.end'
4454 , NULL);
4455 END IF;
4456 EXCEPTION
4457 WHEN NO_DATA_FOUND THEN
4458 -- raise log message;
4459 NULL;
4460
4461 WHEN OTHERS THEN
4462 IF g_fnd_debug = 'Y'
4463 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4464 THEN
4465 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
4466 ,G_MODULE_PREFIX || l_api_name || '.execption'
4467 ,NULL);
4468 END IF;
4469 -- **** for debug information in readonly UT environment.--- begin ****
4470 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4471 ,p_api_name => G_MODULE_PREFIX || l_api_name
4472 ,p_message => SQLERRM);
4473 -- **** for debug information in readonly UT environment.--- end ****
4474
4475 END rpt_get_Int_data;
4476
4477 --========================================================================
4478 -- PROCEDURE : rpt_get_SubPO_data_Onhand PUBLIC ,
4479 -- PARAMETERS: p_rcv_row_type row type id to identify the rcv_transaction
4480 -- COMMENT : get the SubPO info for the component data into jmf_shikyu_cfr_rpt_temp with
4481 -- These subPOs can affect onhand quantity in MP inventory.
4482 -- RPT_DATA_TYPE = CFR_EXT_SUBPO_AFT_ONHAND
4483 -- PRE-COND :
4484 -- EXCEPTIONS:
4485 --========================================================================
4486 PROCEDURE rpt_get_SubPO_data_Onhand(p_rpt_mode IN VARCHAR2) IS
4487 l_api_name CONSTANT VARCHAR2(30) := 'rpt_get_SubPO_data_Onhand';
4488
4489 BEGIN
4490 -- **** for debug information in readonly UT environment.--- begin ****
4491 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4492 ,p_api_name => G_MODULE_PREFIX || l_api_name
4493 ,p_message => 'begin:');
4494 -- **** for debug information in readonly UT environment.--- end ****
4495
4496 IF g_fnd_debug = 'Y'
4497 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4498 THEN
4499 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
4500 ,g_module_prefix || l_api_name
4501 ,'.begin');
4502 END IF;
4503
4504 INSERT INTO JMF_SHIKYU_CFR_RPT_TEMP
4505 (RPT_MODE
4506 ,RPT_DATA_TYPE
4507 ,oem_inv_org_id
4508 ,supplier_id
4509 ,site_id
4510 ,tp_inv_org_id
4511 ,item_id
4512 ,shikyu_price
4513 ,currency_code
4514 ,uom
4515 ,project_id
4516 ,task_id
4517 ,primary_uom
4518 ,subpo_header_id
4519 ,subpo_number
4520 ,subpo_line_num
4521 ,subpo_release_num
4522 ,subpo_shipment_num
4523 ,OSA_ITEM_ID
4524 ,OSA_ITEM_NUMBER
4525 ,OSA_ITEM_DESCRIPTION
4526 ,REQUESTED_COMP_QTY
4527 ,ISSUED_COMP_QTY)
4528 SELECT DISTINCT p_rpt_mode RPT_MODE --temp.rpt_mode
4529 ,CFR_EXT_SUBPO_AFT_ONHAND RPT_DATA_TYPE
4530 ,temp.oem_inv_org_id shikyu_oem_inv_org_id
4531 ,temp.supplier_id shikyu_supplier_id
4532 ,temp.site_id shikyu_site_id
4533 ,temp.tp_inv_org_id shikyu_tp_inv_org_id
4534 ,temp.item_id shikyu_item_id
4535 ,temp.shikyu_price shikyu_price
4536 ,temp.currency_code shikyu_currency
4537 ,temp.uom shikyu_uom
4538 ,temp.project_id
4539 ,temp.task_id
4540 ,temp.primary_uom shikyu_primary_uom
4541 ,temp.subpo_header_id
4542 ,temp.subpo_number
4543 ,temp.subpo_line_num
4544 ,temp.subpo_release_num
4545 ,temp.subpo_shipment_num
4546 ,jso.osa_item_id
4547 ,msibk.concatenated_segments
4548 ,msibk.description
4549 ,wro.required_quantity
4550 ,wro.quantity_issued
4551 FROM JMF_SHIKYU_CFR_RPT_TEMP temp
4552 ,jmf_subcontract_orders jso
4553 ,wip_requirement_operations wro
4554 ,MTL_SYSTEM_ITEMS_B_KFV msibk
4555 WHERE temp.rpt_DATA_TYPE = CFR_CRUDE_DATA
4556 AND temp.subpo_shipment_id = jso.subcontract_po_shipment_id
4557 AND jso.oem_organization_id = msibk.organization_id
4558 AND jso.osa_item_id = msibk.inventory_item_id
4559 AND jso.tp_organization_id = wro.organization_id
4560 AND jso.wip_entity_id = wro.wip_entity_id
4561 AND wro.operation_seq_num = 1
4562 AND wro.repetitive_schedule_id IS NULL
4563 AND temp.item_id = wro.inventory_item_id;
4564 COMMIT; -- for debug on UT ?????
4565 IF g_fnd_debug = 'Y' AND
4566 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4567 THEN
4568 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
4569 , g_module_prefix || l_api_name || '.end'
4570 , NULL);
4571 END IF;
4572 EXCEPTION
4573 WHEN NO_DATA_FOUND THEN
4574 -- raise log message;
4575 NULL;
4576
4577 WHEN OTHERS THEN
4578 IF g_fnd_debug = 'Y'
4579 AND FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4580 THEN
4581 FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED
4582 ,G_MODULE_PREFIX || l_api_name || '.execption'
4583 ,NULL);
4584 END IF;
4585 -- **** for debug information in readonly UT environment.--- begin ****
4586 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => 'FND_LOG.STRING'
4587 ,p_api_name => G_MODULE_PREFIX || l_api_name
4588 ,p_message => 'WHEN OTHERS THEN');
4589 -- **** for debug information in readonly UT environment.--- end ****
4590
4591 END rpt_get_SubPO_data_Onhand;
4592
4593 --========================================================================
4594 -- PROCEDURE : rpt_debug_show_mid_data PUBLIC ,
4595 -- PARAMETERS: p_row_type row type in jmf_shikyu_cfr_mid_temp
4596 -- p_output_to the parameter for debug_output
4597 -- COMMENT : show the data in temp table jmf_shikyu_cfr_mid_temp
4598 -- using debug_output
4599 -- PRE-COND :
4600 -- EXCEPTIONS:
4601 --========================================================================
4602 PROCEDURE rpt_debug_show_mid_data
4603 (
4604 p_row_type IN VARCHAR2
4605 ,p_output_to IN VARCHAR2
4606 ) IS
4607 l_api_name CONSTANT VARCHAR2(30) := 'rpt_debug_show_mid_data';
4608
4609 CURSOR l_cur_get_mid_temp_data(lp_row_type jmf_shikyu_cfr_mid_temp.row_type%TYPE) IS
4610 SELECT row_type
4611 ,shikyu_id
4612 ,tp_inv_org_id
4613 ,item_id
4614 ,uom
4615 ,quantity
4616 ,primary_uom
4617 ,primary_unallocated_quantity
4618 ,primary_unconsumed_quantity
4619 ,project_id
4620 ,task_id
4621 ,oem_inv_org_id
4622 ,supplier_id
4623 ,site_id
4624 ,ou_id
4625 ,get_rcv_flag
4626 ,get_rep_flag
4627 FROM jmf_shikyu_cfr_mid_temp
4628 WHERE (lp_row_type IS NULL)
4629 OR (row_type = lp_row_type)
4630 ORDER BY row_type
4631 ,shikyu_id
4632 ,item_id;
4633
4634 l_row_type jmf_shikyu_cfr_mid_temp.row_type%TYPE;
4635 l_shikyu_id jmf_shikyu_cfr_mid_temp.shikyu_id%TYPE;
4636 l_tp_inv_org_id jmf_shikyu_cfr_mid_temp.tp_inv_org_id%TYPE;
4637 l_item_id jmf_shikyu_cfr_mid_temp.item_id%TYPE;
4638 l_uom jmf_shikyu_cfr_mid_temp.uom%TYPE;
4639 l_quantity jmf_shikyu_cfr_mid_temp.quantity%TYPE;
4640 l_primary_uom jmf_shikyu_cfr_mid_temp.primary_uom%TYPE;
4641 l_primary_unallocated_quantity jmf_shikyu_cfr_mid_temp.primary_unallocated_quantity%TYPE;
4642 l_primary_unconsumed_quantity jmf_shikyu_cfr_mid_temp.primary_unconsumed_quantity%TYPE;
4643 l_project_id jmf_shikyu_cfr_mid_temp.project_id%TYPE;
4644 l_task_id jmf_shikyu_cfr_mid_temp.task_id%TYPE;
4645 l_oem_inv_org_id jmf_shikyu_cfr_mid_temp.oem_inv_org_id%TYPE;
4646 l_supplier_id jmf_shikyu_cfr_mid_temp.supplier_id%TYPE;
4647 l_site_id jmf_shikyu_cfr_mid_temp.site_id%TYPE;
4648 l_ou_id jmf_shikyu_cfr_mid_temp.ou_id%TYPE;
4649 l_get_rcv_flag jmf_shikyu_cfr_mid_temp.get_rcv_flag%TYPE;
4650 l_get_rep_flag jmf_shikyu_cfr_mid_temp.get_rep_flag%TYPE;
4651
4652 BEGIN
4653 -- **** for debug information in readonly UT environment.--- begin ****
4654 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4655 ,p_api_name => G_MODULE_PREFIX ||
4656 l_api_name
4657 ,p_message => '==jmf_shikyu_cfr_mid_temp data Begin==');
4658 -- **** for debug information in readonly UT environment.--- end ****
4659 OPEN l_cur_get_mid_temp_data(p_row_type);
4660 LOOP
4661 --print the data in l_cur_get_mid_temp_data
4662 FETCH l_cur_get_mid_temp_data
4663 INTO l_row_type
4664 ,l_shikyu_id
4665 ,l_tp_inv_org_id
4666 ,l_item_id
4667 ,l_uom
4668 ,l_quantity
4669 ,l_primary_uom
4670 ,l_primary_unallocated_quantity
4671 ,l_primary_unconsumed_quantity
4672 ,l_project_id
4673 ,l_task_id
4674 ,l_oem_inv_org_id
4675 ,l_supplier_id
4676 ,l_site_id
4677 ,l_ou_id
4678 ,l_get_rcv_flag
4679 ,l_get_rep_flag;
4680
4681 EXIT WHEN l_cur_get_mid_temp_data%NOTFOUND;
4682
4683 -- **** for debug information in readonly UT environment.--- begin ****
4684 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4685 ,p_api_name => G_MODULE_PREFIX ||
4686 l_api_name
4687 ,p_message => 'jmf_shikyu_cfr_mid_temp:' ||
4688 ';row_type[' || l_row_type || ']' ||
4689 ';shikyu_id[' || l_shikyu_id || ']' ||
4690 ';tp_inv_org_id[' || l_tp_inv_org_id || ']' ||
4691 ';item_id[' || l_item_id || ']' ||
4692 ';uom[' || l_uom || ']' ||
4693 ';quantity[' || l_quantity || ']' ||
4694 ';primary_uom[' || l_primary_uom || ']' ||
4695 ';primary_unallocated_quantity[' || l_primary_unallocated_quantity || ']' ||
4696 ';primary_unconsumed_quantity[' || l_primary_unconsumed_quantity || ']' ||
4697 ';project_id[' || l_project_id || ']' ||
4698 ';task_id[' || l_task_id || ']' ||
4699 ';oem_inv_org_id[' || l_oem_inv_org_id || ']' ||
4700 ';supplier_id[' || l_supplier_id || ']' ||
4701 ';site_id[' || l_site_id || ']' ||
4702 ';ou_id[' || l_ou_id || ']' ||
4703 ';get_rcv_flag[' || l_get_rcv_flag || ']' ||
4704 ';get_rep_flag[' || l_get_rep_flag || ']'
4705 );
4706 -- **** for debug information in readonly UT environment.--- end ****
4707
4708 END LOOP; --end loop of l_cur_get_mid_temp_data
4709 CLOSE l_cur_get_mid_temp_data;
4710
4711 -- **** for debug information in readonly UT environment.--- begin ****
4712 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4713 ,p_api_name => G_MODULE_PREFIX ||
4714 l_api_name
4715 ,p_message => '==jmf_shikyu_cfr_mid_temp data end==');
4716 -- **** for debug information in readonly UT environment.--- end ****
4717
4718 IF g_fnd_debug = 'Y' AND
4719 FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4720 THEN
4721 fnd_log.STRING( FND_LOG.LEVEL_PROCEDURE
4722 , g_module_prefix || l_api_name || '.end'
4723 , NULL);
4724 END IF;
4725 EXCEPTION
4726 WHEN NO_DATA_FOUND THEN
4727 -- raise log message;
4728 NULL;
4729
4730 WHEN OTHERS THEN
4731 -- **** for debug information in readonly UT environment.--- begin ****
4732 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4733 ,p_api_name => G_MODULE_PREFIX ||
4734 l_api_name ||
4735 '.Exception'
4736 ,p_message => SQLERRM);
4737 -- **** for debug information in readonly UT environment.--- end ****
4738
4739 END rpt_debug_show_mid_data;
4740
4741 --========================================================================
4742 -- PROCEDURE : rpt_debug_show_temp_data PUBLIC ,
4743 -- PARAMETERS: p_rpt_data_type row type in jmf_shikyu_cfr_rpt_temp
4744 -- p_output_to the parameter for debug_output
4745 -- COMMENT : show the data in temp table jmf_shikyu_cfr_rpt_temp
4746 -- using debug_output
4747 -- PRE-COND :
4748 -- EXCEPTIONS:
4749 --========================================================================
4750 PROCEDURE rpt_debug_show_temp_data
4751 (
4752 p_rpt_data_type IN VARCHAR2
4753 ,p_output_to IN VARCHAR2
4754 ) IS
4755 l_api_name CONSTANT VARCHAR2(30) := 'rpt_debug_show_temp_data';
4756
4757 CURSOR l_cur_get_temp_data(lrpt_data_type jmf_shikyu_cfr_rpt_temp.rpt_data_type%TYPE) IS
4758 SELECT rpt_mode
4759 ,rpt_data_type
4760 ,oem_inv_org_id
4761 ,oem_inv_org_code
4762 ,oem_inv_org_name
4763 ,oem_inv_org_address
4764 ,supplier_id
4765 ,supplier_name
4766 ,site_id
4767 ,site_code
4768 ,site_address
4769 ,tp_inv_org_id
4770 ,tp_inv_org_code
4771 ,project_id
4772 ,project_num
4773 ,task_id
4774 ,task_num
4775 ,item_id
4776 ,item_number
4777 ,item_description
4778 ,estimated_qty
4779 ,primary_uom
4780 ,shikyu_price
4781 ,currency_code
4782 ,uom
4783 ,item_cost
4784 ,functional_currency
4785 ,value1 --Qty in Primary UOM
4786 ,value2 --SHIKYU Price in Pri UOM and Pri Currency
4787 ,value3
4788 FROM jmf_shikyu_cfr_rpt_temp
4789 WHERE (lrpt_data_type IS NULL)
4790 OR (rpt_data_type = lrpt_data_type)
4791 ORDER BY rpt_mode
4792 ,rpt_data_type
4793 ,oem_inv_org_id
4794 ,supplier_id
4795 ,site_id;
4796
4797 l_rpt_mode jmf_shikyu_cfr_rpt_temp.rpt_mode%TYPE;
4798 l_rpt_data_type jmf_shikyu_cfr_rpt_temp.rpt_data_type%TYPE;
4799 l_oem_inv_org_id jmf_shikyu_cfr_rpt_temp.oem_inv_org_id%TYPE;
4800 l_oem_inv_org_code jmf_shikyu_cfr_rpt_temp.oem_inv_org_code%TYPE;
4801 l_oem_inv_org_name jmf_shikyu_cfr_rpt_temp.oem_inv_org_name%TYPE;
4802 l_oem_inv_org_address jmf_shikyu_cfr_rpt_temp.oem_inv_org_address%TYPE;
4803 l_supplier_id jmf_shikyu_cfr_rpt_temp.supplier_id%TYPE;
4804 l_supplier_name jmf_shikyu_cfr_rpt_temp.supplier_name%TYPE;
4805 l_site_id jmf_shikyu_cfr_rpt_temp.site_id%TYPE;
4806 l_site_code jmf_shikyu_cfr_rpt_temp.site_code%TYPE;
4807 l_site_address jmf_shikyu_cfr_rpt_temp.site_address%TYPE;
4808 l_tp_inv_org_id jmf_shikyu_cfr_rpt_temp.tp_inv_org_id%TYPE;
4809 l_tp_inv_org_code jmf_shikyu_cfr_rpt_temp.tp_inv_org_code%TYPE;
4810 l_project_id jmf_shikyu_cfr_rpt_temp.project_id%TYPE;
4811 l_project_num jmf_shikyu_cfr_rpt_temp.project_num%TYPE;
4812 l_task_id jmf_shikyu_cfr_rpt_temp.task_id%TYPE;
4813 l_task_num jmf_shikyu_cfr_rpt_temp.task_num%TYPE;
4814 l_item_id jmf_shikyu_cfr_rpt_temp.item_id%TYPE;
4815 l_item_number jmf_shikyu_cfr_rpt_temp.item_number%TYPE;
4816 l_item_description jmf_shikyu_cfr_rpt_temp.item_description%TYPE;
4817 l_estimated_qty jmf_shikyu_cfr_rpt_temp.estimated_qty%TYPE;
4818 l_primary_uom jmf_shikyu_cfr_rpt_temp.primary_uom%TYPE;
4819 l_shikyu_price jmf_shikyu_cfr_rpt_temp.shikyu_price%TYPE;
4820 l_currency_code jmf_shikyu_cfr_rpt_temp.currency_code%TYPE;
4821 l_uom jmf_shikyu_cfr_rpt_temp.uom%TYPE;
4822 l_item_cost jmf_shikyu_cfr_rpt_temp.item_cost%TYPE;
4823 l_functional_currency jmf_shikyu_cfr_rpt_temp.functional_currency%TYPE;
4824 l_value1 jmf_shikyu_cfr_rpt_temp.value1%TYPE;
4825 l_value2 jmf_shikyu_cfr_rpt_temp.value2%TYPE;
4826 l_value3 jmf_shikyu_cfr_rpt_temp.value3%TYPE;
4827
4828 BEGIN
4829 -- **** for debug information in readonly UT environment.--- begin ****
4830 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4831 ,p_api_name => G_MODULE_PREFIX ||
4832 l_api_name
4833 ,p_message => '==jmf_shikyu_cfr_rpt_temp data Begin==');
4834 -- **** for debug information in readonly UT environment.--- end ****
4835 OPEN l_cur_get_temp_data(p_rpt_data_type);
4836 LOOP
4837 --print the data in l_cur_get_mid_temp_data
4838 FETCH l_cur_get_temp_data
4839 INTO l_rpt_mode
4840 ,l_rpt_data_type
4841 ,l_oem_inv_org_id
4842 ,l_oem_inv_org_code
4843 ,l_oem_inv_org_name
4844 ,l_oem_inv_org_address
4845 ,l_supplier_id
4846 ,l_supplier_name
4847 ,l_site_id
4848 ,l_site_code
4849 ,l_site_address
4850 ,l_tp_inv_org_id
4851 ,l_tp_inv_org_code
4852 ,l_project_id
4853 ,l_project_num
4854 ,l_task_id
4855 ,l_task_num
4856 ,l_item_id
4857 ,l_item_number
4858 ,l_item_description
4859 ,l_estimated_qty
4860 ,l_primary_uom
4861 ,l_shikyu_price
4862 ,l_currency_code
4863 ,l_uom
4864 ,l_item_cost
4865 ,l_functional_currency
4866 ,l_value1
4867 ,l_value2
4868 ,l_value3;
4869
4870 EXIT WHEN l_cur_get_temp_data%NOTFOUND;
4871
4872 -- **** for debug information in readonly UT environment.--- begin ****
4873 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4874 ,p_api_name => G_MODULE_PREFIX ||
4875 l_api_name
4876 ,p_message => 'jmf_shikyu_cfr_rpt_temp:' ||
4877 ';rpt_mode[' ||
4878 l_rpt_mode || ']' ||
4879 ';rpt_data_type[' ||
4880 l_rpt_data_type || ']' ||
4881 ';oem_inv_org_id[' ||
4882 l_oem_inv_org_id || ']' ||
4883 ';oem_inv_org_code[' ||
4884 l_oem_inv_org_code || ']' ||
4885 ';oem_inv_org_name[' ||
4886 l_oem_inv_org_name || ']' ||
4887 ';oem_inv_org_address[' ||
4888 l_oem_inv_org_address || ']' ||
4889 ';supplier_id[' ||
4890 l_supplier_id || ']' ||
4891 ';supplier_name[' ||
4892 l_supplier_name || ']' ||
4893 ';site_id[' ||
4894 l_site_id || ']' ||
4895 ';site_code[' ||
4896 l_site_code || ']' ||
4897 ';site_address[' ||
4898 l_site_address || ']' ||
4899 ';tp_inv_org_id[' ||
4900 l_tp_inv_org_id || ']' ||
4901 ';tp_inv_org_code[' ||
4902 l_tp_inv_org_code || ']' ||
4903 ';project_id[' ||
4904 l_project_id || ']' ||
4905 ';project_num[' ||
4906 l_project_num || ']' ||
4907 ';task_id[' ||
4908 l_task_id || ']' ||
4909 ';task_num[' ||
4910 l_task_num || ']' ||
4911 ';item_id[' ||
4912 l_item_id || ']' ||
4913 ';item_number[' ||
4914 l_item_number || ']' ||
4915 ';item_description[' ||
4916 l_item_description || ']' ||
4917 ';estimated_qty[' ||
4918 l_estimated_qty || ']' ||
4919 ';primary_uom[' ||
4920 l_primary_uom || ']' ||
4921 ';shikyu_price[' ||
4922 l_shikyu_price || ']' ||
4923 ';currency_code[' ||
4924 l_currency_code || ']' ||
4925 ';uom[' || l_uom || ']' ||
4926 ';item_cost[' ||
4927 l_item_cost || ']' ||
4928 ';functional_currency[' ||
4929 l_functional_currency || ']' ||
4930 ';value1[' || l_value1 || ']' ||
4931 ';value2[' || l_value2 || ']' ||
4932 ';value3[' || l_value3 || ']');
4933 -- **** for debug information in readonly UT environment.--- end ****
4934
4935 END LOOP; --end loop of l_cur_get_mid_temp_data
4936 CLOSE l_cur_get_temp_data;
4937
4938 -- **** for debug information in readonly UT environment.--- begin ****
4939 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4940 ,p_api_name => G_MODULE_PREFIX ||
4941 l_api_name
4942 ,p_message => '==jmf_shikyu_cfr_rpt_temp data end==');
4943 -- **** for debug information in readonly UT environment.--- end ****
4944
4945 IF g_fnd_debug = 'Y'
4946 AND FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL
4947 THEN
4948 fnd_log.STRING(FND_LOG.LEVEL_PROCEDURE
4949 ,g_module_prefix || l_api_name || '.end'
4950 ,NULL);
4951 END IF;
4952 EXCEPTION
4953 WHEN NO_DATA_FOUND THEN
4954 -- raise log message;
4955 NULL;
4956
4957 WHEN OTHERS THEN
4958 -- **** for debug information in readonly UT environment.--- begin ****
4959 JMF_SHIKYU_RPT_UTIL.debug_output(p_output_to => p_output_to
4960 ,p_api_name => G_MODULE_PREFIX ||
4961 l_api_name ||
4962 '.Exception'
4963 ,p_message => SQLERRM);
4964 -- **** for debug information in readonly UT environment.--- end ****
4965
4966 END rpt_debug_show_temp_data;
4967
4968 END JMF_SHIKYU_RPT_CFR_PVT;