DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_OID_BULKLOAD

Source


1 package body fnd_oid_bulkload as
2 /* $Header: AFSCOBLB.pls 120.4 2007/02/19 07:27:08 bmasa ship $ */
3 --
4 -- Start of Package Globals
5 
6   G_MODULE_SOURCE  constant varchar2(80) := 'fnd.plsql.oid.fnd_oid_bulkload.';
7   G_CREATED	   constant varchar2(1) := 'Y';
8   G_LINKED	   constant varchar2(1) := 'L';
9   G_FAILED	   constant varchar2(1) := 'N';
10   G_NOT_LINKED	   constant varchar2(1) := 'D';
11   G_ALREADY_LINKED constant varchar2(1) := 'G';
12   G_DUP_TRUE	   constant varchar2(1) := 'T';
13 
14 -- End of Package Globals
15 --
16 -------------------------------------------------------------------------------
17 procedure import_user(p_ldap_user in fnd_oid_util.ldap_message_type,
18 		      p_duplicate in varchar2, x_ret_status out nocopy varchar2, p_tca_record  in varchar2 default 'Y') is
19 
20   l_module_source varchar2(256);
21   l_user_count number;
22   l_user_id number;
23   l_user_name fnd_user.user_name%type;
24   l_description fnd_user.description%type;
25   l_fax fnd_user.fax%type;
26   l_email_address fnd_user.email_address%type;
27   l_user_guid fnd_user.user_guid%type;
28 
29 begin
30 
31   fnd_global.apps_initialize(0, -1, -1);
32 
33   l_module_source := G_MODULE_SOURCE || 'import_user: ';
34   x_ret_status := G_FAILED;
35 
36   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL)
37   then
38     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'Begin');
39   end if;
40 
41   l_user_name := p_ldap_user.object_name;
42   l_description := p_ldap_user.description;
43   l_fax := p_ldap_user.facsimileTelephoneNumber;
44   l_email_address := p_ldap_user.mail;
45   l_user_guid := p_ldap_user.orclGUID;
46 
47   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
48     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user name = ' || l_user_name);
49     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'desc = ' || l_description);
50     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'fax = ' || l_fax);
51     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'email = ' || l_email_address);
52     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user guid = ' || l_user_guid);
53   end if;
54 
55   select count(user_name) into l_user_count
56   from fnd_user
57   where user_name = l_user_name;
58 
59   if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
60     fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user count for ' || l_user_name || ' = ' || l_user_count);
61   end if;
62 
63   if (l_user_count = 0) then
64     fnd_user_pkg.CreateUser(x_user_name => l_user_name,
65 			    x_owner => 'CUST',
66 			    x_unencrypted_password => fnd_web_sec.EXTERNAL_PWD,
67 			    x_description => l_description,
68 			    x_fax => l_fax,
69 			    x_email_address => l_email_address,
70 			    x_user_guid => l_user_guid,
71 			    x_change_source =>  fnd_user_pkg.change_source_oid);
72 
73 /*  fnd_oid_util.send_subscription_add_to_OID(p_orcl_guid=>l_user_guid); */
74 
75     fnd_oid_subscriptions.assign_default_resp(p_user_name => l_user_name);
76 
77     if(p_tca_record= 'N') then
78 	x_ret_status := G_CREATED;
79     else
80 	fnd_oid_users.hz_create(p_ldap_message => p_ldap_user,
81 			    x_return_status => x_ret_status);
82 
83     	if (x_ret_status = fnd_api.G_RET_STS_SUCCESS) then
84       		x_ret_status := G_CREATED;
85     	end if;
86     end if;
87   else /* count_user <> 0 */
88     select count(user_name) into l_user_count
89     from fnd_user
90     where user_name = l_user_name
91     and   user_guid is not null;
92 
93     if (l_user_count = 0) then
94       if (fnd_log.LEVEL_STATEMENT >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
95         fnd_log.string(fnd_log.LEVEL_STATEMENT, l_module_source, 'user guid for ' || l_user_name || ' is null');
96       end if;
97       if (p_duplicate = G_DUP_TRUE) then
98         fnd_user_pkg.UpdateUser(x_user_name => l_user_name,
99      			        x_owner => 'CUST',
100    			        x_description => l_description,
101 			        x_fax => l_fax,
102 			        x_email_address => l_email_address,
103 			        x_user_guid => l_user_guid,
104 				x_change_source =>  fnd_user_pkg.change_source_oid);
105 	x_ret_status := G_LINKED;
106       else
107         x_ret_status := G_NOT_LINKED;
108       end if;
109     else
110       x_ret_status := G_ALREADY_LINKED;
111     end if;
112 
113   end if;
114 
115   if (fnd_log.LEVEL_ERROR >= fnd_log.G_CURRENT_RUNTIME_LEVEL) then
116     fnd_log.string(fnd_log.LEVEL_ERROR, l_module_source, 'x_ret_status =' || x_ret_status);
117   end if;
118 
119 end import_user;
120 --
121 -------------------------------------------------------------------------------
122 
123 end fnd_oid_bulkload;
124