DBA Data[Home] [Help]

PACKAGE BODY: APPS.EAM_MATERIAL_REQUEST_PVT

Source


1 PACKAGE  BODY EAM_MATERIAL_REQUEST_PVT AS
2   /* $Header: EAMWEMRB.pls 120.2.12020000.5 2012/11/08 17:58:20 vchidura ship $*/
3   g_pkg_name    CONSTANT VARCHAR2(30):= 'eam_material_request_pvt';
4 
5 --author: dgupta
6 --This procedure allocates material by calling WIP
7 PROCEDURE allocate(
8   p_api_version           IN            NUMBER,
9   p_init_msg_list         IN            VARCHAR2,
10   p_commit                IN            VARCHAR2,
11   p_validation_level      IN            NUMBER,
12   x_return_status         OUT NOCOPY    VARCHAR2,
13   x_msg_count             OUT NOCOPY    NUMBER,
14   x_msg_data              OUT NOCOPY    VARCHAR2,
15   x_request_number        OUT NOCOPY    VARCHAR2,
16   p_wip_entity_type       IN            NUMBER,
17   p_organization_id       IN            NUMBER,
18   p_wip_entity_id         IN            NUMBER,
19   p_operation_seq_num     IN            NUMBER,
20   p_inventory_item_id     IN            NUMBER,
21   p_project_id            IN            NUMBER,
22   p_task_id               IN            NUMBER,
23   p_requested_quantity    IN            NUMBER,
24   p_source_subinventory   IN            VARCHAR2,
25   p_source_locator        IN            NUMBER,
26   p_lot_number            IN            VARCHAR2,
27   p_fm_serial             IN            VARCHAR2,
28   p_to_serial             IN            VARCHAR2
29 )  IS
30 
31   l_api_name                CONSTANT VARCHAR2(30) := 'allocate';
32   l_api_version             CONSTANT NUMBER       := 1.0;
33   l_full_name               CONSTANT VARCHAR2(100) := g_pkg_name || '.' || l_api_name;
34   l_module                  CONSTANT VARCHAR2(60) := 'eam.plsql.'||l_full_name;
35   l_msg_data VARCHAR2(2000);
36   l_msg VARCHAR2(2000);
37   l_return_status VARCHAR2(2000);
38   allocate_table  wip_picking_pub.allocate_comp_tbl_t;
39   l_pickslip_conc_req_id NUMBER := 0;
40   l_current_log_level constant number := FND_LOG.G_CURRENT_RUNTIME_LEVEL ;
41   l_uLog constant BOOLEAN := FND_LOG.LEVEL_UNEXPECTED >= l_current_log_level;
45   l_project_id number := p_project_id;
42   l_pLog constant BOOLEAN := l_uLog AND FND_LOG.LEVEL_PROCEDURE >= l_current_log_level;
43   l_sLog constant BOOLEAN := l_pLog AND FND_LOG.LEVEL_STATEMENT >= l_current_log_level;
44   l_partial_qty NUMBER := 0;
46   l_task_id number := p_task_id;
47 
48 BEGIN
49 	-- Standard Start of API savepoint
50   SAVEPOINT	ALLOCATE_EAM;
51   -- Standard call to check for call compatibility.
52   IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version,
53     l_api_name,	G_PKG_NAME )
54 	THEN
55 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
56 	END IF;
57 	-- Initialize message list if p_init_msg_list is set to TRUE.
58 	IF FND_API.to_Boolean( p_init_msg_list ) THEN
59 		FND_MSG_PUB.initialize;
60 	END IF;
61 	--  Initialize API return status to success
62   x_return_status := FND_API.G_RET_STS_SUCCESS;
63 
64 	-- API body
65   l_msg_data  := NULL;
66   l_return_status := NULL;
67   x_msg_data := null;
68   x_msg_count := 0;
69 
70   --check for invalid parameters
71   if (p_requested_quantity = 0) then
72     return;
73   end if;
74   if (p_requested_quantity < 0) then
75     x_return_status := FND_API.G_RET_STS_ERROR;
76     fnd_message.set_name('EAM','EAM_MR_NEGATIVE_REQ_QTY');
77     fnd_message.set_token('REQUESTED', to_char(p_requested_quantity) );
78     fnd_msg_pub.add;
79 		FND_MSG_PUB.Count_And_Get(
80 	    p_count         	=>      x_msg_count,
81       p_data          	=>      x_msg_data);
82     return;
83   end if;
84 
85   if (l_pLog) then FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, l_module,
86     'Start of ' || l_full_name || '('
87     || 'p_commit='|| p_commit ||','
88     || 'p_wip_entity_type='|| p_wip_entity_type || ','
89     || 'p_organization_id='|| p_organization_id || ','
90     || 'p_wip_entity_id='|| p_wip_entity_id || ','
91     || 'p_operation_seq_num='|| p_operation_seq_num || ','
92     || 'p_inventory_item_id='|| p_inventory_item_id || ','
93     || 'p_project_id='|| p_project_id || ','
94     || 'p_task_id='|| p_task_id || ','
95     || 'p_requested_quantity='|| p_requested_quantity || ','
96     || 'p_source_subinventory='|| p_source_subinventory ||','
97     || 'p_source_locator='|| p_source_locator ||','
98     || 'p_lot_number='|| p_lot_number ||','
99     || 'p_fm_serial='|| p_fm_serial ||','
100     || 'p_to_serial='|| p_to_serial ||','
101     || ')');
102   end if;
103   -- if project or task info is missing, retrieve it, else carry on
104   if ((p_project_id is null) or (p_task_id is null)) then
105     select project_id, task_id into l_project_id, l_task_id
106     from wip_discrete_jobs
107     where wip_entity_id = p_wip_entity_id;
108   else
109   if (p_project_id = FND_API.G_MISS_NUM) then
110     l_project_id := null;
111   end if;
112   if (p_task_id = FND_API.G_MISS_NUM) then
113     l_task_id := null;
114   end if;
115   end if;
116   allocate_table(1).wip_entity_id := p_wip_entity_id;
117   allocate_table(1).use_pickset_flag := 'N'; --this flag only used by flow
118   allocate_table(1).project_id := l_project_id;
119   allocate_table(1).task_id := l_task_id;
120   allocate_table(1).operation_seq_num := p_operation_seq_num;
121   allocate_table(1).inventory_item_id := p_inventory_item_id;
122   allocate_table(1).requested_quantity := p_requested_quantity;
123   allocate_table(1).source_subinventory_code := p_source_subinventory;
124   allocate_table(1).source_locator_id := p_source_locator;
125   allocate_table(1).lot_number := p_lot_number;
126   allocate_table(1).start_serial := p_fm_serial;
127   allocate_table(1).end_serial := p_to_serial;
128 
129   if (l_sLog) then FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, l_module,
130     'Calling wip_picking_pub.allocate_comp');
131   end if;
132   wip_picking_pub.allocate_comp(p_alloc_comp_tbl => allocate_table,
133                      p_cutoff_date => null,
134                      p_wip_entity_type => wip_constants.eam,
135                      p_organization_id => p_organization_id,
136                      x_return_status => l_return_status,
137                      x_msg_data => l_msg_data,
138                      x_mo_req_number => x_request_number,
139                      x_conc_req_id => l_pickslip_conc_req_id);
140   if (l_sLog) then FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, l_module,
141     'After Calling wip_picking_pub.allocate_comp');
142   end if;
143   if (l_sLog) then
144     l_msg := 'WIP returned: Request Number:' || x_request_number || ', x_return_status:'
145     || l_return_status|| ', x_msg_data:' || l_msg_data ||
146     ', x_conc_req_id:' || l_pickslip_conc_req_id;
147     l_msg := REPLACE(l_msg, CHR(0), ' ');
148     FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, l_module, l_msg);
149   end if;
150   x_return_status := l_return_status;
151   if (l_msg_data is not null) then
152     --needed since WIP does not put messages on stack while INV does.
153   	FND_MSG_PUB.Count_And_Get(
154   	  p_count         	=>      x_msg_count,
155       p_data          	=>      x_msg_data);
156     if (x_msg_count = 0 ) then --means not on stack, add it.
157       fnd_message.set_name('EAM','EAM_GENERIC_ERROR');
158       fnd_message.set_token('EAM_ERROR', l_msg_data );
159       fnd_msg_pub.add;
160     end if;
161   end if;
162 
163   if (l_return_status = 'P') then
164     select sum(quantity_detailed) into l_partial_qty
165     from mtl_txn_request_lines
166     where header_id = (select header_id from mtl_txn_request_headers
167       where request_number = x_request_number
168       and organization_id = p_organization_id);
169     if (l_partial_qty = 0) then
170       fnd_message.set_name('EAM','EAM_MR_NO_MATERIAL_AVAILABLE');
171       fnd_msg_pub.add;
175       fnd_message.set_token('REQUESTED', to_char(p_requested_quantity));
172     else
173       fnd_message.set_name('EAM','EAM_MR_PARTIAL_ALLOCATION');
174       fnd_message.set_token('PARTIAL', to_char(l_partial_qty) );
176       fnd_msg_pub.add;
177     end if;
178   end if;
179 
180   if (x_return_status = FND_API.G_RET_STS_ERROR) then
181     if l_msg_data is null then --should not happen, just a safeguard
182       fnd_message.set_name('EAM','EAM_MR_ALLOCATION_FAILED');
183       fnd_msg_pub.add;
184     end if;
185     RAISE FND_API.G_EXC_ERROR;
186   end if;
187 	-- End of API body.
188 
189 	-- Standard check of p_commit.
190 	IF FND_API.To_Boolean( p_commit ) THEN
191 		COMMIT WORK;
192 	END IF;
193 
194 	-- Standard call to get message count and if count is 1, get message info.
195 	FND_MSG_PUB.Count_And_Get(
196 	  p_count         	=>      x_msg_count,
197     p_data          	=>      x_msg_data);
198   if (l_pLog) then FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, l_module,
199     'End of ' || l_full_name );
200   end if;
201 EXCEPTION
202   WHEN FND_API.G_EXC_ERROR THEN
203     ROLLBACK TO ALLOCATE_EAM;
204     IF ( FND_LOG.LEVEL_EXCEPTION >= FND_LOG.G_CURRENT_RUNTIME_LEVEL ) THEN
205 	    FND_LOG.STRING(FND_LOG.LEVEL_EXCEPTION, l_module,
206 	      'Exception Block 1 - Expected Error' );
207     END IF;
208 		x_return_status := FND_API.G_RET_STS_ERROR ;
209 		FND_MSG_PUB.Count_And_Get(
210 	    p_count         	=>      x_msg_count,
211       p_data          	=>      x_msg_data);
212 	WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
213 		ROLLBACK TO ALLOCATE_EAM;
214 	IF ( l_uLog ) THEN
215 	    FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED, l_module,
216 	      'Exception Block 2 - Unexpected error' );
217 	END IF ;
218 		x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
219 		FND_MSG_PUB.Count_And_Get(
220 	    p_count         	=>      x_msg_count,
221       p_data          	=>      x_msg_data);
222 	WHEN OTHERS THEN
223 		ROLLBACK TO ALLOCATE_EAM;
224 	IF ( l_uLog ) THEN
225 	    FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED, l_module,
226 	      'Exception Block 3 - Others' );
227 	END IF ;
228 		x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
229   	IF 	FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
230 		THEN
231       FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
232 		END IF;
233 		FND_MSG_PUB.Count_And_Get(
234 	    p_count         	=>      x_msg_count,
235       p_data          	=>      x_msg_data);
236 END allocate;
237 
238 
239 --14786085
240 
241   --this version is used in the concurrent request
242   --note the commit at the end of this procedure
243   procedure allocate_comp_mat(errbuf OUT NOCOPY VARCHAR2,
244                      retcode OUT NOCOPY NUMBER,
245                      p_wip_entity_type NUMBER,
246                      p_job_type NUMBER DEFAULT 4,   /*Bug 5932126 (FP of 5880558): Added one new parameter for job type*/
247                      p_days_forward NUMBER,
248                      p_organization_id NUMBER,
249                      p_use_pickset_indicator NUMBER,
250                      p_pick_grouping_rule_id NUMBER := NULL, /* Added as part of Enhancement#2578514*/
251                      p_print_pickslips NUMBER DEFAULT NULL,   /* lookup code is 1 for default YES. This parameter is added as part of Enhancement#2578514*/
252                      p_plan_tasks NUMBER DEFAULT NULL,         /* lookup code is 2 for default NO. This parameter is added as part of Enhancement#2578514*/
253                      p_auto_req_material NUMBER DEFAULT NULL,
254                      p_days_to_alloc NUMBER := NULL)    --only used for rep scheds
255   IS
256 
257 --New EAM Cursor for picking up suitable eAM Records(eAM Enhancement - 13608137)
258 ------------------------------------------------------------------------
259 
260 CURSOR c_eam_jobs(l_auto_req_param IN VARCHAR2 ) is
261        select we.wip_entity_id,
262          we.wip_entity_name,
263          wro.OPERATION_SEQ_NUM,
264          wro.INVENTORY_ITEM_ID,
265          wdj.project_id,
266          wdj.task_id,
267 	 wro.date_required date_required,
268          (wro.required_quantity - wro.quantity_issued
269                   -  nvl(wip_picking_pub.quantity_allocated(WRO.WIP_ENTITY_ID, WRO.OPERATION_SEQ_NUM,
270                                      WRO.ORGANIZATION_ID, WRO.INVENTORY_ITEM_ID,  WRO.REPETITIVE_SCHEDULE_ID, WRO.QUANTITY_ISSUED),0)
271                   -  Nvl(wo.CUMULATIVE_SCRAP_QUANTITY*wro.QUANTITY_PER_ASSEMBLY,0) ) AS requested_quantity
272     from wip_entities we,
273          wip_discrete_jobs wdj,
274          wip_parameters wp,
275          wip_requirement_operations wro,
276          wip_operations wo,
277          mtl_system_items msi
278      where we.wip_entity_id = wdj.wip_entity_id
279      and we.organization_id = wdj.organization_id
280      and wp.organization_id = wdj.organization_id
281      and wp.organization_id = we.organization_id
282      AND we.wip_entity_id = wo.wip_entity_id
283      and wro.organization_id = wo.organization_id
284      and wro.wip_entity_id = wo.wip_entity_id
285      and wro.operation_seq_num = wo.operation_seq_num
286      AND wro.inventory_item_id = msi.inventory_item_id
287      AND wro.organization_id = msi.organization_id
288      AND msi.INVENTORY_ITEM_FLAG LIKE 'Y'
289      and we.entity_type = 6 --only for non-closed workorders
290      and wdj.status_type = 3
291      AND wro.AUTO_REQUEST_MATERIAL = l_auto_req_param
292      --and wdj.MATERIAL_ISSUE_BY_MO LIKE 'Y'    --only for workorders that have Enable Material Request as Yes
293      and we.organization_id = p_organization_id
294      and (wo.count_point_type in (1,2) or wo.count_point_type is null)
298      and wro.date_required < sysdate + p_days_forward
295      and wro.required_quantity > (wro.quantity_issued +
296                       nvl(wip_picking_pub.quantity_allocated(WRO.WIP_ENTITY_ID, WRO.OPERATION_SEQ_NUM,
297                                        WRO.ORGANIZATION_ID, WRO.INVENTORY_ITEM_ID,  WRO.REPETITIVE_SCHEDULE_ID, WRO.QUANTITY_ISSUED),0)+ Nvl(wo.CUMULATIVE_SCRAP_QUANTITY*wro.QUANTITY_PER_ASSEMBLY,0))
299         order by date_required, we.wip_entity_id;
300      /*
301      and exists(
302      select 1
303      from wip_requirement_operations wro,
304      wip_operations wo
305    where we.wip_entity_id = wro.wip_entity_id
306      and we.organization_id = wro.organization_id
307      and wro.wip_entity_id = wo.wip_entity_id(+)
308      and wro.operation_seq_num = wo.operation_seq_num(+)
309      and (wo.count_point_type in (1,2) or wo.count_point_type is null)
310      and wro.required_quantity > (wro.quantity_issued +
311                       nvl(wip_picking_pub.quantity_allocated(WRO.WIP_ENTITY_ID, WRO.OPERATION_SEQ_NUM,
312                                        WRO.ORGANIZATION_ID, WRO.INVENTORY_ITEM_ID,  WRO.REPETITIVE_SCHEDULE_ID, WRO.QUANTITY_ISSUED),0)+ Nvl(wo.CUMULATIVE_SCRAP_QUANTITY*wro.QUANTITY_PER_ASSEMBLY,0))
313      and wro.date_required < sysdate + p_days_forward)
314         order by date_required, we.wip_entity_id;
315 					--changed for 14271265
316 					*/
317 
318 
319     l_wipEntityID NUMBER;
320     l_repSchedID NUMBER;
321     l_projectID NUMBER;
322     l_taskID NUMBER;
323     --i NUMBER := 0;
324     eam_i NUMBER := 0;
325    -- l_allocTbl wip_picking_pub.allocate_tbl_t;
326     l_alloc_comp_tbl_t wip_picking_pub.allocate_comp_tbl_t;
327     l_returnStatus VARCHAR2(1);
328     l_msgData VARCHAR2(2000);
329     l_picksetFlag VARCHAR2(1);
330     l_outBuffer VARCHAR2(240);
331     l_conc_req_id NUMBER;
332     l_msgCount NUMBER := 0;
333     l_mo_req_number VARCHAR2(30);
334     l_print_pickslips varchar2(1);
335     l_plan_tasks   BOOLEAN;
336     l_eam_wro_date_req DATE; --  14271265
337     l_op_seq NUMBER;
338     l_inv_item_id NUMBER;
339     l_auto_req_param VARCHAR2(1);
340     l_requested_qty NUMBER;
341 
342 
343 
344     BEGIN
345 
346     retcode := 0;
347     savepoint eam_allocate_concurrent;
348              IF(p_auto_req_material = 2) THEN
349               l_auto_req_param := 'N';
350              ELSE
351               l_auto_req_param := 'Y';
352              END IF;
353 
354     if(p_wip_entity_type = wip_constants.eam) then
355       --Added for opening the eAM Cursor (Added for eAM Enhancement 13608137 )
356        open c_eam_jobs(l_auto_req_param);
357     end if;
358 
359 	if(p_use_pickset_indicator = 2) then
360       l_picksetFlag := 'N';
361     else
362       l_picksetFlag := 'Y';
363     end if;
364 
365 	if((p_print_pickslips IS NULL) OR (p_print_pickslips = 1)) then
366       l_print_pickslips:= 'T';
367     else
368       l_print_pickslips:='F';
369     end if;
370 
371     if (p_plan_tasks = 1) then
372       l_plan_tasks:= TRUE;
373     else
374       l_plan_tasks:= FALSE;
375     end if;
376 
377 	fnd_message.set_name('FND', 'CONC-PARAMETERS');
378     fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
379 
380     select meaning
381       into l_outBuffer
382       from mfg_lookups
383      where lookup_type = 'SYS_YES_NO'
384        and lookup_code = p_use_pickset_indicator;
385 
386     fnd_message.set_name('WIP', 'WIP_PICKING_USE_PICKSETS');
387     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
388     /* Added as part of Enhancement#2578514*/
389     select meaning
390       into l_outBuffer
391       from mfg_lookups
392      where lookup_type = 'SYS_YES_NO'
393        and lookup_code = p_print_pickslips;
394 
395     fnd_message.set_name('WIP', 'WIP_PICKING_PRINT_PICKSLIPS');
396     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
397     /* Added as part of Enhancement#2578514*/
398     if(p_pick_grouping_rule_id IS NOT NULL) then
399     select name
400       into l_outBuffer
401       from wsh_pick_grouping_rules
402     where pick_grouping_rule_id = p_pick_grouping_rule_id;
403 
404     fnd_message.set_name('WIP', 'WIP_PICKING_PICK_GROUPING_RULE');
405     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
406     end if;
407 
408      /* Added as part of Enhancement#2578514*/
409     select meaning
410       into l_outBuffer
411       from mfg_lookups
412      where lookup_type = 'SYS_YES_NO'
413        and lookup_code = p_plan_tasks;
414 
415     fnd_message.set_name('WIP', 'WIP_PICKING_PLAN_TASKS');
416     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
417 
418     select organization_code
419       into l_outBuffer
420       from MTL_PARAMETERS
421      where organization_id = p_organization_id;
422 
423     fnd_message.set_name('WIP', 'WIP_PICKING_ORG');
424     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
425 
426     fnd_message.set_name('WIP', 'WIP_PICKING_DAYS_FORWARD');
427     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || p_days_forward);
428 
429     select meaning
430       into l_outBuffer
431       from mfg_lookups
432      where lookup_type = 'WIP_ENTITY'
433        and lookup_code = p_wip_entity_type;
434 
435     fnd_message.set_name('WIP', 'WIP_PICKING_MFG_MODE');
436     fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
437 
441    if(p_wip_entity_type = wip_constants.discrete) then
438 
439     /* Bug 6046963: Added below if to print job type parameter in case of Discrete Job Comp Pick Release request only*/
440 
442             --Start - Bug 5932126 (FP of 5880558): Added following code to print new parameter for job type
443             select meaning
444               into l_outBuffer
445               from mfg_lookups
446             where lookup_type = 'WIP_ENTITIES'
447             and   lookup_code = p_job_type ;
448 
449             fnd_message.set_name('WIP', 'WIP_PICKING_JOB_TYPE');
450             fnd_file.put_line(which => fnd_file.output, buff => '  ' || fnd_message.get || ' ' || l_outBuffer);
451             --End - Bug 5932126 (FP of 5880558): Added code to print new parameter for job type
452     end if;
453 
454     fnd_file.put_line(which => fnd_file.output, buff => '');
455     fnd_file.put_line(which => fnd_file.output, buff => '');
456 
457     LOOP
458 
459       IF(p_wip_entity_type = wip_constants.eam) THEN
460 
461          fetch c_eam_jobs into l_wipEntityID, l_outBuffer,l_op_seq,l_inv_item_id, l_projectID, l_taskID, l_eam_wro_date_req, l_requested_qty;
462         exit when c_eam_jobs%NOTFOUND;
463       end if;
464 
465       fnd_file.put_line(which => fnd_file.output, buff => l_outBuffer);
466       --Added for eAM Enhancement 13608137
467     if(p_wip_entity_type = wip_constants.eam) THEN
468         eam_i := eam_i + 1;
469         l_alloc_comp_tbl_t(eam_i).wip_entity_id := l_wipEntityID;
470         l_alloc_comp_tbl_t(eam_i).repetitive_schedule_id := l_repSchedID;
471         l_alloc_comp_tbl_t(eam_i).operation_seq_num := l_op_seq;
472         l_alloc_comp_tbl_t(eam_i).inventory_item_id := l_inv_item_id;
473         l_alloc_comp_tbl_t(eam_i).project_id := l_projectID;
474         l_alloc_comp_tbl_t(eam_i).task_id := l_taskID;
475         l_alloc_comp_tbl_t(eam_i).use_pickset_flag := l_picksetFlag;
476 	l_alloc_comp_tbl_t(eam_i).requested_quantity := l_requested_qty;
477      END IF;
478 
479 
480     end loop;
481 
482        	  --Added for eAM Enhancement  13608137
483     if(c_eam_jobs%ISOPEN) then
484        close c_eam_jobs;
485     end if;
486 
487     IF(eam_i>0)   THEN
488 
489                WIP_PICKING_PVT.allocate_comp(p_alloc_comp_tbl => l_alloc_comp_tbl_t,
490                p_days_to_alloc => p_days_to_alloc, --not null only for rep scheds
491                p_auto_detail_flag => NULL,
492                p_cutoff_date => sysdate + p_days_forward,
493                p_wip_entity_type => p_wip_entity_type,
494                p_organization_id => p_organization_id,
495                p_pick_grouping_rule_id => p_pick_grouping_rule_id,  /* Added as part of Enhancement#2578514*/
496                p_print_pick_slip => l_print_pickslips,              /* Added as part of Enhancement#2578514*/
497                p_plan_tasks      => l_plan_tasks,                   /* Added as part of Enhancement#2578514*/
498                x_conc_req_id => l_conc_req_id,
499                x_mo_req_number => l_mo_req_number,
500                x_return_status => l_returnStatus,
501                x_msg_data => errbuf);
502     END IF;
503 
504     if(l_returnStatus = 'P') then
505         fnd_message.set_name('WIP','WIP_PICKING_MO_NUMBER');
506         fnd_message.set_token('MO_NUMBER',l_mo_req_number);
507         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
508         fnd_message.set_name('WIP', 'WIP_PICKING_PARTIAL_ALLOC_CONC');
509         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
510         if(l_print_pickslips = 'T') then
511           fnd_message.set_name('WIP','WIP_PICKING_PRINT_SLIP');
512           fnd_message.set_token('REQ_NUMBER',l_conc_req_id);
513           fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
514         end if;
515 
516       elsif(l_returnStatus = 'S') then
517         fnd_message.set_name('WIP','WIP_PICKING_MO_NUMBER');
518         fnd_message.set_token('MO_NUMBER',l_mo_req_number);
519         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
520         if(l_print_pickslips = 'T') then
521           fnd_message.set_name('WIP','WIP_PICKING_PRINT_SLIP');
522           fnd_message.set_token('REQ_NUMBER',l_conc_req_id);
523           fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
524         end if;
525         fnd_message.set_name('WIP', 'WIP_TXN_COMPLETED');
526         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
527 
528       elsif(l_returnStatus = 'N') then
529         fnd_message.set_name('WIP','WIP_PICKING_NO_ALLOCATION_CONC');
530         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
531 
532       else
533         fnd_file.put_line(which => fnd_file.output, buff => '');
534         fnd_message.set_name('WIP', 'ERROR_DIALOG_TITLE');
535         fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
536         fnd_file.put_line(which => fnd_file.output,
537                           buff => 'Returned status: ' || l_returnStatus);
538         fnd_file.put_line(which => fnd_file.output,
539                           buff => 'Returned message: ' || errbuf);
540         fnd_file.put_line(which => fnd_file.output,
541                           buff => 'Parameters passed to allocate():');
542         fnd_file.put_line(which => fnd_file.output, buff => 'p_days_to_alloc='  ||
543               p_days_to_alloc || ';p_days_forward=' || p_days_forward ||
544               ';p_wip_entity_type=' || p_wip_entity_type || ';p_organization_id=' ||
545               p_organization_id || ';p_pick_grouping_rule_id=' || p_pick_grouping_rule_id
546               || ';l_print_pickslips=' || l_print_pickslips );
547     end if;
548 
549    /*bugfix 4435437: set the process to warning if failed */
550    if (WIP_PICKING_PVT.g_PickRelease_Failed = TRUE) then
551       retcode := 1 ;
552    end if;
556       errbuf := SQLERRM;
553     commit;
554   exception
555     when others then
557       retcode := 2;
558       fnd_file.put_line(which => fnd_file.output, buff => '');
559       fnd_file.put_line(which => fnd_file.output, buff => '');
560       fnd_message.set_name('WIP', 'ERROR_DIALOG_TITLE');
561       fnd_file.put_line(which => fnd_file.output, buff => fnd_message.get);
562       for i in 1..l_msgCount loop
563         fnd_file.put_line(which => fnd_file.output, buff => fnd_msg_pub.get(p_msg_index => l_msgCount - i + 1, p_encoded => fnd_api.g_false));
564       end loop;
565       rollback to eam_allocate_concurrent;
566   end allocate_comp_mat;
567 
568 END  EAM_MATERIAL_REQUEST_PVT;