DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_MSG

Source


1 PACKAGE BODY OE_MSG AS
2 /* $Header: OEXUTMGB.pls 115.1 99/07/16 08:16:42 porting shi $ */
3 
4 ------------------------------------------------------------------------
5 --1. Added message name to message table in the order
6 --   of the index value increase by 1 (start with 1).
7 --2. Return TRUE if successful, otherwise, return FALSE.
8 ------------------------------------------------------------------------
9 function SET_MESSAGE_NAME(
10    MSG_NAME          IN VARCHAR2 DEFAULT NULL
11                           )
12    return BOOLEAN
13 IS
14    RetCode BOOLEAN := TRUE;
15 begin
16 
17   if  ( (MSG_NAME is NULL ) or (OE_Msg_Last_Msg_Count >=100) )
18   then
19      retCode := FALSE;
20      GOTO ExitPoint;
21   end if;
22 
23   -- next available slot
24   OE_Msg_Last_Msg_Count := OE_Msg_Last_Msg_Count +1;
25   OE_Msg_Message_Name_Buffer(OE_Msg_Last_Msg_Count)      := MSG_NAME;
26 
27 <<ExitPoint>>
28   OE_Msg_Token_Count(OE_Msg_Last_Msg_Count) := 0;
29   return(RetCode);
30 end ;
31 
32 
33 
34 ------------------------------------------------------------------------
35 --1. Added message name , token name and token value to table in the order
36 --   of the index value increase by 1 (start with 1).
37 --2. Return TRUE if successful, otherwise, return FALSE.
38 ------------------------------------------------------------------------
39 function SET_BUFFER_MESSAGE(
40    MSG_NAME         IN VARCHAR2 DEFAULT NULL
41 ,  TOKEN_NAME       IN VARCHAR2 DEFAULT NULL
42 ,  TOKEN_VALUE      IN VARCHAR2 DEFAULT NULL
43                             )
44    return BOOLEAN
45 IS
46    RetCode BOOLEAN := TRUE;
47 begin
48 
49   if  (MSG_NAME is NULL )  -- message name can't be NULL
50   then
51      retCode := FALSE;
52      GOTO ExitPoint;
53   end if;
54 
55   if ((OE_Msg_Last_Msg_Count = 0) or
56       (MSG_NAME <> OE_Msg_Message_Name_Buffer(OE_Msg_Last_Msg_Count)) )
57   then
58      retCode := SET_MESSAGE_NAME(MSG_NAME);
59      if ( retCode = FALSE )
60      then
61         GOTO ExitPoint;
62      end if;
63   end if;
64 
65   if ( TOKEN_NAME is not NULL )
66   then
67      OE_Msg_Last_Token_Count := OE_Msg_Last_Token_Count + 1;
68 
69      if ( OE_Msg_Token_Count(OE_Msg_Last_Msg_Count) = 0 )
70      then                            -- first token of this message
71         OE_Msg_Token_Count(OE_Msg_Last_Msg_Count) := OE_Msg_Last_Token_Count;
72      elsif ( (OE_Msg_Last_Token_Count - OE_Msg_Token_Count(OE_Msg_Last_Msg_Count)) >10 )
73      then                            -- Can't over 10 tokens in one message
74         OE_Msg_Last_Token_Count := OE_Msg_Last_Token_Count -1;
75         retCode := FALSE;
76         GOTO ExitPoint;
77      end if;
78 
79      OE_Msg_Token_Name_Buffer(OE_Msg_Last_Token_Count)    := TOKEN_NAME;
80      OE_Msg_Token_Value_Buffer(OE_Msg_Last_Token_Count)   := TOKEN_VALUE;
81 
82   end if;
83 
84 <<ExitPoint>>
85   return(RetCode);
86 end ;
87 
88 
89 --
90 -- NAME
91 --  Set_Buffer_Message
92 --
93 PROCEDURE Set_Buffer_Message(Msg_Name    IN VARCHAR2,
94 			     Token_Name	 IN VARCHAR2 Default NULL,
95 			     Token_Value IN VARCHAR2 Default NULL) is
96  result BOOLEAN;
97 begin
98   result := Set_Buffer_Message(Msg_Name, Token_Name, Token_Value);
99 end;
100 
101 --
102 -- NAME
103 --   Internal_Exception
104 --
105 PROCEDURE Internal_Exception(Routine    VARCHAR2,
106 			     Operation  VARCHAR2,
107 			     Object     VARCHAR2,
108 			     Message    VARCHAR2 Default NULL) is
109   Delimiter VARCHAR2(1);
110 begin
111 
112     Delimiter := '
113 ';
114 
115   Set_Buffer_Message('OE_EXC_INTERNAL_EXCEPTION', 'ROUTINE', Routine);
116   Set_Buffer_Message('OE_EXC_INTERNAL_EXCEPTION', 'OPERATION', Operation);
117   Set_Buffer_Message('OE_EXC_INTERNAL_EXCEPTION', 'OBJECT', Object);
118   Set_Buffer_Message('OE_EXC_INTERNAL_EXCEPTION', 'MESSAGE',
119 		     Substrb(sqlerrm || Delimiter || Message, 1, 255));
120 end;
121 
122 
123 ------------------------------------------------------------------------
124 --1. Get message name and all tokens' name and tokens' value according to
125 --   the input index value.
126 --2. Return TRUE if successful, otherwise, return FALSE.
127 ------------------------------------------------------------------------
128 procedure Get_Message_Name(
129    MSG_NAME          OUT VARCHAR2
130 ,  LAST_MESSAGE      OUT NUMBER
131                            )
132 IS
133 begin
134    -- Get next message name
135    OE_Msg_Show_Msg_Count := OE_Msg_Show_Msg_Count + 1;
136    if ( OE_Msg_Last_Msg_Count >= OE_Msg_Show_Msg_Count )
137    then
138        MSG_NAME  := OE_Msg_Message_Name_Buffer(OE_Msg_Show_Msg_Count);
139    end if ;
140 
141    if ( ( OE_Msg_Last_Msg_Count = 0 )or
142         ( OE_Msg_Last_Msg_Count = OE_Msg_Show_Msg_Count) )
143    then
144       LAST_MESSAGE := 1;  -- TRUE : no more message
145    else
146       LAST_MESSAGE := 0;  -- FALSE
147    end if;
148 end ;
149 
150 
151 
152 ------------------------------------------------------------------------
153 --1. Get message name and all tokens' name and tokens' value according to
154 --   the input index value.
155 --2. Return TRUE if successful, otherwise, return FALSE.
156 ------------------------------------------------------------------------
157 procedure Get_Buffer_Message(
158    TOKEN_NAME        OUT VARCHAR2
159 ,  TOKEN_VALUE       OUT VARCHAR2
160 ,  LAST_TOKEN        IN OUT NUMBER
161                            )
162 IS
163   No_Token_Flag      boolean := FALSE;
164 begin
165 
166    if ( OE_Msg_Last_Msg_Count <= 0 )
167    then                 --no message available
168        LAST_TOKEN := 1; --TRUE
169        TOKEN_NAME := '';
170        No_Token_Flag:= TRUE;
171    else
172        if ( OE_Msg_Token_Count(OE_Msg_Show_Msg_Count) = 0 )
173        then
174            TOKEN_NAME := '';  -- no token belongs to this message
175            No_Token_Flag := TRUE;
176            LAST_TOKEN := 1; --TRUE
177        else
178            TOKEN_NAME := OE_Msg_Token_Name_Buffer(OE_Msg_Show_Token_Count);
179            TOKEN_VALUE:= OE_Msg_Token_Value_Buffer(OE_Msg_Show_Token_Count);
180        end if;
181 
182        if (  No_Token_Flag = FALSE )
183        then
184            if ( OE_Msg_Show_Token_Count = Get_Last_Token_Of_This_Msg )
185            then                  --no token or last token
186                 LAST_TOKEN := 1; --TRUE
187            else
188                 LAST_TOKEN := 0;  --FALSE
189            end if;
190            OE_Msg_Show_Token_Count := OE_Msg_Show_Token_Count + 1;
191        end if;
192     end if;
193 
194     if ( (LAST_TOKEN = 1 ) AND
195          (OE_Msg_Last_Msg_Count <= OE_Msg_Show_Msg_Count ) )
196     then
197          CLEAN_BUFFER_MESSAGE;
198     end if;
199 end ;
200 
201 
202 ------------------------------------------------------------------------
203 --1. Get the last token's index of the current message.
204 --2. Return last token's index number.
205 ------------------------------------------------------------------------
209    Last_Token_Count   NUMBER := 0;
206 function Get_Last_Token_Of_This_Msg
207    return NUMBER
208 IS
210    TempIndex           NUMBER;
211 begin
212 
213    if ( OE_Msg_Show_Msg_Count < OE_Msg_Last_Msg_Count )
214    then
215 
216         FOR TempIndex in OE_Msg_Show_Msg_Count .. OE_Msg_Last_Msg_Count-1 LOOP
217             if ( OE_Msg_Token_Count(TempIndex+1) <> 0 )
218             then
219                Last_Token_Count := OE_Msg_Token_Count(TempIndex+1) -1;
220             end if;
221         END LOOP;
222    end if;
223 
224    if ( Last_Token_Count = 0 )
225    then
226        Last_Token_Count := OE_Msg_Last_Token_Count;
227    end if;
228 
229    return (Last_Token_Count);
230 end;  -- Get_Last_Token_Of_This_Msg
231 
232 
233 ------------------------------------------------------------------------
234 --1.Clean all the Token name and Token Value tables.
235 --2.Reset Message Count to 0 .
236 --3.Clean Message Name and Token Count table.
237 ------------------------------------------------------------------------
238 procedure CLEAN_BUFFER_MESSAGE is
239 Empty_Buffer                 MESSAGE_TABLE_TYPE;  -- Empty Message stack
240 Empty_Token_Count_Buffer     TOKEN_COUNT_TABLE_TYPE ;
241 begin
242     OE_Msg_Message_Name_Buffer := Empty_Buffer;
243     OE_Msg_Token_Name_Buffer   := Empty_Buffer;
244     OE_Msg_Token_Value_Buffer  := Empty_Buffer;
245     OE_Msg_Token_Count         := Empty_Token_Count_Buffer;
246     OE_Msg_Last_Msg_Count      := 0;
247     OE_Msg_Last_Token_Count    := 0;
248     OE_Msg_Show_Msg_Count      := 0;
249     OE_Msg_Show_Token_Count    := 1;
250 
251 end;
252 
253 
254 ------------------------------------------------------------------------
255 --Append debug info. to the OE_Debug_Info_Buffer and use carriage return
256 --as seperator.
257 ------------------------------------------------------------------------
258 procedure Set_Debug_Info(
259    Debug_Info      IN VARCHAR2 DEFAULT NULL
260                         )
261 IS
262 begin
263    OE_Debug_Info_Buffer := OE_Debug_Info_Buffer||'\n'|| Debug_Info;
264 end ; -- Set_Debug_Info
265 
266 
267 ------------------------------------------------------------------------
268 --1. copy Debug_Info_Buffer to the Debug_Info
269 --2. Clear out the Debug_Info_Buffer.
270 ------------------------------------------------------------------------
271 procedure Get_Debug_Info(
272    Debug_Info        OUT VARCHAR2
273                          )
274 IS
278 end ;
275 begin
276     Debug_Info := OE_Debug_Info_Buffer;
277     Clean_Debug_Info;
279 
280 ------------------------------------------------------------------------
281 -- Set OE_Debug_Info_Buffer as empty
282 ------------------------------------------------------------------------
283 procedure Clean_Debug_Info
284 IS
285 begin
286     OE_Debug_Info_Buffer := NULL;
287 end ;
288 
289 
290 END OE_MSG;