DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_KANBAN_GRP

Source


1 PACKAGE BODY INV_KANBAN_GRP as
2 /* $Header: INVGKBNB.pls 115.1 2003/08/21 01:11:53 cjandhya noship $ */
3 
4 G_PKG_NAME                    CONSTANT VARCHAR2(30) := 'INV_KANBAN_GRP';
5 
6 PROCEDURE mydebug(msg IN VARCHAR2) IS
7 BEGIN
8    inv_log_util.trace(msg, 'INV_KANBAN_GRP', 9);
9 END mydebug;
10 
11 /*****************************************************************
12 ** API name    INV_KANBAN_GRP
13 ** Type        Group
14 **
15 **
16 **Version     Current version = 1.0
17 **            Initial version = 1.0
18 **Name
19 ** PROCEDURE UPDATE_CARD_SUPPLY_STATUS
20 **
21 ** Purpose
22 **    This procedure updates the supply status of the kanban card.
23 ** Input parameters
24 **  p_api_version      IN  NUMBER (required)
25 **                API Version of this procedure
26 **  p_init_msg_level   IN  VARCHAR2 (optional)
27 **                     DEFAULT = FND_API.G_FALSE,
28 **  p_commit           IN  VARCHAR2 (optional)
29 **                     DEFAULT = FND_API.G_FALSE,
30 **  p_kanban_card_id   In VARCHAR2 (required)
31 **                     kanban card id to be updated
32 **  p_supply_status    IN varchar2 (required)
33 **                       INV_KANBAN_PVT.G_Supply_Status_New
34 **                       INV_KANBAN_PVT.G_Supply_Status_Full
35 **                       INV_KANBAN_PVT.G_Supply_Status_Empty
36 **                       INV_KANBAN_PVT.G_Supply_Status_InProcess
37 **                       INV_KANBAN_PVT.G_Supply_Status_InTransit
38 **  p_document_type   IN NUMBER
39 **                     INV_KANBAN_PVT.G_Doc_type_PO          	  1;
40 **                     INV_KANBAN_PVT.G_Doc_type_Release    	  2;
41 **                     INV_KANBAN_PVT.G_Doc_type_Internal_Req	  3;
42 **                     INV_KANBAN_PVT.G_Doc_type_Transfer_Order     4;
43 **                     INV_KANBAN_PVT.G_Doc_type_Discrete_Job       5;
44 **                     INV_KANBAN_PVT.G_Doc_type_Rep_Schedule       6;
45 **                     INV_KANBAN_PVT.G_Doc_type_Flow_Schedule      7;
46 **                     INV_KANBAN_PVT.G_Doc_type_lot_job   	  8;
47 **  p_Document_Header_Id IN  NUMBER
48 **                     Document header id displayed on card activity
49 **  p_Document_detail_Id IN  NUMBER
50 **                     Document detail id displayed on card activity
51 **  p_need_by_date       IN  DATE
52 **                     Need by date to be specified on the requisition
53 **  P_replenish_quantity IN  NUMBER
54 **                     Overrides the kanban size if passed
55 **  p_source_wip_entity_id IN NUMBER
56 **                     SOURCE_WIP_ENTITY diplayed on card activity.
57 **  Output Parameters
58 **    x_msg_count - number of error messages in the buffer
59 **    x_msg_data  - error messages
60 **    x_return_status - fnd_api.g_ret_sts_error, fnd_api.g_ret_sts_success,
61 **                      fnd_api.g_ret_unexp_error
62 ******************************************************************/
63 
64 PROCEDURE UPDATE_CARD_SUPPLY_STATUS
65   (x_msg_count                     OUT NOCOPY NUMBER,
66    x_msg_data                      OUT NOCOPY VARCHAR2,
67    x_return_status                 OUT NOCOPY VARCHAR2,
68    p_api_version_number            IN  NUMBER,
69    p_init_msg_list                 IN  VARCHAR2 := FND_API.G_FALSE,
70    p_commit                        IN  VARCHAR2 := FND_API.G_FALSE,
71    p_kanban_card_id                IN  NUMBER,
72    p_supply_status                 IN  NUMBER,
73    p_document_type                 IN  NUMBER DEFAULT NULL,
74    p_document_header_id            IN  NUMBER DEFAULT NULL,
75    p_document_detail_id            IN  NUMBER DEFAULT NULL,
76    p_replenish_quantity            IN  NUMBER DEFAULT NULL,
77    p_need_by_date                  IN  DATE   DEFAULT NULL,
78    p_source_wip_entity_id          IN  NUMBER DEFAULT NULL
79  )
80   IS
81 
82      l_api_version_number          CONSTANT NUMBER := 1.0;
83      l_api_name                    CONSTANT VARCHAR2(30):= 'UPDATE_CARD_SUPPLY_STATUS';
84 BEGIN
85    mydebug('Input: kcard id '||p_kanban_card_id||
86 	   'Sup_Sts  '||p_supply_status||
87 	   'doc type '||p_document_type||
88 	   'doc Hdr  '||p_document_header_id||
89 	   'doc dtl  '||p_document_detail_id);
90 
91    mydebug('need by date '||p_need_by_date||
92 	   'source wip id '||p_source_wip_entity_id);
93    --  Standard call to check for call compatibility
94 
95    IF NOT FND_API.COMPATIBLE_API_CALL
96      (   l_api_version_number
97 	 ,   p_api_version_number
98 	 ,   l_api_name
99 	 ,   G_PKG_NAME
100 	 )
101      THEN
102       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
103    END IF;
104 
105    mydebug('Calling INV_Kanban_PVT.Update_Card_Supply_Status');
106 
107    INV_KANBAN_PVT.UPDATE_CARD_SUPPLY_STATUS
108      (   p_api_version_number          => 1.0
109 	 ,   p_init_msg_list               => p_init_msg_list
110 	 ,   p_validation_level            => FND_API.G_VALID_LEVEL_FULL
111 	 ,   p_commit                      => p_commit
112 	 ,   x_return_status               => x_return_status
113 	 ,   x_msg_count                   => x_msg_count
114 	 ,   x_msg_data                    => x_msg_data
115 	 ,   p_kanban_card_id              => p_kanban_card_id
116 	 ,   p_supply_status               => p_supply_status
117 	 ,   p_document_type               => p_document_type
118 	 ,   p_document_header_id          => p_document_header_id
119 	 ,   p_document_detail_id          => p_document_detail_id
120 	 ,   p_replenish_quantity          => p_replenish_quantity
121 	 ,   p_need_by_date                => p_need_by_date
122 	 ,   p_source_wip_entity_id        => p_source_wip_entity_id);
123 
124    mydebug('ret_sts '||x_return_status||
125 	   'msg '||x_msg_data||
126 	   'msg cnt'||x_msg_count);
127 EXCEPTION
128    WHEN FND_API.G_EXC_ERROR THEN
129       x_return_status := FND_API.G_RET_STS_ERROR;
130       --  Get message count and data
131       FND_MSG_PUB.Count_And_Get
132         (   p_count  => x_msg_count
133 	    ,p_data  => x_msg_data
134 	    );
135 
136    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
137          x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
138          --  Get message count and data
139 
140 	 FND_MSG_PUB.Count_And_Get
141 	   (   p_count  => x_msg_count
142 	       ,p_data  => x_msg_data
143 	       );
144 
145    WHEN OTHERS THEN
146       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
147       IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
148         THEN
149 	 FND_MSG_PUB.Add_Exc_Msg
150 	   (   G_PKG_NAME
151 	       ,'Update_Card_Supply_Status'
152 	       );
153       END IF;
154       --  Get message count and data
155       FND_MSG_PUB.Count_And_Get
156         (   p_count   => x_msg_count
157 	    ,p_data   => x_msg_data
158 	    );
159 
160 END UPDATE_CARD_SUPPLY_STATUS;
161 
162 
163 
164 
165 PROCEDURE Create_Non_Replenishable_Card
166   (X_Return_Status      Out NOCOPY Varchar2,
167    x_msg_data           OUT NOCOPY VARCHAR2,
168    x_msg_count          OUT NOCOPY NUMBER,
169    X_Kanban_Card_Id 	OUT NOCOPY NUMBER,
170    p_pull_sequence_id   IN  NUMBER,
171    p_kanban_size        IN  NUMBER)
172   IS
173      CURSOR pullseq IS
174 	SELECT
175           pull_sequence_id , organization_id , inventory_item_id ,
176           subinventory_name , locator_id , source_type , supplier_id,
177           supplier_site_id, source_organization_id, source_subinventory,
178 	  source_locator_id, wip_line_id, kanban_size, number_of_cards,
179 	  release_kanban_flag
180 	  from
181           MTL_KANBAN_PULL_SEQUENCES
182 	  where
183           pull_sequence_id = p_pull_sequence_id;
184 
185      l_kanban_card_ids    INV_Kanban_PVT.kanban_card_id_tbl_type;
186      l_pull_seq_rec       INV_Kanban_PVT.pull_sequence_rec_type;
187      l_return_status      varchar2(1) := FND_API.G_RET_STS_SUCCESS;
188      l_pullseq_found BOOLEAN := FALSE;
189 BEGIN
190 
191    mydebug('p_pull_sequence_id '||p_pull_sequence_id);
192    mydebug('p_kanban_size      '||p_kanban_size);
193 
194    FOR pullseq_rec IN pullseq LOOP
195 
196       l_pullseq_found := TRUE;
197 
198       l_pull_seq_rec.pull_sequence_id          := pullseq_rec.pull_sequence_id;
199       l_pull_seq_rec.organization_id           := pullseq_rec.organization_id;
200       l_pull_seq_rec.inventory_item_id         := pullseq_rec.inventory_item_id;
201       l_pull_seq_rec.subinventory_name         := pullseq_rec.subinventory_name;
202       l_pull_seq_rec.locator_id                := pullseq_rec.locator_id;
203       l_pull_seq_rec.source_type               := pullseq_rec.source_type;
204       l_pull_seq_rec.Kanban_size               := Nvl(p_kanban_size, pullseq_rec.kanban_size);
205       l_pull_seq_rec.number_of_cards           := 1;
206       l_pull_seq_rec.supplier_id               := pullseq_rec.supplier_id;
207       l_pull_seq_rec.supplier_site_id          := pullseq_rec.supplier_site_id;
208       l_pull_seq_rec.source_organization_id    := pullseq_rec.source_organization_id;
209       l_pull_seq_rec.source_subinventory       := pullseq_rec.source_subinventory;
210       l_pull_seq_rec.source_locator_id         := pullseq_rec.source_locator_id;
211       l_pull_seq_rec.wip_line_id       	       := pullseq_rec.wip_line_id;
212       l_pull_seq_rec.release_kanban_flag       := pullseq_rec.release_kanban_flag;
213       l_pull_seq_rec.Kanban_Card_Type 	       := INV_Kanban_Pvt.g_card_type_nonreplenishable;
214 
215       -- No need to check for non replenishable cards
216       -- if  INV_kanban_PVT.Ok_To_Create_Kanban_Cards(p_pull_sequence_id => p_Pull_sequence_id )  then
217 
218 	 mydebug('OK to create kanban cards');
219 
220 	 INV_kanban_PVT.create_kanban_cards( X_return_status          => l_return_status,
221 					     x_kanban_card_ids        => l_kanban_card_ids,
222 					     p_pull_sequence_rec      => l_pull_seq_rec,
223 					     p_supply_status          => inv_kanban_pvt.g_supply_status_new);
224 
225 	 mydebug('INV_kanban_PVT.create_kanban_cards ret_sts '||l_return_status);
226 
227 	  if  l_return_status = FND_API.G_RET_STS_ERROR  then
228 	    Raise FND_API.G_EXC_ERROR;
229 	  elsif l_return_status = FND_API.G_RET_STS_UNEXP_ERROR then
230 	     Raise FND_API.G_EXC_UNEXPECTED_ERROR;
231 	   ELSIF  l_return_status <>  FND_API.g_ret_sts_success THEN
232 	     Raise FND_API.G_EXC_UNEXPECTED_ERROR;
233 	 end if;
234 
235 	 IF l_kanban_card_ids.count >= 1 THEN
236 	    mydebug(' Created Kanban_card '||l_kanban_card_ids(1));
237 	    x_kanban_card_id := l_kanban_card_ids(1);
238 	  ELSE
239 	    mydebug(' No cards created') ;
240 	    x_kanban_card_id := NULL;
241 	 END IF;
242 
243        --ELSE --if  INV_kanban_PVT.Ok_To_Create_Kanban_Cards(p_pull_sequence_id => p_Pull_sequence_id )
244        -- mydebug('Not OK to create kanban cards');
245        -- Raise FND_API.G_EXC_ERROR;
246        --END if;--if  INV_kanban_PVT.Ok_To_Create_Kanban_Cards(p_pull_sequence_id => p_Pull_sequence_id )
247 
248    END LOOP;--FOR pullseq_rec IN pullseq LOOP
249 
250    IF l_pullseq_found = FALSE THEN
251       mydebug('No pull sequence found');
252       FND_MESSAGE.SET_NAME('INV','INV_INVALID_PULL_SEQ');
253       FND_MSG_PUB.Add;
254       Raise FND_API.G_EXC_ERROR;
255    END IF;
256 
257    x_return_status := fnd_api.g_ret_sts_success;
258 
259 EXCEPTION
260 
261    WHEN FND_API.G_EXC_ERROR THEN
262 
263         x_return_status := FND_API.G_RET_STS_ERROR;
264 
265         --  Get message count and data
266 
267         FND_MSG_PUB.Count_And_Get
268         (   p_count                       => x_msg_count
269 	    ,   p_data                        => x_msg_data
270         );
271 
272    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
273 
274         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
275 
276         --  Get message count and data
277 
278         FND_MSG_PUB.Count_And_Get
279 	  (   p_count                       => x_msg_count
280 	      ,   p_data                        => x_msg_data
281         );
282 
283     WHEN OTHERS THEN
284 
285        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
286 
287        IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
288 	 THEN
289             FND_MSG_PUB.Add_Exc_Msg
290 	      (   G_PKG_NAME
291 		  ,'Create_Non_Replenishable_Card'
292 		  );
293        END IF;
294 
295        --  Get message count and data
296 
297        FND_MSG_PUB.Count_And_Get
298         (   p_count                       => x_msg_count
299 	    ,p_data                        => x_msg_data
300 	    );
301 
302 
303 END Create_Non_Replenishable_Card;
304 
305 END INV_Kanban_GRP;