1 PACKAGE BODY eam_transactions_pvt AS
2 /* $Header: EAMVTXNB.pls 115.3 2002/11/20 19:05:35 aan noship $*/
3
4 G_PKG_NAME CONSTANT VARCHAR2(30) := '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_commit in VARCHAR2 := FND_API.G_FALSE,
21 x_errCode OUT NOCOPY NUMBER,
22 x_msg_count OUT NOCOPY NUMBER,
23 x_msg_data OUT NOCOPY VARCHAR2,
24 x_return_status OUT NOCOPY VARCHAR2,
25 x_statement OUT NOCOPY NUMBER) IS
26
27 l_transaction_header_id NUMBER;
28 l_transaction_temp_id NUMBER;
29 l_serial_transaction_temp_id NUMBER;
30 l_transaction_temp_id_s NUMBER;
31 l_transaction_quantity NUMBER;
32 l_primary_quantity NUMBER;
33 l_transaction_action_id NUMBER;
34 l_transaction_type_id NUMBER;
35 l_transaction_source_type_id NUMBER;
36 l_project_id NUMBER;
37 l_task_id NUMBER;
38 l_revision VARCHAR2(3);
39 item wma_common.Item;
40 l_statement NUMBER := 0;
41
42 BEGIN
43
44 -- prepare the data to insert into MTL_MATERIAL_TRANSACTIONS_TEMP,
45 -- MTL_SERIAL_NUMBERS_TEMP, and MTL_TRANSACTION_LOTS_TEMP
46 select mtl_material_transactions_s.nextval into l_transaction_header_id
47 from dual;
48
49 x_statement := 10;
50
51 -- Initialize API return status to success
52 x_return_status := FND_API.G_RET_STS_SUCCESS;
53
54 -- get the item info
55 item := wma_derive.getItem(p_inventory_item_id, p_organization_id, p_locator_id);
56 if (item.invItemID is null) then
57 fnd_message.set_name ('EAM', 'EAM_ITEM_DOES_NOT_EXIST');
58 x_errCode := 1;
59 x_return_status := 'E';
60 x_msg_data := fnd_message.get;
61 return;
62 end if; -- end item info check
63
64 x_statement := 20;
65
66 /*
67 -- get bom_revision
68 bom_revisions.get_revision (examine_type => 'ALL',
69 org_id => p_organization_id,
70 item_id => p_rebuild_item_id,
71 rev_date => sysdate,
72 itm_rev => l_revision);
73 -- i_revision := null;
74 */
75 l_revision := null;
76
77
78 l_primary_quantity := p_transaction_quantity;
79
80 -- call inventory API to insert data to mtl_material_transactions_temp
81 -- the spec file is INVTRXUS.pls
82
83 x_errCode := inv_trx_util_pub.insert_line_trx(
84 p_trx_hdr_id => l_transaction_header_id,
85 p_item_id => p_inventory_item_id,
86 p_revision => l_revision,
87 p_org_id => p_organization_id,
88 p_trx_action_id => p_transaction_action_id,
89 p_subinv_code => p_subinventory,
90 p_locator_id => p_locator_id,
91 p_trx_type_id => p_transaction_type_id,
92 p_trx_src_type_id => p_transaction_source_type_id,
93 p_dist_id => p_dist_acct_id,
94 p_trx_qty => p_transaction_quantity,
95 p_pri_qty => l_primary_quantity,
96 p_uom => item.primaryUOMCode,
97 p_date => sysdate,
98 p_user_id => p_user_id,
99 x_trx_tmp_id => l_transaction_temp_id,
100 x_proc_msg => x_msg_data);
101
102 x_statement := 30;
103
104 if (x_errCode <> 0) then
105 x_return_status := 'E';
106 return;
107 end if;
108
109 -- Check whether the item is under lot or serial control or not
110 -- If it is, insert the data to coresponding tables
111 if(item.lotControlCode = WIP_CONSTANTS.LOT) then
112
113 -- the item is under lot control
114
115 -- call inventory API to insert data to mtl_transaction_lots_temp
116 -- the spec file is INVTRXUS.pls
117 x_errCode := inv_trx_util_pub.insert_lot_trx(
118 p_trx_tmp_id => l_transaction_temp_id,
119 p_user_id => p_user_id,
120 p_lot_number => p_lot_number,
121 p_trx_qty => p_transaction_quantity,
122 p_pri_qty => l_primary_quantity,
123 x_ser_trx_id => l_serial_transaction_temp_id,
124 x_proc_msg => x_msg_data);
125
126 if (x_errCode <> 0) then
127 x_return_status := 'E';
128 return;
129 end if;
130
131 else
132 null;
133 end if; -- end lot control check
134
135 -- Check if the item is under serial control or not
136 if(item.serialNumberControlCode in (WIP_CONSTANTS.FULL_SN,
137 WIP_CONSTANTS.DYN_RCV_SN)) then
138 -- item is under serial control
139
140 -- Check if the item is under lot control or not
141 if(item.lotControlCode = WIP_CONSTANTS.LOT) then
142
143 -- under lot control
144 l_transaction_temp_id_s := l_serial_transaction_temp_id;
145 else
146 l_transaction_temp_id_s := l_transaction_temp_id;
147 end if; -- end lot control check
148
149
150 -- call inventory API to insert data to mtl_serial_numbers_temp
151 -- the spec file is INVTRXUS.pls
152 x_errCode := inv_trx_util_pub.insert_ser_trx(
153 p_trx_tmp_id => l_transaction_temp_id_s,
154 p_user_id => p_user_id,
155 p_fm_ser_num => p_serial_number,
156 p_to_ser_num => p_serial_number,
157 x_proc_msg => x_msg_data);
158
159 if (x_errCode <> 0) then
160 return;
161 end if;
162
163 else
164 null;
165 end if; -- end serial control check
166
167 x_statement := 40;
168
169 -- Call Inventory API to process to item
170 -- the spec file is INVTRXWS.pls
171
172 x_errCode := inv_lpn_trx_pub.process_lpn_trx(
173 p_trx_hdr_id => l_transaction_header_id,
174 p_commit => p_commit,
175 x_proc_msg => x_msg_data);
176
177 x_statement := 50;
178
179 END process_eam_txn;
180
181
182 END eam_transactions_pvt;
183