DBA Data[Home] [Help]

PACKAGE BODY: APPS.RCV_TRANSACTION_SV

Source


1 PACKAGE BODY RCV_TRANSACTION_SV AS
2 /* $Header: RCVTXPQB.pls 120.5.12010000.2 2008/08/04 08:43:06 rramasam ship $ */
3 
4 PROCEDURE DISTRIBUTION_DETAIL( x_rcv_transaction_id           IN NUMBER,
5                                x_destination_type_code       OUT NOCOPY VARCHAR2,
6                                x_destination_context         OUT NOCOPY VARCHAR2,
7                                x_destination_type_dsp        OUT NOCOPY VARCHAR2,
8                                x_wip_entity_id               OUT NOCOPY NUMBER,
9                                x_wip_line_id                 OUT NOCOPY NUMBER,
10                                x_wip_repetitive_schedule_id  OUT NOCOPY NUMBER,
11                                x_deliver_to_person_id        OUT NOCOPY NUMBER,
12                                x_deliver_to_location_id      OUT NOCOPY NUMBER,
13                                x_po_distribution_id          OUT NOCOPY NUMBER,
14                                v_currency_conv_rate          IN OUT NOCOPY NUMBER,
15                                v_currency_conv_date          IN OUT NOCOPY DATE,
16 -- <RCV ENH FPI START>
17                                x_kanban_card_number     OUT NOCOPY VARCHAR2,
18                                x_project_number         OUT NOCOPY VARCHAR2,
19                                x_task_number            OUT NOCOPY VARCHAR2,
20                                x_charge_account         OUT NOCOPY VARCHAR2) is
21 -- <RCV ENH FPI END>
22 
23 
24   x_progress  VARCHAR2(3) := NULL;
25 
26 -- <RCV ENH FPI START>
27   l_code_combination_id PO_DISTRIBUTIONS.code_combination_id%TYPE;
28 -- <RCV ENH FPI END>
29 
30 x_project_id   PO_DISTRIBUTIONS.project_id%type; -- bug 5220069
31 x_task_id      PO_DISTRIBUTIONS.task_id%type;    -- bug 5220069
32 begin
33   x_progress := 10;
34 
35   /* Bug 4753498: Replaced pa_tasks_expend_v with pa_tasks in following query */
36 
37   select pod.destination_type_code,
38          pod.destination_type_code,
39          plc.displayed_field,
40          pod.wip_entity_id,
41          pod.wip_line_id,
42          pod.wip_repetitive_schedule_id,
43          pod.deliver_to_person_id,
44          pod.deliver_to_location_id,
45          pod.po_distribution_id,
46          round(pod.rate,28),   -- Bug 409020
47          pod.rate_date, -- Bug 409020
48          mkc.kanban_card_number,  -- <RCV ENH FPI>
49          pod.project_id,          -- bug 5220069
50          pod.task_id,             -- bug 5220069
51          pod.code_combination_id
52   into   x_destination_type_code,
53          x_destination_context,
54          x_destination_type_dsp,
55          x_wip_entity_id,
56          x_wip_line_id,
57          x_wip_repetitive_schedule_id,
58          x_deliver_to_person_id,
59          x_deliver_to_location_id,
60          x_po_distribution_id,
61          v_currency_conv_rate,
62          v_currency_conv_date,
63          x_kanban_card_number,   -- <RCV ENH FPI>
64          x_project_id,       -- bug 5220069
65          x_task_id,          -- bug 5220069
66          l_code_combination_id   -- <RCV ENH FPI>
67   from   po_distributions pod,
68          po_lookup_codes plc,
69          mtl_supply ms,
70          mtl_kanban_cards mkc   -- <RCV ENH FPI>
71   where  ms.supply_type_code    = 'RECEIVING'
72   and    ms.supply_source_id    = x_rcv_transaction_id
73   and    pod.po_distribution_id = ms.po_distribution_id
74   and    plc.lookup_type        = 'RCV DESTINATION TYPE'
75   and    plc.lookup_code        = pod.destination_type_code
76   AND    pod.kanban_card_id = mkc.kanban_card_id (+);    -- <RCV ENH FPI>
77 
78 -- <RCV ENH FPI START>
79   x_progress := 20;
80    /* Bug 5220069 START
81       Due to performance problems because of outer joins on project_id and
82       task_id related conditions in the above sql, writing a separate select
83       to retrieve the project and task numbers. This sql will be executed
84       only when project/task references are there in the PO distribution.
85    */
86 
87    x_project_number  := NULL;
88    x_task_number     := NULL;
89    IF (x_project_id is not null AND x_task_id is not null) THEN
90       BEGIN
91          x_progress  := 21;
92          select PPA.SEGMENT1 PROJECT_NUMBER ,
93                 PT.TASK_NUMBER
94          into   x_project_number,
95                 x_task_number
96          from   PA_PROJECTS_ALL PPA,
97                 PA_TASKS PT
98          where PPA.PROJECT_ID = PT.PROJECT_ID
99               and PPA.project_id = x_project_id
100               and PT.task_id = x_task_id;
101        EXCEPTION
102          WHEN NO_DATA_FOUND THEN
103             x_project_number  := NULL;
104             x_task_number     := NULL;
105        END;
106   END IF;
107 
108   x_progress  := 23;
109   IF x_project_id is not null AND x_project_number is null THEN --if x_project_number is still null then it could be in PJM_SEIBAN_NUMBERS
110      BEGIN
111         x_progress  := 25;
112         select PSN.PROJECT_NUMBER ,
113                NULL
114         into   x_project_number,
115                x_task_number
116         from   PJM_SEIBAN_NUMBERS PSN
117         where  PSN.project_id = x_project_id;
118      EXCEPTION
119        WHEN NO_DATA_FOUND THEN
120             x_project_number  := NULL;
121             x_task_number     := NULL;
122        END;
123   END IF;
124   x_progress  := 30;
125    /* Bug 5220069 END */
126 
127   x_charge_account :=
128       PO_COMPARE_REVISIONS.get_charge_account(l_code_combination_id);
129 -- <RCV ENH FPI END>
130 
131   EXCEPTION
132     when others then
133       po_message_s.sql_error('DISTRIBUTION_DETAIL',x_progress,sqlcode);
134       raise;
135 end DISTRIBUTION_DETAIL;
136 
137 FUNCTION GET_RECEIVING_DISPLAY_VALUE RETURN VARCHAR2 IS
138   x_receiving VARCHAR2(80);
139   x_progress  VARCHAR2(3) := NULL;
140 begin
141 
142   x_progress := 10;
143   select displayed_field
144   into   x_receiving
145   from   po_lookup_codes
146   where  lookup_type = 'RCV DESTINATION TYPE'
147   and    lookup_code = 'RECEIVING';
148 
149   RETURN(x_receiving);
150 
151   EXCEPTION
152    when others then
153      po_message_s.sql_error('GET_RECEIVING_DISPLAY_VALUE ',x_progress,sqlcode);
154      raise;
155 end GET_RECEIVING_DISPLAY_VALUE;
156 
157 FUNCTION GET_LOCATION (x_location_id  IN NUMBER, x_line_location_id IN NUMBER) RETURN VARCHAR2 IS
158 
159   x_progress      VARCHAR2(3) := NULL;
160 
161 /** PO UTF8 Column Expansion Project 9/23/2002 tpoon **/
162 /** Changed x_location_code to use %TYPE **/
163 --  x_location_code VARCHAR2(30);
164   x_location_code hr_locations_all.location_code%TYPE;
165 
166 /* bug2199615 */
167   x_oe_line_id    NUMBER;
168 BEGIN
169 
170 
171 /* bug fix : 2199615 - regression from 2288234
172    fix for 2288234 caused regression - removed lot of code from version 115.13
173    for clarity. Replaced bad code that caused regression with call to OE api to
174    check if drop_ship
175 */
176 
177   x_progress := 10;
178 
179   x_oe_line_id := OE_DROP_SHIP_GRP.PO_Line_Location_Is_Drop_Ship(x_line_location_id);
180 
181   IF (x_oe_line_id IS NOT NULL) THEN          /* drop ship */
182     SELECT substr(rtrim(address1) || '-' || rtrim(city),1,20)
183     INTO   x_location_code
184     FROM   hz_locations
185     WHERE  location_id = x_location_id;
186   ELSE                                   /* not a drop ship */
187     SELECT location_code
188     INTO   x_location_code
189     FROM   hr_locations
190     WHERE  location_id = x_location_id;
191   END IF;
192 
193   RETURN (x_location_code);
194 EXCEPTION
195 /*Begin Bug 3284237. Added the exception part.Drop ship created in 11.0 and then
196   customer upgraded to 11i*/
197   when no_data_found then
198     BEGIN
199      if (x_oe_line_id IS NOT NULL) THEN
200       select location_code
201       into  x_location_code
202       from  hr_locations
203       where  location_id               = x_location_id;
204        RETURN(x_location_code);
205      end if;
206     END;
207 /*End Bug 3284237*/
208   WHEN OTHERS THEN
209     po_message_s.sql_error('GET_LOCATION',x_progress,sqlcode);
210 
211 END GET_LOCATION;
212 
213 FUNCTION GET_DELIVER_PERSON (x_employee_id  IN NUMBER) RETURN VARCHAR2 IS
214 
215   x_progress      VARCHAR2(3) := NULL;
216   x_name          VARCHAR2(240);
217 
218 BEGIN
219   x_progress := 10;
220   select full_name
221   into   x_name
222   from   per_employees_current_x    -- Bug 7257731: Changed the view name from hr_employees to per_employees_current_x
223   where  employee_id = x_employee_id;
224 
225   RETURN(x_name);
226 
227   EXCEPTION
228     when others then
229     po_message_s.sql_error('GET_DELIVER_PERSON',x_progress,sqlcode);
230     raise;
231 end GET_DELIVER_PERSON;
232 
233 PROCEDURE HAZARD_CLASS_INFO (x_hazard_id    IN  NUMBER,
234                              x_hazard_class OUT NOCOPY VARCHAR2) is
235   x_progress VARCHAR2(3) := NULL;
236 BEGIN
237   x_progress := 10;
238   select hazard_class
239   into   x_hazard_class
240   from   po_hazard_classes
241   where  hazard_class_id = x_hazard_id;
242   EXCEPTION
243    when others then
244      po_message_s.sql_error('HAZARD_CLASS_INFO',x_progress,sqlcode);
245      raise;
246 end HAZARD_CLASS_INFO;
247 
248 PROCEDURE UN_NUMBER_INFO (x_un_number_id   IN NUMBER,
249                           x_un_number     OUT NOCOPY VARCHAR2) is
250   x_progress VARCHAR2(3) := NULL;
251 BEGIN
252   x_progress := 10;
253   select un_number
254   into   x_un_number
255   from   po_un_numbers
256   where  un_number_id = x_un_number_id;
257   EXCEPTION
258   when others then
259      po_message_s.sql_error('UN_NUMBER_INFO',x_progress,sqlcode);
260      raise;
261 end UN_NUMBER_INFO;
262 
263 PROCEDURE  DEFAULT_SUBINV_LOCATOR (x_subinventory  IN OUT NOCOPY VARCHAR2 ,
264                                    x_item_id       IN     NUMBER,
265                                    x_org_id        IN     NUMBER,
266                                    x_po_distribution_id IN NUMBER,
267                                    x_oe_order_line_id IN NUMBER,
268                                    x_locator_id   OUT NOCOPY     NUMBER ) is
269   x_progress   VARCHAR2(3) := NULL;
270 begin
271   if x_subinventory is null then
272     x_progress := 10;
273 
274     -- Need this if condition for rma receipts
275 
276     if X_po_distribution_id is not null then
277       select destination_subinventory
278       into   x_subinventory
279       from   po_distributions
280       where  po_distribution_id = X_po_distribution_id;
281 
282     -- Bug 3378162: for rma receipts, default subinventory from oe line.
283     elsif x_oe_order_line_id is not null then
284         select subinventory
285         into   x_subinventory
286         from   oe_order_lines_all
287         where  line_id = x_oe_order_line_id;
288     end if;
289 
290     IF  x_subinventory is null then
291 
292        x_progress := 20;
293 
294        select subinventory_code
295        into   x_subinventory
296        from   mtl_item_sub_defaults
297        where  inventory_item_id = x_item_id
298        and    organization_id   = x_org_id
299        and    default_type      = 2;
300 
301    END IF;
302 
303   end if;
304   if x_subinventory is not null then
305     select locator_id
306     into   x_locator_id
307     from   mtl_item_loc_defaults
308     where  inventory_item_id = x_item_id
309     and    organization_id   = x_org_id
310     and    subinventory_code = x_subinventory
311     and    default_type      = 2;
312   end if;
313 
314   EXCEPTION
315    when no_data_found then
316       null;
317    when others then
318      po_message_s.sql_error('DEFAULT_SUBINV_LOCATOR',x_progress,sqlcode);
319      raise;
320 end DEFAULT_SUBINV_LOCATOR;
321 
322 PROCEDURE VALIDATE_ID ( x_deliver_to_location_id IN OUT NOCOPY NUMBER,
323                         x_location_id            IN OUT NOCOPY NUMBER,
324                         x_deliver_to_person_id   IN OUT NOCOPY NUMBER,
325                         x_subinventory           IN OUT NOCOPY VARCHAR2,
326                         x_org_id                 IN     NUMBER,
327                         x_date                   IN     DATE) is
328   x_del_loc_val VARCHAR2(60);
329   x_loc_val     VARCHAR2(60);
330   x_del_per_val VARCHAR2(60);
331   x_subinv      VARCHAR2(60);
332   x_progress    VARCHAR2(3) := NULL;
333 begin
334   x_progress := 10;
335   begin
336 
337    /* 1942696*/
338 
339 /** Bug#6497729:
340  **  When NO_DATA_FOUND exception occurs, we are setting 'deliver to person'/'deliver to location'
341  **  to Zero and this Zero is getting stored in rcv_transactions table for deliver_to_person_id
342  **  and deliver_to_location_id and causes data corruption.
343  **  So, we have set 'null' instead of setting it to Zero and we have to fire queries,
344  **  only if 'deliver to person'/'deliver to location' is not null.
345  */
346    begin
347       if x_deliver_to_location_id is not null then--Bug#6497729
348        select 'Check to see if deliver_to_location_id is valid'
349        INTO   x_del_loc_val
350        from   hr_locations
351        WHERE  nvl(inventory_organization_id,x_org_id) =  x_org_id
352        AND    (inactive_date IS NULL
353               OR
354               inactive_date > x_date)
355        AND    location_id = x_deliver_to_location_id;
356       end if;--Bug#6497729
357    exception
358    when NO_DATA_FOUND then
359        select 'Check to see if deliver_to_location_id is valid'
360        INTO   x_del_loc_val
361        from   hz_locations
362        WHERE    (address_expiration_date IS NULL
363          OR
364          address_expiration_date > x_date)
365        AND    location_id = x_deliver_to_location_id;
366 
367    end;
368 
369     EXCEPTION
370       when no_data_found then
371         x_deliver_to_location_id := null;--Bug#6497729
372       when others then
373         po_message_s.sql_error('VALIDATE_ID',x_progress,sqlcode);
374         raise;
375   END;
376 
377   x_progress := 20;
378 
379   /* 1942696*/
380   begin
381    begin
382       if x_location_id is not null then--Bug#6497729
383         select 'Check to see if location_id is valid'
384         into   x_loc_val
385         from   hr_locations
386         WHERE  nvl(inventory_organization_id,x_org_id) =  x_org_id
387         AND    receiving_site_flag = 'Y'
388         AND    (inactive_date IS NULL
389                OR
390               inactive_date > x_date)
391         AND    location_id = x_location_id;
392       end if;--Bug#6497729
393    exception
394    when NO_DATA_FOUND then
395        select 'Check to see if location_id is valid'
396        into   x_loc_val
397        from   hz_locations
398        WHERE    (address_expiration_date IS NULL
399          OR
400        address_expiration_date > x_date)
401        AND    location_id = x_location_id;
402    end;
403 
404   EXCEPTION
405     when no_data_found then
406       x_location_id := null;--Bug#6497729
407     when others then
408       po_message_s.sql_error('VALIDATE_ID',x_progress,sqlcode);
409       raise;
410   END;
411 
412   x_progress := 30;
413   BEGIN
414 
415     if x_deliver_to_person_id is not null then--Bug#6497729
416        select 'Check to see if deliver_to_person_id is valid'
417        into   x_del_per_val
418        from   hr_employees_current_v
419        WHERE (inactive_date IS NULL
420               OR
421               inactive_date > x_date)
422        AND    employee_id = x_deliver_to_person_id;
423     end if;--Bug#6497729
424     EXCEPTION
425       when no_data_found then
426         x_deliver_to_person_id := null;--Bug#6497729
427       when others then
428         po_message_s.sql_error('VALIDATE_ID',x_progress,sqlcode);
429         raise;
430   END;
431 
432   BEGIN
433     x_progress := 40;
434     select 'Check to see if subinventory is valid'
435     into   x_subinv
436     from   mtl_secondary_inventories
437     WHERE (disable_date IS NULL
438          OR
439            disable_date > x_date)
440     AND    organization_id = x_org_id
441     AND    secondary_inventory_name = x_subinventory;
442 
443     EXCEPTION
444       when no_data_found then
445         x_subinventory := '';
446       when others then
447         po_message_s.sql_error('VALIDATE_ID',x_progress,sqlcode);
448         raise;
449   END;
450 
451 
452 end VALIDATE_ID;
453 
454 FUNCTION LOCATOR_TYPE (x_org_id IN NUMBER ,
455                        x_subinv IN VARCHAR2) RETURN VARCHAR2 is
456   x_progress     VARCHAR2(3) := NULL;
457   x_locator_type VARCHAR2(30);
458 begin
459   x_progress := 10;
460   select locator_type
461   into   x_locator_type
462   from   mtl_secondary_inventories
463   where  organization_id = x_org_id
464   and    secondary_inventory_name = x_subinv;
465   RETURN(x_locator_type);
466   EXCEPTION
467     when no_data_found then
468     RETURN(NULL);
469     when others then
470     po_message_s.sql_error('LOCATOR_TYPE',x_progress,sqlcode);
471     raise;
472 end LOCATOR_TYPE;
473 
474 --Bug#2109106. This function has been overloaded.
475   procedure POST_QUERY ( x_transaction_id                IN NUMBER,
476                          x_receipt_source_code           IN VARCHAR2,
477                          x_organization_id               IN NUMBER,
478                          x_hazard_class_id               IN NUMBER,
479                          x_un_number_id                  IN NUMBER,
480                          x_shipment_header_id            IN NUMBER,
481                          x_shipment_line_id              IN NUMBER,
482                          x_po_line_location_id           IN NUMBER,
483                          x_po_line_id                    IN NUMBER,
484                          x_po_header_id                  IN NUMBER,
485                          x_po_release_id                 IN NUMBER,
486                          x_vendor_id                     IN NUMBER,
487                          x_item_id                       IN NUMBER,
488                          x_item_revision                 IN VARCHAR2,
489                          x_transaction_date              IN DATE,
490                          x_creation_date                 IN DATE,
491                          x_location_id                   IN NUMBER,
492                          x_subinventory                  IN VARCHAR2,
493                          x_destination_type_code         IN VARCHAR2,
494                          x_destination_type_dsp          IN VARCHAR2,
495                          x_primary_uom                   IN VARCHAR2,
496                          x_routing_id                   IN NUMBER,
497           x_po_distribution_id           IN OUT NOCOPY NUMBER,
498                          x_final_dest_type_code         IN OUT NOCOPY VARCHAR2,
499                          x_final_dest_type_dsp          IN OUT NOCOPY VARCHAR2,
500                          x_final_location_id            IN OUT NOCOPY NUMBER,
501                          x_final_subinventory           IN OUT NOCOPY VARCHAR2,
502                          x_destination_context          IN OUT NOCOPY VARCHAR2,
503                          x_wip_entity_id                IN OUT NOCOPY NUMBER,
504                          x_wip_line_id                  IN OUT NOCOPY NUMBER,
505                          x_wip_repetitive_schedule_id   IN OUT NOCOPY NUMBER,
506                          x_outside_processing           IN OUT NOCOPY VARCHAR2,
507                          x_job_schedule_dsp             IN OUT NOCOPY VARCHAR2,
508                          x_op_seq_num_dsp               IN OUT NOCOPY VARCHAR2,
509                          x_department_code              IN OUT NOCOPY VARCHAR2 ,
510                          x_production_line_dsp          IN OUT NOCOPY VARCHAR2,
511                          x_bom_resource_id              IN OUT NOCOPY NUMBER,
512                          x_final_deliver_to_person_id   IN OUT NOCOPY NUMBER,
513                          x_final_deliver_to_location_id IN OUT NOCOPY NUMBER,
514                          x_person                       IN OUT NOCOPY VARCHAR2,
515                          x_location                     IN OUT NOCOPY VARCHAR2,
516                          x_hazard_class                 IN OUT NOCOPY VARCHAR2,
517                          x_un_number                    IN OUT NOCOPY VARCHAR2,
518                          x_sub_locator_control          IN OUT NOCOPY VARCHAR2 ,
519                          x_count                        IN OUT NOCOPY NUMBER ,
520                          x_locator_id                   IN OUT NOCOPY NUMBER ,
521                          x_available_qty                IN OUT NOCOPY NUMBER,
522                          x_primary_available_qty        IN OUT NOCOPY NUMBER,
523                          x_tolerable_qty                IN OUT NOCOPY NUMBER ,
524                          x_uom                          IN OUT NOCOPY VARCHAR2,
525                          x_count_po_distribution        IN OUT NOCOPY NUMBER,
526                          x_receiving_dsp_value          IN OUT NOCOPY VARCHAR2,
527           x_po_operation_seq_num    IN OUT NOCOPY NUMBER,
528           x_po_resource_seq_num     IN OUT NOCOPY NUMBER,
529                          x_currency_conv_rate           IN OUT NOCOPY NUMBER,
530                          x_currency_conv_date           IN OUT NOCOPY DATE,
531                          x_oe_order_line_id             IN NUMBER ,
532          /* Bug# 1548597 */
533                          x_secondary_available_qty      IN OUT NOCOPY NUMBER,
534 -- <RCV ENH FPI START>
535                          p_req_line_id               IN NUMBER,
536                          p_req_distribution_id       IN NUMBER,
537                          x_kanban_card_number        OUT NOCOPY VARCHAR2,
538                          x_project_number            OUT NOCOPY VARCHAR2,
539                          x_task_number               OUT NOCOPY VARCHAR2,
540                          x_charge_account            OUT NOCOPY VARCHAR2
541 -- <RCV ENH FPI END>
542                        ) is
543 
544   x_progress               VARCHAR2(3) ;
545   l_creation_date          DATE;
546   l_destination_type_code  VARCHAR2(30);
547   l_destination_type_dsp   VARCHAR2(80);
548   l_subinventory           VARCHAR2(30);
549   l_deliver_to_person_id   NUMBER;
550   l_po_distribution_id     NUMBER;
551   l_location_id            NUMBER;
552   l_deliver_to_location_id NUMBER;
553   l_wip_entity_id          NUMBER;
554   l_available_qty          NUMBER;
555   l_primary_available_qty  NUMBER;
556   l_tolerable_qty          NUMBER;
557   l_locator_id             NUMBER;
558   l_uom                    VARCHAR2(30);
559   X_success                BOOLEAN := FALSE;
560   X_project_id                 NUMBER ; -- bug 1662321
561   X_task_id       NUMBER ; -- bug 1662321
562 
563 
564 -- <RCV ENH FPI START>
565   l_status VARCHAR2(1) := FND_API.G_RET_STS_SUCCESS;
566   l_dest_subinv PO_DISTRIBUTIONS.destination_subinventory%TYPE;
567   l_dummy_rate PO_DISTRIBUTIONS.rate%TYPE;
568   l_dummy_rate_date PO_DISTRIBUTIONS.rate_date%TYPE;
569   l_dummy_person HR_EMPLOYEES.full_name%TYPE;
570   l_dummy_subinv PO_REQUISITION_LINES.destination_subinventory%TYPE;
571 -- <RCV ENH FPI END>
572 
573   BEGIN
574 
575     /* Chk avaliable qty for the transaction */
576     RCV_QUANTITIES_S.GET_AVAILABLE_QUANTITY ('TRANSFER',
577                                              x_transaction_id,
578                                              x_receipt_source_code,
579                                              null,
580                                              x_transaction_id,
581                                              null,
582                                              l_available_qty,
583                                              l_tolerable_qty,
584                                              l_uom,
585                   /*Bug# 1548597 */
586                                               x_secondary_available_qty);
587 
588     /* Chk if available qty greater than 0 */
589     if nvl(l_available_qty,0) > 0 then
590 
591       /* Get the available qty in PRIMARY UOM */
592       PO_UOM_S.UOM_CONVERT (l_available_qty,
593                             l_uom,
594                             x_item_id,
595                             x_primary_uom,
596                             l_primary_available_qty );
597 
598       /* Copy initial destination type code and destination type dsp item
599          into local variables so that final updated values could be returned
600       */
601       l_destination_type_code := x_destination_type_code;
602       l_destination_type_dsp  := x_destination_type_dsp;
603       l_location_id           := x_location_id;
604       l_subinventory          := x_subinventory;
605       if x_receipt_source_code = 'VENDOR' then
606         if l_destination_type_code = 'SINGLE' then
607           x_progress := 20;
608           DISTRIBUTION_DETAIL( x_transaction_id,
609                                l_destination_type_code,
610                                x_destination_context,
611                                l_destination_type_dsp,
612                                l_wip_entity_id,
613                                x_wip_line_id,
614                                x_wip_repetitive_schedule_id,
615                                l_deliver_to_person_id,
616                                l_deliver_to_location_id,
617                                l_po_distribution_id,
618                                x_currency_conv_rate,
619                                x_currency_conv_date,
620 -- <RCV ENH FPI START>
621                                x_kanban_card_number,
622                                x_project_number,
623                                x_task_number,
624                                x_charge_account );
625 -- <RCV ENH FPI END>
626 
627           /* Get outside processing details, only if valid wip_entity_id
628              has been entered
629           */
630           if nvl(l_wip_entity_id,0) <> 0 then
631             x_progress := 30;
632             RCV_CORE_S.GET_OUTSIDE_PROCESSING_INFO(l_po_distribution_id,
633                                                    x_organization_id,
634                                                    x_job_schedule_dsp,
635                                                    x_op_seq_num_dsp,
636                                                    x_department_code,
637                                                    x_production_line_dsp,
638                                                    x_bom_resource_id,
639                              x_po_operation_seq_num,
640                           x_po_resource_seq_num);
641             x_outside_processing := 'Y';
642           else
643             x_outside_processing := 'N';
644           end if;
645 -- <RCV ENH FPI START>
646         ELSIF (l_destination_type_code = 'MULTIPLE') THEN
647           x_progress := 35;
648 
649           RCV_DISTRIBUTIONS_S.get_misc_distr_info(
650             x_return_status => l_status,
651             p_line_location_id => x_po_line_location_id,
652             p_po_distribution_id => NULL,
653             x_kanban_card_number => x_kanban_card_number,
654             x_project_number => x_project_number,
655             x_task_number => x_task_number,
656             x_charge_account => x_charge_account,
657             x_deliver_to_person => x_person,
658             x_job => x_job_schedule_dsp,
659             x_outside_line_num => x_production_line_dsp,
660             x_sequence => x_op_seq_num_dsp,
661             x_department => x_department_code,
662             x_dest_subinv => l_dest_subinv,
663             x_rate => l_dummy_rate,
664             x_rate_date => l_dummy_rate_date);
665 
666           IF (l_status <> FND_API.G_RET_STS_SUCCESS) THEN
667             RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
668           END IF;
669 
670 -- <RCV ENH FPI END>
671         end if;
672 
673       elsif x_receipt_source_code = 'CUSTOMER' then
674         -- Final destination is always inventory for rma receitps.
675    x_outside_processing := 'N';
676    l_destination_type_code := 'INVENTORY';
677    x_destination_context := 'INVENTORY';
678 
679    select plc.displayed_field
680    into l_destination_type_dsp
681    from po_lookup_codes plc
682    where plc.lookup_type = 'RCV DESTINATION TYPE'
683    and   plc.lookup_code = l_destination_type_code;
684 
685         /* Bug#4684017.Project and task info was not getting defaulted for a RMA.
686       Fix is to get the project information from OM tables */
687 
688         IF (x_oe_order_line_id IS NOT NULL) THEN
689 
690              SELECT project_id, task_id
691              INTO   X_project_id,X_task_id
692              FROM   oe_order_lines_all
693              WHERE  line_id = x_oe_order_line_id;
694 
695                 IF ( X_project_id IS NOT NULL AND
696                      X_task_id IS NOT NULL ) THEN
697 
698                    Begin
699 
700                      select pa.project_number,pt.task_number
701                        into x_project_number,x_task_number
702                        from pjm_projects_all_v pa,
703                             pa_tasks_expend_v pt
704                       where pa.project_id = X_project_id
705                         and pt.task_id = X_task_id
706                         and pa.project_id=pt.project_id;
707 
708 
709                      Exception
710                         when no_data_found then
711                         null;
712                    End;
713 
714                 ELSIF (  X_project_id IS NOT NULL AND
715                          X_task_id IS NULL ) THEN
716 
717                      Begin
718                         select project_number
719                          into x_project_number
720                          from pjm_projects_all_v
721                         where project_id = X_project_id;
722 
723                        Exception
724                           when no_data_found then
725                           null;
726                      End;
727 
728                 END IF;
729 
730         END IF;
731 
732      /* Bug#4684017 END */
733 
734 -- <RCV ENH FPI START>
735       ELSIF x_receipt_source_code = 'INTERNAL ORDER' THEN
736 
737 -- We do not need subinv from this procedure because it will be provided
738 -- from the view for this case.
739         RCV_DISTRIBUTIONS_S.get_misc_req_distr_info(
740           x_return_status => l_status,
741           p_requisition_line_id => p_req_line_id,
742           p_req_distribution_id => p_req_distribution_id,
743           x_kanban_card_number => x_kanban_card_number,
744           x_project_number => x_project_number,
745           x_task_number => x_task_number,
746           x_charge_account => x_charge_account,
747           x_deliver_to_person => l_dummy_person,
748           x_dest_subinv => l_dummy_subinv);
749 
750         IF (x_final_deliver_to_person_id IS NOT NULL) THEN
751           l_deliver_to_person_id := x_final_deliver_to_person_id;
752         END IF;
753 
754         IF (l_status <> FND_API.G_RET_STS_SUCCESS) THEN
755           RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
756         END IF;
757 
758 -- <RCV ENH FPI END>
759 
760       end if;
761 
762      /* Bug 2436516 - The hazard class was not getting displayed for
763          multiple distributions in the Receiving Transactions form.
764          The hazard class was retrieved only for single distributions.
765          Modified the code to get hazard class for multiple distributions also
766      */
767 
768        if nvl(x_hazard_class_id,0) <> 0 then
769           x_progress := 40;
770           HAZARD_CLASS_INFO (x_hazard_class_id,
771                              x_hazard_class );
772         end if;
773 
774       if l_destination_type_code <> 'MULTIPLE' then
775         if nvl(x_un_number_id,0) <> 0 then
776           x_progress := 50;
777           UN_NUMBER_INFO (x_un_number_id,
778                           x_un_number);
779         end if;
780         x_progress := 60;
781 
782    if x_receipt_source_code <> 'CUSTOMER' then
783 
784          x_count := RCV_CORE_S.GET_NOTE_COUNT (x_shipment_header_id,
785                                                 x_shipment_line_id,
786                                                  x_po_line_location_id,
787                                                x_po_line_id,
788                                                 x_po_release_id,
789                                                 x_po_header_id,
790                                                       x_item_id );
791    end if;
792 
793         if l_destination_type_code = 'INVENTORY' then
794           x_progress := 70;
795           DEFAULT_SUBINV_LOCATOR (l_subinventory,
796                                   x_item_id,
797                                   x_organization_id,
798               l_po_distribution_id,
799                                   x_oe_order_line_id,
800                                   x_locator_id );
801 
802      /* Bug 3537022.
803       * Get locator_id from rcv_shipment_lines for intransit
804       * shipments.
805      */
806           x_progress := 80;
807 
808      if (x_receipt_source_code = 'INVENTORY') then
809          select locator_id
810          into x_locator_id
811          from rcv_shipment_lines
812          where shipment_line_id = x_shipment_line_id;
813      end if;
814 
815     x_progress := 90;
816 
817           -- default deliver_to_location_id for rma deliver
818           if x_receipt_source_code = 'CUSTOMER' then
819 
820              select haou.location_id
821              into   l_deliver_to_location_id
822              from   hr_all_organization_units haou
823              where  haou.organization_id = (select ship_from_org_id
824                                             from   oe_order_lines_all
825                                             where  line_id = x_oe_order_line_id);
826 
827           end if;
828         elsif x_destination_type_code = 'RECEIVING' then
829           po_message_s.app_error(x_destination_type_code);
830           l_subinventory := '';
831           x_locator_id := NULL;
832 
833         end if;
834         /* l_creation_date := x_creation_date;
835         if x_transaction_date is not null then
836           l_creation_date := x_transaction_date;
837         end if; */
838         l_creation_date := sysdate;
839         x_progress := 80;
840         VALIDATE_ID (l_deliver_to_location_id,
841                      l_location_id,
842                      l_deliver_to_person_id,
843                      l_subinventory,
844                      x_organization_id,
845                      l_creation_date );
846         x_progress := 90;
847         x_sub_locator_control := LOCATOR_TYPE (x_organization_id,
848                                                l_subinventory );
849 
850         --get deliver to location name
851         if nvl(l_deliver_to_location_id,0) <> 0 then
852           x_progress := 100;
853 
854 /* bug2199615 */
855           x_location := GET_LOCATION (l_deliver_to_location_id, x_po_line_location_id );
856         end if;
857 
858         --get person name
859         if nvl(l_deliver_to_person_id,0) <> 0 then
860           x_progress := 110;
861           x_person   := GET_DELIVER_PERSON (l_deliver_to_person_id);
862         end if;
863       else   /* Destination type = 'Multiple' */
864         --retreive no_of_distributions for the shipment
865         x_progress := 115;
866         select count(*)
867         into   x_count_po_distribution
868         from   po_distributions
869         where  line_location_id   = x_po_line_location_id;
870 
871       end if;
872 
873       x_progress := 120;
874       x_receiving_dsp_value := GET_RECEIVING_DISPLAY_VALUE;
875 
876     end if;
877 
878     /* copy the local values to final parameters */
879     x_final_dest_type_code         := l_destination_type_code;
880     x_final_dest_type_dsp          := l_destination_type_dsp;
881     x_final_deliver_to_person_id   := l_deliver_to_person_id;
882     x_final_deliver_to_location_id := l_deliver_to_location_id;
883     x_final_location_id            := l_location_id;
884     x_final_subinventory           := l_subinventory;
885     x_available_qty                := l_available_qty;
886     x_tolerable_qty                := l_tolerable_qty;
887     x_uom                          := l_uom;
888     x_primary_available_qty        := l_primary_available_qty;
889     x_wip_entity_id                := l_wip_entity_id;
890     x_po_distribution_id           := l_po_distribution_id;
891 
892     l_subinventory := x_final_subinventory;
893     l_locator_id   := x_locator_id;
894 
895     X_success := rcv_sub_locator_sv.put_away_api (
896        x_po_line_location_id  ,
897                  l_po_distribution_id   ,
898        x_shipment_line_id     ,
899                  x_receipt_source_code  ,
900                  x_organization_id      ,
901                  x_organization_id      ,
902        x_item_id     ,
903        x_item_revision  ,
904        x_vendor_id               ,
905        x_location_id ,
906           l_deliver_to_location_id,
907           l_deliver_to_person_id ,
908                  x_available_qty        ,
909                  l_primary_available_qty,
910        x_primary_uom    ,
911             x_tolerable_qty   ,
912                  x_uom             ,
913        x_routing_id           ,
914                  l_subinventory         ,
915                  l_locator_id           ,
916                  x_final_subinventory   ,
917                  x_locator_id);
918 
919 -- <RCV ENH FPI START>
920 -- Want to skip all validations fro fields coming out from get_misc_distr_info.
921 -- Therefore the assignment are put here.
922 
923    IF (l_dest_subinv IS NOT NULL) THEN
924      x_final_subinventory := l_dest_subinv;
925    END IF;
926 
927 -- <RCV ENH FPI END>
928 
929    IF (x_receipt_source_code <> 'CUSTOMER') THEN
930 
931       IF (l_po_distribution_id IS NOT NULL AND
932           x_locator_id IS NOT NULL) THEN
933 
934           X_progress := '133';
935 
936           SELECT project_id, task_id
937           INTO   X_project_id, X_task_id
938           FROM   po_distributions
939           WHERE  po_distribution_id = l_po_distribution_id;
940       END IF;
941 
942    ELSE
943              X_progress := '135';
944          /* Locator field defaulting for rma's */
945          IF (x_oe_order_line_id IS NOT NULL AND
946            x_locator_id IS NOT NULL) THEN
947 
948            SELECT project_id, task_id
949            INTO   X_project_id,X_task_id
950            FROM   oe_order_lines_all
951            WHERE  line_id = x_oe_order_line_id;
952 
953          END IF;
954 
955         /* Bug# 1717095 - Need to get the Currency details for the Order */
956 
957         SELECT currency_conversion_rate,currency_conversion_date
958         INTO   x_currency_conv_rate,x_currency_conv_date
959         FROM   rcv_transactions
960         WHERE  transaction_id = x_transaction_id;
961 
962    END IF;
963           /*
964           ** Set the default values for the locator based on a
965           ** project manufacturing call.  If the default locator
966           ** does not have the project and task that is specified
967           ** on the po and the locator control is dynamic then
968           ** project manufacturing will create a new locator row
969           ** copying all values from the existing locator row while
970           ** adding the new project and task is values
971           */
972     /*bug 1349864 added begin and end statement. This fix was
973      * made as part of the bug fix 1662321
974     */
975           IF X_project_id IS NOT NULL then
976 --                 x_sub_locator_control = 3) THEN  - fixed bug: 588172
977 
978         begin
979         x_progress := '150';
980              l_locator_id := X_locator_id; -- Bug 2772050
981              PJM_PROJECT_LOCATOR.Get_DefaultProjectLocator(
982                         X_organization_id,
983                    l_locator_id, -- Bug 2772050
984                         X_project_id,
985                         X_task_id,
986                         X_locator_id);
987         exception
988       when others then
989          null;
990         end;
991 
992            END IF;
993 
994   EXCEPTION
995     WHEN OTHERS THEN
996       po_message_s.sql_error('POST_QUERY',x_progress,sqlcode);
997       raise;
998   END POST_QUERY;
999 
1000 -- Bug#2109106. This function has been overloaded.This has been done because
1001 --  the change done for OPM to include the parameter x_secondary_available_qty
1002 --  breaks the inventory api call to this procedure.x_secondary_available_qty
1003 --  has been removed from the parameters.
1004 --  This change has been done for WMS only.
1005 
1006   procedure POST_QUERY ( x_transaction_id                IN NUMBER,
1007                          x_receipt_source_code           IN VARCHAR2,
1008                          x_organization_id               IN NUMBER,
1009                          x_hazard_class_id               IN NUMBER,
1010                          x_un_number_id                  IN NUMBER,
1011                          x_shipment_header_id            IN NUMBER,
1012                          x_shipment_line_id              IN NUMBER,
1013                          x_po_line_location_id           IN NUMBER,
1014                          x_po_line_id                    IN NUMBER,
1015                          x_po_header_id                  IN NUMBER,
1016                          x_po_release_id                 IN NUMBER,
1017                          x_vendor_id                     IN NUMBER,
1018                          x_item_id                       IN NUMBER,
1019                          x_item_revision                 IN VARCHAR2,
1020                          x_transaction_date              IN DATE,
1021                          x_creation_date                 IN DATE,
1022                          x_location_id                   IN NUMBER,
1023                          x_subinventory                  IN VARCHAR2,
1024                          x_destination_type_code         IN VARCHAR2,
1025                          x_destination_type_dsp          IN VARCHAR2,
1026                          x_primary_uom                   IN VARCHAR2,
1027                          x_routing_id                   IN NUMBER,
1028           x_po_distribution_id           IN OUT NOCOPY NUMBER,
1029                          x_final_dest_type_code         IN OUT NOCOPY VARCHAR2,
1030                          x_final_dest_type_dsp          IN OUT NOCOPY VARCHAR2,
1031                          x_final_location_id            IN OUT NOCOPY NUMBER,
1032                          x_final_subinventory           IN OUT NOCOPY VARCHAR2,
1033                          x_destination_context          IN OUT NOCOPY VARCHAR2,
1034                          x_wip_entity_id                IN OUT NOCOPY NUMBER,
1035                          x_wip_line_id                  IN OUT NOCOPY NUMBER,
1036                          x_wip_repetitive_schedule_id   IN OUT NOCOPY NUMBER,
1037                          x_outside_processing           IN OUT NOCOPY VARCHAR2,
1038                          x_job_schedule_dsp             IN OUT NOCOPY VARCHAR2,
1039                          x_op_seq_num_dsp               IN OUT NOCOPY VARCHAR2,
1040                          x_department_code              IN OUT NOCOPY VARCHAR2 ,
1041                          x_production_line_dsp          IN OUT NOCOPY VARCHAR2,
1042                          x_bom_resource_id              IN OUT NOCOPY NUMBER,
1043                          x_final_deliver_to_person_id   IN OUT NOCOPY NUMBER,
1044                          x_final_deliver_to_location_id IN OUT NOCOPY NUMBER,
1045                          x_person                       IN OUT NOCOPY VARCHAR2,
1046                          x_location                     IN OUT NOCOPY VARCHAR2,
1047                          x_hazard_class                 IN OUT NOCOPY VARCHAR2,
1048                          x_un_number                    IN OUT NOCOPY VARCHAR2,
1049                          x_sub_locator_control          IN OUT NOCOPY VARCHAR2 ,
1050                          x_count                        IN OUT NOCOPY NUMBER ,
1051                          x_locator_id                   IN OUT NOCOPY NUMBER ,
1052                          x_available_qty                IN OUT NOCOPY NUMBER,
1053                          x_primary_available_qty        IN OUT NOCOPY NUMBER,
1054                          x_tolerable_qty                IN OUT NOCOPY NUMBER ,
1055                          x_uom                          IN OUT NOCOPY VARCHAR2,
1056                          x_count_po_distribution        IN OUT NOCOPY NUMBER,
1057                          x_receiving_dsp_value          IN OUT NOCOPY VARCHAR2,
1058           x_po_operation_seq_num    IN OUT NOCOPY NUMBER,
1059           x_po_resource_seq_num     IN OUT NOCOPY NUMBER,
1060                          x_currency_conv_rate           IN OUT NOCOPY NUMBER,
1061                          x_currency_conv_date           IN OUT NOCOPY DATE,
1062                          x_oe_order_line_id             IN NUMBER ) IS
1063 
1064   x_progress               VARCHAR2(3) ;
1065   l_creation_date          DATE;
1066   l_destination_type_code  VARCHAR2(30);
1067   l_destination_type_dsp   VARCHAR2(80);
1068   l_subinventory           VARCHAR2(30);
1069   l_deliver_to_person_id   NUMBER;
1070   l_po_distribution_id     NUMBER;
1071   l_location_id            NUMBER;
1072   l_deliver_to_location_id NUMBER;
1073   l_wip_entity_id          NUMBER;
1074   l_available_qty          NUMBER;
1075   l_primary_available_qty  NUMBER;
1076   l_tolerable_qty          NUMBER;
1077   l_locator_id             NUMBER;
1078   l_uom                    VARCHAR2(30);
1079   X_success                BOOLEAN := FALSE;
1080   X_project_id             NUMBER ; -- bug 1662321
1081   X_task_id       NUMBER ; -- bug 1662321
1082 
1083 -- <RCV ENH FPI START>
1084   l_po_kanban_card_number MTL_KANBAN_CARDS.kanban_card_number%TYPE;
1085   l_po_project_number PJM_PROJECTS_ALL_V.project_number%TYPE;
1086   l_po_task_number PA_TASKS_EXPEND_V.task_number%TYPE;
1087   l_po_charge_account GL_CODE_COMBINATIONS_KFV.concatenated_segments%TYPE;
1088 -- <RCV ENH FPI END>
1089 
1090   BEGIN
1091     /* Chk avaliable qty for the transaction */
1092 
1093 -- Bug#2109106  The parameter x_secondary_available_qty has been removed.
1094     RCV_QUANTITIES_S.GET_AVAILABLE_QUANTITY ('TRANSFER',
1095                                              x_transaction_id,
1096                                              x_receipt_source_code,
1097                                              null,
1098                                              x_transaction_id,
1099                                              null,
1100                                              l_available_qty,
1101                                              l_tolerable_qty,
1102                                              l_uom);
1103 
1104     /* Chk if available qty greater than 0 */
1105     if nvl(l_available_qty,0) > 0 then
1106 
1107       /* Get the available qty in PRIMARY UOM */
1108       PO_UOM_S.UOM_CONVERT (l_available_qty,
1109                             l_uom,
1110                             x_item_id,
1111                             x_primary_uom,
1112                             l_primary_available_qty );
1113 
1114       /* Copy initial destination type code and destination type dsp item
1115          into local variables so that final updated values could be returned
1116       */
1117       l_destination_type_code := x_destination_type_code;
1118       l_destination_type_dsp  := x_destination_type_dsp;
1119       l_location_id           := x_location_id;
1120       l_subinventory          := x_subinventory;
1121       if x_receipt_source_code = 'VENDOR' then
1122         if l_destination_type_code = 'SINGLE' then
1123           x_progress := 20;
1124           DISTRIBUTION_DETAIL( x_transaction_id,
1125                                l_destination_type_code,
1126                                x_destination_context,
1127                                l_destination_type_dsp,
1128                                l_wip_entity_id,
1129                                x_wip_line_id,
1130                                x_wip_repetitive_schedule_id,
1131                                l_deliver_to_person_id,
1132                                l_deliver_to_location_id,
1133                                l_po_distribution_id,
1134                                x_currency_conv_rate,
1135                                x_currency_conv_date,
1136 -- <RCV ENH FPI START>
1137                                l_po_kanban_card_number,
1138                                l_po_project_number,
1139                                l_po_task_number,
1140                                l_po_charge_account);
1141 -- <RCV ENH FPI END>
1142 
1143           /* Get outside processing details, only if valid wip_entity_id
1144              has been entered
1145           */
1146           if nvl(l_wip_entity_id,0) <> 0 then
1147             x_progress := 30;
1148             RCV_CORE_S.GET_OUTSIDE_PROCESSING_INFO(l_po_distribution_id,
1149                                                    x_organization_id,
1150                                                    x_job_schedule_dsp,
1151                                                    x_op_seq_num_dsp,
1152                                                    x_department_code,
1153                                                    x_production_line_dsp,
1154                                                    x_bom_resource_id,
1155                              x_po_operation_seq_num,
1156                           x_po_resource_seq_num);
1157             x_outside_processing := 'Y';
1158           else
1159             x_outside_processing := 'N';
1160           end if;
1161         end if;
1162 
1163       elsif x_receipt_source_code = 'CUSTOMER' then
1164 
1165    x_outside_processing := 'N';
1166    l_destination_type_code := 'RECEIVING';
1167    x_destination_context := 'RECEIVING';
1168 
1169    select plc.displayed_field
1170    into l_destination_type_dsp
1171    from po_lookup_codes plc
1172    where plc.lookup_type = 'RCV DESTINATION TYPE'
1173    and   plc.lookup_code = l_destination_type_code;
1174 
1175 
1176       end if;
1177 
1178       if l_destination_type_code <> 'MULTIPLE' then
1179         if nvl(x_hazard_class_id,0) <> 0 then
1180           x_progress := 40;
1181           HAZARD_CLASS_INFO (x_hazard_class_id,
1182                              x_hazard_class );
1183         end if;
1184         if nvl(x_un_number_id,0) <> 0 then
1185           x_progress := 50;
1186           UN_NUMBER_INFO (x_un_number_id,
1187                           x_un_number);
1188         end if;
1189         x_progress := 60;
1190 
1191    if x_receipt_source_code <> 'CUSTOMER' then
1192 
1193          x_count := RCV_CORE_S.GET_NOTE_COUNT (x_shipment_header_id,
1194                                                 x_shipment_line_id,
1195                                                  x_po_line_location_id,
1196                                                x_po_line_id,
1197                                                 x_po_release_id,
1198                                                 x_po_header_id,
1199                                                       x_item_id );
1200    end if;
1201 
1202         if l_destination_type_code = 'INVENTORY' then
1203 
1204           x_progress := 70;
1205            DEFAULT_SUBINV_LOCATOR (l_subinventory,
1206                                    x_item_id,
1207                                    x_organization_id,
1208                               l_po_distribution_id,
1209                                    x_oe_order_line_id,
1210                                    x_locator_id );
1211 
1212      /* Bug 3537022.
1213       * Get locator_id from rcv_shipment_lines for intransit
1214       * shipments.
1215      */
1216           x_progress := 80;
1217 
1218      if (x_receipt_source_code = 'INVENTORY') then
1219          select locator_id
1220          into x_locator_id
1221          from rcv_shipment_lines
1222          where shipment_line_id = x_shipment_line_id;
1223      end if;
1224 
1225     x_progress := 90;
1226         end if;
1227 
1228         /* l_creation_date := x_creation_date;
1229         if x_transaction_date is not null then
1230           l_creation_date := x_transaction_date;
1231         end if; */
1232         l_creation_date := sysdate;
1233         x_progress := 80;
1234         VALIDATE_ID (l_deliver_to_location_id,
1235                      l_location_id,
1236                      l_deliver_to_person_id,
1237                      l_subinventory,
1238                      x_organization_id,
1239                      l_creation_date );
1240         x_progress := 90;
1241         x_sub_locator_control := LOCATOR_TYPE (x_organization_id,
1242                                                l_subinventory );
1243 
1244         --get deliver to location name
1245         if nvl(l_deliver_to_location_id,0) <> 0 then
1246           x_progress := 100;
1247 
1248 /* bug2199615 */
1249           x_location := GET_LOCATION (l_deliver_to_location_id, x_po_line_location_id );
1250         end if;
1251 
1252         --get person name
1253         if nvl(l_deliver_to_person_id,0) <> 0 then
1254           x_progress := 110;
1255           x_person   := GET_DELIVER_PERSON (l_deliver_to_person_id);
1256         end if;
1257       else   /* Destination type = 'Multiple' */
1258         --retreive no_of_distributions for the shipment
1259         x_progress := 115;
1260         select count(*)
1261         into   x_count_po_distribution
1262         from   po_distributions
1263         where  line_location_id   = x_po_line_location_id;
1264 
1265       end if;
1266 
1267       x_progress := 120;
1268       x_receiving_dsp_value := GET_RECEIVING_DISPLAY_VALUE;
1269 
1270     end if;
1271 
1272     /* copy the local values to final parameters */
1273     x_final_dest_type_code         := l_destination_type_code;
1274     x_final_dest_type_dsp          := l_destination_type_dsp;
1275     x_final_deliver_to_person_id   := l_deliver_to_person_id;
1276     x_final_deliver_to_location_id := l_deliver_to_location_id;
1277     x_final_location_id            := l_location_id;
1278     x_final_subinventory           := l_subinventory;
1279     x_available_qty                := l_available_qty;
1280     x_tolerable_qty                := l_tolerable_qty;
1281     x_uom                          := l_uom;
1282     x_primary_available_qty        := l_primary_available_qty;
1283     x_wip_entity_id                := l_wip_entity_id;
1284     x_po_distribution_id           := l_po_distribution_id;
1285 
1286     l_subinventory := x_final_subinventory;
1287     l_locator_id   := x_locator_id;
1288 
1289     X_success := rcv_sub_locator_sv.put_away_api (
1290        x_po_line_location_id  ,
1291                  l_po_distribution_id   ,
1292        x_shipment_line_id     ,
1293                  x_receipt_source_code  ,
1294                  x_organization_id      ,
1295                  x_organization_id      ,
1296        x_item_id     ,
1297        x_item_revision  ,
1298        x_vendor_id               ,
1299        x_location_id ,
1300           l_deliver_to_location_id,
1301           l_deliver_to_person_id ,
1302                  x_available_qty        ,
1303                  l_primary_available_qty,
1304        x_primary_uom    ,
1305             x_tolerable_qty   ,
1306                  x_uom             ,
1307        x_routing_id           ,
1308                  l_subinventory         ,
1309                  l_locator_id           ,
1310                  x_final_subinventory   ,
1311                  x_locator_id);
1312 
1313    IF (x_receipt_source_code <> 'CUSTOMER') THEN
1314 
1315       IF (l_po_distribution_id IS NOT NULL AND
1316           x_locator_id IS NOT NULL) THEN
1317 
1318           X_progress := '133';
1319 
1320           SELECT project_id, task_id
1321           INTO   X_project_id, X_task_id
1322           FROM   po_distributions
1323           WHERE  po_distribution_id = l_po_distribution_id;
1324       END IF;
1325 
1326    ELSE
1327              X_progress := '135';
1328          /* Locator field defaulting for rma's */
1329          IF (x_oe_order_line_id IS NOT NULL AND
1330            x_locator_id IS NOT NULL) THEN
1331 
1332            SELECT project_id, task_id
1333            INTO   X_project_id,X_task_id
1334            FROM   oe_order_lines_all
1335            WHERE  line_id = x_oe_order_line_id;
1336 
1337          END IF;
1338 
1339         /* Bug# 1717095 - Need to get the Currency details for the Order */
1340 
1341         SELECT currency_conversion_rate,currency_conversion_date
1342         INTO   x_currency_conv_rate,x_currency_conv_date
1343         FROM   rcv_transactions
1344         WHERE  transaction_id = x_transaction_id;
1345 
1346    END IF;
1347           /*
1348           ** Set the default values for the locator based on a
1349           ** project manufacturing call.  If the default locator
1350           ** does not have the project and task that is specified
1351           ** on the po and the locator control is dynamic then
1352           ** project manufacturing will create a new locator row
1353           ** copying all values from the existing locator row while
1354           ** adding the new project and task is values
1355           */
1356     /*bug 1349864 added begin and end statement. This fix was
1357      * made as part of the bug fix 1662321
1358     */
1359           IF X_project_id IS NOT NULL then
1360 --                 x_sub_locator_control = 3) THEN  - fixed bug: 588172
1361 
1362         begin
1363         x_progress := '150';
1364              l_locator_id := X_locator_id; -- Bug 2772050
1365              PJM_PROJECT_LOCATOR.Get_DefaultProjectLocator(
1366                         X_organization_id,
1367                    l_locator_id, -- Bug 2772050
1368                         X_project_id,
1369                         X_task_id,
1370                         X_locator_id);
1371         exception
1372       when others then
1373          null;
1374         end;
1375 
1376            END IF;
1377 
1378   EXCEPTION
1379     WHEN OTHERS THEN
1380       po_message_s.sql_error('POST_QUERY',x_progress,sqlcode);
1381       raise;
1382   END POST_QUERY;
1383 End rcv_transaction_sv;
1384