1 PACKAGE BODY AHL_UC_Utilization_PUB AS
2 /* $Header: AHLPUCUB.pls 115.1 2002/12/04 19:08:48 sracha noship $ */
3
4
5 G_PKG_NAME CONSTANT VARCHAR2(30) := 'AHL_UC_Utilization_PUB';
6
7
8 -----------------------------------------
9 -- Define Procedure for Utilization --
10 -----------------------------------------
11 -- Start of Comments --
12 -- Procedure name : Update_Utilization
13 -- Type : Public
14 -- Function : Updates the utilization based on the counter rules defined in the master configuration
15 -- given the details of an item/counter id/counter name/uom_code.
16 -- Casacades the updates down to all the children if the cascade_flag is set to 'Y'.
17 -- Pre-reqs :
18 -- Parameters :
19 -- Standard IN Parameters :
20 -- p_api_version IN NUMBER Required
21 -- p_init_msg_list IN VARCHAR2 Default FND_API.G_FALSE
22 -- p_commit IN VARCHAR2 Default FND_API.G_FALSE
23 -- p_validation_level IN NUMBER Default FND_API.G_VALID_LEVEL_FULL
24 --
25 -- Standard OUT Parameters :
26 -- x_return_status OUT VARCHAR2 Required
27 -- x_msg_count OUT NUMBER Required
28 -- x_msg_data OUT VARCHAR2 Required
29 --
30 -- Update_Utilization Parameters:
31 --
32 -- p_Utilization_tbl IN Required.
33 -- For each record, at any given time only one of the following combinations is valid to identify the
34 -- item instance to be updated:
35 -- 1. Organization id and Inventory_item_id AND Serial Number.
36 -- This information will identify the part number and serial number of a configuration.
37 -- 2. Counter ID -- if this is passed a specific counter ONLY will be updated irrespective of the value
38 -- of p_cascade_flag.
39 -- 3. CSI_ITEM_INSTANCE_ID -- if this is passed, then this item instance and items down the hierarchy (depends on
40 -- the value cascade_flag) will be updated.
41 -- At any given time only one of the following combinations is valid to identify the type of item counters to be
42 -- updated:
43 -- 1. UOM_CODE
44 -- 2. COUNTER_NAME
45 --
46 -- Reading_Value IN Required.
47 -- This will be the value of the counter reading.
48 --
49 -- cascade_flag -- Can take values Y and N. Y indicates that the counter updates will cascade down the hierarchy
50 -- beginning at the item number passed. Ift its value is N then only the item counter will be updated.
51 --
52
53 -- End of Comments --
54
55
56 PROCEDURE Update_Utilization(p_api_version IN NUMBER,
57 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE,
58 p_commit IN VARCHAR2 := FND_API.G_FALSE,
59 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
60 p_Utilization_tbl IN AHL_UC_Utilization_PVT.Utilization_Tbl_Type,
61 x_return_status OUT NOCOPY VARCHAR2,
62 x_msg_count OUT NOCOPY NUMBER,
63 x_msg_data OUT NOCOPY VARCHAR2 ) IS
64
65 l_api_version CONSTANT NUMBER := 1.0;
66 l_api_name CONSTANT VARCHAR2(30) := 'Update_Utilization';
67
68 BEGIN
69
70 -- Standard start of API savepoint
71 SAVEPOINT Update_Utilization_Pub;
72 -- Standard call to check for call compatibility
73 IF NOT FND_API.Compatible_API_Call(l_api_version, p_api_version, l_api_name,
74 G_PKG_NAME) THEN
75 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
76 END IF;
77
78 -- Initialize message list if p_init_msg_list is set to TRUE
79 IF FND_API.To_Boolean(p_init_msg_list) THEN
80 FND_MSG_PUB.Initialize;
81 END IF;
82
83 -- Initialize Procedure return status to success
84 x_return_status := FND_API.G_RET_STS_SUCCESS;
85
86 -- Call Private API.
87 AHL_UC_UTILIZATION_PVT.Update_Utilization(
88 p_api_version => 1.0,
89 p_Utilization_tbl => p_utilization_tbl,
90 x_return_status => x_return_status,
91 x_msg_count => x_msg_count,
92 x_msg_data => x_msg_data);
93
94 -- Raise errors if exceptions occur
95 IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
96 RAISE FND_API.G_EXC_ERROR;
97 ELSIF (x_return_status = FND_API.G_RET_STS_UNEXP_ERROR) THEN
98 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
99 END IF;
100
101 -- Standard check of p_commit
102 IF FND_API.TO_BOOLEAN(p_commit) THEN
103 COMMIT WORK;
104 END IF;
105
106 -- Standard call to get message count and if count is 1, get message info
107 FND_MSG_PUB.Count_And_Get
108 ( p_count => x_msg_count,
109 p_data => x_msg_data,
110 p_encoded => fnd_api.g_false);
111
112
113
114 --
115 EXCEPTION
116 WHEN FND_API.G_EXC_ERROR THEN
117 x_return_status := FND_API.G_RET_STS_ERROR;
118 Rollback to Update_Utilization_Pub;
119 FND_MSG_PUB.count_and_get( p_count => x_msg_count,
120 p_data => x_msg_data,
121 p_encoded => fnd_api.g_false);
122
123 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
124 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
125 Rollback to Update_Utilization_Pub;
126 FND_MSG_PUB.count_and_get( p_count => x_msg_count,
127 p_data => x_msg_data,
128 p_encoded => fnd_api.g_false);
129
130 WHEN OTHERS THEN
131 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
132 Rollback to Update_Utilization_Pub;
133 IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
134 fnd_msg_pub.add_exc_msg(p_pkg_name => G_PKG_NAME,
135 p_procedure_name => 'Update_Utilization',
136 p_error_text => SUBSTR(SQLERRM,1,240));
137 END IF;
138 FND_MSG_PUB.count_and_get( p_count => x_msg_count,
139 p_data => x_msg_data,
140 p_encoded => fnd_api.g_false);
141
142 END Update_Utilization;
143
144 END AHL_UC_Utilization_PUB;