DBA Data[Home] [Help]

PACKAGE BODY: APPS.FND_CONC_MAINTAIN

Source


1 package body FND_CONC_MAINTAIN as
2 /* $Header: AFCPMNTB.pls 120.2 2005/08/19 20:01:06 tkamiya ship $ */
3 
4   C_PKG_NAME 	CONSTANT VARCHAR2(30) := 'FND_CONC_MAINTAIN';
5   C_LOG_HEAD 	CONSTANT VARCHAR2(30) := 'fnd.plsql.FND_CONC_MAINTAIN.';
6 
7   G_ALREADY_INITED       varchar2(1)  := 'N';
8 
9 /* APPS_INITIALIZE_FOR_MGR-
10 **   Initialize the application context (userid, respid, etc) if it hasn't
11 **   already been set.  This will point to a special user APPSMGR which
12 **   is used for running requests to maintain the data.
13 **   This should be called before submitting requests in places like loaders
14 **   where there is no user signed in.
15 */
16 PROCEDURE apps_initialize_for_mgr
17   IS
18      l_api_name     CONSTANT VARCHAR2(30) := 'APPS_INITIALIZE_FOR_MGR';
19      l_user_id      NUMBER := 5; /* Hardcoded userid of APPSMGR */
20      l_resp_id      NUMBER := fnd_global.resp_id;
21      l_resp_appl_id NUMBER := fnd_global.resp_appl_id;
22 BEGIN
23    if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
24    fnd_log.string(FND_LOG.LEVEL_PROCEDURE,
25           c_log_head || l_api_name || '.begin',
26           c_pkg_name || '.' ||l_api_name);
27    end if;
28 
29    if ((G_ALREADY_INITED = 'Y') AND (fnd_global.user_id = l_user_id)) then
30      if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
31      fnd_log.string(FND_LOG.LEVEL_PROCEDURE,
32           c_log_head || l_api_name || '.end_quick',
33           c_pkg_name || '.' ||l_api_name|| 'Already inited so no work.');
34      end if;
35      return;
36    end if;
37    --
38    -- Set the Apps Context to APPSMGR user (a special user for this purpose)
39    -- and the System Administrator Resp.
40    --
41    begin
42       SELECT r.application_id, r.responsibility_id
43 	INTO l_resp_appl_id, l_resp_id
44 	FROM fnd_application a, fnd_responsibility r
45 	WHERE r.application_id = a.application_id
46 	AND a.application_short_name = 'SYSADMIN'
47 	AND r.responsibility_key = 'SYSTEM_ADMINISTRATOR';
48    exception
49      when others then
50      /* If there is any problem with the SQL, just use the seeded resp id*/
51      l_resp_appl_id := 1;
52      l_resp_id := 20420;
53    end;
54 
55    fnd_global.apps_initialize(user_id      => l_user_id,
56 				 resp_id      => l_resp_id,
57 				 resp_appl_id => l_resp_appl_id);
58 
59     g_already_inited := 'Y';
60       if (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
61       fnd_log.string(FND_LOG.LEVEL_STATEMENT,
62           c_log_head || l_api_name || '.',
63           'We set Apps Context to ' ||
64           '(user_id=' || l_user_id ||
65           ', resp_id=' || l_resp_id ||
66           ', resp_appl_id=' || l_resp_appl_id || ')'
67          );
68       end if;
69 
70    if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
71    fnd_log.string(FND_LOG.LEVEL_PROCEDURE,
72           c_log_head || l_api_name || '.end',
73           c_pkg_name || '.' ||l_api_name|| ' Returning');
74    end if;
75 END apps_initialize_for_mgr;
76 
77 /*
78 ** GET_PENDING_REQUEST_ID-
79 ** Returns zero if the request ID isn't pending right away.
80 */
81 FUNCTION get_pending_request_id
82   (p_application_short_name  IN VARCHAR2,
83    p_concurrent_program_name IN VARCHAR2)
84 RETURN number
85 IS
86    l_api_name     CONSTANT VARCHAR2(30) := 'GET_PENDING_REQUEST_ID';
87    l_request_id NUMBER;
88 BEGIN
89        if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
90        fnd_log.string(FND_LOG.LEVEL_PROCEDURE,
91           c_log_head || l_api_name || '.begin',
92           c_pkg_name || '.' ||l_api_name ||'( p_application_short_name:'||
93           p_application_short_name || ' p_concurrent_program_name:'||
94           p_concurrent_program_name ||')');
95        end if;
96 
97 	SELECT request_id
98 	  INTO l_request_id
99 	  FROM fnd_concurrent_requests fcr,
100 	       fnd_concurrent_programs fcp,
101 	       fnd_application fa
102 	  WHERE fa.application_short_name = p_application_short_name
103 	  AND fcp.application_id = fa.application_id
104 	  AND fcp.concurrent_program_name = p_concurrent_program_name
105 	  AND fcr.program_application_id = fcp.application_id
106 	  AND fcr.concurrent_program_id  = fcp.concurrent_program_id
107 	  AND fcr.status_code in ('I', 'Q', 'R')
108 	  AND fcr.phase_code = 'P'
109 	  AND ROWNUM = 1;
110 
111        if (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) then
112        fnd_log.string(FND_LOG.LEVEL_PROCEDURE,
113           c_log_head || l_api_name || '.end',
114           c_pkg_name || '.' ||l_api_name|| ' Returning request id:'
115           ||l_request_id);
116        end if;
117 	RETURN(l_request_id);
118 EXCEPTION
119    WHEN OTHERS THEN
120       RETURN(0);
121 END get_pending_request_id;
122 
123 
124 end FND_CONC_MAINTAIN;