DBA Data[Home] [Help]

PACKAGE BODY: APPS.AHL_DI_ASSO_DOC_ASO_PUB

Source


1 PACKAGE BODY AHL_DI_ASSO_DOC_ASO_PUB AS
2 /* $Header: AHLPDASB.pls 115.26 2003/10/20 19:36:13 sikumar noship $ */
3 --
4 G_PKG_NAME  VARCHAR2(30)  := 'AHL_DI_ASSO_DOC_ASO_PUB';
5 --
6 /*-----------------------------------------------------------*/
7 /* procedure name: Check_lookup_name_Or_Id(private procedure)*/
8 /* description :  used to retrieve lookup code               */
9 /*                                                           */
10 /*-----------------------------------------------------------*/
11 
12 --G_DEBUG 		 VARCHAR2(1):=FND_PROFILE.VALUE('AHL_API_FILE_DEBUG_ON');
13   G_DEBUG                VARCHAR2(1)   := AHL_DEBUG_PUB.is_log_enabled;
14 
15 PROCEDURE Check_lookup_name_Or_Id
16  ( p_lookup_type      IN FND_LOOKUPS.lookup_type%TYPE,
17    p_lookup_code      IN FND_LOOKUPS.lookup_code%TYPE,
18    p_meaning          IN FND_LOOKUPS.meaning%TYPE,
19    p_check_id_flag    IN VARCHAR2,
20    x_lookup_code      OUT NOCOPY FND_LOOKUPS.lookup_code%TYPE,
21    x_return_status    OUT NOCOPY VARCHAR2)
22 IS
23 BEGIN
24       IF (p_lookup_code IS NOT NULL) THEN
25         IF (p_check_id_flag = 'Y') THEN
26           SELECT lookup_code INTO x_lookup_code
27            FROM FND_LOOKUP_VALUES_VL
28           WHERE lookup_type = p_lookup_type
29             AND lookup_code = p_lookup_code
30             AND sysdate between start_date_active
31             AND nvl(end_date_active,sysdate);
32         ELSE
33            x_lookup_code := p_lookup_code;
34         END IF;
35      ELSE
36           SELECT lookup_code INTO x_lookup_code
37            FROM FND_LOOKUP_VALUES_VL
38           WHERE lookup_type = p_lookup_type
39             AND meaning     = p_meaning
40             AND sysdate between start_date_active
41             AND nvl(end_date_active,sysdate);
42     END IF;
43       x_return_status := FND_API.G_RET_STS_SUCCESS;
44 EXCEPTION
45    WHEN no_data_found THEN
46       x_return_status := FND_API.G_RET_STS_ERROR;
47    WHEN too_many_rows THEN
48       x_return_status := FND_API.G_RET_STS_ERROR;
49    WHEN OTHERS THEN
50       x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
51       RAISE;
52 END;
53 /*------------------------------------------------------*/
54 /* procedure name: create_association                   */
55 /* description :  Creates new association record        */
56 /*                for an associated document            */
57 /*                                                      */
58 /*------------------------------------------------------*/
59 
60 PROCEDURE CREATE_ASSOCIATION
61 (
62  p_api_version               IN      NUMBER    :=  1.0            ,
63  p_init_msg_list             IN      VARCHAR2  := FND_API.G_TRUE  ,
64  p_commit                    IN      VARCHAR2  := FND_API.G_FALSE ,
65  p_validate_only             IN      VARCHAR2  := FND_API.G_TRUE  ,
66  p_validation_level          IN      NUMBER    := FND_API.G_VALID_LEVEL_FULL,
67  p_x_association_tbl         IN  OUT NOCOPY association_tbl       ,
68  p_module_type               IN      VARCHAR2                     ,
69  x_return_status                 OUT NOCOPY VARCHAR2                     ,
70  x_msg_count                     OUT NOCOPY NUMBER                       ,
71  x_msg_data                      OUT NOCOPY VARCHAR2)
72 IS
73 --Used to retrieve document id
74 CURSOR get_doc_id_info(c_document_no  VARCHAR2)
75 IS
76  SELECT document_id
77    FROM AHL_DOCUMENTS_B
78   WHERE document_no = c_document_no;
79 -- Used to retrieve document revision
80 CURSOR get_doc_rev_id_info(c_revision_no VARCHAR2,
81                            c_document_id  NUMBER)
82 IS
83  SELECT doc_revision_id
84    FROM AHL_DOC_REVISIONS_B
85   WHERE revision_no = c_revision_no
86     AND document_id = c_document_id;
87 
88 -- {{ adharia bug #2450326 - added- 9/7/2002
89 --To retrieve document id
90 CURSOR get_doc_rev_count(c_document_id  VARCHAR2)
91 IS
92  SELECT COUNT(*)
93    FROM AHL_DOC_REVISIONS_B
94   WHERE document_id = c_document_id;
95 
96 --to get the rev info based on the doc id used if only one rev is present for the document
97 CURSOR get_doc_rev_info(c_document_id  NUMBER)
98 IS
99  SELECT doc_revision_id, revision_no
100    FROM AHL_DOC_REVISIONS_B
101   WHERE document_id = c_document_id;
102 -- }} adharia bug #2450326 - added- 9/7/2002
103 
104 --
105  l_api_name     CONSTANT VARCHAR2(30) := 'CREATE_ASSOCIATION';
106  l_api_version  CONSTANT NUMBER       := 1.0;
107  l_num_rec               NUMBER;
108  l_msg_count             NUMBER;
109  l_msg_data              VARCHAR2(2000);
110  l_return_status         VARCHAR2(1);
111  l_document_id           NUMBER;
112  l_doc_revision_id       NUMBER;
113  l_aso_object_type_code  VARCHAR2(30);
114  l_association_tbl       AHL_DI_ASSO_DOC_ASO_PVT.association_tbl;
115  l_init_msg_list          VARCHAR2(10) := FND_API.G_TRUE;
116 
117  l_pre_V_msg_count             NUMBER;
118  l_pre_V_msg_data              VARCHAR2(2000);
119  l_pre_V_return_status         VARCHAR2(1);
120  l_post_V_msg_count             NUMBER;
121  l_post_V_msg_data              VARCHAR2(2000);
122  l_post_V_return_status         VARCHAR2(1);
123  l_pre_C_msg_count             NUMBER;
124  l_pre_C_msg_data              VARCHAR2(2000);
125  l_pre_C_return_status         VARCHAR2(1);
126  l_post_C_msg_count             NUMBER;
127  l_post_C_msg_data              VARCHAR2(2000);
128  l_post_C_return_status         VARCHAR2(1);
129 -- {{ adharia bug #2450326 - added- 9/7/2002
130 l_rev_count              NUMBER;
131 l_doc_revision_no        VARCHAR2(30);
132 -- }} adharia bug #2450326 - added- 9/7/2002
133 
134 
135 BEGIN
136 
137    -- Standard Start of API savepoint
138    SAVEPOINT create_association;
139    -- Check if API is called in debug mode. If yes, enable debug.
140    IF G_DEBUG='Y' THEN
141 		  AHL_DEBUG_PUB.enable_debug;
142 
143 	END IF;
144    -- Debug info.
145    IF G_DEBUG='Y' THEN
146       IF G_DEBUG='Y' THEN
147 		  AHL_DEBUG_PUB.debug( 'enter ahl_di_asso_doc_aso_pub.Create Association','+DOBJASS+');
148 
149 	END IF;
150    END IF;
151    -- Standard call to check for call compatibility.
152    IF FND_API.to_boolean(l_init_msg_list)
153    THEN
154      FND_MSG_PUB.initialize;
155    END IF;
156    --  Initialize API return status to success
157     x_return_status := 'S';
158    -- Initialize message list if p_init_msg_list is set to TRUE.
159    IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
160                                       p_api_version,
161                                       l_api_name,G_PKG_NAME)
162    THEN
163        RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
164    END IF;
165    --Starts API Body
166    IF p_x_association_tbl.COUNT > 0
167    THEN
168      FOR i IN p_x_association_tbl.FIRST..p_x_association_tbl.LAST
169      LOOP
170         -- Module type is 'JSP' then make it null for the following fields
171         IF (p_module_type = 'JSP') THEN
172             p_x_association_tbl(i).document_id := null;
173             p_x_association_tbl(i).doc_revision_id := null;
174         END IF;
175 
176  --{{adharia-- bug #2450326 - added- 9/7/2002
177          IF (p_x_association_tbl(i).document_no IS NULL) OR
178             (p_x_association_tbl(i).document_no = FND_API.G_MISS_CHAR)
179           THEN
180 		 FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOCUMENT_NO_NULL');
181                  FND_MSG_PUB.ADD;
182           ELSE
183 
184                  OPEN get_doc_id_info(p_x_association_tbl(i).document_no);
185                  FETCH get_doc_id_info INTO l_document_id;
186                  IF get_doc_id_info%FOUND
187                  THEN
188                    l_association_tbl(i).document_id := l_document_id;
189                  ELSE
190                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
191                    FND_MSG_PUB.ADD;
192                  END IF;
193                  CLOSE get_doc_id_info;
194 
195                  OPEN  get_doc_rev_count(l_document_id);
196                  FETCH get_doc_rev_count INTO l_rev_count;
197                  CLOSE get_doc_rev_count;
198                  IF l_rev_count = 0
199                  THEN
200                    l_association_tbl(i).doc_revision_id := NULL;
201                  ELSIF l_rev_count =1
202                  THEN
203 			 OPEN get_doc_rev_info(l_document_id);
204 			 FETCH get_doc_rev_info INTO l_doc_revision_id, l_doc_revision_no;
205 			 IF get_doc_rev_info%FOUND
206 			 THEN
207 	                   l_association_tbl(i).doc_revision_id := l_doc_revision_id;
208 	                 ELSE
209 	                   FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
210 	                   FND_MSG_PUB.ADD;
211 	                 END IF;
212 	                 CLOSE get_doc_rev_info;
213                  ELSIF l_rev_count > 1
214                  THEN
215 
216 			 OPEN  get_doc_rev_id_info(p_x_association_tbl(i).revision_no,
217 						   l_document_id);
218 			 FETCH get_doc_rev_id_info INTO l_doc_revision_id;
219 			 IF get_doc_rev_id_info%FOUND
220 			 THEN
221 			  l_association_tbl(i).doc_revision_id := l_doc_revision_id;
222 			  ELSE
223 			   FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
224 			   FND_MSG_PUB.ADD;
225 			 END IF;
226 			 CLOSE get_doc_rev_id_info;
227                  END IF;
228           END IF;
229 --}} adharia -- bug #2450326 - added- 9/7/2002
230          -- For Aso Object Type code, meaning presents
231          IF p_x_association_tbl(i).aso_object_desc IS NOT NULL AND
232             p_x_association_tbl(i).aso_object_desc <> FND_API.G_MISS_CHAR
233          THEN
234 
235              Check_lookup_name_Or_Id (
236                   p_lookup_type  => 'AHL_OBJECT_TYPE',
237                   p_lookup_code  => null,
238                   p_meaning      => p_x_association_tbl(i).aso_object_desc,
239                   p_check_id_flag => 'Y',
240                   x_lookup_code   => l_association_tbl(i).aso_object_type_code,
241                   x_return_status => l_return_status);
242 
243          IF nvl(l_return_status, 'X') <> 'S'
244          THEN
245             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJ_TYP_NOT_EXISTS');
246             FND_MSG_PUB.ADD;
247          END IF;
248         END IF;
249         -- If Type Code presents
250         IF p_x_association_tbl(i).aso_object_type_code IS NOT NULL AND
251            p_x_association_tbl(i).aso_object_type_code <> FND_API.G_MISS_CHAR
252          THEN
253            l_association_tbl(i).aso_object_type_code := p_x_association_tbl(i).aso_object_type_code;
254        --If both missing
255        ELSE
256             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJECT_TYPE_NULL');
257             FND_MSG_PUB.ADD;
258         END IF;
259         l_association_tbl(i).aso_object_id         := p_x_association_tbl(i).aso_object_id;
260         l_association_tbl(i).use_latest_rev_flag   := p_x_association_tbl(i).use_latest_rev_flag;
261         l_association_tbl(i).serial_no             := p_x_association_tbl(i).serial_no;
262         l_association_tbl(i).source_lang           := p_x_association_tbl(i).source_lang;
263         l_association_tbl(i).chapter               := p_x_association_tbl(i).chapter;
264         l_association_tbl(i).section               := p_x_association_tbl(i).section;
265         l_association_tbl(i).subject 	           := p_x_association_tbl(i).subject;
266         l_association_tbl(i).page                  := p_x_association_tbl(i).page;
267         l_association_tbl(i).figure                := p_x_association_tbl(i).figure;
268         l_association_tbl(i).note                  := p_x_association_tbl(i).note;
269         l_association_tbl(i).attribute_category    := p_x_association_tbl(i).attribute_category;
270         l_association_tbl(i).attribute1            := p_x_association_tbl(i).attribute1;
271         l_association_tbl(i).attribute2            := p_x_association_tbl(i).attribute2;
272         l_association_tbl(i).attribute3            := p_x_association_tbl(i).attribute3;
273         l_association_tbl(i).attribute4            := p_x_association_tbl(i).attribute4;
274         l_association_tbl(i).attribute5            := p_x_association_tbl(i).attribute5;
275         l_association_tbl(i).attribute6            := p_x_association_tbl(i).attribute6;
276         l_association_tbl(i).attribute7            := p_x_association_tbl(i).attribute7;
277         l_association_tbl(i).attribute8            := p_x_association_tbl(i).attribute8;
278         l_association_tbl(i).attribute9            := p_x_association_tbl(i).attribute9;
279         l_association_tbl(i).attribute10           := p_x_association_tbl(i).attribute10;
280         l_association_tbl(i).attribute11           := p_x_association_tbl(i).attribute11;
281         l_association_tbl(i).attribute12           := p_x_association_tbl(i).attribute12;
282         l_association_tbl(i).attribute13           := p_x_association_tbl(i).attribute13;
283         l_association_tbl(i).attribute14           := p_x_association_tbl(i).attribute14;
284         l_association_tbl(i).attribute15           := p_x_association_tbl(i).attribute15;
285         l_association_tbl(i).delete_flag           := p_x_association_tbl(i).delete_flag;
286         l_association_tbl(i).object_version_number := p_x_association_tbl(i).object_version_number;
287    --Standard check to count messages
288    l_msg_count := FND_MSG_PUB.count_msg;
289    IF l_msg_count > 0 THEN
290       X_msg_count := l_msg_count;
291       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
292       RAISE FND_API.G_EXC_ERROR;
293    END IF;
294  END LOOP;
295 END IF;
296 
297 /*------------------------------------------------------------------------*/
298 /* procedure name: AHL_DI_ASSO_DOC_ASO_CUHK.CREATE_ASSOCIATION_PRE        */
299 /*                 AHL_DI_ASSO_DOC_ASO_VUHK.CREATE_ASSOCIATION_PRE        */
300 /* description   :  Added by Senthil to call User Hooks                   */
301 /* Date     : Dec 10 2001                                                 */
302 /*------------------------------------------------------------------------*/
303 
304 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','CREATE_ASSOCIATION',
305 					'B', 'C' )  then
306    IF G_DEBUG='Y' THEN
307 		  AHL_DEBUG_PUB.debug( 'Start of api Customer Create Association_Pre');
308 
309 	END IF;
310             AHL_DI_ASSO_DOC_ASO_CUHK.CREATE_ASSOCIATION_PRE(
311 			P_X_ASSOCIATION_TBL    	=>	l_association_tbl,
312 			X_RETURN_STATUS        	=>	l_pre_C_return_status      ,
313 			X_MSG_COUNT            	=>	l_pre_C_msg_count           ,
314 			X_MSG_DATA             	=>	l_pre_C_msg_data  );
315 
316    IF G_DEBUG='Y' THEN
317 		  AHL_DEBUG_PUB.debug( 'End of api Customer Create Association_Pre');
318 
319 	END IF;
320 
321       		IF   l_pre_C_return_status = FND_API.G_RET_STS_ERROR  THEN
322     			RAISE FND_API.G_EXC_ERROR;
323              	ELSIF l_pre_C_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
324 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
325 		END IF;
326 END IF;
327 
328 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','CREATE_ASSOCIATION',
329 					'B', 'V' )  then
330    IF G_DEBUG='Y' THEN
331 		  AHL_DEBUG_PUB.debug( 'Start of api Vertical Create Association_Pre');
332 
333 	END IF;
334             AHL_DI_ASSO_DOC_ASO_VUHK.CREATE_ASSOCIATION_PRE(
335 			P_X_ASSOCIATION_TBL    	=>	l_association_tbl,
336 			X_RETURN_STATUS        	=>	l_pre_V_return_status      ,
337 			X_MSG_COUNT            	=>	l_pre_V_msg_count           ,
338 			X_MSG_DATA             	=>	l_pre_V_msg_data  );
339    IF G_DEBUG='Y' THEN
340 		  AHL_DEBUG_PUB.debug( 'End of api Vertical Create Association_Pre');
341 
342 	END IF;
343       		IF   l_pre_V_return_status = FND_API.G_RET_STS_ERROR  THEN
344     			RAISE FND_API.G_EXC_ERROR;
345              	ELSIF l_pre_V_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
346 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
347 		END IF;
348 END IF;
349 /*---------------------------------------------------------*/
350 /*     End ; Date     : Dec 10 2001                             */
351 /*---------------------------------------------------------*/
352 
353 -- Call the Private API
354  AHL_DI_ASSO_DOC_ASO_PVT.CREATE_ASSOCIATION
355         (
356          p_api_version       => 1.0,
357          p_init_msg_list     => l_init_msg_list,
358          p_commit            => p_commit,
359          p_validate_only     => p_validate_only,
360          p_validation_level  => p_validation_level,
361          p_x_association_tbl => l_association_tbl,
362          x_return_status     => l_return_status,
363          x_msg_count         => l_msg_count,
364          x_msg_data          => l_msg_data
365          );
366 
367    --Standard check to count messages
368    l_msg_count := FND_MSG_PUB.count_msg;
369 
370    IF l_msg_count > 0 THEN
371       X_msg_count := l_msg_count;
372       l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
373       RAISE FND_API.G_EXC_ERROR;
374    END IF;
375 
376  --Assign values
377  IF l_association_tbl.COUNT > 0
378  THEN
379    FOR i IN l_association_tbl.FIRST..l_association_tbl.LAST
380    LOOP
381      p_x_association_tbl(i).doc_title_asso_id := l_association_tbl(i).doc_title_asso_id;
382    END LOOP;
383  END IF;
384 
385 /*------------------------------------------------------------------------*/
386 /* procedure name: AHL_DI_ASSO_DOC_ASO_CUHK.CREATE_ASSOCIATION_POST       */
387 /*                 AHL_DI_ASSO_DOC_ASO_VUHK.CREATE_ASSOCIATION_POST       */
388 /* description   :  Added by Senthil to call User Hooks                   */
389 /* Date     : Dec 10 2001                                                 */
390 /*------------------------------------------------------------------------*/
391 
392 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','CREATE_ASSOCIATION',
393 					'A', 'C' )  then
394    IF G_DEBUG='Y' THEN
395 		  AHL_DEBUG_PUB.debug( 'Start of api Customer Create Association_Post');
396 
397 	END IF;
398             AHL_DI_ASSO_DOC_ASO_CUHK.CREATE_ASSOCIATION_POST(
399 			P_ASSOCIATION_TBL    	=>	l_association_tbl,
400 			X_RETURN_STATUS        	=>	l_post_C_return_status      ,
401 			X_MSG_COUNT            	=>	l_post_C_msg_count           ,
402 			X_MSG_DATA             	=>	l_post_C_msg_data  );
403    IF G_DEBUG='Y' THEN
404 		  AHL_DEBUG_PUB.debug( 'End of api Customer Create Association_Post');
405 
406 	END IF;
407       		IF   l_post_C_return_status = FND_API.G_RET_STS_ERROR  THEN
408     			RAISE FND_API.G_EXC_ERROR;
409              	ELSIF l_post_C_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
410 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
411 		END IF;
412 END IF;
413 
414 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','CREATE_ASSOCIATION',
415 					'A', 'V' )  then
416    IF G_DEBUG='Y' THEN
417 		  AHL_DEBUG_PUB.debug( 'Start of api Vertical Create Association_Post');
418 
419 	END IF;
420             AHL_DI_ASSO_DOC_ASO_VUHK.CREATE_ASSOCIATION_POST(
421 			P_ASSOCIATION_TBL    	=>	l_association_tbl,
422 			X_RETURN_STATUS        	=>	l_post_V_return_status      ,
423 			X_MSG_COUNT            	=>	l_post_V_msg_count           ,
424 			X_MSG_DATA             	=>	l_post_V_msg_data  );
425    IF G_DEBUG='Y' THEN
426 		  AHL_DEBUG_PUB.debug( 'End of api Vertical Create Association_Post');
427 
428 	END IF;
429       		IF   l_post_V_return_status = FND_API.G_RET_STS_ERROR  THEN
430     			RAISE FND_API.G_EXC_ERROR;
431              	ELSIF l_post_V_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
432 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
433 		END IF;
434 END IF;
435 
436 /*---------------------------------------------------------*/
437 /*     End ; Date     : Dec 10 2001                        */
438 /*---------------------------------------------------------*/
439 
440    --Standard check for commit
441    IF FND_API.TO_BOOLEAN(p_commit) THEN
442       COMMIT;
443    END IF;
444    -- Debug info
445    IF G_DEBUG='Y' THEN
446 		  AHL_DEBUG_PUB.debug( 'End of public api Create Association','+DOBJASS+');
447 
448 	END IF;
449    -- Check if API is called in debug mode. If yes, disable debug.
450    IF G_DEBUG='Y' THEN
451 		  AHL_DEBUG_PUB.disable_debug;
452 
453 	END IF;
454 
455 EXCEPTION
456  WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
457     ROLLBACK TO create_association;
458     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
459     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
460                                p_count => x_msg_count,
461                                p_data  => x_msg_data);
462         --Debug Info
463         IF G_DEBUG='Y' THEN
464 
465 		  AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'ERROR' );
466 
467 
468 
469 
470 		  AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Create Association','+DOCJASS+');
471 
472 
473 
474         -- Check if API is called in debug mode. If yes, disable debug.
475 
476 		  AHL_DEBUG_PUB.disable_debug;
477 
478 	END IF;
479 
480  WHEN FND_API.G_EXC_ERROR THEN
481     ROLLBACK TO create_association;
482     X_return_status := FND_API.G_RET_STS_ERROR;
483     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
484                                p_count => l_msg_count,
485                                p_data  => X_msg_data);
486      x_msg_count := l_msg_count;
487 
488         -- Debug info.
489         IF G_DEBUG='Y' THEN
490             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'UNEXPECTED ERROR' );
491             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Create Association','+DOCJASS+');
492 
493 	-- Check if API is called in debug mode. If yes, disable debug.
494         AHL_DEBUG_PUB.disable_debug;
495 
496         END IF;
497 
498 
499  WHEN OTHERS THEN
500     ROLLBACK TO create_association;
501     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
502     IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
503     THEN
504     fnd_msg_pub.add_exc_msg(p_pkg_name        =>  'AHL_DI_ASSO_DOC_ASO_PUB',
505                             p_procedure_name  =>  'CREATE_ASSOCIATION',
506                             p_error_text      => SUBSTR(SQLERRM,1,240));
507     END IF;
508     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
509                                p_count => l_msg_count,
510                                p_data  => X_msg_data);
511     x_msg_count := l_msg_count;
512         -- Debug info.
513         IF G_DEBUG='Y' THEN
514             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'SQL ERROR' );
515             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Create Association','+DOCJASS+');
516         -- Check if API is called in debug mode. If yes, disable debug.
517         AHL_DEBUG_PUB.disable_debug;
518 
519 	END IF;
520 
521 END CREATE_ASSOCIATION;
522 
523 /*------------------------------------------------------*/
524 /* procedure name: modify_association                   */
525 /* description :  Updates and removes the association   */
526 /*                record                                */
527 /*                                                      */
528 /*------------------------------------------------------*/
529 PROCEDURE MODIFY_ASSOCIATION
530 (
531  p_api_version               IN     NUMBER    :=  1.0            ,
532  p_init_msg_list             IN     VARCHAR2  := FND_API.G_TRUE  ,
533  p_commit                    IN     VARCHAR2  := FND_API.G_FALSE ,
534  p_validate_only             IN     VARCHAR2  := FND_API.G_TRUE  ,
535  p_validation_level          IN     NUMBER    := FND_API.G_VALID_LEVEL_FULL,
536  p_x_association_tbl         IN OUT NOCOPY association_tbl       ,
537  p_module_type               IN     VARCHAR2                     ,
538  x_return_status                OUT NOCOPY VARCHAR2                     ,
539  x_msg_count                    OUT NOCOPY NUMBER                       ,
540  x_msg_data                     OUT NOCOPY VARCHAR2
541 )
542 IS
543 -- {{ adharia -- bug #2450326 - added- 9/7/2002
544 --To retrieve document id
545 CURSOR get_doc_id_info(c_document_no  VARCHAR2)
546 IS
547  SELECT document_id
548    FROM AHL_DOCUMENTS_B
549   WHERE document_no = c_document_no;
550 
551 --To retrieve count of revisions of the doc
552 CURSOR get_doc_rev_count(c_document_id  VARCHAR2)
553 IS
554  SELECT COUNT(*)
555    FROM AHL_DOC_REVISIONS_B
556   WHERE document_id = c_document_id;
557 
558 --to get the rev info based on the doc id used if only one rev is present for the document
559 CURSOR get_doc_rev_info(c_document_id  NUMBER)
560 IS
561  SELECT doc_revision_id, revision_no
562    FROM AHL_DOC_REVISIONS_B
563   WHERE document_id = c_document_id;
564 -- }} adharia -- bug #2450326 - added- 9/7/2002
565 
566 --To retrieve document revision
567 CURSOR get_doc_rev_id_info(c_revision_no VARCHAR2,
568                            c_document_id  NUMBER)
569 IS
570  SELECT doc_revision_id
571    FROM AHL_DOC_REVISIONS_B A
572   WHERE revision_no = c_revision_no
573     AND document_id = c_document_id;
574 --
575 l_api_name     CONSTANT  VARCHAR2(30) := 'MODIFY_ASSOCIATION';
576 l_api_version  CONSTANT  NUMBER       := 1.0;
577 l_msg_count              NUMBER;
578 l_msg_data               VARCHAR2(2000);
579 l_return_status          VARCHAR2(1);
580 l_aso_object_type_code   VARCHAR2(30);
581 l_document_id            NUMBER;
582 l_doc_revision_id        NUMBER;
583 l_association_tbl        AHL_DI_ASSO_DOC_ASO_PVT.association_tbl;
584 l_init_msg_list          VARCHAR2(10) := FND_API.G_TRUE;
585 
586 l_pre_V_msg_count        NUMBER;
587 l_pre_V_msg_data         VARCHAR2(2000);
588 l_pre_V_return_status    VARCHAR2(1);
589 l_post_V_msg_count       NUMBER;
590 l_post_V_msg_data        VARCHAR2(2000);
591 l_post_V_return_status   VARCHAR2(1);
592 l_pre_C_msg_count        NUMBER;
593 l_pre_C_msg_data         VARCHAR2(2000);
594 l_pre_C_return_status    VARCHAR2(1);
595 l_post_C_msg_count       NUMBER;
596 l_post_C_msg_data        VARCHAR2(2000);
597 l_post_C_return_status   VARCHAR2(1);
598 -- {{ adharia -- bug #2450326 - added- 9/7/2002
599 l_rev_count              NUMBER;
600 l_doc_revision_no        VARCHAR2(30);
601 -- }} adharia -- bug #2450326 - added- 9/7/2002
602 
603 BEGIN
604     -- Standard Start of API savepoint
605    SAVEPOINT modify_association;
606    -- Check if API is called in debug mode. If yes, enable debug.
607    IF G_DEBUG='Y' THEN
608 		  AHL_DEBUG_PUB.enable_debug;
609 
610 	END IF;
611    -- Debug info.
612    IF G_DEBUG='Y' THEN
613        IF G_DEBUG='Y' THEN
614 		  AHL_DEBUG_PUB.debug( 'enter ahl_di_asso_doc_aso_pub.Rajanth Testing the code','+DOBJASS+');
615 
616 	END IF;
617     END IF;
618     -- Standard call to check for call compatibility.
619     IF FND_API.to_boolean(l_init_msg_list)
620     THEN
621       FND_MSG_PUB.initialize;
622     END IF;
623     --  Initialize API return status to success
624     x_return_status := 'S';
625     -- Initialize message list if p_init_msg_list is set to TRUE.
626     IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
627                                        p_api_version,
628                                        l_api_name,G_PKG_NAME)
629     THEN
630         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
631     END IF;
632    --Starts API Body
633    IF p_x_association_tbl.COUNT > 0
634    THEN
635      FOR i IN p_x_association_tbl.FIRST..p_x_association_tbl.LAST
636      LOOP
637         -- Module type is 'JSP' then make it null for the following fields
638         IF (p_module_type = 'JSP') THEN
639             p_x_association_tbl(i).document_id := null;
640             p_x_association_tbl(i).doc_revision_id := null;
641         END IF;
642 
643         -- {{adharia  -- bug #2450326 - added- 9/7/2002
644  -- EDIT OPERATION  ...START
645      IF (p_x_association_tbl(i).delete_flag <> 'Y')
646      THEN
647          IF (p_x_association_tbl(i).document_no IS NULL) OR
648             (p_x_association_tbl(i).document_no = FND_API.G_MISS_CHAR)
649           THEN
650 		 FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOCUMENT_NO_NULL');
651                  FND_MSG_PUB.ADD;
652           ELSE
653         -- For document id
654                  OPEN get_doc_id_info(p_x_association_tbl(i).document_no);
655                  FETCH get_doc_id_info INTO l_document_id;
656                  IF get_doc_id_info%FOUND
657                  THEN
658                    l_association_tbl(i).document_id := l_document_id;
659                  ELSE
660                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
661                    FND_MSG_PUB.ADD;
662                  END IF;
663                  CLOSE get_doc_id_info;
664 
665         -- For count of rev for the document
666                  OPEN  get_doc_rev_count(l_document_id);
667                  FETCH get_doc_rev_count INTO l_rev_count;
668                  CLOSE get_doc_rev_count;
669                  -- if no rev doc revid =null and you can associate the doc
670                  IF l_rev_count = 0
671                  THEN
672                    l_association_tbl(i).doc_revision_id := NULL;
673                  -- if one   rev is present associate it directly
674                  ELSIF l_rev_count =1
675                  THEN
676 
677 			 OPEN get_doc_rev_info(l_document_id);
678 			 FETCH get_doc_rev_info INTO l_doc_revision_id, l_doc_revision_no;
679 			 IF get_doc_rev_info%FOUND
680 			 THEN
681 	                   l_association_tbl(i).doc_revision_id := l_doc_revision_id;
682 	                 ELSE
683 	                   FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
684 	                   FND_MSG_PUB.ADD;
685 	                 END IF;
686 	                 CLOSE get_doc_rev_info;
687 	         -- if more than one rev are present then check if the rev id passes is valid else throw error
688                  ELSIF l_rev_count > 1
689                  THEN
690 
691 			 OPEN  get_doc_rev_id_info(p_x_association_tbl(i).revision_no,
692 						   l_document_id);
693 			 FETCH get_doc_rev_id_info INTO l_doc_revision_id;
694 			 IF get_doc_rev_id_info%FOUND
695 			 THEN
696 			  l_association_tbl(i).doc_revision_id := l_doc_revision_id;
697 			  ELSE
698 			   FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
699 			   FND_MSG_PUB.ADD;
700 			 END IF;
701 			 CLOSE get_doc_rev_id_info;
702                  END IF;
703           END IF;
704    -- EDIT OPERATION      ... END
705 
706    -- DELETE OPERATION
707      ELSIF (p_x_association_tbl(i).delete_flag = 'Y')
708      THEN
709          --For Document Id,
710       IF (p_x_association_tbl(i).document_id IS NULL OR
711          p_x_association_tbl(i).document_id = FND_API.G_MISS_NUM)
712          THEN
713 
714           -- If name is available
715            IF (p_x_association_tbl(i).document_no IS NOT NULL) AND
716               (p_x_association_tbl(i).document_no <> FND_API.G_MISS_CHAR)
717               THEN
718                  OPEN  get_doc_id_info(p_x_association_tbl(i).document_no);
719                  FETCH get_doc_id_info INTO l_document_id;
720                  IF get_doc_id_info%FOUND
721                  THEN
722                   l_association_tbl(i).document_id := l_document_id;
723                   ELSE
724                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
725                    FND_MSG_PUB.ADD;
726                  END IF;
727                  CLOSE get_doc_id_info;
728            --If Document Id is present
729          ELSIF (p_x_association_tbl(i).document_id IS NOT NULL) AND
730                (p_x_association_tbl(i).document_id <> FND_API.G_MISS_NUM)
731             THEN
732                l_association_tbl(i).document_id := l_document_id;
733          ELSE
734               --Both Document Id and Name are missing
735                l_association_tbl(i).document_id := l_document_id;
736         END IF;
737        END IF;
738 
739          --For Document Revision Id,
740          -- If Revision no is available
741          IF p_x_association_tbl(i).doc_revision_id IS NULL OR
742             p_x_association_tbl(i).doc_revision_id = FND_API.G_MISS_NUM
743            THEN
744            IF (p_x_association_tbl(i).revision_no IS NOT NULL) AND
745               (p_x_association_tbl(i).revision_no <> FND_API.G_MISS_CHAR)
746               THEN
747                  OPEN  get_doc_rev_id_info(p_x_association_tbl(i).revision_no,
748                                            l_document_id);
749                  FETCH get_doc_rev_id_info INTO l_doc_revision_id;
750                  IF get_doc_rev_id_info%FOUND
751                  THEN
752                   l_association_tbl(i).doc_revision_id := l_doc_revision_id;
753                   ELSE
754                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
755                    FND_MSG_PUB.ADD;
756                  END IF;
757                  CLOSE get_doc_rev_id_info;
758            --If Doc Revision Id is present
759          ELSIF (p_x_association_tbl(i).doc_revision_id IS NOT NULL) AND
760                (p_x_association_tbl(i).doc_revision_id <> FND_API.G_MISS_NUM)
761             THEN
762                l_association_tbl(i).doc_revision_id := l_doc_revision_id;
763         END IF;
764       END IF;
765     END IF;--END IF DELETE FLAG
766 -- }}adharia -- bug #2450326 - added- 9/7/2002
767 
768            -- For Aso Object Type code, meaning presents
769          IF p_x_association_tbl(i).aso_object_desc IS NOT NULL AND
770             p_x_association_tbl(i).aso_object_desc <> FND_API.G_MISS_CHAR
771          THEN
772 
773              Check_lookup_name_Or_Id (
774                   p_lookup_type  => 'AHL_OBJECT_TYPE',
775                   p_lookup_code  => null,
776                   p_meaning      => p_x_association_tbl(i).aso_object_desc,
777                   p_check_id_flag => 'Y',
778                   x_lookup_code   => l_association_tbl(i).aso_object_type_code,
779                   x_return_status => l_return_status);
780 
781          IF nvl(l_return_status, 'X') <> 'S'
782          THEN
783             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJ_TYPE_NOT_EXISTS');
784             FND_MSG_PUB.ADD;
785          END IF;
786         END IF;
787         -- If Type Code presents
788         IF p_x_association_tbl(i).aso_object_type_code IS NOT NULL AND
789            p_x_association_tbl(i).aso_object_type_code <> FND_API.G_MISS_CHAR
790          THEN
791            l_association_tbl(i).aso_object_type_code := p_x_association_tbl(i).aso_object_type_code;
792        --If both missing
793        ELSE
794            l_association_tbl(i).aso_object_type_code := p_x_association_tbl(i).aso_object_type_code;
795         END IF;
796 
797         l_association_tbl(i).doc_title_asso_id   := p_x_association_tbl(i).doc_title_asso_id;
798         l_association_tbl(i).use_latest_rev_flag := p_x_association_tbl(i).use_latest_rev_flag;
799         l_association_tbl(i).aso_object_id       := p_x_association_tbl(i).aso_object_id;
800         l_association_tbl(i).serial_no           := p_x_association_tbl(i).serial_no;
801         l_association_tbl(i).source_lang         := p_x_association_tbl(i).source_lang;
802         l_association_tbl(i).chapter             := p_x_association_tbl(i).chapter;
803         l_association_tbl(i).section             := p_x_association_tbl(i).section;
804         l_association_tbl(i).subject 	         := p_x_association_tbl(i).subject;
805         l_association_tbl(i).page                := p_x_association_tbl(i).page;
806         l_association_tbl(i).figure              := p_x_association_tbl(i).figure;
807         l_association_tbl(i).note                := p_x_association_tbl(i).note;
808         l_association_tbl(i).attribute_category  := p_x_association_tbl(i).attribute_category;
809         l_association_tbl(i).attribute1          := p_x_association_tbl(i).attribute1;
810         l_association_tbl(i).attribute2          := p_x_association_tbl(i).attribute2;
811         l_association_tbl(i).attribute3          := p_x_association_tbl(i).attribute3;
812         l_association_tbl(i).attribute4          := p_x_association_tbl(i).attribute4;
813         l_association_tbl(i).attribute5          := p_x_association_tbl(i).attribute5;
814         l_association_tbl(i).attribute6          := p_x_association_tbl(i).attribute6;
815         l_association_tbl(i).attribute7          := p_x_association_tbl(i).attribute7;
816         l_association_tbl(i).attribute8          := p_x_association_tbl(i).attribute8;
817         l_association_tbl(i).attribute9          := p_x_association_tbl(i).attribute9;
818         l_association_tbl(i).attribute10         := p_x_association_tbl(i).attribute10;
819         l_association_tbl(i).attribute11         := p_x_association_tbl(i).attribute11;
820         l_association_tbl(i).attribute12         := p_x_association_tbl(i).attribute12;
821         l_association_tbl(i).attribute13         := p_x_association_tbl(i).attribute13;
822         l_association_tbl(i).attribute14         := p_x_association_tbl(i).attribute14;
823         l_association_tbl(i).attribute15         := p_x_association_tbl(i).attribute15;
824         l_association_tbl(i).delete_flag         := p_x_association_tbl(i).delete_flag;
825         l_association_tbl(i).object_version_number := p_x_association_tbl(i).object_version_number;
826    --Standard check to count messages
827    l_msg_count := FND_MSG_PUB.count_msg;
828 
829    IF l_msg_count > 0 THEN
830       X_msg_count := l_msg_count;
831       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
832       RAISE FND_API.G_EXC_ERROR;
833    END IF;
834  END LOOP;
835 END IF;
836 
837 /*------------------------------------------------------------------------*/
838 /* procedure name: AHL_DI_ASSO_DOC_ASO_CUHK.MODIFY_ASSOCIATION_PRE        */
839 /*                 AHL_DI_ASSO_DOC_ASO_VUHK.MODIFY_ASSOCIATION_PRE        */
840 /* description   :  Added by Senthil to call User Hooks                   */
841 /* Date     : Dec 10 2001                                                 */
842 /*------------------------------------------------------------------------*/
843 
844 
845 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','MODIFY_ASSOCIATION',
846 					'B', 'C' )  then
847    IF G_DEBUG='Y' THEN
848 		  AHL_DEBUG_PUB.debug( 'Start of api Customer MODIFY_ASSOCIATION_PRE');
849 
850 	END IF;
851             AHL_DI_ASSO_DOC_ASO_CUHK.MODIFY_ASSOCIATION_PRE(
852 			P_X_ASSOCIATION_TBL    	=>	l_association_tbl    ,
853 			X_RETURN_STATUS        	=>	l_pre_C_return_status        ,
854 			X_MSG_COUNT            	=>	l_pre_C_msg_count            ,
855 			X_MSG_DATA             	=>	l_pre_C_msg_data             );
856 
857       		IF   l_pre_C_return_status = FND_API.G_RET_STS_ERROR  THEN
858     			RAISE FND_API.G_EXC_ERROR;
859              	ELSIF l_pre_C_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
860 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
861 		END IF;
862 END IF;
863 
864 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','MODIFY_ASSOCIATION',
865 					'B', 'V' )  then
866    IF G_DEBUG='Y' THEN
867 		  AHL_DEBUG_PUB.debug( 'Start of api Vertical MODIFY_ASSOCIATION_PRE');
868 
869 	END IF;
870             AHL_DI_ASSO_DOC_ASO_VUHK.MODIFY_ASSOCIATION_PRE(
871 			P_X_ASSOCIATION_TBL    	=>	l_association_tbl    ,
872 			X_RETURN_STATUS        	=>	l_pre_V_return_status        ,
873 			X_MSG_COUNT            	=>	l_pre_V_msg_count            ,
874 			X_MSG_DATA             	=>	l_pre_V_msg_data             );
875 
876       		IF   l_pre_V_return_status = FND_API.G_RET_STS_ERROR  THEN
877     			RAISE FND_API.G_EXC_ERROR;
878              	ELSIF l_pre_V_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
879 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
880 		END IF;
881 END IF;
882 
883 /*---------------------------------------------------------*/
884 /*     End ; Date     : Dec 10 2001                        */
885 /*---------------------------------------------------------*/
886 
887  -- Call the Private API
888  AHL_DI_ASSO_DOC_ASO_PVT.MODIFY_ASSOCIATION
889         (
890          p_api_version       => 1.0,
891          p_init_msg_list     => l_init_msg_list,
892          p_commit            => p_commit,
893          p_validate_only     => p_validate_only,
894          p_validation_level  => p_validation_level,
895          p_x_association_tbl => l_association_tbl,
896          x_return_status     => l_return_status,
897          x_msg_count         => l_msg_count,
898          x_msg_data          => l_msg_data
899          );
900    --Standard check to count messages
901    l_msg_count := FND_MSG_PUB.count_msg;
902 
903    IF l_msg_count > 0 THEN
904       X_msg_count := l_msg_count;
905       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
906       RAISE FND_API.G_EXC_ERROR;
907    END IF;
908 
909 
910 /*------------------------------------------------------------------------*/
911 /* procedure name: AHL_DI_ASSO_DOC_ASO_CUHK.MODIFY_ASSOCIATION_POST       */
912 /*                 AHL_DI_ASSO_DOC_ASO_VUHK.MODIFY_ASSOCIATION_POST       */
913 /* description   :  Added by Senthil to call User Hooks                   */
914 /* Date     : Dec 10 2001                                                 */
915 /*------------------------------------------------------------------------*/
916 
917 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','MODIFY_ASSOCIATION',
918 					'A', 'C' )  then
919    IF G_DEBUG='Y' THEN
920 		  AHL_DEBUG_PUB.debug( 'Start of api Customer MODIFY_ASSOCIATION_POST');
921 
922 	END IF;
923             AHL_DI_ASSO_DOC_ASO_CUHK.MODIFY_ASSOCIATION_POST(
924 			P_ASSOCIATION_TBL    	=>	l_association_tbl    ,
925 			X_RETURN_STATUS        	=>	l_post_C_return_status        ,
926 			X_MSG_COUNT            	=>	l_post_C_msg_count            ,
927 			X_MSG_DATA             	=>	l_post_C_msg_data             );
928 
929       		IF   l_post_C_return_status = FND_API.G_RET_STS_ERROR  THEN
930     			RAISE FND_API.G_EXC_ERROR;
931              	ELSIF l_post_C_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
932 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
933 		END IF;
934 END IF;
935 
936 IF   JTF_USR_HKS.Ok_to_Execute( 'AHL_DI_ASSO_DOC_ASO_PUB','MODIFY_ASSOCIATION',
937 					'A', 'V' )  then
938    IF G_DEBUG='Y' THEN
939 		  AHL_DEBUG_PUB.debug( 'Start of api Vertical MODIFY_ASSOCIATION_POST');
940 
941 	END IF;
942             AHL_DI_ASSO_DOC_ASO_VUHK.MODIFY_ASSOCIATION_POST(
943 			P_ASSOCIATION_TBL    	=>	l_association_tbl    ,
944 			X_RETURN_STATUS        	=>	l_post_V_return_status        ,
945 			X_MSG_COUNT            	=>	l_post_V_msg_count            ,
946 			X_MSG_DATA             	=>	l_post_V_msg_data             );
947 
948       		IF   l_post_V_return_status = FND_API.G_RET_STS_ERROR  THEN
949     			RAISE FND_API.G_EXC_ERROR;
950              	ELSIF l_post_V_return_status = FND_API.G_RET_STS_UNEXP_ERROR  THEN
951 			RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
952 		END IF;
953 END IF;
954 
955 /*---------------------------------------------------------*/
956 /*     End ; Date     : Dec 10 2001                        */
957 /*---------------------------------------------------------*/
958 
959    --Standard check for commit
960    IF FND_API.TO_BOOLEAN(p_commit) THEN
961         COMMIT;
962    END IF;
963    -- Debug info
964    IF G_DEBUG='Y' THEN
965 		  AHL_DEBUG_PUB.debug( 'End of public api Modify Association','+DOBJASS+');
966 
967 	END IF;
968    -- Check if API is called in debug mode. If yes, disable debug.
969    IF G_DEBUG='Y' THEN
970 		  AHL_DEBUG_PUB.disable_debug;
971 
972 	END IF;
973 
974 EXCEPTION
975  WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
976     ROLLBACK TO modify_association;
977     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
978     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
979                                p_count => x_msg_count,
980                                p_data  => x_msg_data);
981         --Debug Info
982         IF G_DEBUG='Y' THEN
983             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'ERROR' );
984             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Modify Association','+DOCJASS+');
985 
986         -- Check if API is called in debug mode. If yes, disable debug.
987            AHL_DEBUG_PUB.disable_debug;
988 
989 	END IF;
990 
991  WHEN FND_API.G_EXC_ERROR THEN
992     ROLLBACK TO modify_association;
993     X_return_status := FND_API.G_RET_STS_ERROR;
994     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
995                                p_count => x_msg_count,
996                                p_data  => X_msg_data);
997         -- Debug info.
998         IF G_DEBUG='Y' THEN
999             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'UNEXPECTED ERROR' );
1000             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Modify Association','+DOCJASS+');
1001 
1002         -- Check if API is called in debug mode. If yes, disable debug.
1003             AHL_DEBUG_PUB.disable_debug;
1004 
1005 	END IF;
1006 
1007  WHEN OTHERS THEN
1008     ROLLBACK TO modify_association;
1009     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1010     IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1011     THEN
1012     fnd_msg_pub.add_exc_msg(p_pkg_name        =>  'AHL_DI_ASSO_DOC_ASO_PUB',
1013                             p_procedure_name  =>  'MODIFY_ASSOCIATION',
1014                             p_error_text      => SUBSTR(SQLERRM,1,240));
1015     END IF;
1016     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
1017                                p_count => x_msg_count,
1018                                p_data  => X_msg_data);
1019 
1020         -- Debug info.
1021         IF G_DEBUG='Y' THEN
1022             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'SQL ERROR' );
1023             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Modify Association','+DOCJASS+');
1024 
1025         -- Check if API is called in debug mode. If yes, disable debug.
1026             AHL_DEBUG_PUB.disable_debug;
1027 
1028 	END IF;
1029 
1030 END MODIFY_ASSOCIATION;
1031 ----------------------------PROCESS_ASSOCIATION------------------------------
1032 PROCEDURE PROCESS_ASSOCIATION
1033 (
1034  p_api_version               IN     NUMBER    :=  1.0            ,
1035  p_init_msg_list             IN     VARCHAR2  := FND_API.G_TRUE  ,
1036  p_commit                    IN     VARCHAR2  := FND_API.G_FALSE ,
1037  p_validate_only             IN     VARCHAR2  := FND_API.G_TRUE  ,
1038  p_validation_level          IN     NUMBER    := FND_API.G_VALID_LEVEL_FULL,
1039  p_x_association_tblm         IN OUT NOCOPY association_tbl       ,
1040  p_x_association_tblc         IN OUT NOCOPY association_tbl       ,
1041  p_module_type               IN     VARCHAR2                     ,
1042  x_return_status                OUT NOCOPY VARCHAR2                     ,
1043  x_msg_count                    OUT NOCOPY NUMBER                       ,
1044  x_msg_data                     OUT NOCOPY VARCHAR2
1045 )
1046 IS
1047 --To retrieve document id
1048 CURSOR get_doc_id_info(c_document_no  VARCHAR2)
1049 IS
1050  SELECT document_id
1051    FROM AHL_DOCUMENTS_B
1052   WHERE document_no = c_document_no;
1053 --To retrieve document revision
1054 CURSOR get_doc_rev_id_info(c_revision_no VARCHAR2,
1055                            c_document_id  NUMBER)
1056 IS
1057  SELECT doc_revision_id
1058    FROM AHL_DOC_REVISIONS_B A
1059   WHERE revision_no = c_revision_no
1060     AND document_id = c_document_id;
1061 --
1062 l_api_name     CONSTANT  VARCHAR2(30) := 'PROCESS_ASSOCIATION';
1063 l_api_version  CONSTANT  NUMBER       := 1.0;
1064 l_msg_count              NUMBER;
1065 l_msg_data               VARCHAR2(2000);
1066 l_return_status          VARCHAR2(1);
1067 l_aso_object_type_code   VARCHAR2(30);
1068 l_document_id            NUMBER;
1069 l_doc_revision_id        NUMBER;
1070 l_association_tbl        AHL_DI_ASSO_DOC_ASO_PVT.association_tbl;
1071 l_association_tblc       AHL_DI_ASSO_DOC_ASO_PVT.association_tbl;
1072 l_init_msg_list          VARCHAR2(10) := FND_API.G_TRUE;
1073 l_pre_V_msg_count        NUMBER;
1074 l_pre_V_msg_data         VARCHAR2(2000);
1075 l_pre_V_return_status    VARCHAR2(1);
1076 l_post_V_msg_count       NUMBER;
1077 l_post_V_msg_data        VARCHAR2(2000);
1078 l_post_V_return_status   VARCHAR2(1);
1079 l_pre_C_msg_count        NUMBER;
1080 l_pre_C_msg_data         VARCHAR2(2000);
1081 l_pre_C_return_status    VARCHAR2(1);
1082 l_post_C_msg_count       NUMBER;
1083 l_post_C_msg_data        VARCHAR2(2000);
1084 l_post_C_return_status   VARCHAR2(1);
1085 BEGIN
1086     -- Standard Start of API savepoint
1087     SAVEPOINT process_association;
1088    -- Check if API is called in debug mode. If yes, enable debug.
1089    IF G_DEBUG='Y' THEN
1090 		  AHL_DEBUG_PUB.enable_debug;
1091 
1092 	END IF;
1093    -- Debug info.
1094    IF G_DEBUG='Y' THEN
1095        IF G_DEBUG='Y' THEN
1096 		  AHL_DEBUG_PUB.debug( 'enter ahl_di_asso_doc_aso_pub.Process Association','+DOBJASS+');
1097 
1098 	END IF;
1099     END IF;
1100     -- Standard call to check for call compatibility.
1101     IF FND_API.to_boolean(l_init_msg_list)
1102     THEN
1103       FND_MSG_PUB.initialize;
1104     END IF;
1105     --  Initialize API return status to success
1106     x_return_status := 'S';
1107     -- Initialize message list if p_init_msg_list is set to TRUE.
1108     IF NOT FND_API.COMPATIBLE_API_CALL(l_api_version,
1109                                        p_api_version,
1110                                        l_api_name,G_PKG_NAME)
1111     THEN
1112         RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1113     END IF;
1114    --Starts API to modify Body
1115    IF p_x_association_tblm.COUNT > 0
1116    THEN
1117      FOR i IN p_x_association_tblm.FIRST..p_x_association_tblm.LAST
1118      LOOP
1119         -- Module type is 'JSP' then make it null for the following fields
1120         IF (p_module_type = 'JSP') THEN
1121             p_x_association_tblm(i).document_id := null;
1122             p_x_association_tblm(i).doc_revision_id := null;
1123         END IF;
1124 
1125          --For Document Id,
1126       IF (p_x_association_tblm(i).document_id IS NULL OR
1127          p_x_association_tblm(i).document_id <> FND_API.G_MISS_NUM)
1128          THEN
1129 
1130           -- If name is available
1131            IF (p_x_association_tblm(i).document_no IS NOT NULL) AND
1132               (p_x_association_tblm(i).document_no <> FND_API.G_MISS_CHAR)
1133               THEN
1134                  OPEN  get_doc_id_info(p_x_association_tblm(i).document_no);
1135                  FETCH get_doc_id_info INTO l_document_id;
1136                  IF get_doc_id_info%FOUND
1137                  THEN
1138                   l_association_tbl(i).document_id := l_document_id;
1139                   ELSE
1140                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
1141                    FND_MSG_PUB.ADD;
1142                  END IF;
1143                  CLOSE get_doc_id_info;
1144            --If Document Id is present
1145          ELSIF (p_x_association_tblm(i).document_id IS NOT NULL) AND
1146                (p_x_association_tblm(i).document_id <> FND_API.G_MISS_NUM)
1147             THEN
1148                l_association_tbl(i).document_id := l_document_id;
1149          ELSE
1150               --Both Document Id and Name are missing
1151                l_association_tbl(i).document_id := l_document_id;
1152         END IF;
1153        END IF;
1154          --For Document Revision Id,
1155           -- If Revision no is available
1156          IF p_x_association_tblm(i).doc_revision_id IS NULL OR
1157             p_x_association_tblm(i).doc_revision_id = FND_API.G_MISS_NUM
1158            THEN
1159            IF (p_x_association_tblm(i).revision_no IS NOT NULL) AND
1160               (p_x_association_tblm(i).revision_no <> FND_API.G_MISS_CHAR)
1161               THEN
1162                  OPEN  get_doc_rev_id_info(p_x_association_tblm(i).revision_no,
1163                                            l_document_id);
1164                  FETCH get_doc_rev_id_info INTO l_doc_revision_id;
1165                  IF get_doc_rev_id_info%FOUND
1166                  THEN
1167                   l_association_tbl(i).doc_revision_id := l_doc_revision_id;
1168                   ELSE
1169                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
1170                    FND_MSG_PUB.ADD;
1171                  END IF;
1172                  CLOSE get_doc_rev_id_info;
1173            --If Doc Revision Id is present
1174          ELSIF (p_x_association_tblm(i).doc_revision_id IS NOT NULL) AND
1175                (p_x_association_tblm(i).doc_revision_id <> FND_API.G_MISS_NUM)
1176             THEN
1177                l_association_tbl(i).doc_revision_id := l_doc_revision_id;
1178         END IF;
1179       END IF;
1180            -- For Aso Object Type code, meaning presents
1181          IF p_x_association_tblm(i).aso_object_desc IS NOT NULL AND
1182             p_x_association_tblm(i).aso_object_desc <> FND_API.G_MISS_CHAR
1183          THEN
1184 
1185              Check_lookup_name_Or_Id (
1186                   p_lookup_type  => 'AHL_OBJECT_TYPE',
1187                   p_lookup_code  => null,
1188                   p_meaning      => p_x_association_tblm(i).aso_object_desc,
1189                   p_check_id_flag => 'Y',
1190                   x_lookup_code   => l_association_tbl(i).aso_object_type_code,
1191                   x_return_status => l_return_status);
1192 
1193          IF nvl(l_return_status, 'X') <> 'S'
1194          THEN
1195             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJ_TYPE_NOT_EXISTS');
1196             FND_MSG_PUB.ADD;
1197          END IF;
1198         END IF;
1199         -- If Type Code presents
1200         IF p_x_association_tblm(i).aso_object_type_code IS NOT NULL AND
1201            p_x_association_tblm(i).aso_object_type_code <> FND_API.G_MISS_CHAR
1202          THEN
1203            l_association_tbl(i).aso_object_type_code := p_x_association_tblm(i).aso_object_type_code;
1204        --If both missing
1205        ELSE
1206            l_association_tbl(i).aso_object_type_code := p_x_association_tblm(i).aso_object_type_code;
1207         END IF;
1208            -- For Source Ref Code, meaning presents
1209          IF p_x_association_tblm(i).source_ref_mean IS NOT NULL AND
1210             p_x_association_tblm(i).source_ref_mean <> FND_API.G_MISS_CHAR
1211          THEN
1212 
1213              Check_lookup_name_Or_Id (
1214                   p_lookup_type  => 'AHL_DI_SOURCE_REF',
1215                   p_lookup_code  => null,
1216                   p_meaning      => p_x_association_tblm(i).source_ref_mean,
1217                   p_check_id_flag => 'Y',
1218                   x_lookup_code   => l_association_tbl(i).source_ref_code,
1219                   x_return_status => l_return_status);
1220 
1221          IF nvl(l_return_status, 'X') <> 'S'
1222          THEN
1223             FND_MESSAGE.SET_NAME('AHL','AHL_DI_SOURCE_REF_NOT_EXISTS');
1224             FND_MSG_PUB.ADD;
1225          END IF;
1226         END IF;
1227 
1228         -- If Type Code presents
1229         IF p_x_association_tblm(i).source_ref_code IS NOT NULL AND
1230            p_x_association_tblm(i).source_ref_code <> FND_API.G_MISS_CHAR
1231          THEN
1232            l_association_tbl(i).source_ref_code := p_x_association_tblm(i).source_ref_code;
1233        --If both missing
1234        ELSE
1235            l_association_tbl(i).source_ref_code := p_x_association_tblm(i).source_ref_code;
1236         END IF;
1237 
1238         l_association_tbl(i).doc_title_asso_id   := p_x_association_tblm(i).doc_title_asso_id;
1239         l_association_tbl(i).use_latest_rev_flag := p_x_association_tblm(i).use_latest_rev_flag;
1240         l_association_tbl(i).aso_object_id       := p_x_association_tblm(i).aso_object_id;
1241         l_association_tbl(i).serial_no           := p_x_association_tblm(i).serial_no;
1242         l_association_tbl(i).source_lang         := p_x_association_tblm(i).source_lang;
1243         l_association_tbl(i).chapter             := p_x_association_tblm(i).chapter;
1244         l_association_tbl(i).section             := p_x_association_tblm(i).section;
1245         l_association_tbl(i).subject             := p_x_association_tblm(i).subject;
1246         l_association_tbl(i).page                := p_x_association_tblm(i).page;
1247         l_association_tbl(i).figure              := p_x_association_tblm(i).figure;
1248         l_association_tbl(i).note                := p_x_association_tblm(i).note;
1249         l_association_tbl(i).source_ref_code     := p_x_association_tblm(i).source_ref_code;
1250         l_association_tbl(i).attribute_category  := p_x_association_tblm(i).attribute_category;
1251         l_association_tbl(i).attribute1          := p_x_association_tblm(i).attribute1;
1252         l_association_tbl(i).attribute2          := p_x_association_tblm(i).attribute2;
1253         l_association_tbl(i).attribute3          := p_x_association_tblm(i).attribute3;
1254         l_association_tbl(i).attribute4          := p_x_association_tblm(i).attribute4;
1255         l_association_tbl(i).attribute5          := p_x_association_tblm(i).attribute5;
1256         l_association_tbl(i).attribute6          := p_x_association_tblm(i).attribute6;
1257         l_association_tbl(i).attribute7          := p_x_association_tblm(i).attribute7;
1258         l_association_tbl(i).attribute8          := p_x_association_tblm(i).attribute8;
1259         l_association_tbl(i).attribute9          := p_x_association_tblm(i).attribute9;
1260         l_association_tbl(i).attribute10         := p_x_association_tblm(i).attribute10;
1261         l_association_tbl(i).attribute11         := p_x_association_tblm(i).attribute11;
1262         l_association_tbl(i).attribute12         := p_x_association_tblm(i).attribute12;
1263         l_association_tbl(i).attribute13         := p_x_association_tblm(i).attribute13;
1264         l_association_tbl(i).attribute14         := p_x_association_tblm(i).attribute14;
1265         l_association_tbl(i).attribute15         := p_x_association_tblm(i).attribute15;
1266         l_association_tbl(i).delete_flag         := p_x_association_tblm(i).delete_flag;
1267         l_association_tbl(i).object_version_number := p_x_association_tblm(i).object_version_number;
1268    --Standard check to count messages
1269    l_msg_count := FND_MSG_PUB.count_msg;
1270 
1271    IF l_msg_count > 0 THEN
1272       X_msg_count := l_msg_count;
1273       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1274       RAISE FND_API.G_EXC_ERROR;
1275    END IF;
1276  END LOOP;
1277 END IF;
1278    IF G_DEBUG='Y' THEN
1279        IF G_DEBUG='Y' THEN
1280 		  AHL_DEBUG_PUB.debug( 'before modify');
1281 
1282 	END IF;
1283     END IF;
1284 
1285 IF p_x_association_tblm.COUNT > 0
1286 THEN
1287 
1288  -- Call the Private API
1289  AHL_DI_ASSO_DOC_ASO_PVT.MODIFY_ASSOCIATION
1290         (
1291          p_api_version       => 1.0,
1292          p_init_msg_list     => l_init_msg_list,
1293          p_commit            => p_commit,
1294          p_validate_only     => p_validate_only,
1295          p_validation_level  => p_validation_level,
1296          p_x_association_tbl => l_association_tbl,
1297          x_return_status     => l_return_status,
1298          x_msg_count         => l_msg_count,
1299          x_msg_data          => l_msg_data
1300          );
1301    --Standard check to count messages
1302    l_msg_count := FND_MSG_PUB.count_msg;
1303 
1304    IF l_msg_count > 0 THEN
1305       X_msg_count := l_msg_count;
1306       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1307       RAISE FND_API.G_EXC_ERROR;
1308    END IF;
1309  END IF;
1310 ---------------------------------CREATE PART OF CODE---------------------
1311    IF p_x_association_tblc.COUNT > 0
1312    THEN
1313      FOR i IN p_x_association_tblc.FIRST..p_x_association_tblc.LAST
1314      LOOP
1315         -- Module type is 'JSP' then make it null for the following fields
1316         IF (p_module_type = 'JSP') THEN
1317             p_x_association_tblc(i).document_id := null;
1318             p_x_association_tblc(i).doc_revision_id := null;
1319         END IF;
1320 
1321 
1322      IF (p_x_association_tblc(i).document_id IS NULL OR
1323          p_x_association_tblc(i).document_id = FND_API.G_MISS_NUM)
1324       THEN
1325 
1326         -- For Document Id, If docuemnt no is passed
1327            IF (p_x_association_tblc(i).document_no IS NOT NULL) AND
1328               (p_x_association_tblc(i).document_no <> FND_API.G_MISS_CHAR)
1329               THEN
1330                  OPEN  get_doc_id_info(p_x_association_tblc(i).document_no);
1331                  FETCH get_doc_id_info INTO l_document_id;
1332               	   IF get_doc_id_info%FOUND
1333                  THEN
1334                   l_association_tblc(i).document_id := l_document_id;
1335                   ELSE
1336                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
1337                    FND_MSG_PUB.ADD;
1338                  END IF;
1339                  CLOSE get_doc_id_info;
1340              ELSE
1341                  FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_INVALID');
1342                  FND_MSG_PUB.ADD;
1343              END IF;
1344 
1345            --If Document Id is present
1346            ELSIF (p_x_association_tblc(i).document_id IS NOT NULL)  AND
1347               (p_x_association_tblc(i).document_id <> FND_API.G_MISS_NUM)
1348               THEN
1349                   l_association_tblc(i).document_id := p_x_association_tblc(i).document_id;
1350            ELSE
1351               --Both Document Id and Name are missing
1352               FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_ID_NOT_EXISTS');
1353               FND_MSG_PUB.ADD;
1354             END IF;
1355         -- For Document Revision Id
1356      IF (p_x_association_tblc(i).doc_revision_id IS NULL OR
1357          p_x_association_tblc(i).doc_revision_id = FND_API.G_MISS_NUM)
1358       THEN
1359 
1360          -- If Revision No is available
1361            IF (p_x_association_tblc(i).revision_no IS NOT NULL) AND
1362               (p_x_association_tblc(i).revision_no <> FND_API.G_MISS_CHAR)
1363               THEN
1364 
1365                  OPEN  get_doc_rev_id_info(p_x_association_tblc(i).revision_no,
1366                                            l_document_id);
1367                  FETCH get_doc_rev_id_info INTO l_doc_revision_id;
1368                  IF get_doc_rev_id_info%FOUND
1369                  THEN
1370                   l_association_tblc(i).doc_revision_id := l_doc_revision_id;
1371                   ELSE
1372                    FND_MESSAGE.SET_NAME('AHL','AHL_DI_DOC_REV_ID_INVALID');
1373                    FND_MSG_PUB.ADD;
1374                  END IF;
1375                  CLOSE get_doc_rev_id_info;
1376             ELSE
1377              l_association_tblc(i).doc_revision_id := p_x_association_tblc(i).doc_revision_id;
1378             END IF;
1379            --If Revision Id is present
1380           ELSIF (p_x_association_tblc(i).doc_revision_id IS NOT NULL) AND
1381               (p_x_association_tblc(i).doc_revision_id <> FND_API.G_MISS_NUM)
1382               THEN
1383                   l_association_tblc(i).doc_revision_id := p_x_association_tblc(i).doc_revision_id;
1384            ELSE
1385              l_association_tblc(i).doc_revision_id := p_x_association_tblc(i).doc_revision_id;
1386          END IF;
1387 
1388          -- For Aso Object Type code, meaning presents
1389          IF p_x_association_tblc(i).aso_object_desc IS NOT NULL AND
1390             p_x_association_tblc(i).aso_object_desc <> FND_API.G_MISS_CHAR
1391          THEN
1392 
1393              Check_lookup_name_Or_Id (
1394                   p_lookup_type  => 'AHL_OBJECT_TYPE',
1395                   p_lookup_code  => null,
1396                   p_meaning      => p_x_association_tblc(i).aso_object_desc,
1397                   p_check_id_flag => 'Y',
1398                   x_lookup_code   => l_association_tblc(i).aso_object_type_code,
1399                   x_return_status => l_return_status);
1400 
1401          IF nvl(l_return_status, 'X') <> 'S'
1402          THEN
1403             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJ_TYP_NOT_EXISTS');
1404             FND_MSG_PUB.ADD;
1405          END IF;
1406         END IF;
1407         -- If Type Code presents
1408         IF p_x_association_tblc(i).aso_object_type_code IS NOT NULL AND
1409            p_x_association_tblc(i).aso_object_type_code <> FND_API.G_MISS_CHAR
1410          THEN
1411            l_association_tblc(i).aso_object_type_code := p_x_association_tblc(i).aso_object_type_code;
1412        --If both missing
1413        ELSE
1414             FND_MESSAGE.SET_NAME('AHL','AHL_DI_ASO_OBJECT_TYPE_NULL');
1415             FND_MSG_PUB.ADD;
1416         END IF;
1417            -- For Source Ref Code, meaning presents
1418 /*         IF p_x_association_tblc(i).source_ref_mean IS NOT NULL AND
1419             p_x_association_tblc(i).source_ref_mean <> FND_API.G_MISS_CHAR
1420          THEN
1421 
1422              Check_lookup_name_Or_Id (
1423                   p_lookup_type  => 'AHL_DI_SOURCE_REF',
1424                   p_lookup_code  => null,
1425                   p_meaning      => p_x_association_tblc(i).source_ref_mean,
1426                   p_check_id_flag => 'Y',
1427                   x_lookup_code   => l_association_tbl(i).source_ref_code,
1428                   x_return_status => l_return_status);
1429 
1430          IF nvl(l_return_status, 'X') <> 'S'
1431          THEN
1432             FND_MESSAGE.SET_NAME('AHL','AHL_DI_SOURCE_REF_NOT_EXISTS');
1433             FND_MSG_PUB.ADD;
1434          END IF;
1435         END IF;   */
1436    IF G_DEBUG='Y' THEN
1437        IF G_DEBUG='Y' THEN
1438 		  AHL_DEBUG_PUB.debug('SOURCE CODE :' ||p_x_association_tblc(i).source_ref_code);
1439 
1440 	END IF;
1441     END IF;
1442 
1443         -- If Type Code presents
1444         IF p_x_association_tblc(i).source_ref_code IS NOT NULL AND
1445            p_x_association_tblc(i).source_ref_code <> FND_API.G_MISS_CHAR
1446          THEN
1447            l_association_tbl(i).source_ref_code := p_x_association_tblc(i).source_ref_code;
1448        --If both missing
1449        ELSE
1450            l_association_tbl(i).source_ref_code := p_x_association_tblc(i).source_ref_code;
1451         END IF;
1452 
1453         l_association_tblc(i).aso_object_id         := p_x_association_tblc(i).aso_object_id;
1454         l_association_tblc(i).use_latest_rev_flag   := p_x_association_tblc(i).use_latest_rev_flag;
1455         l_association_tblc(i).serial_no             := p_x_association_tblc(i).serial_no;
1456         l_association_tblc(i).source_lang           := p_x_association_tblc(i).source_lang;
1457         l_association_tblc(i).chapter               := p_x_association_tblc(i).chapter;
1458         l_association_tblc(i).section               := p_x_association_tblc(i).section;
1459         l_association_tblc(i).subject               := p_x_association_tblc(i).subject;
1460         l_association_tblc(i).page                  := p_x_association_tblc(i).page;
1461         l_association_tblc(i).figure                := p_x_association_tblc(i).figure;
1462         l_association_tblc(i).note                  := p_x_association_tblc(i).note;
1463         l_association_tblc(i).source_ref_code       := p_x_association_tblc(i).source_ref_code;
1464         l_association_tblc(i).attribute_category    := p_x_association_tblc(i).attribute_category;
1465         l_association_tblc(i).attribute1            := p_x_association_tblc(i).attribute1;
1466         l_association_tblc(i).attribute2            := p_x_association_tblc(i).attribute2;
1467         l_association_tblc(i).attribute3            := p_x_association_tblc(i).attribute3;
1468         l_association_tblc(i).attribute4            := p_x_association_tblc(i).attribute4;
1469         l_association_tblc(i).attribute5            := p_x_association_tblc(i).attribute5;
1470         l_association_tblc(i).attribute6            := p_x_association_tblc(i).attribute6;
1471         l_association_tblc(i).attribute7            := p_x_association_tblc(i).attribute7;
1472         l_association_tblc(i).attribute8            := p_x_association_tblc(i).attribute8;
1473         l_association_tblc(i).attribute9            := p_x_association_tblc(i).attribute9;
1474         l_association_tblc(i).attribute10           := p_x_association_tblc(i).attribute10;
1475         l_association_tblc(i).attribute11           := p_x_association_tblc(i).attribute11;
1476         l_association_tblc(i).attribute12           := p_x_association_tblc(i).attribute12;
1477         l_association_tblc(i).attribute13           := p_x_association_tblc(i).attribute13;
1478         l_association_tblc(i).attribute14           := p_x_association_tblc(i).attribute14;
1479         l_association_tblc(i).attribute15           := p_x_association_tblc(i).attribute15;
1480         l_association_tblc(i).delete_flag           := p_x_association_tblc(i).delete_flag;
1481         l_association_tblc(i).object_version_number := p_x_association_tblc(i).object_version_number;
1482    --Standard check to count messages
1483    l_msg_count := FND_MSG_PUB.count_msg;
1484    IF l_msg_count > 0 THEN
1485       X_msg_count := l_msg_count;
1486       X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1487       RAISE FND_API.G_EXC_ERROR;
1488    END IF;
1489  END LOOP;
1490 END IF;
1491 
1492 /*------------------------------------------------------------------------*/
1493 /* procedure name: AHL_DI_ASSO_DOC_ASO_CUHK.CREATE_ASSOCIATION_PRE        */
1494 /*                 AHL_DI_ASSO_DOC_ASO_VUHK.CREATE_ASSOCIATION_PRE        */
1495 /* description   :  Added by Senthil to call User Hooks                   */
1496 /* Date     : Dec 10 2001                                                 */
1497 /*------------------------------------------------------------------------*/
1498 
1499 
1500 -- Call the Private API
1501    IF p_x_association_tblC.COUNT > 0
1502    THEN
1503     x_return_status := 'S';
1504  AHL_DI_ASSO_DOC_ASO_PVT.CREATE_ASSOCIATION
1505         (
1506          p_api_version       => 1.0,
1507          p_init_msg_list     => l_init_msg_list,
1508          p_commit            => p_commit,
1509          p_validate_only     => p_validate_only,
1510          p_validation_level  => p_validation_level,
1511          p_x_association_tbl => l_association_tblc,
1512          x_return_status     => l_return_status,
1513          x_msg_count         => l_msg_count,
1514          x_msg_data          => l_msg_data
1515          );
1516 
1517    --Standard check to count messages
1518    l_msg_count := FND_MSG_PUB.count_msg;
1519 
1520    IF l_msg_count > 0 THEN
1521       X_msg_count := l_msg_count;
1522       l_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1523       RAISE FND_API.G_EXC_ERROR;
1524    END IF;
1525 
1526  --Assign values
1527  IF l_association_tblc.COUNT > 0
1528  THEN
1529    FOR i IN l_association_tblc.FIRST..l_association_tblc.LAST
1530    LOOP
1531      p_x_association_tblc(i).doc_title_asso_id := l_association_tblc(i).doc_title_asso_id;
1532    END LOOP;
1533  END IF;
1534 END IF;
1535 --
1536 --Standard check for commit
1537    IF FND_API.TO_BOOLEAN(p_commit) THEN
1538         COMMIT;
1539    END IF;
1540    -- Debug info
1541    IF G_DEBUG='Y' THEN
1542 		  AHL_DEBUG_PUB.debug( 'End of public api Process Association','+DOBJASS+');
1543 
1544 	END IF;
1545    -- Check if API is called in debug mode. If yes, disable debug.
1546    IF G_DEBUG='Y' THEN
1547 		  AHL_DEBUG_PUB.disable_debug;
1548 
1549 	END IF;
1550 
1551 EXCEPTION
1552  WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1553     ROLLBACK TO PROCESS_association;
1554     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1555     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
1556                                p_count => x_msg_count,
1557                                p_data  => x_msg_data);
1558         --Debug Info
1559         IF G_DEBUG='Y' THEN
1560             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'ERROR' );
1561             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Proces Association','+DOCJASS+');
1562 
1563 	-- Check if API is called in debug mode. If yes, disable debug.
1564            AHL_DEBUG_PUB.disable_debug;
1565 
1566 	END IF;
1567 
1568 
1569 
1570  WHEN FND_API.G_EXC_ERROR THEN
1571     ROLLBACK TO PROCESS_association;
1572     X_return_status := FND_API.G_RET_STS_ERROR;
1573     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
1574                                p_count => x_msg_count,
1575                                p_data  => X_msg_data);
1576         -- Debug info.
1577         IF G_DEBUG='Y' THEN
1578             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'UNEXPECTED ERROR' );
1579             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Process Association','+DOCJASS+');
1580 
1581         -- Check if API is called in debug mode. If yes, disable debug.
1582            AHL_DEBUG_PUB.disable_debug;
1583 
1584 	END IF;
1585 
1586  WHEN OTHERS THEN
1587     ROLLBACK TO PROCESS_association;
1588     X_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1589     IF FND_MSG_PUB.check_msg_level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1590     THEN
1591     fnd_msg_pub.add_exc_msg(p_pkg_name        =>  'AHL_DI_ASSO_DOC_ASO_PUB',
1592                             p_procedure_name  =>  'PROCESS_ASSOCIATION',
1593                             p_error_text      => SUBSTR(SQLERRM,1,240));
1594     END IF;
1595     FND_MSG_PUB.count_and_get( p_encoded => FND_API.G_FALSE,
1596                                p_count => x_msg_count,
1597                                p_data  => X_msg_data);
1598 
1599         -- Debug info.
1600         IF G_DEBUG='Y' THEN
1601             AHL_DEBUG_PUB.log_app_messages (x_msg_count, x_msg_data, 'SQL ERROR' );
1602             AHL_DEBUG_PUB.debug( 'ahl_di_asso_doc_aso_pub.Process Association','+DOCJASS+');
1603 
1604 
1605         -- Check if API is called in debug mode. If yes, disable debug.
1606             AHL_DEBUG_PUB.disable_debug;
1607 
1608 	END IF;
1609 
1610 END PROCESS_ASSOCIATION;
1611 
1612 END AHL_DI_ASSO_DOC_ASO_PUB;