DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_EAM_TRANSACTIONS_PVT

Source


1 PACKAGE BODY WIP_EAM_TRANSACTIONS_PVT AS
2 /* $Header: WIPVETXB.pls 115.4 2003/03/27 00:45:26 hkarmach noship $*/
3 
4 G_PKG_NAME             CONSTANT VARCHAR2(30) := 'WIP_EAM_TRANSACTIONS_PVT';
5 
6 PROCEDURE process_eam_txn(
7                        p_subinventory               IN  VARCHAR2 := null,
8                        p_lot_number                 IN  VARCHAR2 := null,
9                        p_serial_number              IN  VARCHAR2 := null,
10                        p_organization_id            IN  NUMBER   := null,
11                        p_locator_id                 IN  NUMBER   := null,
12                        p_qa_collection_id           IN  NUMBER   := null,
13                        p_inventory_item_id          IN  NUMBER   := null,
14                        p_dist_acct_id               IN  NUMBER   := null,
15                        p_user_id                    IN  NUMBER   := FND_GLOBAL.USER_ID,
16                        p_transaction_type_id        IN  NUMBER   := null,
17                        p_transaction_source_type_id IN  NUMBER   := null,
18                        p_transaction_action_id      IN  NUMBER   := null,
19                        p_transaction_quantity       IN  number   := 0,
20 		       p_revision		    IN  VARCHAR2 := null,
21                        p_commit                     IN  VARCHAR2 := FND_API.G_FALSE,
22                        x_errCode                    OUT NOCOPY NUMBER,
23                        x_msg_count                  OUT NOCOPY NUMBER,
24                        x_msg_data                   OUT NOCOPY VARCHAR2,
25                        x_return_status              OUT NOCOPY VARCHAR2,
26                        x_statement                  OUT NOCOPY NUMBER) IS
27 
28   l_transaction_header_id      NUMBER;
29   l_transaction_temp_id        NUMBER;
30   l_serial_transaction_temp_id NUMBER;
31   l_transaction_temp_id_s      NUMBER;
32   l_transaction_quantity       NUMBER;
33   l_primary_quantity           NUMBER;
34   l_transaction_action_id      NUMBER;
35   l_transaction_type_id        NUMBER;
36   l_transaction_source_type_id NUMBER;
37   l_project_id                 NUMBER;
38   l_transaction_flag	       VARCHAR2(3);
39   l_task_id                    NUMBER;
40   l_revision                   VARCHAR2(3);
41   item                         wma_common.Item;
42   l_statement                  NUMBER := 0;
43 
44 BEGIN
45 
46 
47     savepoint eam_transaction;
48 
49 
50 -- prepare the data to insert into MTL_MATERIAL_TRANSACTIONS_TEMP,
51 -- MTL_SERIAL_NUMBERS_TEMP, and MTL_TRANSACTION_LOTS_TEMP
52     select mtl_material_transactions_s.nextval
53       into l_transaction_header_id
54       from dual;
55 
56     x_statement := 10;
57 
58    --  Initialize API return status to success
59     x_return_status := FND_API.G_RET_STS_SUCCESS;
60 
61   -- get the item info
62     item := wma_derive.getItem(p_inventory_item_id, p_organization_id, p_locator_id);
63 
64     if (item.invItemID is null) then
65 
66         fnd_message.set_name ('WIP', 'WIP_EAM_ITEM_DOES_NOT_EXIST');
67         x_errCode := 1;
68         x_return_status := 'E';
69         x_msg_data  := fnd_message.get;
70 
71         return;
72 
73     end if; -- end item info check
74 
75     x_statement := 20;
76 
77 --  check if the item is transactable and in active status.
78 --  If not, raise an error.
79 
80 	select mtl_transactions_enabled_flag
81 	into l_transaction_flag
82 	from mtl_system_items
83 	where inventory_item_id = p_inventory_item_id
84 	and organization_id = p_organization_id;
85 
86 	if l_transaction_flag = 'N' then
87 		fnd_message.set_name('WIP', 'WIP_EAM_ITEM_NONTRANSACTABLE');
88         	FND_MSG_PUB.ADD;
89         	RAISE FND_API.G_EXC_ERROR;
90 	end if;
91 
92     l_revision := p_revision;
93 
94     l_primary_quantity := p_transaction_quantity;
95 
96 -- call inventory API to insert data to mtl_material_transactions_temp
97 -- the spec file is INVTRXUS.pls
98 
99     x_errCode := inv_trx_util_pub.insert_line_trx(
100                  p_trx_hdr_id      => l_transaction_header_id,
101                  p_item_id         => p_inventory_item_id,
102                  p_revision        => l_revision,
103                  p_org_id          => p_organization_id,
104 --               p_transaction_mode => 1,
105                  p_trx_action_id   => p_transaction_action_id,
106                  p_subinv_code     => p_subinventory,
107                  p_locator_id      => p_locator_id,
108                  p_trx_type_id     => p_transaction_type_id,
109                  p_trx_src_type_id => p_transaction_source_type_id,
110                  p_dist_id         => p_dist_acct_id,
111                  p_trx_qty         => p_transaction_quantity,
112                  p_pri_qty         => l_primary_quantity,
113                  p_uom             => item.primaryUOMCode,
114                  p_date            => sysdate,
115                  p_user_id         => p_user_id,
116                  x_trx_tmp_id      => l_transaction_temp_id,
117                  x_proc_msg        => x_msg_data);
118 
119     x_statement := 30;
120 
121     if (x_errCode <> 0) then
122 
123         x_return_status := 'E';
124         return;
125 
126     end if;
127 
128 -- Check whether the item is under lot or serial control or not
129 -- If it is, insert the data to coresponding tables
130 
131     if(item.lotControlCode = WIP_CONSTANTS.LOT) then
132     -- the item is under lot control
133 
134 -- call inventory API to insert data to mtl_transaction_lots_temp
135 -- the spec file is INVTRXUS.pls
136         x_errCode := inv_trx_util_pub.insert_lot_trx(
137                      p_trx_tmp_id    => l_transaction_temp_id,
138                      p_user_id       => p_user_id,
139                      p_lot_number    => p_lot_number,
140                      p_trx_qty       => p_transaction_quantity,
141                      p_pri_qty       => l_primary_quantity,
142                      x_ser_trx_id    => l_serial_transaction_temp_id,
143                      x_proc_msg      => x_msg_data);
144 
145         if (x_errCode <> 0) then
146 
147             x_return_status := 'E';
148             return;
149 
150         end if;
151 
152 --    else
153 --        null;
154 
155     end if; -- end lot control check
156 
157   -- Check if the item is under serial control or not
158     if(item.serialNumberControlCode in (WIP_CONSTANTS.FULL_SN, WIP_CONSTANTS.DYN_RCV_SN)) then
159     -- item is under serial control
160 
161     -- Check if the item is under lot control or not
162         if(item.lotControlCode = WIP_CONSTANTS.LOT) then
163         -- under lot control
164             l_transaction_temp_id_s := l_serial_transaction_temp_id;
165 
166         else
167 
168             l_transaction_temp_id_s := l_transaction_temp_id;
169 
170         end if;   -- end lot control check
171 
172     -- call inventory API to insert data to mtl_serial_numbers_temp
173     -- the spec file is INVTRXUS.pls
174         x_errCode := inv_trx_util_pub.insert_ser_trx(
175                        p_trx_tmp_id     => l_transaction_temp_id_s,
176                        p_user_id        => p_user_id,
177                        p_fm_ser_num     => p_serial_number,
178                        p_to_ser_num     => p_serial_number,
179                        x_proc_msg       => x_msg_data);
180 
181         if (x_errCode <> 0) then
182 
183             return;
184 
185         end if;
186 
187     else
188 
189         null;
190 
191     end if;  -- end serial control check
192 
193     x_statement := 40;
194 
195 -- Call Inventory API to process to item
196 -- the spec file is INVTRXWS.pls
197 
198 /*
199              UPDATE MTL_MATERIAL_TRANSACTIONS_TEMP
200              SET TRANSACTION_MODE = 1
201              WHERE TRANSACTION_HEADER_ID = l_transaction_temp_id;
202 */
203 
204     x_errCode := inv_lpn_trx_pub.process_lpn_trx(
205                        p_trx_hdr_id => l_transaction_header_id,
206                        p_proc_mode  => 1,
207                        p_commit     => p_commit,
208                        x_proc_msg   => x_msg_data);
209 
210     x_statement := 50;
211 
212     exception
213     WHEN FND_API.G_EXC_ERROR THEN
214 
215         ROLLBACK TO eam_transaction;
216 
217         x_return_status := FND_API.G_RET_STS_ERROR;
218 
219         FND_MSG_PUB.Count_And_Get
220         (   p_encoded           =>      FND_API.G_FALSE,
221             p_count             =>      x_msg_count,
222             p_data              =>      x_msg_data
223         );
224 
225      WHEN OTHERS THEN
226 
227         ROLLBACK TO eam_transaction;
228 
229         x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
230 
231         FND_MSG_PUB.Count_And_Get
232         (   p_encoded           =>      FND_API.G_FALSE,
233             p_count             =>      x_msg_count,
234             p_data              =>      x_msg_data
235         );
236 
237 END process_eam_txn;
238 
239 END WIP_EAM_TRANSACTIONS_PVT;