DBA Data[Home] [Help]

PACKAGE BODY: APPS.JTF_TERRITORY_GLOBAL_PUB

Source


1 Package Body JTF_TERRITORY_GLOBAL_PUB AS
2 /* $Header: jtfxstrb.pls 120.0 2005/06/02 18:23:19 appldev 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 G_Profile_Value VARCHAR2(25) := FND_PROFILE.Value('JTF_TERR_NO_OF_WINNERS');
38 
39 --*******************************************************
40 --    Start of Comments
41 --*******************************************************
42 
43 /* Reset global variables:
44 ** for each call to Get_Winning_Territory_Members API
45 */
46 FUNCTION   Reset return BOOLEAN
47 AS
48 BEGIN
49 
50      /* reset number of winners for a
51      ** top-level territory node
52      ** JDOCHERT 09/17: BUG#1408610 FIX
53      */
54      g_num_winners := 0;
55 
56      /* Reset the global index */
57      g_TblIndex := 1;
58 
59      /* Reset contents of PL/SQL table */
60      G_WinningTerr_Tbl.Delete;
61 
62      return TRUE;
63 
64 END  Reset;
65 
66 /* Return the count of the winning Terr Table */
67 FUNCTION   get_RecordCount return NUMBER
68 as
69 BEGIN
70      return G_WinningTerr_Tbl.Count;
71 END Get_RecordCount;
72 
73 
74 /* Add record to table of winners for the Territory Assignment Engine */
75 PROCEDURE  Add_Record( p_WinningTerr_Rec   IN  JTF_TERRITORY_PUB.WinningTerr_rec_type,
76                        p_Number_Of_Winners IN  NUMBER,
77                        X_Return_Status     OUT NOCOPY VARCHAR2)
78 AS
79 BEGIN
80 
81     /* Store winning territory record */
82     If (p_WinningTerr_Rec.TERR_ID IS NOT NULL) THEN
83 
84        G_WinningTerr_Tbl(G_TblIndex).PARTY_ID                 := g_PARTY_ID;
85        G_WinningTerr_Tbl(G_TblIndex).PARTY_SITE_ID            := g_PARTY_SITE_ID;
86        G_WinningTerr_Tbl(G_TblIndex).TERR_ID                  := p_WinningTerr_Rec.TERR_ID;
87        G_WinningTerr_Tbl(G_TblIndex).TERR_NAME                := p_WinningTerr_Rec.TERR_NAME;
88        G_WinningTerr_Tbl(G_TblIndex).RANK                     := p_WinningTerr_Rec.RANK;
89        G_WinningTerr_Tbl(G_TblIndex).ORG_ID                   := p_WinningTerr_Rec.ORG_ID;
90        G_WinningTerr_Tbl(G_TblIndex).PARENT_TERRITORY_ID      := p_WinningTerr_Rec.PARENT_TERRITORY_ID;
91        G_WinningTerr_Tbl(G_TblIndex).TEMPLATE_TERRITORY_ID    := p_WinningTerr_Rec.TEMPLATE_TERRITORY_ID;
92        G_WinningTerr_Tbl(G_TblIndex).ESCALATION_TERRITORY_ID  := p_WinningTerr_Rec.ESCALATION_TERRITORY_ID;
93 
94        /* Set the status to SUCCESS */
95        X_Return_Status :=     FND_API.G_RET_STS_SUCCESS;
96 
97        -- Increment the index, if the profile is set to multiple winners
98        --If NVL(G_Profile_Value, 'SINGLE') = 'MULTIPLE' Then
99        --   g_TblIndex := g_TblIndex + 1;
100        --End If;
101 
102        /* Increment the index, if the profile is set to multiple winners */
103        IF (p_number_of_winners > 1) THEN
104 
105           g_TblIndex := g_TblIndex + 1;
106 
107           /* track number of winners for a territory node at the
108           ** top-level (directly below the Catch_all) in the
109           ** territory hierarchy
110           ** JDOCHERT 09/17: BUG#1408610 FIX
111           */
112           g_num_winners := g_num_winners + 1;
113 
114        END IF;
115 
116     Else
117        X_Return_Status :=    FND_API.G_RET_STS_ERROR ;
118     END If;
119 
120 END Add_Record;
121 
122 
123 END JTF_TERRITORY_GLOBAL_PUB;