1 package body AK_AMPARAM_REGISTRY_GRP as
2 /* $Header: akdgaprb.pls 120.2 2005/09/15 22:26:29 tshort noship $ */
3
4 --========================================================
5 -- Procedure DOWNLOAD_AMPARAM_REGISTRY
6 --
7 -- Usage Group API for downloading amparam_registry objects
8 --
9 -- Desc This API first write out standard loader
10 -- file header for attributes to a flat file.
11 -- Then it calls the private API to extract the
12 -- amparam_registry records selected by application ID or by
13 -- key values from the database to the output file.
14 --
15 -- Results The API returns the standard p_return_status parameter
16 -- indicating one of the standard return statuses :
17 -- * Unexpected error
18 -- * Error
19 -- * Success
20 -- Parameters
21 -- p_nls_language : IN optional
22 -- NLS language for database. If none if given,
23 -- the current NLS language will be used.
24 --
25 -- One of the following three parameters must be given:
26 --
27 -- p_application_id : IN optional
28 -- If given, all query objects for this application ID
29 -- will be written to the output file.
30 -- p_application_short_name : IN optional
31 -- If given, all query objects for this application short
32 -- name will be written to the output file.
33 -- Application short name will be ignored if an
34 -- application ID is given.
35 -- p_amparamreg_pk_tbl : IN optional
36 -- If given, only amparam_registry objects whose key values are
37 -- included in this table will be written to the
38 -- output file.
39 --
40 --
41 -- Version Initial version number = 1.0
42 -- History Current version number = 1.0
43 --=======================================================
44 procedure DOWNLOAD_AMPARAM_REGISTRY (
45 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
46 p_api_version_number IN NUMBER,
47 p_init_msg_tbl IN BOOLEAN := FALSE,
48 p_msg_count OUT NOCOPY NUMBER,
49 p_msg_data OUT NOCOPY VARCHAR2,
50 p_return_status OUT NOCOPY VARCHAR2,
51 p_nls_language IN VARCHAR2 := FND_API.G_MISS_CHAR,
52 p_application_id IN NUMBER := FND_API.G_MISS_NUM,
53 p_application_short_name IN VARCHAR2 := FND_API.G_MISS_CHAR,
54 p_amparamreg_pk_tbl IN AK_AMPARAM_REGISTRY_PUB.AmParamReg_Pk_Tbl_Type :=
55 AK_AMPARAM_REGISTRY_PUB.G_MISS_AMPARAMREG_PK_TBL
56 ) is
57 l_api_version_number CONSTANT number := 1.0;
58 l_api_name CONSTANT varchar2(30) := 'Download AmParam Registry';
59 l_application_id number;
60 l_index NUMBER;
61 l_index_out NUMBER;
62 l_nls_language VARCHAR2(30);
63 l_return_status varchar2(1);
64 begin
65 --
66 -- Check verion number
67 --
68 IF NOT FND_API.Compatible_API_Call (
69 l_api_version_number, p_api_version_number, l_api_name,
70 G_PKG_NAME) then
71 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
72 return;
73 END IF;
74
75 -- Initialize the message table if requested.
76
77 if p_init_msg_tbl then
78 FND_MSG_PUB.initialize;
79 end if;
80
81 if (AK_DOWNLOAD_GRP.G_WRITE_HEADER) then
82 --
83 -- Call private download procedure to verify parameters,
84 -- load application ID, and write header information such
85 -- as nls_language and codeset to data file.
86 --
87 AK_ON_OBJECTS_PVT.download_header(
88 p_validation_level => p_validation_level,
89 p_api_version_number => 1.0,
90 p_return_status => l_return_status,
91 p_nls_language => p_nls_language,
92 p_application_id => p_application_id,
93 p_application_short_name => p_application_short_name,
94 p_table_size => p_amparamreg_pk_tbl.count,
95 p_download_by_object => AK_ON_OBJECTS_PVT.G_AMPARAM_REGISTRY,
96 p_nls_language_out => l_nls_language,
97 p_application_id_out => l_application_id
98 );
99 else
100 l_application_id := p_application_id;
101 select userenv('LANG') into l_nls_language
102 from dual;
103 end if;
104
105 --
106 -- If API call returns with an error status...
107 --
108 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
109 (l_return_status = FND_API.G_RET_STS_ERROR) then
110 RAISE FND_API.G_EXC_ERROR;
111 end if;
112
113 --
114 -- - call the download procedure for attributes to retrieve the
115 -- selected attributes from the database into a table of type
116 -- AK_ON_OBJECTS_PUB.Buffer_Tbl_Type.
117 --
118 -- dbms_output.put_line('Start downloading amparam registry');
119
120 AK_AMPARAM_REGISTRY_PVT.DOWNLOAD_AMPARAM_REGISTRY(
121 p_validation_level => p_validation_level,
122 p_api_version_number => 1.0,
123 p_return_status => l_return_status,
124 p_application_id => l_application_id,
125 p_amparamreg_pk_tbl => p_amparamreg_pk_tbl,
126 p_nls_language => l_nls_language
127 );
128
129 --
130 -- If download call returns with an error status or
131 -- download failed to retrieve any information from the database..
132 --
133 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
134 (l_return_status = FND_API.G_RET_STS_ERROR) then
135 RAISE FND_API.G_EXC_ERROR;
136 end if;
137
138 p_return_status := FND_API.G_RET_STS_SUCCESS;
139
140 FND_MSG_PUB.Count_And_Get (
141 p_count => p_msg_count,
142 p_data => p_msg_data);
143
144 EXCEPTION
145 WHEN FND_API.G_EXC_ERROR THEN
146 p_return_status := FND_API.G_RET_STS_ERROR;
147 FND_MSG_PUB.Count_And_Get (
148 p_count => p_msg_count,
149 p_data => p_msg_data);
150 WHEN OTHERS THEN
151 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
152 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
153 SUBSTR (SQLERRM, 1, 240) );
154 FND_MSG_PUB.Add;
155 FND_MSG_PUB.Count_And_Get (
156 p_count => p_msg_count,
157 p_data => p_msg_data);
158
159 end DOWNLOAD_AMPARAM_REGISTRY;
160
161 --=======================================================
162 -- Procedure CREATE_AMPARAM_REGISTRY
163 --
164 -- Usage Group API for creating a amparam_registry object
165 --
166 -- Desc Calls the private API to creates a amparam_registry object
167 -- using the given info
168 --
169 -- Results The API returns the standard p_return_status parameter
170 -- indicating one of the standard return statuses :
171 -- * Unexpected error
172 -- * Error
173 -- * Success
174 -- Parameters amparam_registry object columns
175 --
176 -- Version Initial version number = 1.0
177 -- History Current version number = 1.0
178 --=======================================================
179 procedure CREATE_AMPARAM_REGISTRY (
180 p_validation_level IN NUMBER := FND_API.G_VALID_LEVEL_FULL,
181 p_api_version_number IN NUMBER,
182 p_init_msg_tbl IN BOOLEAN := FALSE,
183 p_msg_count OUT NOCOPY NUMBER,
184 p_msg_data OUT NOCOPY VARCHAR2,
185 p_return_status OUT NOCOPY VARCHAR2,
186 p_applicationmodule_defn_name IN VARCHAR2,
187 p_param_name IN VARCHAR2,
188 p_param_value IN VARCHAR2,
189 p_application_id IN NUMBER
190 ) is
191 l_api_version_number CONSTANT number := 1.0;
192 l_api_name CONSTANT varchar2(30) := 'Create_amparam_registry';
193 l_return_status VARCHAR2(1);
194 begin
195 /* Check API version number */
196 IF NOT FND_API.Compatible_API_Call (
197 l_api_version_number, p_api_version_number, l_api_name,
198 G_PKG_NAME) then
199 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
200 return;
201 END IF;
202
203 -- Initialize the message table if requested.
204
205 if p_init_msg_tbl then
206 FND_MSG_PUB.initialize;
207 end if;
208
209 savepoint start_create_amparam_registry;
210
211 --
212 -- Call private procedure to create a query object
213 --
214 AK_AMPARAM_REGISTRY_PVT.CREATE_AMPARAM_REGISTRY(
215 p_validation_level => p_validation_level,
216 p_api_version_number => 1.0,
217 p_msg_count => p_msg_count,
218 p_msg_data => p_msg_data,
219 p_return_status => l_return_status,
220 p_applicationmodule_defn_name => p_applicationmodule_defn_name,
221 p_param_name => p_param_name,
222 p_param_value => p_param_value,
223 p_application_id => p_application_id
224 );
225
226 --
227 -- If API call returns with an error status...
228 --
229 if (l_return_status = FND_API.G_RET_STS_UNEXP_ERROR) or
230 (l_return_status = FND_API.G_RET_STS_ERROR) then
231 RAISE FND_API.G_EXC_ERROR;
232 end if;
233
234 p_return_status := FND_API.G_RET_STS_SUCCESS;
235
236 EXCEPTION
237 WHEN FND_API.G_EXC_ERROR THEN
238 p_return_status := FND_API.G_RET_STS_ERROR;
239 rollback to start_create_amparam_registry;
240 WHEN OTHERS THEN
241 p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
242 FND_MSG_PUB.Build_Exc_Msg( G_PKG_NAME, l_api_name,
243 SUBSTR (SQLERRM, 1, 240) );
244 FND_MSG_PUB.Add;
245 rollback to start_create_amparam_registry;
246 end CREATE_AMPARAM_REGISTRY;
247
248 end AK_AMPARAM_REGISTRY_GRP;