DBA Data[Home] [Help]

PACKAGE BODY: APPS.GMA_GLOBAL_GRP

Source


1 PACKAGE BODY GMA_GLOBAL_GRP AS
2 --$Header: GMAGGBLB.pls 115.2 2002/11/01 21:04:16 appldev ship $
3 -- Body start of comments
4 --+==========================================================================+
5 --|                   Copyright (c) 1998 Oracle Corporation                  |
6 --|                          Redwood Shores, CA, USA                         |
7 --|                            All rights reserved.                          |
8 --+==========================================================================+
9 --| FILE NAME                                                                |
10 --|    GMAGGBLB.pls                                                          |
11 --|                                                                          |
12 --| PACKAGE NAME                                                             |
13 --|    GMA_GLOBAL_GRP                                                        |
14 --|                                                                          |
15 --| DESCRIPTION                                                              |
16 --|    This package contains all Utility functions pertaining to System      |
17 --|    Module                                                                |
18 --|                                                                          |
19 --| CONTENTS                                                                 |
20 --|    Get_Doc_No                                                            |
21 --|    Get_Reason_Code                                                       |
22 --|    Get_Who                                                               |
23 --|                                                                          |
24 --| HISTORY                                                                  |
25 --|    17-FEB-1999  M.Godfrey    Upgrade to R11                              |
26 --|    23-JUL-2002  Teresa Wong  Modified Get_Who to return -1 if user was   |
27 --|				 not defined.  (SYSADMIN has a valid user_id |
28 --|				 of 0.)   			             |
29 --|                                                                          |
30 --+==========================================================================+
31 -- Body end of comments
32 
33 -- Func start of comments
34 --+==========================================================================+
35 --|  FUNCTION NAME                                                           |
36 --|    Get_Doc_No                                                            |
37 --|                                                                          |
38 --|  USAGE                                                                   |
39 --|    Get next Document Number                                              |
40 --|                                                                          |
41 --|  DESCRIPTION                                                             |
42 --|    This global function gets the next document numbr for a given         |
43 --|    document type/Oraganization Code                                      |
44 --|                                                                          |
45 --|  PARAMETERS                                                              |
46 --|    p_doc_type  IN VARCHAR2 - Document Type                               |
47 --|    p_orgn_code IN VARCHAR2 - Organization Code                           |
48 --|                                                                          |
49 --|  RETURNS                                                                 |
50 --|    Document Number - If successful                                       |
51 --|    Blank           - If errors                                           |
52 --|                                                                          |
53 --|  HISTORY                                                                 |
54 --|                                                                          |
55 --+==========================================================================+
56 -- Func end of comments
57 FUNCTION Get_Doc_No
58 ( p_doc_type  IN sy_docs_seq.doc_type%TYPE
59 , p_orgn_code IN sy_docs_seq.orgn_code%TYPE
60 )
61 RETURN VARCHAR2
62 IS
63 l_doc_no        VARCHAR2(10);
64 l_doc_mask      VARCHAR2(10);
65 l_last_assigned NUMBER(10);
66 l_format_size   NUMBER(5);
67 l_pad_char      VARCHAR2(1);
68 CURSOR sy_docs_seq_c1 IS
69 SELECT
70   last_assigned
71 , format_size
72 , pad_char
73 FROM
74   sy_docs_seq
75 WHERE
76     doc_type  = p_doc_type
77 AND orgn_code = p_orgn_code;
78 
79 BEGIN
80 
81   -- Update sy_docs_seq
82   UPDATE sy_docs_seq
83   SET
84     last_assigned = last_assigned + 1
85   WHERE
86     doc_type  = p_doc_type AND
87     orgn_code = p_orgn_code;
88 
89   -- Now get new document no
90   OPEN sy_docs_seq_c1;
91 
92   FETCH sy_docs_seq_c1 INTO
93     l_last_assigned
94   , l_format_size
95   , l_pad_char;
96 
97   CLOSE sy_docs_seq_c1;
98 
99   -- Sort out format mask
100   l_doc_mask := LTRIM(RPAD(l_pad_char,l_format_size,l_pad_char));
101   l_doc_no   := LTRIM(TO_CHAR(l_last_assigned, l_doc_mask));
102 
103   RETURN l_doc_no;
104 
105 EXCEPTION
106   WHEN OTHERS THEN
107     RAISE;
108 
109 END Get_doc_no;
110 
111 --+=========================================================================+
112 --| PROCEDURE NAME                                                          |
113 --|    Get_Reason_Code                                                      |
114 --|                                                                         |
115 --| USAGE                                                                   |
116 --|    Used to retrieve reason code details                                 |
117 --|                                                                         |
118 --| DESCRIPTION                                                             |
119 --|    This procedure is used to retrieve all details from sy_reas_cds      |
120 --|                                                                         |
121 --| PARAMETERS                                                              |
122 --|    p_reason_code IN  VARCHAR2(4)  - Reason code to be retrieved         |
123 --|    x_sy_reas_cds OUT RECORD       - Record containing sy_reas_cds       |
124 --|                                                                         |
125 --| HISTORY                                                                 |
126 --|    01-OCT-1998      M.Godfrey     Created                               |
127 --|    01-NOV-2002      RTARDIO       Added NOCOPY for bug 2650392          |
128 --+=========================================================================+
129 PROCEDURE Get_Reason_Code
130 ( p_reason_code  IN  sy_reas_cds.reason_code%TYPE
131 , x_sy_reas_cds  OUT NOCOPY sy_reas_cds%ROWTYPE
132 )
133 IS
134 CURSOR sy_reas_cds_c1 IS
135 SELECT
136   *
137 FROM
138   sy_reas_cds
139 WHERE
140   reason_code   = p_reason_code AND
141   delete_mark = 0;
142 
143 BEGIN
144 
145   OPEN sy_reas_cds_c1;
146 
147   FETCH sy_reas_cds_c1 INTO x_sy_reas_cds;
148 
149   IF (sy_reas_cds_c1%NOTFOUND)
150   THEN
151     x_sy_reas_cds.reason_code := NULL;
152   END IF;
153 
154   CLOSE sy_reas_cds_c1;
155 
156 EXCEPTION
157   WHEN OTHERS THEN
158     RAISE;
159 
160 END Get_Reason_Code;
161 
162 --+=========================================================================+
163 --| PROCEDURE NAME                                                          |
164 --|    Get_Who                                                              |
165 --|                                                                         |
166 --| USAGE                                                                   |
167 --|    Used to retrieve WHO information                                     |
168 --|                                                                         |
169 --| DESCRIPTION                                                             |
170 --|    This procedure is used to retrieve the who field information         |
171 --|                                                                         |
172 --| PARAMETERS                                                              |
173 --|    p_user_name   IN  VARCHAR2     - User name                           |
174 --|    x_user_id     OUT NUMBER       - user id of the user                 |
175 --|                                                                         |
176 --| HISTORY                                                                 |
177 --|    17-FEB-1999      M.Godfrey     Created for R11                       |
178 --|    23-JUL-2002      Teresa Wong   Modified code to return -1 if user    |
179 --|				      was not defined.  (SYSADMIN has       |
180 --|				      a valid user_id of 0.)                |
181 --|    01-NOV-2002      RTARDIO       Added NOCOPY for bug 2650392          |
182 --+=========================================================================+
183 PROCEDURE Get_Who
184 ( p_user_name    IN  fnd_user.user_name%TYPE
185 , x_user_id      OUT NOCOPY fnd_user.user_id%TYPE
186 )
187 IS
188 CURSOR fnd_user_c1 IS
189 SELECT
190   user_id
191 FROM
192   fnd_user
193 WHERE
194   user_name = p_user_name;
195 
196 BEGIN
197 
198   OPEN fnd_user_c1;
199 
200   FETCH fnd_user_c1 INTO x_user_id;
201 
202   -- TKW B2476518 7/23/2002
203   -- If user not found, return -1 instead of 0.
204   IF (fnd_user_c1%NOTFOUND)
205   THEN
206     x_user_id := -1;
207   END IF;
208 
209   CLOSE fnd_user_c1;
210 
211 EXCEPTION
212   WHEN OTHERS THEN
213     RAISE;
214 
215 END Get_Who;
216 
217 END GMA_GLOBAL_GRP;