DBA Data[Home] [Help]

PACKAGE BODY: APPS.AMS_RUNTIME_SCRIPTING_PVT

Source


1 PACKAGE BODY AMS_RUNTIME_SCRIPTING_PVT as
2 /* $Header: amsvsceb.pls 115.2 2002/12/11 14:32:33 sanshuma noship $ */
3 -- ===============================================================
4 -- Start of Comments
5 -- Package name
6 --          AMS_RUNTIME_SCRIPTING_PVT
7 -- Purpose
8 --
9 -- History
10 --
11 -- NOTE
12 --
13 -- End of Comments
14 -- ===============================================================
15 
16 
17 G_PKG_NAME CONSTANT VARCHAR2(30):= 'AMS_RUNTIME_SCRIPTING_PVT';
18 G_FILE_NAME CONSTANT VARCHAR2(12) := 'amsvsceb.pls';
19 
20 g_ItemType    Varchar2(10) := 'AMSRSPWD';
21 g_processName Varchar2(30) := 'SENDPWD';
22 
23 -----------------------------------------------------------------------
24 -- PROCEDURE
25 --    notifyForgetLogin
26 --
27 -- PURPOSE
28 --    Sends email to user with given email address
29 --
30 -- NOTES
31 --
32 -----------------------------------------------------------------------
33 PROCEDURE notifyForgetLogin(
34       p_api_version           IN      NUMBER,
35       p_init_msg_list         IN      VARCHAR2 DEFAULT fnd_api.g_false,
36       p_commit                IN      VARCHAR2 DEFAULT fnd_api.g_false,
37       p_user_name             IN      VARCHAR2,
38       p_password              IN      VARCHAR2,
39       p_email_address         IN      VARCHAR2,
40       p_subject               IN      VARCHAR2,
41       p_uname_label           IN      VARCHAR2,
42       p_pwd_label             IN      VARCHAR2,
43       x_return_status         OUT     NOCOPY VARCHAR2,
44       x_msg_count             OUT     NOCOPY NUMBER,
45       x_msg_data              OUT     NOCOPY VARCHAR2
46 )
47 IS
48    l_api_name      CONSTANT VARCHAR2(30)   := 'notifyForgetLogin';
49    l_api_version   CONSTANT NUMBER         := 1.0;
50 
51    l_adhoc_user        WF_USERS.NAME%TYPE;
52    l_item_key          WF_ITEMS.ITEM_KEY%TYPE;
53    l_item_owner        WF_USERS.NAME%TYPE := 'SYSADMIN';
54 
55    l_partyId           Number;
56 
57    l_user_name         Varchar2(30) := NULL;
58    l_disp_name         Varchar2(50) := NULL;
59    l_role_name         Varchar2(30) := NULL;
60    l_role_disp_name    Varchar2(50) := NULL;
61 
62    l_UserType          Varchar2(30) := 'ALL';
63     l_messageName       WF_MESSAGES.NAME%TYPE;
64    l_msgEnabled        VARCHAR2(3) :='Y';
65 
66    CURSOR c_login_user(c_login_name VARCHAR2) IS
67    SELECT USR.CUSTOMER_ID Name
68    FROM   FND_USER USR
69    WHERE  USR.EMPLOYEE_ID  IS NULL
70    AND    user_name = c_login_name;
71 
72 BEGIN
73 
74    -- Standard call to check for call compatibility.
75    IF NOT FND_API.Compatible_API_Call( l_api_version,
76                                        p_api_version,
77                                        l_api_name,
78                                        G_PKG_NAME )
79    THEN
80       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
81    END IF;
82 
83    -- Initialize message list if p_init_msg_list is set to TRUE.
84    IF FND_API.to_Boolean( p_init_msg_list ) THEN
85       FND_MSG_PUB.initialize;
86    END IF;
87 
88    --  Initialize API return status to success
89    x_return_status := FND_API.G_RET_STS_SUCCESS;
90 
91    AMS_UTILITY_PVT.debug_message('notifyForgetLogin starts');
92 
93    l_adhoc_user := upper(p_user_name);
94 
95    FOR c_rec IN c_login_user(l_adhoc_user) LOOP
96      l_adhoc_user := 'HZ_PARTY:'||c_rec.Name;
97      l_partyId    := c_rec.Name;
98    END LOOP;
99 
100    AMS_UTILITY_PVT.debug_message('adhoc user : '||l_adhoc_user);
101    AMS_UTILITY_PVT.debug_message('party id : '||l_partyId);
102 
103    IF(l_partyId IS NULL) THEN
104       RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
105    END IF;
106 
107    wf_directory.createadhocuser(name => l_user_name,
108         display_name => l_disp_name,
109 	  notification_preference => 'MAILTEXT',
110         email_address => p_email_address
111    );
112 
113    AMS_UTILITY_PVT.debug_message('ad hoc user name '||l_user_name||' display name '||l_disp_name);
114 
115    l_item_key := '-'||to_char(sysdate,'MMDDYYHH24MISS')||
116                    '-'||l_adhoc_user;
117 
118    AMS_UTILITY_PVT.debug_message('Create and Start Process with Item Key: '||l_item_key);
119 
120    wf_engine.CreateProcess(
121            itemtype  => g_ItemType,
122            itemkey   => l_item_key,
123            process   => g_processName);
124 
125     wf_engine.SetItemUserKey(
126            itemtype  => g_ItemType,
127            itemkey   => l_item_key,
128            userkey   => l_item_key);
129 
130     -- user name label
131     wf_engine.SetItemAttrText(
132            itemtype  => g_ItemType,
133            itemkey   => l_item_key,
134            aname     => 'AMS_USERNAME_LABEL',
135            avalue    =>  p_uname_label);
136 
137     -- password label
138     wf_engine.SetItemAttrText(
139            itemtype  => g_ItemType,
140            itemkey   => l_item_key,
141            aname     => 'AMS_PWD_LABEL',
142            avalue    =>  p_pwd_label);
143 
144     -- user name
145     wf_engine.SetItemAttrText(
146            itemtype  => g_ItemType,
150 
147            itemkey   => l_item_key,
148            aname     => 'AMS_USERNAME',
149            avalue    =>  p_user_name);
151     -- password
152     wf_engine.SetItemAttrText(
153            itemtype  => g_ItemType,
154            itemkey   => l_item_key,
155            aname     => 'AMS_PWD',
156            avalue    =>  p_password);
157 
158     -- performer
159     wf_engine.SetItemAttrText(
160            itemtype  => g_ItemType,
161            itemkey   => l_item_key,
162            aname     => 'AMS_PERF',
163            avalue    =>  l_user_name);
164 
165     -- email address
166     wf_engine.SetItemAttrText(
167            itemtype  => g_ItemType,
168            itemkey   => l_item_key,
169            aname     => 'AMS_EMAIL_ADDRESS',
170            avalue    =>  p_email_address);
171 
172     -- subject
173     wf_engine.SetItemAttrText(
174            itemtype  => g_ItemType,
175            itemkey   => l_item_key,
176            aname     => 'AMS_SUBJECT',
177            avalue    =>  p_subject);
178 
179     wf_engine.SetItemOwner(
180            itemtype  => g_ItemType,
181            itemkey   => l_item_key,
182            owner     => l_item_owner);
183 
184     wf_engine.StartProcess(
185            itemtype  => g_ItemType,
186            itemkey   => l_item_key);
187 
188    AMS_UTILITY_PVT.debug_message('Process Started');
189 
190    AMS_UTILITY_PVT.debug_message('notifyForgetLogin ends');
191 
192    -- Standard check for p_commit
193    IF FND_API.to_Boolean( p_commit )
194    THEN
195       COMMIT WORK;
196    END IF;
197 
198    -- Standard call to get message count and if count is 1, get message info.
199    FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE,
200                              p_count   => x_msg_count    ,
201                              p_data    => x_msg_data     );
202 
203 EXCEPTION
204    WHEN FND_API.G_EXC_ERROR THEN
205      x_return_status := FND_API.G_RET_STS_ERROR;
206      -- Standard call to get message count and if count=1, get the message
207      FND_MSG_PUB.Count_And_Get (
208             p_encoded => FND_API.G_FALSE,
209             p_count   => x_msg_count,
210             p_data    => x_msg_data
211      );
212      raise;
213 
214    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
215      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
216      -- Standard call to get message count and if count=1, get the message
217      FND_MSG_PUB.Count_And_Get (
218             p_encoded => FND_API.G_FALSE,
219             p_count => x_msg_count,
220             p_data  => x_msg_data
221      );
222      raise;
223 
224    WHEN OTHERS THEN
225      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
226      IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
227      THEN
228         FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME,l_api_name);
229      END IF;
230      -- Standard call to get message count and if count=1, get the message
231      FND_MSG_PUB.Count_And_Get (
232             p_encoded => FND_API.G_FALSE,
233             p_count => x_msg_count,
234             p_data  => x_msg_data
235      );
236      raise;
237 
238 END notifyForgetLogin;
239 
240 
241 END AMS_RUNTIME_SCRIPTING_PVT;