DBA Data[Home] [Help]

PACKAGE BODY: APPS.IBU_HZ_PERSON

Source


1 PACKAGE BODY IBU_HZ_PERSON AS
2 /* $Header: ibuulngb.pls 120.1 2005/09/07 12:04:08 mkcyee noship $ */
3 
4 G_PKG_NAME CONSTANT VARCHAR2(30) := 'IBU_HZ_PERSON';
5 --G_CREATED_BY_MODULE VARCHAR2(30) := 'EMAIL SUBSCRIPTION';
6 G_APPLICATION_ID NUMBER := 672;
7 
8 
9 /*+====================================================================
10 | PROCEDURE NAME
11 |    Update_Person_Language
12 |
13 | DESCRIPTION
14 |  If the API finds a language preference for the given party then it updates
15 |  the primary indicator to 'N' then it sets the new language as the primary
16 |  language. If it does not find any language preference for the party then
17 |  it creates a new one and makes it primary
18 |
19 |  REFERENCED APIS
20 |     This API calls the following APIs
21 |    -  HZ_PERSON_INFO_V2PUB.create_person_language if no row exists
22 |    -  HZ_PERSON_INFO_V2PUB.update_person_language if row exists
23 +======================================================================*/
24 
25 PROCEDURE Update_Person_Language(
26     p_party_id		     IN    NUMBER,
27     p_language_name      IN    VARCHAR2,
28     p_created_by_module  IN    VARCHAR2,
29     x_debug_buf          OUT NOCOPY  VARCHAR2,
30     x_return_status      OUT NOCOPY  VARCHAR2,
31     x_msg_count          OUT NOCOPY  NUMBER,
32     x_msg_data           OUT NOCOPY  VARCHAR2
33     )
34 IS
35     CURSOR c_party_type (p_party_id number) is
36     SELECT PARTY_TYPE
37     FROM HZ_PARTIES
38     WHERE PARTY_ID = p_party_id;
39 
40     CURSOR c_person_party (p_party_id number) is
41     SELECT SUBJECT_ID
42     FROM HZ_RELATIONSHIPS
43     WHERE PARTY_ID = p_party_id
44     AND SUBJECT_TYPE = 'PERSON';
45 
46     l_per_language_rec   hz_person_info_v2pub.person_language_rec_type;
47     l_id                 NUMBER;
48     l_per_language_rec2   hz_person_info_v2pub.person_language_rec_type;
49     l_language_use_reference_id number;
50     l_object_version_number       NUMBER;
51     l_party_type         VARCHAR2(100);
52     l_person_party       NUMBER;
53     l_party_id           NUMBER;
54 
55 BEGIN
56 
57 	x_debug_buf := x_debug_buf || 'enter ibu_hz_person.update_person_language';
58 
59 	x_debug_buf := x_debug_buf || 'finding party type';
60 	OPEN c_party_type (p_party_id);
61 	FETCH c_party_type into l_party_type;
62 	IF c_party_type%NOTFOUND THEN
63 		x_debug_buf := x_debug_buf || 'party type not found';
64 	END IF;
65 	CLOSE c_party_type;
66 
67 	IF (l_party_type = 'PARTY_RELATIONSHIP') THEN
68 		x_debug_buf := x_debug_buf || 'party type is relationship';
69 		OPEN c_person_party (p_party_id);
70 		FETCH c_person_party into l_person_party;
71 		IF c_person_party %NOTFOUND THEN
72 			x_debug_buf := x_debug_buf || 'person party not found';
73           ELSE
74                l_party_id := l_person_party;
75 		END IF;
76 		CLOSE c_person_party;
77 	ELSE
78 		x_debug_buf := x_debug_buf || 'person type is person';
79 		l_party_id := p_party_id;
80 	END IF;
81 
82       FND_MSG_PUB.initialize;
83 
84 	 SAVEPOINT Update_Person_Language;
85 
86   --begin unset primary language indicator
87   BEGIN
88     SELECT language_use_reference_id, object_version_number
89     INTO   l_id, l_object_version_number
90     FROM   hz_person_language
91     WHERE  party_id=l_party_id and primary_language_indicator='Y';
92 
93     l_per_language_rec.primary_language_indicator := 'N';
94     l_per_language_rec.language_use_reference_id := l_id;
95 
96 	x_debug_buf := x_debug_buf || 'Call HZ_PERSON_INFO_V2PUB.update_person_language API to unset primary';
97 
98     hz_person_info_v2pub.update_person_language(
99             p_person_language_rec => l_per_language_rec,
100             p_object_version_number => l_object_version_number,
101             x_return_status => x_return_status,
102             x_msg_count => x_msg_count,
103             x_msg_data => x_msg_data);
104 
105 	x_debug_buf := x_debug_buf || ' After Call HZ_PERSON_INFO_V2PUB.update_person_language APIto unset primary';
106     EXCEPTION WHEN NO_DATA_FOUND THEN
107     NULL;
108   END;
109   --end unset primary language indicator
110 
111   --begin set primary language indicator
112   BEGIN
113       SELECT language_use_reference_id, object_version_number
114       INTO   l_id, l_object_version_number
115       FROM   hz_person_language
116       WHERE  party_id=l_party_id
117       AND    language_name=p_language_name
118       AND    status = 'A';
119 
120       l_per_language_rec2.primary_language_indicator := 'Y';
121       l_per_language_rec2.language_use_reference_id := l_id;
122 
123 
124 	x_debug_buf := x_debug_buf || 'Call HZ_PERSON_INFO_V2PUB.update_person_language API to set primary';
125      hz_person_info_v2pub.update_person_language(
126             p_person_language_rec => l_per_language_rec2,
127             p_object_version_number => l_object_version_number,
128             x_return_status => x_return_status,
129             x_msg_count => x_msg_count,
130             x_msg_data => x_msg_data);
131 
132 	x_debug_buf := x_debug_buf || 'After Call HZ_PERSON_INFO_V2PUB.update_person_language API to set primary';
133       EXCEPTION WHEN NO_DATA_FOUND THEN
134         l_per_language_rec2.primary_language_indicator := 'Y';
135         l_per_language_rec2.party_id := l_party_id;
136         l_per_language_rec2.language_name := p_language_name;
137         l_per_language_rec2.created_by_module := p_created_by_module;
138 
139 	x_debug_buf := x_debug_buf || 'Call HZ_PERSON_INFO_V2PUB.create_person_language API to set primary';
140         hz_person_info_v2pub.create_person_language(
141              p_person_language_rec => l_per_language_rec2,
142              x_language_use_reference_id => l_language_use_reference_id,
143             x_return_status => x_return_status,
144             x_msg_count => x_msg_count,
145             x_msg_data => x_msg_data);
146 	x_debug_buf := x_debug_buf || 'Call HZ_PERSON_INFO_V2PUB.create_person_language API to set primary';
147 
148     END;
149     --end set primary language indicator
150 
151 
152 
153     -- standard call to get message count and if count is 1, get message info
154     FND_MSG_PUB.count_and_get(
155       p_encoded => FND_API.G_FALSE,
156       p_count => x_msg_count,
157       p_data => x_msg_data
158     );
159 
160 --standard exception catching for main body
161 EXCEPTION
162   WHEN FND_API.G_EXC_ERROR THEN
163 
164     x_return_status := FND_API.G_RET_STS_ERROR;
165     FND_MSG_PUB.count_and_get(
166       p_encoded => FND_API.G_FALSE,
167       p_count => x_msg_count,
168       p_data => x_msg_data
169     );
170 	x_debug_buf := x_debug_buf || 'G_EXC_ERROR exception';
171 	x_debug_buf := x_debug_buf || 'x_msg_count ' || to_char(x_msg_count);
172 	x_debug_buf := x_debug_buf || 'x_msg_data ' || x_msg_data;
173 	x_debug_buf := x_debug_buf || 'error code : '|| to_char(SQLCODE);
174 	x_debug_buf := x_debug_buf || 'error text : '|| SQLERRM;
175 
176     ROLLBACK TO Update_Person_Language;
177 
178   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
179 
180     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
181     FND_MSG_PUB.count_and_get(
182       p_encoded => FND_API.G_FALSE,
183       p_count => x_msg_count,
184       p_data => x_msg_data
185     );
186 
187 	x_debug_buf := x_debug_buf || 'G_EXC_UNEXPECTED_ERROR exception';
188 	x_debug_buf := x_debug_buf || 'x_msg_count ' || to_char(x_msg_count);
189 	x_debug_buf := x_debug_buf || 'x_msg_data ' || x_msg_data;
190 	x_debug_buf := x_debug_buf || 'error code : '|| to_char(SQLCODE);
191 	x_debug_buf := x_debug_buf || 'error text : '|| SQLERRM;
192 
193     ROLLBACK TO Update_Person_Language;
194 
195   WHEN OTHERS THEN
196 
197 
198 
199     x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
200     FND_MSG_PUB.count_and_get(
201       p_encoded => FND_API.G_FALSE,
202       p_count => x_msg_count,
203       p_data => x_msg_data
204     );
205 	x_debug_buf := x_debug_buf || 'OTHER exception';
206 	x_debug_buf := x_debug_buf || 'x_msg_count ' || to_char(x_msg_count);
207 	x_debug_buf := x_debug_buf || 'x_msg_data ' || x_msg_data;
208 	x_debug_buf := x_debug_buf || 'error code : '|| to_char(SQLCODE);
209 	x_debug_buf := x_debug_buf || 'error text : '|| SQLERRM;
210 
211     ROLLBACK TO Update_Person_Language;
212 
213 END update_person_language;
214 
215 END IBU_HZ_PERSON;