1 Package Body JTF_TERRITORY_GLOBAL_PUB AS
2 /* $Header: jtfxstrb.pls 120.2 2009/06/15 12:14:31 ppillai ship $ */
3 -- ---------------------------------------------------
4 -- Start of Comments
5 -- ---------------------------------------------------
6 -- PACKAGE NAME: JTF_TERRITORY_GLOBAL_PUB
7 -- ---------------------------------------------------
8 -- PURPOSE
9 -- Joint task force core territory manager public api's.
10 -- This package is used to return a list of winning Territories.
11 -- Reason to go with this approach is because of limitation in
12 -- pl/sql wrt binding user defined data types to return a list
13 -- of winning Territories
14 --
15 -- Procedures:
16 -- (see below for specification)
17 --
18 -- NOTES
19 -- This package is publicly available for use
20 --
21 -- HISTORY
22 -- 06/09/99 VNEDUNGA Created
23 -- 12/01/99 VNEDUNGA Changing the FND_PROFILE call
24 -- 12/02/99 VNEDUNGA Changing the reset function to return TRUE
25 -- Add the code to store TERR_NAME is PL/SQL table
26 -- 02/24/00 VNEDUNGA Overloading add record for the new Terr Engine
27 -- 09/17/00 JDOCHERT BUG#1408610 FIX +
28 -- remove obsolete overloaded Add_Record procedure
29 --
30 --
31 --
32 -- End of Comments
33 --
34 -- ------------------------------------------------------
35 -- Global Variables
36 -- ------------------------------------------------------
37 --Bug 8582900
38 --G_Profile_Value VARCHAR2(25) := FND_PROFILE.Value('JTF_TERR_NO_OF_WINNERS');
39
40 --*******************************************************
41 -- Start of Comments
42 --*******************************************************
43
44 /* Reset global variables:
45 ** for each call to Get_Winning_Territory_Members API
46 */
47 FUNCTION Reset return BOOLEAN
48 AS
49 BEGIN
50
51 /* reset number of winners for a
52 ** top-level territory node
53 ** JDOCHERT 09/17: BUG#1408610 FIX
54 */
55 g_num_winners := 0;
56
57 /* Reset the global index */
58 g_TblIndex := 1;
59
60 /* Reset contents of PL/SQL table */
61 G_WinningTerr_Tbl.Delete;
62
63 return TRUE;
64
65 END Reset;
66
67 /* Return the count of the winning Terr Table */
68 FUNCTION get_RecordCount return NUMBER
69 as
70 BEGIN
71 return G_WinningTerr_Tbl.Count;
72 END Get_RecordCount;
73
74
75 /* Add record to table of winners for the Territory Assignment Engine */
76 PROCEDURE Add_Record( p_WinningTerr_Rec IN JTF_TERRITORY_PUB.WinningTerr_rec_type,
77 p_Number_Of_Winners IN NUMBER,
78 X_Return_Status OUT NOCOPY VARCHAR2)
79 AS
80 BEGIN
81
82 /* Store winning territory record */
83 If (p_WinningTerr_Rec.TERR_ID IS NOT NULL) THEN
84
85 G_WinningTerr_Tbl(G_TblIndex).PARTY_ID := g_PARTY_ID;
86 G_WinningTerr_Tbl(G_TblIndex).PARTY_SITE_ID := g_PARTY_SITE_ID;
87 G_WinningTerr_Tbl(G_TblIndex).TERR_ID := p_WinningTerr_Rec.TERR_ID;
88 G_WinningTerr_Tbl(G_TblIndex).TERR_NAME := p_WinningTerr_Rec.TERR_NAME;
89 G_WinningTerr_Tbl(G_TblIndex).RANK := p_WinningTerr_Rec.RANK;
90 G_WinningTerr_Tbl(G_TblIndex).ORG_ID := p_WinningTerr_Rec.ORG_ID;
91 G_WinningTerr_Tbl(G_TblIndex).PARENT_TERRITORY_ID := p_WinningTerr_Rec.PARENT_TERRITORY_ID;
92 G_WinningTerr_Tbl(G_TblIndex).TEMPLATE_TERRITORY_ID := p_WinningTerr_Rec.TEMPLATE_TERRITORY_ID;
93 G_WinningTerr_Tbl(G_TblIndex).ESCALATION_TERRITORY_ID := p_WinningTerr_Rec.ESCALATION_TERRITORY_ID;
94
95 /* Set the status to SUCCESS */
96 X_Return_Status := FND_API.G_RET_STS_SUCCESS;
97
98 -- Increment the index, if the profile is set to multiple winners
99 --If NVL(G_Profile_Value, 'SINGLE') = 'MULTIPLE' Then
100 -- g_TblIndex := g_TblIndex + 1;
101 --End If;
102
103 /* Increment the index, if the profile is set to multiple winners */
104 IF (p_number_of_winners > 1) THEN
105
106 g_TblIndex := g_TblIndex + 1;
107
108 /* track number of winners for a territory node at the
109 ** top-level (directly below the Catch_all) in the
110 ** territory hierarchy
111 ** JDOCHERT 09/17: BUG#1408610 FIX
112 */
113 g_num_winners := g_num_winners + 1;
114
115 END IF;
116
117 Else
118 X_Return_Status := FND_API.G_RET_STS_ERROR ;
119 END If;
120
121 END Add_Record;
122
123
124 END JTF_TERRITORY_GLOBAL_PUB;