DBA Data[Home] [Help]

PACKAGE BODY: APPS.PO_WF_DEBUG_PKG

Source


1 PACKAGE BODY PO_WF_DEBUG_PKG as
2 /* $Header: POXWDBGB.pls 120.1 2007/02/15 20:48:21 dedelgad ship $*/
3 
4 /***************************************************************************************
5 *
6 * THis package is used to track the progress of all the functions in the workflow as
7 * they are invoked by the workflow process. It captures the following:
8 * - the Process Name
9 * - the unique ID of the Item going through the process
10 * - the Package.procedure name being executed
11 * - the progress within that Package.procedure
12 *
13 ***************************************************************************************/
14 
15 procedure insert_debug (itemtype varchar2,
16                         itemkey  varchar2,
17                         x_progress  varchar2) is
18 
19 /* Bug# 1632741: kagarwal
20 ** Desc: Making procedure insert_debug an autonomous transaction as
21 ** there should never be a commit in any code that is called by the
22 ** workflow engine that will be executed in the same transaction.
23 */
24 
25   pragma AUTONOMOUS_TRANSACTION;
26 
27   l_document_id        number := NULL;
28   l_document_number    varchar2(25) := NULL;
29   l_preparer_id        number := NULL;
30   l_approver_empid     number := NULL;
31   l_Forward_to_id      number := NULL;
32   l_Forward_to_username varchar2(100) := NULL;
33   l_Forward_from_id    number := NULL;
34   l_Forward_from_username varchar2(100) := NULL;
35   l_Authorization_status  varchar2(25) := NULL;
36 
37   x_option_value       varchar2(10);
38 
39 BEGIN
40 
41 
42 /* If it's Req or PO approval then get some of the info that we want to log.
43 ** If the profile option is set , then log debug messages.
44 */
45 /* Bug 2834040 fixed. replaced the wf_engine call with po_wf_util_pkg
46    wrapper call so that debug messages will get logged inspite of
47    the workflow attributes not being set.
48 */
49 fnd_profile.get('PO_SET_DEBUG_WORKFLOW_ON',x_option_value);
50 
51 IF x_option_value = 'Y' THEN
52 
53   IF itemtype IN ('REQAPPRV','POAPPRV')  THEN
54 
55    l_document_number:= PO_WF_UTIL_PKG.GetItemAttrText (     itemtype   => itemtype,
56                                         itemkey    => itemkey,
57                                         aname      => 'DOCUMENT_NUMBER');
58         --
59    l_document_id:=     PO_WF_UTIL_PKG.GetItemAttrNumber (   itemtype   => itemType,
60                                         itemkey    => itemkey,
61                                         aname      => 'DOCUMENT_ID');
62 
63    l_preparer_id:=     PO_WF_UTIL_PKG.GetItemAttrNumber (   itemtype        => itemType,
64                                         itemkey         => itemkey,
65                                         aname           => 'PREPARER_ID');
66         --
67    l_Forward_to_id:=   PO_WF_UTIL_PKG.GetItemAttrNumber (     itemtype        => itemtype,
68                                         itemkey         => itemkey,
69                                         aname           => 'FORWARD_TO_ID');
70         --
71    l_Forward_from_id:=  PO_WF_UTIL_PKG.GetItemAttrNumber (     itemtype        => itemtype,
72                                         itemkey         => itemkey,
73                                         aname           => 'FORWARD_FROM_ID');
74         --
75    l_Forward_to_username:= PO_WF_UTIL_PKG.GetItemAttrText ( itemtype   => itemType,
76                                         itemkey    => itemkey,
77                                         aname      => 'FORWARD_TO_USERNAME');
78 
79    l_Forward_from_username:= PO_WF_UTIL_PKG.GetItemAttrText ( itemtype   => itemType,
80                                         itemkey    => itemkey,
81                                         aname      => 'FORWARD_FROM_USER_NAME');
82 
83    l_approver_empid:=     PO_WF_UTIL_PKG.GetItemAttrNumber (itemtype => itemtype,
84                                         itemkey  => itemkey,
85                                         aname    => 'APPROVER_EMPID');
86 
87    l_authorization_status :=  PO_WF_UTIL_PKG.GetItemAttrText (itemtype => itemtype,
88                                         itemkey  => itemkey,
89                                         aname    => 'AUTHORIZATION_STATUS');
90   END IF;
91 
92   BEGIN
93 
94       insert into PO_WF_DEBUG
95                         (EXECUTION_SEQUENCE,
96                          EXECUTION_DATE,
97                          ITEMTYPE,
98                          ITEMKEY,
99                          DOCUMENT_ID,
100                          DOCUMENT_NUMBER,
101                          PREPARER_ID,
102                          APPROVER_EMPID,
103                          FORWARD_TO_ID,
104                          FORWARD_TO_USERNAME,
105                          FORWARD_FROM_ID,
106                          FORWARD_FROM_USERNAME,
107                          AUTHORIZATION_STATUS,
108                          DEBUG_MESSAGE)
109                         values(po_wf_debug_s.nextval,
110                                 sysdate,
111                                 itemtype,
112                                 itemkey,
113                                 l_document_id,
114                                 l_document_number,
115                                 l_preparer_id,
116                                 l_approver_empid,
117                                 l_Forward_to_id,
118                                 l_Forward_to_username,
119                                 l_Forward_from_id,
120                                 l_Forward_from_username,
121                                 l_Authorization_status,
122                                 x_progress);
123 
124   EXCEPTION
125 
126     WHEN OTHERS THEN
127       NULL;  -- Don't raise any exceptions. Just don't log to the table.
128   END;
129 
130 COMMIT;
131 
132 END IF;
133 
134 EXCEPTION
135      WHEN OTHERS THEN
136       NULL;  -- Don't raise any exceptions. Just don't log to the table.
137 END insert_debug;
138 
139 -- <R12 PO OTM Integration START>
140 PROCEDURE debug_stmt(
141    p_log_head                       IN             VARCHAR2
142 ,  p_token                          IN             VARCHAR2
143 ,  p_message                        IN             VARCHAR2
144 )
145 IS
146 
147 PRAGMA AUTONOMOUS_TRANSACTION;
148 
149 l_option_value VARCHAR2(10);
150 
151 BEGIN
152 
153 FND_PROFILE.get('PO_SET_DEBUG_WORKFLOW_ON', l_option_value);
154 
155 IF (l_option_value = 'Y') THEN
156   BEGIN
157     INSERT INTO po_wf_debug (  execution_sequence
158                              , execution_date
159                              , debug_message
160                             )
161     VALUES                  (  po_wf_debug_s.NEXTVAL
162                              , SYSDATE
163                              , SUBSTRB(p_log_head || '.' || p_token || ':' || p_message, 1, 1000));
164   EXCEPTION
165     WHEN OTHERS THEN
166       NULL;
167   END;
168 
169   COMMIT;
170 END IF;
171 
172 END debug_stmt;
173 
174 PROCEDURE debug_begin(
175    p_log_head                       IN             VARCHAR2
176 )
177 IS
178 BEGIN
179   debug_stmt(p_log_head,'BEGIN','Entry into procedure '||p_log_head||'.');
180 END debug_begin;
181 
182 PROCEDURE debug_end(
183    p_log_head                       IN             VARCHAR2
184 )
185 IS
186 BEGIN
187   debug_stmt(p_log_head,'END','Exiting procedure '||p_log_head||' normally.');
188 END debug_end;
189 
190 PROCEDURE debug_var(
191    p_log_head                       IN             VARCHAR2
192 ,  p_progress                       IN             VARCHAR2
193 ,  p_name                           IN             VARCHAR2
194 ,  p_value                          IN             VARCHAR2
195 )
196 IS
197 BEGIN
198   IF (p_value IS NULL) THEN
199     debug_stmt(p_log_head,p_progress,p_name||' IS NULL');
200   ELSE
201     debug_stmt(p_log_head,p_progress,p_name||' = '||p_value);
202   END IF;
203 END debug_var;
204 
205 PROCEDURE debug_var(
206    p_log_head                       IN             VARCHAR2
207 ,  p_progress                       IN             VARCHAR2
208 ,  p_name                           IN             VARCHAR2
209 ,  p_value                          IN             NUMBER
210 )
211 IS
212 BEGIN
213   IF (p_value IS NULL) THEN
214     debug_stmt(p_log_head,p_progress,p_name||' IS NULL');
215   ELSE
216     debug_stmt(p_log_head,p_progress,p_name||' = '||TO_CHAR(p_value));
217   END IF;
218 END debug_var;
219 
220 
221 
222 PROCEDURE debug_var(
223    p_log_head                       IN             VARCHAR2
224 ,  p_progress                       IN             VARCHAR2
225 ,  p_name                           IN             VARCHAR2
226 ,  p_value                          IN             DATE
227 )
228 IS
229 BEGIN
230   IF (p_value IS NULL) THEN
231     debug_stmt(p_log_head,p_progress,p_name||' IS NULL');
232   ELSE
233     debug_stmt(p_log_head,p_progress,p_name||' = '||TO_CHAR(p_value));
234   END IF;
235 END debug_var;
236 
237 
238 PROCEDURE debug_var(
239    p_log_head                       IN             VARCHAR2
240 ,  p_progress                       IN             VARCHAR2
241 ,  p_name                           IN             VARCHAR2
242 ,  p_value                          IN             BOOLEAN
243 )
244 IS
245 BEGIN
246   IF (p_value IS NULL) THEN
247     debug_stmt(p_log_head,p_progress,p_name||' IS NULL');
248   ELSIF (p_value) THEN
249     debug_var(p_log_head,p_progress,p_name,'TRUE');
250   ELSE
251     debug_var(p_log_head,p_progress,p_name,'FALSE');
252   END IF;
253 END debug_var;
254 
255 PROCEDURE debug_unexp(
256    p_log_head                       IN             VARCHAR2
257 ,  p_progress                       IN             VARCHAR2
258 ,  p_message                        IN             VARCHAR2
259       DEFAULT NULL
260 )
261 IS
262 BEGIN
263   debug_stmt(p_log_head,p_progress,'EXCEPTION: '||p_message||'; SQLCODE = '||
264   TO_CHAR(SQLCODE) || '; SQLERRM = ' || SQLERRM);
265 END debug_unexp;
266 -- <R12 PO OTM Integration END>
267 
268 
269 END PO_WF_DEBUG_PKG;