DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTA_SYNC_COMMON

Source


1 PACKAGE BODY jta_sync_common AS
2 /* $Header: jtavscb.pls 120.4 2006/04/12 03:31:10 deeprao ship $ */
3 /*=======================================================================+
4  |  Copyright (c) 2002 Oracle Corporation Redwood Shores, California, USA|
5  |                            All rights reserved.                       |
6  +=======================================================================+
7  | FILENAME                                                              |
8  |   jtavscb.pls                                                         |
9  |                                                                       |
10  | DESCRIPTION                                                           |
11  |   - This package is implemented for the commonly used procedure or    |
12  |        function.                                                      |
13  |                                                                       |
14  | NOTES                                                                 |
15  |                                                                       |
16  | Date          Developer        Change                                 |
17  | ------        ---------------  -------------------------------------- |
18  | 01-Feb-2002   rdespoto         Modified                               |
19  | 12-Feb-2002   cjang            Added get_userid,get_resourceid,       |
20  |                                   get_timezoneid,get_messages         |
21  | 27-Feb-2002   hbouten          Added get_territory_code               |
22  +======================================================================*/
23    FUNCTION get_seqid
24    RETURN NUMBER
25    IS
26       l_seqnum  NUMBER := 0;
27    BEGIN
28       SELECT jta_sync_contact_mapping_s.nextval
29         INTO l_seqnum
30         FROM DUAL;
31 
32       RETURN l_seqnum;
33    END get_seqid;
34 
35    FUNCTION is_success (
36       p_return_status IN VARCHAR2
37       )
38       RETURN BOOLEAN
39    IS
40    BEGIN
41       IF (p_return_status = fnd_api.g_ret_sts_success)
42       THEN
43          RETURN TRUE;
44       ELSE
45          RETURN FALSE;
46       END IF;
47    END;
48 
49    PROCEDURE put_messages_to_result (
50       p_task_rec     IN OUT NOCOPY jta_sync_task.task_rec,
51       p_status       IN     NUMBER,
52       p_user_message IN     VARCHAR2
53    )
54    IS
55       no_of_messages NUMBER;
56       l_msg_data VARCHAR2(2000);
57    BEGIN
58    --   p_task_rec.resultusermessage := p_user_message;
59      fnd_message.set_name('JTF', p_user_message);
60      fnd_msg_pub.add;
61 
62      IF fnd_msg_pub.count_msg > 0
63      THEN
64        FOR j IN 1 .. fnd_msg_pub.count_msg
65        LOOP
66          l_msg_data := fnd_msg_pub.get (p_msg_index => j, p_encoded => 'F');
67          p_task_rec.resultusermessage := p_task_rec.resultusermessage ||
68                                             fnd_global.local_chr (10)||l_msg_data;
69        END LOOP;
70      END IF;
71 
72      p_task_rec.resultusermessage := substr(p_task_rec.resultusermessage,1,2000);
73      p_task_rec.resultid := p_status;
74      p_task_rec.resultsystemmessage := jta_sync_common.sync_failure;
75    END;
76 
77 
78 /* Commenting the method for bug # 5029377
79    PROCEDURE put_messages_to_result (
80       p_contact_rec  IN OUT NOCOPY jta_sync_contact.contact_rec,
81       p_status       IN     NUMBER
82    )
83    IS
84    BEGIN
85       p_contact_rec.resultid   := p_status;
86       p_contact_rec.syncAnchor := SYSDATE;
87       p_contact_rec.resultusermessage := jta_sync_contact_common.GET_MSG();
88 
89    IF (p_status = 0) THEN
90       p_contact_rec.resultsystemmessage := sync_success;
91    ELSE
92       p_contact_rec.resultsystemmessage := sync_failure;
93    END IF;
94 
95    END put_messages_to_result; */
96 
97    PROCEDURE apps_login (
98       p_user_id IN NUMBER
99    )
100    IS
101    BEGIN
102       fnd_global.apps_initialize (user_id => p_user_id
103                                 , resp_id => fnd_global.resp_id --21787
104                                 , resp_appl_id => fnd_global.resp_appl_id --690
105                                 , security_group_id => fnd_global.security_group_id --0
106       );
107    END;
108 
109 
110    PROCEDURE get_userid (p_user_name  IN VARCHAR2
111                         ,x_user_id   OUT NOCOPY NUMBER)
112    IS
113        CURSOR c_user IS
114        SELECT user_id
115          FROM fnd_user
116         WHERE user_name = p_user_name;
117    BEGIN
118        OPEN c_user;
119        FETCH c_user INTO x_user_id;
120        IF c_user%NOTFOUND THEN
121            x_user_id := 0;
122        END IF;
123        CLOSE c_user;
124    END get_userid;
125 
126    PROCEDURE get_resourceid (p_user_id      IN NUMBER
127                             ,x_resource_id OUT NOCOPY NUMBER)
128    IS
129        CURSOR c_resource IS
130        SELECT resource_id
131          FROM jtf_rs_resource_extns
132         WHERE user_id = p_user_id;
133    BEGIN
134        OPEN c_resource;
135        FETCH c_resource INTO x_resource_id;
136        IF c_resource%NOTFOUND THEN
137            x_resource_id := 0;
138        END IF;
139        CLOSE c_resource;
140    END get_resourceid;
141 
142    PROCEDURE get_timezoneid (p_timezone_name  IN VARCHAR2
143                             ,x_timezone_id   OUT NOCOPY NUMBER)
144    IS
145        CURSOR c_timezone IS
146        SELECT timezone_id
147          FROM HZ_TIMEZONES
148         WHERE global_timezone_name = p_timezone_name;
149    BEGIN
150        OPEN c_timezone;
151        FETCH c_timezone INTO x_timezone_id;
152        IF c_timezone%NOTFOUND THEN
153            x_timezone_id := 0;
154        END IF;
155        CLOSE c_timezone;
156    END get_timezoneid;
157 
158    FUNCTION get_messages
159    RETURN VARCHAR2
160    IS
161        l_msg_count NUMBER;
162        l_msg_data  VARCHAR2(5000);
163    BEGIN
164        l_msg_count := fnd_msg_pub.count_msg;
165 
166        FOR i IN 1..l_msg_count LOOP
167            l_msg_data := substr(l_msg_data||fnd_msg_pub.get( i , 'F' ),1,5000);
168        END LOOP;
169 
170        RETURN l_msg_data;
171    END get_messages;
172 
173    --------------------------------------------------------------------------
174    --  API name    : get_territory_code
175    --  Type        : Private
176    --  Function    : Tries to convert a country into a CRM territory_code
177    --  Notes:
178    --------------------------------------------------------------------------
179    FUNCTION get_territory_code
180    ( p_country IN     VARCHAR2
181    )RETURN VARCHAR2
182    IS
183      CURSOR c_territory
184      (b_country IN VARCHAR2
185      )IS SELECT territory_code code
186          FROM fnd_territories_tl -- using TL since a match in any language will do
187          WHERE UPPER(b_country) = UPPER(territory_short_name)
188          OR    UPPER(b_country) = UPPER(description)
189          OR    UPPER(b_country) = UPPER(territory_code);
190 
191      l_territory_code VARCHAR2(2);
192 
193    BEGIN
194     OPEN c_territory(p_country);
195 
196     FETCH c_territory INTO l_territory_code;
197 
198     CLOSE c_territory;
199 
200     RETURN NVL(l_territory_code,p_country);
201 
202    END get_territory_code;
203 
204 END;