DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_RESCHEDULE_PKG

Source


1 PACKAGE BODY po_reschedule_pkg as
2 /* $Header: POXRSCHB.pls 120.2.12010000.2 2008/08/04 08:32:15 rramasam ship $ */
3 
4 -- Read the profile option that enables/disables the debug log
5 g_fnd_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
6 
7 g_pkg_name       CONSTANT VARCHAR2(30) := 'PO_RESCHEDULE_PKG';
8 g_module_prefix  CONSTANT VARCHAR2(40) := 'po.plsql.' || g_pkg_name || '.';
9 
10 -- START Forward declarations for private procedures:
11 PROCEDURE add_error_to_msg_list (
12   p_api_name VARCHAR2,
13   p_message  VARCHAR2
14 );
15 -- END Forward declarations for private procedures
16 
17 -- <APS FPJ START>
18 g_debug_stmt  CONSTANT BOOLEAN := PO_DEBUG.is_debug_stmt_on;
19 g_debug_unexp CONSTANT BOOLEAN := PO_DEBUG.is_debug_unexp_on;
20 
21 -- Forward declare private procedure po_reschedule_req
22 PROCEDURE PO_RESCHEDULE_REQ (
23     p_line_location_id_tbl   IN         po_tbl_number,
24     p_estimated_pickup_dates IN         po_tbl_date,
25     p_ship_methods           IN         po_tbl_varchar30,
26     x_return_status	     OUT NOCOPY VARCHAR2
27 ); -- Bug 5255550
28 -- <APS FPJ END>
29 -- 2279541  added new parameter x_shipment_num
30 -- bug 5255550 : Overloaded the reschedule API for backward compatibility
31 Function RESCHEDULE (
32        X_need_by_date_old date,
33         X_need_by_date date,
34         X_po_header_id number,
35         X_po_line_id number,
36         X_supply_number varchar2,
37         X_shipment_num number,
38         p_estimated_pickup_date DATE,
39         p_ship_method VARCHAR2
40     ) Return boolean IS
41 
42         l_need_by_dates_old 	   po_tbl_date;
43         l_need_by_dates 	   po_tbl_date;
44         l_po_line_ids 		   po_tbl_number;
45         l_shipment_nums 	   po_tbl_number;
46         l_estimated_pickup_dates   po_tbl_date;
47         l_ship_methods		   po_tbl_varchar30;
48         l_api_name     		   CONSTANT VARCHAR2(30) := 'RESCHEDULE';
49         l_result 		   BOOLEAN;
50 
51 BEGIN
52 
53     SELECT X_need_by_date_old,
54 	   X_need_by_date,
55 	   X_po_line_id
56 	   /*  Bug 5610714 ,
57 	   X_shipment_num,
58 	   p_estimated_pickup_date,
59 	   p_ship_method */
60     BULK COLLECT INTO
61            l_need_by_dates_old,
62            l_need_by_dates,
63            l_po_line_ids
64 	   /*  Bug 5610714,
65            l_shipment_nums,
66 	   l_estimated_pickup_dates,
67 	   l_ship_methods */
68      FROM  DUAL;
69 
70 IF X_shipment_num IS NOT NULL THEN
71 -- 5610714 Initialize the Collection with the parameter value
72 	l_shipment_nums := po_tbl_number(X_shipment_num);
73 END IF;
74 
75 IF p_estimated_pickup_date IS NOT NULL THEN
76 -- 5610714 Initialize the Collection with the parameter value
77 	l_estimated_pickup_dates := po_tbl_date(p_estimated_pickup_date);
78 END IF;
79 
80 IF p_ship_method IS NOT NULL THEN
81 -- 5610714 Initialize the Collection with the parameter value
82 	l_ship_methods := po_tbl_varchar30(p_ship_method);
83 END IF;
84 
85 
86 l_result:=  RESCHEDULE(X_need_by_dates_old => l_need_by_dates_old,
87 	     	   X_need_by_dates     => l_need_by_dates,
88 		       X_po_header_id 	   => X_po_header_id,
89 		       X_po_line_ids	     => l_po_line_ids,
90 		       X_supply_number	   => X_supply_number,
91 		       X_shipment_nums	   => l_shipment_nums,
92 		       p_estimated_pickup_dates =>l_estimated_pickup_dates,
93 		       p_ship_methods	     => l_ship_methods);
94 
95 RETURN(l_result);
96 
97 EXCEPTION
98 WHEN OTHERS THEN
99    	 add_error_to_msg_list ( p_api_name => l_api_name,
100                                  p_message => 'An exception Occurred ');
101      RAISE FND_API.G_EXC_ERROR;
102 END;
103 
104 
105 -- bug 5255550 : Reschedule API rewrite
106 -- Previously, the reschedule api was called once per line by APS.
107 -- This was not only performance intensive, but also made the reschedule
108 -- program to fail, since approval launched on the first call to resched.
109 -- api might put the doc in 'IN PROCESS' state due to which the
110 -- successive calls might not be able to make any modifications to the doc.
111 -- Now APS will pass all the lines/shipments for 1 PO/Release at once.
112 
113 -- 2279541  added new parameter x_shipment_num
114 Function RESCHEDULE (
115 		                  X_need_by_dates_old 	   po_tbl_date,
116 	                    X_need_by_dates 	       po_tbl_date,
117 	                    X_po_header_id	  	     number,
118                       X_po_line_ids 		       po_tbl_number,
119                       X_supply_number 	       VARCHAR2,
120                       X_shipment_nums 	       po_tbl_number,
121                       p_estimated_pickup_dates po_tbl_date,
122                       p_ship_methods		       po_tbl_varchar30
123 ) Return boolean IS
124 
125 l_po_release_id         number;
126 X_po_type               varchar2(25) := 'RELEASE';
127 x_progress    		      varchar2(300);
128 x_pare_right            number;
129 x_pare_left             number;
130 x_release_num           number;
131 
132 -- <PO_CHANGE_API FPJ START>
133 -- In 115.13, modified the PO Reschedule API to call the PO Change API
134 -- instead of updating the database tables directly.
135 -- Bug 5255550
136 l_original_org_context  VARCHAR2(10) := null;
137 l_document_org_id       NUMBER;
138 l_changes               PO_CHANGES_REC_TYPE;
139 l_shipment_changes      PO_SHIPMENTS_REC_TYPE;
140 l_line_location_id_tbl  PO_TBL_NUMBER;
141 l_need_by_date_tbl      PO_TBL_DATE;
142 l_nbd_validate_tbl      PO_TBL_VARCHAR2000:=NULL;
143 l_return_status         VARCHAR2(1);
144 l_api_errors            PO_API_ERRORS_REC_TYPE;
145 l_release_type          PO_RELEASES_ALL.RELEASE_TYPE%TYPE;
146 l_session_gt_key        NUMBER;
147 l_api_name     CONSTANT VARCHAR2(30) := 'RESCHEDULE';
148 l_log_head CONSTANT VARCHAR2(100):= g_module_prefix||l_api_name;
149 l_progress              VARCHAR2(3):='000';
150 l_promised_by_date_tbl  PO_TBL_DATE; --Bug5633563
151 l_need_by_promise_def_prf  VARCHAR2(1); --Bug5633563
152 -- <PO_CHANGE_API FPJ END>
153 
154 
155 BEGIN
156 --Bug 5255550
157 
158 -- Step1 get the release id from x_supply number into l_po_release_id;
159 -- debug <Start>
160   po_debug.debug_begin(l_log_head);
161 -- debug <End>
162 
163  select instr(x_supply_number, '(')
164   into   x_pare_left
165   from   dual;
166 
167   if x_pare_left <= 0 then
168      X_po_type := 'PO';
169   ELSE
170      x_po_type := 'RELEASE';
171   end if;
172   -- debug <START>
173   PO_DEBUG.debug_var(l_log_head,l_progress,'x_po_type', x_po_type);
174   -- debug <END>
175 
176 l_progress:= '010';
177   if X_po_type <> 'PO' then
178     -- Get the index of ')' in the supply number
179     select instr(x_supply_number, ')')
180     into   x_pare_right
181     from   dual;
182 
183     if x_pare_right <=0 then
184       -- No ending parentheis.
185       add_error_to_msg_list (
186         p_api_name => l_api_name,
187         p_message => 'Incorrect format for supply number: '||x_supply_number
188       );
189       RAISE FND_API.G_EXC_ERROR;
190     end if;
191 
192     select to_number(substr(x_supply_number, x_pare_left+1,
193            x_pare_right - x_pare_left-1))
194     into   x_release_num
195     from   dual;
196 
197 
198    l_progress:= '020';
199    -- debug <START>
200    PO_DEBUG.debug_var(l_log_head,l_progress,'x_release_num', x_release_num);
201    -- debug <END>
202 
203     begin
204       -- Get the po_release_id out of supply_number
205       select po_release_id,release_type
206       into   l_po_release_id,l_release_type
207       from   po_releases_all
208       where  po_header_id = x_po_header_id
209       and  release_num  = x_release_num;
210 
211    l_progress:= '030';
212    -- debug <START>
213    PO_DEBUG.debug_var(l_log_head,l_progress,'l_po_release_id', l_po_release_id);
214    -- debug <END>
215 
216     exception
217       when no_data_found then
218         -- Wrong format for supply number
219         add_error_to_msg_list (
220           p_api_name => l_api_name,
221           p_message => 'Incorrect format for supply number: '||x_supply_number
222         );
223         RAISE FND_API.G_EXC_ERROR;
224     end;
225   end if;
226 
227   l_progress:= '040';
228 /* Step 2: save the existing org_context. get the org_id from
229    po_header_id and set the context to this org_id */
230  l_original_org_context := PO_MOAC_UTILS_PVT.get_current_org_id ; -- <R12 MOAC>
231 
232   -- debug <START>
233   PO_DEBUG.debug_var(l_log_head,l_progress,'l_original_org_context', l_original_org_context);
234   -- debug <END>
235 
236   --Bug 5255550
237   BEGIN
238     -- Retrieve the document's operating unit.
239     IF (x_po_type = 'RELEASE') THEN
240       SELECT org_id
241       INTO l_document_org_id
242       FROM po_releases_all
243       WHERE po_release_id = l_po_release_id;/*Bug 5255550*/
244     ELSE -- PO
245       SELECT org_id
246       INTO l_document_org_id
247       FROM po_headers_all
248       WHERE po_header_id = x_po_header_id;
249     END IF; -- x_po_type
250 
251   l_progress:= '050';
252   -- debug <START>
253   PO_DEBUG.debug_var(l_log_head,l_progress,'l_document_org_id', l_document_org_id);
254   -- debug <END>
255 
256   -- Set the org context to the document's OU.
257     PO_MOAC_UTILS_PVT.set_org_context(l_document_org_id) ;       -- <R12 MOAC>
258   EXCEPTION
259     WHEN NO_DATA_FOUND THEN
260       add_error_to_msg_list (
261         p_api_name => l_api_name,
262         p_message => 'Could not obtain the document operating unit.'
263       );
264       RAISE FND_API.G_EXC_ERROR;
265   END;
266    /*STEP 3: get all the shipments */
267 
268  /* It is not possible to use forall, and bulk collect simultaneously.
269     Hence for performance reasons, we will use scratch pad, to insert data
270    and then use bulk collect to get all the data in plsql table*/
271 
272 
273 /* If l_po_release_id is present, it means that the document is a release */
274 l_session_gt_key := PO_CORE_S.get_session_gt_nextval();
275 
276 l_progress:= '060';
277   -- debug <START>
278   PO_DEBUG.debug_var(l_log_head,l_progress,'l_session_gt_key', l_session_gt_key);
279   -- debug <END>
280 
281 -- Bug 5610714 replacing x_shipment_nums.Count with X_po_line_ids.Count as x_shipment_nums can be Null
282 -- Bug 5610714 Added the following If Condition to handle the issue of passing x_shipment_nums as Null.
283 -- x_shipment_nums(1) will be Null if this call is routed thru overloaded RESCHEDULE api.
284 
285 If x_shipment_nums is Null then
286 	forall i in 1..X_po_line_ids.Count
287 
288 
289 	/*
290 	  po_session_gt map:
291 	  KEY  : unique key for the current session processing
292 	  NUM1 : line_location_id
293 	  NUM2 : shipment_num
294 	  DATE1: db dates in po_line_locations_all
295 	  DATE2: new need by dates passed in
296 	  CHAR1: old need by dates passed in ,
297 		 using the char field since session_gt has only 2 date columns
298 	  CHAR2: indicates a valid record
299 
300 	  */
301 
302 	    insert into po_session_gt (key,
303 				       num1,
304 				       num2,
305 				       date1,
306 				       date2,
307 				       char1, -- we're using this for date passed in.
308 				       char2  -- we're using this to mark a valid record
309 				       )
310 	    select l_session_gt_key,
311 		   pll.line_location_id,
312 		   pll.shipment_num,
313 		   -- Have picked this from the existing code. From the planning perspective
314 		   -- promised date becomes important and should be preferred over nbd
315 		   Nvl(pll.promised_date,pll.need_by_date),
316 		   X_need_by_dates(i),
317 		   To_Char(X_need_by_dates_old(i),'DD-MON-YYYY:hh:mi:ss'),
318 		   'Y'
319 	      from po_line_locations_all pll
320 	     where pll.po_line_id = X_po_line_ids(i)
321 	       and pll.po_header_id = X_po_header_id
322 	       and (l_po_release_id is NULL OR
323 				pll.po_release_id = l_po_release_id);
324 
325 ELSE
326 	forall i in 1..X_po_line_ids.Count
327 
328 	/*
329 	  po_session_gt map:
330 	  KEY  : unique key for the current session processing
331 	  NUM1 : line_location_id
332 	  NUM2 : shipment_num
333 	  DATE1: db dates in po_line_locations_all
334 	  DATE2: new need by dates passed in
335 	  CHAR1: old need by dates passed in ,
336 		 using the char field since session_gt has only 2 date columns
337 	  CHAR2: indicates a valid record
338 
339 	  */
340 
341 	    insert into po_session_gt (key,
342 				       num1,
343 				       num2,
344 				       date1,
345 				       date2,
346 				       char1, -- we're using this for date passed in.
347 				       char2  -- we're using this to mark a valid record
348 				       )
349 	    select l_session_gt_key,
350 		   pll.line_location_id,
351 		   X_shipment_nums(i),
352 		   -- Have picked this from the existing code. From the planning perspective
353 		   -- promised date becomes important and should be preferred over nbd
354 		   Nvl(pll.promised_date,pll.need_by_date),
355 		   X_need_by_dates(i),
356 		   To_Char(X_need_by_dates_old(i),'DD-MON-YYYY:hh:mi:ss'),
357 		   'Y'
358 	      from po_line_locations_all pll
359 	     where pll.po_line_id = X_po_line_ids(i)
360 	       and pll.shipment_num = Nvl(X_shipment_nums(i), pll.shipment_num)
361 	       and pll.po_header_id = X_po_header_id
362 	       and (l_po_release_id is NULL OR
363 				pll.po_release_id = l_po_release_id);
364 End If;   -- End Of Bug 5610714
365 
366 
367 
368 --Validations <START>
369 
370 -- Validation #1 : Old Need by date passed and the db need by date should
371 --                 Match
372 
373 l_progress:= '070';
374 UPDATE po_session_gt scratch
375 SET char2 = 'N'
376 WHERE  scratch.char1 <>
377                 To_char(scratch.date1,'DD-MON-YYYY:hh:mi:ss')
378   AND scratch.KEY = l_session_gt_key;
379 
380  l_progress:= '080';
381 SELECT 'Supply Number '||x_supply_number||' Shipment Number '
382        ||to_char(scratch.num2)||': Need by date does not match the date passed in'
383 BULK collect INTO l_nbd_validate_tbl
384 FROM po_session_gt scratch
385 WHERE scratch.KEY = l_session_gt_key
386   AND Nvl(scratch.char2,'Y') = 'N';
387 
388   IF (l_nbd_validate_tbl IS NOT NULL) then
389    FOR i IN 1..l_nbd_validate_tbl.COUNT LOOP
390       add_error_to_msg_list ( p_api_name => l_api_name,
391                               p_message => l_nbd_validate_tbl(i) );
392     END LOOP;
393   END IF;
394 
395     l_nbd_validate_tbl := NULL;
396 
397 -- Validation 2: New need by date should not be NULL
398  l_progress:= '090';
399 UPDATE po_session_gt scratch
400 SET char2 = 'N'
401 WHERE  scratch.date2 IS NULL
402   AND scratch.KEY = l_session_gt_key;
403 
404 SELECT 'Supply Number '||x_supply_number||' Shipment Number '
405        ||scratch.num2||': New Need by date is NULL'
406 BULK collect INTO l_nbd_validate_tbl
407 FROM po_session_gt scratch
408 WHERE scratch.KEY = l_session_gt_key
409   AND scratch.date2 IS NULL;
410 
411   IF (l_nbd_validate_tbl IS NOT NULL) then
412    FOR i IN 1..l_nbd_validate_tbl.COUNT LOOP
413       add_error_to_msg_list ( p_api_name => l_api_name,
414                               p_message => l_nbd_validate_tbl(i) );
415     END LOOP;
416   END IF;
417 
418 --Validations <END>
419 
420 /*Step 4: construct two tables one for shipments, and one for need_by_dates*/
421 l_progress:= '100';
422 
423 select num1, date2
424 bulk collect into l_line_location_id_tbl, l_need_by_date_tbl
425 from po_session_gt SCRATCH
426 WHERE KEY = l_session_gt_key
427 AND Nvl(scratch.char2,'Y') = 'Y' ;
428 /* Step 5:
429 
430 if p_estimate_date, p_ship_method is not null then call reschedule req
431     -- should be in the loop,
432     -- since one po/release can be linked to different reqs.*/
433 
434 -- should not do this for a scheduled release.
435 l_progress:= '110';
436 
437 l_progress:= '120';
438  IF ((p_estimated_pickup_dates IS NOT NULL) OR (p_ship_methods IS NOT NULL))
439     AND (Nvl(l_release_type,'PO') <> 'SCHEDULED') THEN
440 
441 l_progress:= '130';
442           PO_RESCHEDULE_REQ(
443               p_line_location_id_tbl      => l_line_location_id_tbl,
444               p_estimated_pickup_dates    => p_estimated_pickup_dates,
445               p_ship_methods              => p_ship_methods,
446               x_return_status             => l_return_status);
447 
448   -- debug <START>
449   PO_DEBUG.debug_var(l_log_head,l_progress,'l_return_status', l_return_status);
450   -- debug <END>
451 
452       IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
453           RAISE FND_API.G_EXC_ERROR;
454       END IF;
455   END IF;
456 -- Construct the shipment changes object.
457   /*Bug 5633563
458   If profile option PO: Default PO Promise Date from Need By Date
459   is set then new need_by_date must be copied to promised_by_date
460  */
461   fnd_profile.get('PO_NEED_BY_PROMISE_DEFAULTING', l_need_by_promise_def_prf);
462   IF nvl(l_need_by_promise_def_prf,'N') = 'Y' THEN
463     l_promised_by_date_tbl := PO_TBL_DATE();
464     select date2
465     bulk collect into l_promised_by_date_tbl
466     from po_session_gt SCRATCH
467     WHERE KEY = l_session_gt_key
468     AND Nvl(scratch.char2,'Y') = 'Y' ;
469     l_shipment_changes := PO_SHIPMENTS_REC_TYPE.create_object (
470     p_po_line_location_id => l_line_location_id_tbl,
471     p_need_by_date => l_need_by_date_tbl,
472     p_promised_date=> l_promised_by_date_tbl
473     );
474   ELSE
475     l_shipment_changes := PO_SHIPMENTS_REC_TYPE.create_object (
476     p_po_line_location_id => l_line_location_id_tbl,
477     p_need_by_date => l_need_by_date_tbl
478     );
479   END IF;
480   /*Bug 5633563 :old code
481     l_shipment_changes := PO_SHIPMENTS_REC_TYPE.create_object (
482     p_po_line_location_id => l_line_location_id_tbl,
483     p_need_by_date => l_need_by_date_tbl
484   );5633563*/
485 
486   -- Construct the document changes object.
487   l_changes := PO_CHANGES_REC_TYPE.create_object (
488     p_po_header_id => x_po_header_id,
489     p_po_release_id => l_po_release_id,
490     p_shipment_changes => l_shipment_changes
491   );
492 
493 /*Step 7: Call update_documents; */
494 l_progress:= '150';
495 PO_DOCUMENT_UPDATE_PVT.update_document(
496     p_api_version => 1.0,
497     p_init_msg_list => FND_API.G_TRUE,
498     x_return_status => l_return_status,
499     p_changes => l_changes,
500     p_run_submission_checks => FND_API.G_FALSE,
501     p_launch_approvals_flag => FND_API.G_TRUE,
502     p_buyer_id => NULL,
503     p_update_source => NULL,
504     p_override_date => NULL,
505     x_api_errors => l_api_errors
506   );
507 
508 l_progress:= '160';
509  /* Step 8: add the errors to the error list.*/
510   -- debug <START>
511   PO_DEBUG.debug_stmt(l_log_head,l_progress,'After return from update document');
512   PO_DEBUG.debug_var(l_log_head,l_progress,'l_return_status', l_return_status);
513   -- debug <END>
514 
515   IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
516     -- PO Change API returned some errors. Add them to the API message list.
517     FND_MSG_PUB.initialize;
518     FOR i IN 1..l_api_errors.message_text.COUNT LOOP
519       add_error_to_msg_list ( p_api_name => l_api_name,
520                               p_message => l_api_errors.message_text(i) );
521     END LOOP;
522     RAISE FND_API.G_EXC_ERROR;
523   END IF;
524 
525 l_progress:= '160';
526   -- debug <START>
527   PO_DEBUG.debug_stmt(l_log_head,l_progress,'setting the context back to '
528                       ||l_original_org_context);
529    -- debug <END>
530  /* Step 9: set the context back to the orginal context.*/
531   PO_MOAC_UTILS_PVT.set_org_context(l_original_org_context) ;       -- <R12 MOAC>
532 
533   /* Delete all the data from po_session_gt */
534 l_progress:= '170';
535 
536   -- debug <START>
537   PO_DEBUG.debug_stmt(l_log_head,l_progress,'Deleting data from session gt '
538                       );
539    -- debug <END>
540 
541   DELETE FROM po_session_gt
542   WHERE KEY = l_session_gt_key;
543 
544  /*Step 10 : return from the api */
545   PO_DEBUG.debug_end(l_log_head);
546   return TRUE;
547 
548 
549 EXCEPTION
550   WHEN FND_API.G_EXC_ERROR THEN
551     -- Set the org context back to the original operating unit.
552     IF (l_original_org_context IS NOT NULL) THEN
553       PO_MOAC_UTILS_PVT.set_org_context(l_original_org_context) ;       -- <R12 MOAC>
554     END IF;
555     DELETE FROM po_session_gt
556     WHERE KEY = l_session_gt_key;
557     RETURN FALSE;
558 
559   WHEN OTHERS THEN
560       DELETE FROM po_session_gt
561       WHERE KEY = l_session_gt_key;
562       IF (l_original_org_context IS NOT NULL) THEN
563          FND_CLIENT_INFO.set_org_context(l_original_org_context);
564       END IF;
565 
566 END RESCHEDULE;
567 
568 
569 
570 -------------------------------------------------------------------------------
571 --Start of Comments
572 --Name: reschedule_req
573 --Function:
574 --Pre-reqs:
575 --  None.
576 --Modifies:
577 --  po_requistion_lines_all
578 --Locks:
579 --  None.
580 --  1. Given release_id and possible shipment_num, query out the backing
581 --   requistion lines and update them with new estimated_pickup_date and
582 --   ship_method.
583 --  2. Given po_line_id and possible shipment_num, query out the backing
584 --   requistion lines and update them with new estimated_pickup_date and
585 --   ship_method.
586 --IN:
587 --l_line_location_id_tbl
588 --  Specifies collection of line_location_ids
589 --p_estimated_pickup_date
590 --  Specifies new estimated_pickup_dates.
591 --p_ship_method
592 --  Sepcifies new ship_methods.
593 --OUT:
594 --x_return_status
595 --  Indicates API return status as 'S' or 'U'.
596 --End of Comments
597 -------------------------------------------------------------------------------
598 PROCEDURE PO_RESCHEDULE_REQ (
599     p_line_location_id_tbl   IN         po_tbl_number,
600     p_estimated_pickup_dates IN         po_tbl_date,
601     p_ship_methods           IN         po_tbl_varchar30,
602     x_return_status         OUT NOCOPY VARCHAR2
603 ) IS
604 l_api_name CONSTANT VARCHAR2(30) := 'PO_RESCHEDULE_REQ';
605 l_log_head CONSTANT VARCHAR2(200) := g_module_prefix || l_api_name;
606 l_progress          VARCHAR2(3);
607 BEGIN
608 -- Bug 5255550
609     x_return_status := FND_API.G_RET_STS_SUCCESS;
610     l_progress:= '000';
611     PO_DEBUG.debug_begin(l_log_head);
612 
613         --SQL What: line_location_id, query out
614         --SQL       the backing requistion lines and update them with new
615         --SQL       estimated_pickup_dates and ship_methods
616         --SQL Where:all req lines associated to the shipments, and having
617         --SQL       estimated_pickup_dates, ship_methods.
618         --SQL Why: Same as SQL What
619 
620         forall i in 1..p_line_location_id_tbl.count
621         UPDATE po_requisition_lines_all REQ
622            SET REQ.estimated_pickup_date =
623                    NVL(p_estimated_pickup_dates(i), REQ.estimated_pickup_date),
624                REQ.ship_method = NVL(p_ship_methods(i), REQ.ship_method)
625          WHERE REQ.line_location_id = p_line_location_id_tbl(i);
626 
627 l_progress:= '020';
628 
629 PO_DEBUG.debug_end(l_log_head);
630 
631 EXCEPTION
632     WHEN OTHERS THEN
633         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
634         FND_MSG_PUB.initialize;
635         add_error_to_msg_list (
636             p_api_name => l_api_name,
637             p_message  => 'Can not update estimated_pickup_date and ship_method on requisitions');
638 
639         IF (g_debug_unexp) THEN
640             PO_DEBUG.debug_exc (
641                 p_log_head => l_log_head,
642                 p_progress => l_progress || 'with sqlcode' || sqlcode);
643         END IF;
644 
645 END PO_RESCHEDULE_REQ;
646 -- <APS FPJ END>
647 
648 -- <PO_CHANGE_API FPJ START>
649 -------------------------------------------------------------------------------
650 --Start of Comments
651 --Name: add_error_to_msg_list
652 --Function:
653 --  Adds the given error message to the standard API message list and
654 --  to the FND log, if enabled.
655 --End of Comments
656 -------------------------------------------------------------------------------
657 PROCEDURE add_error_to_msg_list (
658   p_api_name VARCHAR2,
659   p_message  VARCHAR2
660 ) IS
661 BEGIN
662   -- Add a generic error to the API message list.
663   FND_MESSAGE.set_name ('PO', 'PO_GENERIC_ERROR');
664   FND_MESSAGE.set_token ('ERROR_TEXT', p_message);
665   FND_MSG_PUB.add;
666 
667   -- Also add it to the FND log, if enabled.
668   IF (g_fnd_debug = 'Y') THEN
669     IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL <= FND_LOG.LEVEL_ERROR) THEN
670       FND_LOG.string( FND_LOG.LEVEL_ERROR, g_module_prefix || p_api_name,
671                     p_message);
672     END IF;
673   END IF;
674 END add_error_to_msg_list;
675 -- <PO_CHANGE_API FPJ END>
676 
677 -- <PO_CHANGE_API FPJ START>
678 -- In 115.13, removed the following private procedures from this package,
679 -- because their functionality is now handled by the PO Change API:
680 --   update_po_tables, update_po_tables_rel, check_revision_number,
681 --   wf_approve_doc, SetupWorkflow
682 -- <PO_CHANGE_API FPJ END>
683 
684 END PO_RESCHEDULE_PKG;
685 
686