DBA Data[Home] [Help]

PACKAGE BODY: APPS.ITG_X_UTILS

Source


1 PACKAGE BODY itg_x_utils AS
2 /* $Header: itgxutlb.pls 120.6 2006/06/13 12:07:17 bsaratna noship $ */
3 
4    g_cbod_desc VARCHAR2(2000);
5 
6 
7   /*
8   ** Given an Address Style, return the Region with the
9   ** County name or equivalent
10   */
11   FUNCTION getCounty (
12     addrStyle IN  Varchar2,
13     regionOne IN  Varchar2,
14     regionTwo IN  Varchar2
15   ) return varchar2 as
16   BEGIN
17     IF    addrStyle IS NULL THEN
18       RETURN NULL;
19     ELSIF addrStyle = 'GB'  THEN
20       RETURN regionOne;
21     ELSIF addrStyle = 'US'  THEN
22       RETURN regionOne;
23     ELSE
24       RETURN NULL;
25     END IF;
26   END getCounty;
27 
28 /* Checks  given poline has any approved schedule lines */
29 
30   FUNCTION isPoLineApproved(v_po_line_id in Number)
31     RETURN NUMBER as
32     CURSOR getPoLineApproval IS SELECT COUNT(*)
33         FROM po_line_locations_all
34                 WHERE po_line_id=v_po_line_id and approved_flag='Y';
35 
36      returnvalue number(10);
37   BEGIN
38     open getPoLineApproval;
39     fetch getPoLineApproval into returnvalue;
40     close getPoLineApproval;
41     return (returnvalue);
42   END;
43   /*
44   ** Gets the fnd_id_flex_segments.application_column_name that is the
45   ** qualifier provided for the chart structure provided.  This is used in
46   ** the object view definitions (e.g., SYNC_COA and SYNC_PO) for outbound.
47   */
48   function getFlexQualifierSegment (
49     p_idFlexNum         number,
50     p_flexQualifierName varchar2
51   ) return varchar2 as
52     cursor getAppColName is
53       SELECT s.application_column_name
54         FROM fnd_id_flex_segments s,
55              fnd_segment_attribute_values sav,
56              fnd_segment_attribute_types sat
57        WHERE s.application_id           = sav.application_id
58          AND s.id_flex_code             = sav.id_flex_code
59          AND s.id_flex_num              = sav.id_flex_num
60          AND s.enabled_flag             = 'Y'
61          AND s.application_column_name  = sav.application_column_name
62          AND sav.application_id         = sat.application_id
63          AND sav.id_flex_code           = sat.id_flex_code
64          AND sav.id_flex_num            = p_idFlexNum
65          AND sav.attribute_value        = 'Y'
66          AND sav.segment_attribute_type = sat.segment_attribute_type
67          AND sat.application_id         = 101
68          AND sat.id_flex_code           = 'GL#'
69          AND sat.unique_flag            = 'Y'
70          AND sat.segment_attribute_type = p_flexQualifierName;
71     returnValue varchar2(30);
72   begin
73     open getAppColName;
74     fetch getAppColName into returnValue;
75     close getAppColName;
76     RETURN (returnValue);
77   end getFlexQualifierSegment;
78 
79   /*
80   ** get_inventory_org_id is used to get the inventory_organization_id
81   ** given the org_id using the financials_system_params_all table
82   */
83   FUNCTION get_inventory_org_id (p_org_id NUMBER)
84   RETURN NUMBER AS
85     CURSOR cur_fin_system_params IS
86       SELECT inventory_organization_id
87         FROM financials_system_params_all
88        WHERE org_id=p_org_id;
89      v_inv_org  financials_system_params_all.inventory_organization_id%TYPE;
90   BEGIN
91     OPEN cur_fin_system_params;
92     FETCH cur_fin_system_params INTO v_inv_org;
93     CLOSE cur_fin_system_params;
94     RETURN v_inv_org;
95   END get_inventory_org_id;
96 
97   /*
98   ** Return the distinct po_requisition_headers_all.segment1 for the
99   ** po_distributions_all.po_req_distribution_id.  If segment1 is not
100   ** distinct for the input value, the first value selected is returned.
101   */
102   FUNCTION getRequistnid ( poReqDistId IN Number )
103     RETURN varchar2 AS
104   returnValue po_requisition_headers_all.segment1%TYPE;
105   CURSOR getSegment1 IS
106     SELECT reqHead.segment1
107       FROM po_requisition_headers_all reqHead,
108            po_requisition_lines_all   reqLine,
109            po_req_distributions_all   reqDist
110      WHERE reqHead.requisition_header_id    = reqLine.requisition_header_id
111        AND reqLine.requisition_line_id      = reqDist.requisition_line_id
112        AND reqDist.distribution_id          = poReqDistId;
113   BEGIN
114     IF poReqDistId IS NOT NULL THEN
115       OPEN getSegment1;
116       FETCH getSegment1 Into returnValue;
117       CLOSE getSegment1;
118     END IF;
119     RETURN returnValue;
120   END getRequistnid;
121 
122   /*
123   ** Given a po_req_distribution_id, return the line_num from po_requisition_lines_all
124   */
125   function getReqLineNum ( poReqDistId IN Number )
126     RETURN varchar2 AS
127   returnValue                         po_requisition_headers_all.segment1%TYPE;
128   CURSOR getLineNum IS
129     SELECT reqLine.line_num
130      FROM po_requisition_lines_all    reqLine,
131           po_req_distributions_all    reqDist
132     WHERE reqLine.requisition_line_id = reqDist.requisition_line_id
133       AND reqDist.distribution_id     = poReqDistId;
134   BEGIN
135     IF poReqDistId IS NOT NULL THEN
136       OPEN getLineNum;
137       FETCH getLineNum INTO returnValue;
138       CLOSE getLineNum;
139     END IF;
140     RETURN returnValue;
141   END getReqLineNum;
142 
143   /*
144   ** Given an Address Style, return the Region with the
145   ** State/Province name or equivalent
146   */
147   FUNCTION getState (
148     addrStyle IN  VARCHAR2,
149     regionOne IN  VARCHAR2,
150     regionTwo IN  VARCHAR2
151   ) RETURN VARCHAR2 AS
152   BEGIN
153     IF    addrStyle IS NULL THEN
154       RETURN NULL;
155     ELSIF addrStyle = 'AU'  THEN
156       RETURN regionOne;
157     ELSIF addrStyle = 'BR'  THEN
158       RETURN regionTwo;
159     ELSIF addrStyle = 'CA'  THEN
160       RETURN regionOne;
161     ELSIF addrStyle = 'IT'  THEN
162       RETURN regionOne;
163     ELSIF addrStyle = 'MX'  THEN
164       RETURN regionOne;
165     ELSIF addrStyle = 'PT'  THEN
166       RETURN regionOne;
167     ELSIF addrStyle = 'ES'  THEN
168       RETURN regionOne;
169     ELSIF addrStyle = 'CH'  THEN
170       RETURN regionOne;
171     ELSIF addrStyle = 'US'  THEN
172       RETURN regionTwo;
173     ELSE
174       RETURN NULL;
175     END IF;
176   END getState;
177 
178   /*
179   ** getTaxId looks up a TIN or VRN for a given US or non-US
180   ** company.  Returns a NULL if no ID number found.
181   */
182   FUNCTION getTaxId (
183     country    IN varchar2,
184     orgId      IN number,
185     orgName    IN varchar2,
186     orgUnit    IN number,
187     invOrg     IN number
188   ) RETURN VARCHAR2 AS
189     CURSOR getTIN IS
190       SELECT ap.tax_identification_num, ap.entity_name
191       FROM ap_reporting_entities_all    ap,
192            hr_all_organization_units    unit
193       WHERE ap.location_id              = unit.location_id
194       AND   ap.org_id                   = orgId
195       AND   unit.organization_id        = orgUnit;
196     CURSOR getVRN IS
197       SELECT fsp.vat_registration_num
198       FROM financials_system_params_all fsp,
199            inv_organization_info_v org -- Modified for performance bug#4941286
200       WHERE fsp.set_of_books_id = org.set_of_books_id
201       AND   org.organization_id = invOrg;
202     taxId varchar2(100);
203   BEGIN
204     IF country IS NULL THEN
205       taxId := null;
206     ELSIF UPPER(country) = 'US' THEN
207       FOR r IN getTIN LOOP
208         IF upper(r.entity_name) = upper(orgName) THEN
209           taxId := r.tax_identification_num;
210           EXIT;
211         ELSIF getTIN%ROWCOUNT = 1 THEN
212           taxId := r.tax_identification_num;
213         END IF;
214       END LOOP;
215     ELSE
216       OPEN getVRN;
217       FETCH getVRN INTO taxId;
218       CLOSE getVRN;
219     END IF;
220     RETURN taxId;
221   END getTaxId;
222 
223   /*
224   ** Return a concatenated segment string with
225   ** appropriate delimiter for the given flexfield
226   */
227   FUNCTION SegString (
228     appId     IN NUMBER,
229     flexCode  IN VARCHAR2,
230     flexNum   IN NUMBER,
231     segment1  IN VARCHAR2,         segment2  IN VARCHAR2,
232     segment3  IN VARCHAR2,         segment4  IN VARCHAR2 := NULL,
233     segment5  IN VARCHAR2 := NULL, segment6  IN VARCHAR2 := NULL,
234     segment7  IN VARCHAR2 := NULL, segment8  IN VARCHAR2 := NULL,
235     segment9  IN VARCHAR2 := NULL, segment10 IN VARCHAR2 := NULL,
236     segment11 IN VARCHAR2 := NULL, segment12 IN VARCHAR2 := NULL,
237     segment13 IN VARCHAR2 := NULL, segment14 IN VARCHAR2 := NULL,
238     segment15 IN VARCHAR2 := NULL, segment16 IN VARCHAR2 := NULL,
239     segment17 IN VARCHAR2 := NULL, segment18 IN VARCHAR2 := NULL,
240     segment19 IN VARCHAR2 := NULL, segment20 IN VARCHAR2 := NULL,
241     segment21 IN VARCHAR2 := NULL, segment22 IN VARCHAR2 := NULL,
242     segment23 IN VARCHAR2 := NULL, segment24 IN VARCHAR2 := NULL,
243     segment25 IN VARCHAR2 := NULL, segment26 IN VARCHAR2 := NULL,
244     segment27 IN VARCHAR2 := NULL, segment28 IN VARCHAR2 := NULL,
245     segment29 IN VARCHAR2 := NULL, segment30 IN VARCHAR2 := NULL
246   ) RETURN varchar2 AS
247     l_flexNum fnd_id_flex_structures.id_flex_num%TYPE := flexNum;
248     CURSOR getFlexNum IS
249       SELECT id_flex_num
250       FROM fnd_id_flex_structures
251       WHERE application_id = appId
252       AND   id_flex_code   = flexCode
253       AND   enabled_flag   = 'Y';
254     delim fnd_id_flex_structures.concatenated_segment_delimiter%TYPE;
255     CURSOR getFlexDelimiter is
256       SELECT concatenated_segment_delimiter
257       FROM fnd_id_flex_structures
258       WHERE application_id = appId
259       AND   id_flex_code   = flexCode
260       AND   id_flex_num    = l_flexNum
261       AND   enabled_flag   = 'Y';
262     CURSOR getFlexSegs is
263       SELECT application_column_name col
264       FROM fnd_id_flex_segments s
265       WHERE application_id = appId
266       AND   id_flex_code   = flexCode
267       AND   id_flex_num    = l_flexNum
268       AND   enabled_flag   = 'Y'
269       ORDER BY segment_num;
270     segStr Varchar2(512);
271   BEGIN
272     /* If the flexNum is null look it up */
273     IF l_flexNum IS NULL THEN
274       FOR r IN getFlexNum LOOP
275         IF getFlexNum%ROWCOUNT > 1 THEN
276           /* Must be one and only one enabled
277            * structure when the flexNum param is null
278            */
279           l_flexNum := NULL;
280           EXIT;
281         ELSE
282           l_flexNum := r.id_flex_num;
283         END IF;
284       END LOOP;
285     END IF;
286     /* Get the concatenated segs */
287     IF l_flexNum is not NULL THEN
288       /* Get the flexfield delimiter */
289       OPEN getFlexDelimiter;
290       FETCH getFlexDelimiter INTO delim;
291       CLOSE getFlexDelimiter;
292       IF delim IS NOT NULL THEN
293         /* Construct the contcatenated string */
294         FOR s IN getFlexSegs LOOP
295           IF    s.col = 'SEGMENT1'  THEN segStr := segStr||delim||segment1;
296           ELSIF s.col = 'SEGMENT2'  THEN segStr := segStr||delim||segment2;
297           ELSIF s.col = 'SEGMENT3'  THEN segStr := segStr||delim||segment3;
298           ELSIF s.col = 'SEGMENT4'  THEN segStr := segStr||delim||segment4;
299           ELSIF s.col = 'SEGMENT5'  THEN segStr := segStr||delim||segment5;
300           ELSIF s.col = 'SEGMENT6'  THEN segStr := segStr||delim||segment6;
301           ELSIF s.col = 'SEGMENT7'  THEN segStr := segStr||delim||segment7;
302           ELSIF s.col = 'SEGMENT8'  THEN segStr := segStr||delim||segment8;
303           ELSIF s.col = 'SEGMENT9'  THEN segStr := segStr||delim||segment9;
304           ELSIF s.col = 'SEGMENT10' THEN segStr := segStr||delim||segment10;
305           ELSIF s.col = 'SEGMENT11' THEN segStr := segStr||delim||segment11;
306           ELSIF s.col = 'SEGMENT12' THEN segStr := segStr||delim||segment12;
307           ELSIF s.col = 'SEGMENT13' THEN segStr := segStr||delim||segment13;
308           ELSIF s.col = 'SEGMENT14' THEN segStr := segStr||delim||segment14;
309           ELSIF s.col = 'SEGMENT15' THEN segStr := segStr||delim||segment15;
310           ELSIF s.col = 'SEGMENT16' THEN segStr := segStr||delim||segment16;
311           ELSIF s.col = 'SEGMENT17' THEN segStr := segStr||delim||segment17;
312           ELSIF s.col = 'SEGMENT18' THEN segStr := segStr||delim||segment18;
313           ELSIF s.col = 'SEGMENT19' THEN segStr := segStr||delim||segment19;
314           ELSIF s.col = 'SEGMENT20' THEN segStr := segStr||delim||segment20;
315           ELSIF s.col = 'SEGMENT21' THEN segStr := segStr||delim||segment21;
316           ELSIF s.col = 'SEGMENT22' THEN segStr := segStr||delim||segment22;
317           ELSIF s.col = 'SEGMENT23' THEN segStr := segStr||delim||segment23;
318           ELSIF s.col = 'SEGMENT24' THEN segStr := segStr||delim||segment24;
319           ELSIF s.col = 'SEGMENT25' THEN segStr := segStr||delim||segment25;
320           ELSIF s.col = 'SEGMENT26' THEN segStr := segStr||delim||segment26;
321           ELSIF s.col = 'SEGMENT27' THEN segStr := segStr||delim||segment27;
322           ELSIF s.col = 'SEGMENT28' THEN segStr := segStr||delim||segment28;
323           ELSIF s.col = 'SEGMENT29' THEN segStr := segStr||delim||segment29;
324           ELSIF s.col = 'SEGMENT30' THEN segStr := segStr||delim||segment30;
325           END IF;
326         END LOOP;
327         segStr := substr( segStr, 2 );
328       END IF;
329     END IF;
330     RETURN segStr;
331   END SegString;
332 
333   /*
334   ** Returns the sign of a number
335   */
336   FUNCTION signOf ( anyNumber IN Number ) return varchar2 is
337   BEGIN
338     IF anyNumber IS NULL THEN
339       RETURN '';
340     ELSIF anyNumber < 0 THEN
341       RETURN '-';
342     ELSE
343       RETURN '+';
344     END IF;
345   END signOf;
346 
347   /*
348   ** sumPoLineLocs summarizes the quantity*price_override
349   ** from po_line_locations_all for the given po_header_id
350   **
351   ** Taken from Po_Ip_Oagxml_Pkg.
352   */
353   FUNCTION sumPoLineLocs (
354     poHeaderId IN NUMBER,
355     poRelease  IN NUMBER := NULL
356   ) RETURN NUMBER as
357     returnValue NUMBER := 0;
358     CURSOR sumValue IS
359       SELECT sum( quantity * price_override )
360         FROM po_line_locations_all
361        WHERE po_header_id = poHeaderId;
362     CURSOR sumValueRel IS
363       SELECT sum( quantity * price_override )
364         FROM po_line_locations_all
365        WHERE po_header_id  = poHeaderId
366          AND po_release_id = poRelease;
367   BEGIN
368     IF poHeaderId IS NOT NULL THEN
369       IF poRelease IS NULL THEN
370         Open sumValue;
371         Fetch sumValue INTO returnValue;
372         Close sumValue;
373       ELSE
374         OPEN sumValueRel;
375         FETCH sumValueRel into returnValue;
376         CLOSE sumValueRel;
377       END IF;
378     END IF;
379     RETURN returnValue;
380   END sumPoLineLocs;
381 
382   FUNCTION sumReqLines (
383     reqHeaderId IN NUMBER
384   ) RETURN NUMBER AS
385     returnValue NUMBER := 0;
386     CURSOR sumValue IS
387       SELECT sum( quantity * unit_price )
388       FROM po_requisition_lines_all
389       WHERE requisition_header_id = reqHeaderId;
390   BEGIN
391     IF reqHeaderId IS NOT NULL THEN
392       OPEN sumValue;
393       FETCH sumValue INTO returnValue;
394       CLOSE sumValue;
395     END IF;
396     RETURN returnValue;
397   END sumReqLines;
398 
399   FUNCTION getAttachments(p_table_name VARCHAR2,
400                           p_type       VARCHAR2,
401                           p_id         NUMBER
402   ) RETURN VARCHAR2 AS
403     v_text fnd_documents_short_text.short_text%TYPE;
404     CURSOR cur_short_text IS
405       SELECT short.short_text FROM
406         fnd_attached_documents fad,
407         fnd_documents_vl fdv,
408         fnd_document_entities fde,
409         fnd_document_categories_vl fdcv,
410         fnd_documents_short_text short
411       WHERE
412         fad.document_id = fdv.document_id AND
413         short.media_id  = fdv.media_id AND
414         fad.entity_name = fde.entity_name AND
415         fdcv.category_id = fdv.category_id AND
416         fde.data_object_code  = p_table_name  AND
417         fad.pk1_value   = p_id          AND
418         fdcv.name       = p_type
419         order by short.media_id;
420   BEGIN
421     OPEN cur_short_text;
422     LOOP
423       FETCH cur_short_text INTO v_text;
424       EXIT WHEN   cur_short_text%NOTFOUND;
425     END LOOP;
426     RETURN v_text;
427   END;
428 
429   PROCEDURE getTextAttachments(p_table_name VARCHAR2,
430                            p_id         NUMBER,
431                                    x_pointernal OUT NOCOPY VARCHAR2,
432                            x_misc       OUT NOCOPY VARCHAR2,
433                            x_approver   OUT NOCOPY VARCHAR2,
434                            x_buyer      OUT NOCOPY VARCHAR2,
435                            x_payables   OUT NOCOPY VARCHAR2,
436                            x_reciever   OUT NOCOPY VARCHAR2,
437                            x_vendor     OUT NOCOPY VARCHAR2
438 
439   ) IS
440 
441      TYPE attch_tab_type IS TABLE OF VARCHAR2(4000) INDEX BY varchar2(30);
442 
443       attch_tab attch_tab_type;
444         l_text VARCHAR2(4000);
445         l_type VARCHAR2(60);
446 
447     CURSOR cur_short_text IS
448       SELECT short.short_text, fdcv.name FROM
449         fnd_attached_documents fad,
450         fnd_documents_vl fdv,
451         fnd_document_entities fde,
452         fnd_document_categories_vl fdcv,
453         fnd_documents_short_text short
454       WHERE
455         fad.document_id = fdv.document_id AND
456         short.media_id  = fdv.media_id AND
457         fad.entity_name = fde.entity_name AND
458         fdcv.category_id = fdv.category_id AND
459         fde.data_object_code  = p_table_name  AND
460         fad.pk1_value   = p_id
461           order by short.media_id; -- Check if removing this makes much performance difference
462   BEGIN
463         --  5185353
464         attch_tab('PO Internal'):= '';
465         attch_tab('MISC')       := '';
466         attch_tab('Approver')   := '';
467         attch_tab('Buyer')      := '';
468         attch_tab('Payables')   := '';
469         attch_tab('Reciever')   := '';
470         attch_tab('Vendor')     := '';
471 
472     OPEN cur_short_text;
473     LOOP
474       FETCH cur_short_text INTO l_text,l_type;
475       EXIT WHEN   cur_short_text%NOTFOUND;
476 
477         IF l_text IS NOT NULL THEN
478                 attch_tab(l_type) := l_text;
479         END IF;
480     END LOOP;
481     CLOSE cur_short_text;
482 
483     x_pointernal := attch_tab('PO Internal');
484     x_misc       := attch_tab('MISC');
485     x_approver   := attch_tab('Approver');
486     x_buyer      := attch_tab('Buyer');
487     x_payables   := attch_tab('Payables');
488     x_reciever   := attch_tab('Reciever');
489     x_vendor     := attch_tab('Vendor');
490   EXCEPTION
491         WHEN OTHERS THEN
492                 null; -- do we want to fail the XGM?
493   END;
494 
495 
496   PROCEDURE addCBODDescMsg(p_msg_app      IN VARCHAR2,
497                                    p_msg_code     IN VARCHAR2,
498                            p_token_vals   IN VARCHAR2 := NULL,
499                            p_translatable IN BOOLEAN  := TRUE,
500                            p_reset        IN BOOLEAN  := FALSE)
501   IS
502     msg_code VARCHAR2(2000);
503   BEGIN
504         IF p_reset THEN
505         g_cbod_desc := NULL;
506       END IF;
507 
508       IF p_translatable THEN
509           msg_code := 'T^^' ||p_msg_app || '^^' || p_msg_code || '^^' || p_token_vals || '^^' || '}}';
510       ELSE
511           msg_code := 'F^^' || p_msg_code || '}}';
512       END IF;
513       g_cbod_desc := g_cbod_desc || msg_code;
514   END;
515 
516 -- Todo :       Revisit and add comments.
517 --              Escape inputs/outputs containing delimiters
518 --              Add lenght checks for output(4000 bytes)
519 FUNCTION translateCBODDescMsg(p_msg_list IN VARCHAR2) RETURN VARCHAR2 AS
520     msg_list VARCHAR2(4000);
521     cur_msg  VARCHAR2(4000);
522     ret_msg  VARCHAR2(4000);
523     i        NUMBER;
524     j        NUMBER;
525     k        NUMBER;
526     fnd_msg  VARCHAR2(200);
527     fnd_app  VARCHAR2(200);
528     fnd_token_val  VARCHAR2(200);
529     fnd_token_nam  VARCHAR2(200);
530   BEGIN
531     msg_list := p_msg_list;
532     i := INSTR(msg_list, '}}');
533     WHILE i > 0
534     LOOP
535       cur_msg  := substr(msg_list,1,i-1);
536       msg_list := substr(msg_list,i+2);
537 
538 
539 
540 
541       IF substr(cur_msg,1,3) = 'F^^'  THEN
542         cur_msg := substr(cur_msg,4);
543         ret_msg := ret_msg || ' ' || cur_msg ;
544       ELSE
545         cur_msg := substr(cur_msg,4);
546 
547 
548         j       := INSTR(cur_msg, '^^');
549         fnd_app := SUBSTR(cur_msg,1,j-1);
550         cur_msg := substr(cur_msg,j+2);
551 
552 
553         j       := INSTR(cur_msg, '^^');
554         fnd_msg := SUBSTR(cur_msg,1,j-1);
555         cur_msg := substr(cur_msg,j+2);
556 
557 
558           FND_MESSAGE.SET_NAME(fnd_app,fnd_msg);
559 
560           j :=  INSTR(cur_msg, '^^');
561 
562         WHILE j > 0
563         LOOP
564           k := INSTR(cur_msg,'::');
565           fnd_token_nam := SUBSTR(cur_msg,1,k-1);
566 
567           fnd_token_val := SUBSTR(cur_msg,k+2,j-k-2);
568 
569             IF fnd_token_val IS NOT NULL OR fnd_token_nam IS NOT NULL THEN
570                   FND_MESSAGE.SET_TOKEN(fnd_token_nam,fnd_token_val);
571             END IF;
572           cur_msg   := SUBSTR(cur_msg,j+2);
573           j := INSTR(cur_msg, '^^');
574         END LOOP;
575         ret_msg := ret_msg || ' ' || FND_MESSAGE.GET;
576       END IF;
577 
578       i := INSTR(msg_list, '}}');
579     END LOOP;
580     RETURN ret_msg;
581   EXCEPTION
582         WHEN OTHERS THEN
583             itg_debug.msg('ITG_X_UTILS.translateCBODDescMsg ' || SQLCODE || ':' || SQLERRM);
584                 RETURN p_msg_list;
585   END;
586 
587 
588   FUNCTION getCBODDescMsg(p_reset IN BOOLEAN := FALSE) RETURN VARCHAR2 AS
589     ret_mesg VARCHAR2(4000);
590   BEGIN
591     ret_mesg := g_cbod_desc;
592     IF p_reset THEN
593         g_cbod_desc := NULL;
594     END IF;
595     return ret_mesg;
596   END;
597 
598 
599 BEGIN
600   /* Package initialization. */
601   SELECT to_char(e.party_id), to_char(e.party_site_id)
602   INTO   g_party_id,          g_party_site_id
603   FROM   hr_locations_all h,
604          ecx_tp_headers   e
605   WHERE  h.location_id   = e.party_id
606   AND    e.party_type    = c_party_type
607   AND    h.location_code = c_party_site_name;
608 
609   SELECT name
610   INTO   g_local_system
611   FROM   wf_systems
612   WHERE  guid = wf_core.translate('WF_SYSTEM_GUID');
613 
614   g_event_key_pfx := 'ITG:' ;
615   g_cbod_desc     := NULL;
616 
617   /* 4169685: REMOVE INSTALL DATA INSERTION FROM HR_LOCATIONS TABLE
618    * Indicate that package has been properly initialized.
619    */
620   g_initialized   := TRUE;
621 
622 
623 EXCEPTION
624   WHEN NO_DATA_FOUND THEN
625     /* Indicate that package has NOT been properly initialized -
626      * g_party_id and g_party_site_id are not valid for XMLG and CLN usage.
627      */
628     g_initialized := FALSE;
629 END;