DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_BOOK_WF

Source


1 PACKAGE BODY OE_Book_WF as
2 /* $Header: OEXWBOKB.pls 120.0 2005/06/01 00:48:35 appldev noship $ */
3 
4 PROCEDURE Book_Order(
5     itemtype  in varchar2,
6     itemkey   in varchar2,
7     actid     in number,
8     funcmode  in varchar2,
9     resultout in out NOCOPY /* file.sql.39 change */ varchar2)
10 IS
11 l_header_id		NUMBER;
12 l_return_status	VARCHAR2(30);
13 l_msg_count		NUMBER;
14 l_msg_data		VARCHAR2(2000);
15 l_booked_flag           VARCHAR2(1);
16 --
17 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
18 --
19 BEGIN
20 
21   --
22   -- RUN mode - normal process execution
23   --
24   if (funcmode = 'RUN') then
25 
26         l_header_id	:= to_number(itemkey);
27 
28         -- BEGIN: During BULK order import, booking validations and
29         -- business logic are executed as a part of the import so order
30         -- could be booked prior to the workflow activity. Therefore,
31         -- return if order is booked.
32         IF OE_BULK_WF_UTIL.G_HEADER_INDEX IS NOT NULL THEN
33 
34           l_booked_flag := OE_BULK_ORDER_PVT.G_HEADER_REC.booked_flag
35                             (OE_BULK_WF_UTIL.G_HEADER_INDEX);
36           IF l_booked_flag = 'Y' THEN
37             resultout := 'COMPLETE:COMPLETE';
38             RETURN;
39           END IF;
40 
41         END IF;
42         -- END: code for BULK order import
43 
44 	OE_STANDARD_WF.Set_Msg_Context(actid);
45 
46 	IF l_debug_level  > 0 THEN
47 	    oe_debug_pub.add(  'CALL CHECK_BOOKING_HOLDS' ) ;
48 	END IF;
49 	OE_ORDER_BOOK_UTIL.Check_Booking_Holds
50 			( p_header_id			=> l_header_id
51 			, x_return_status		=> l_return_status
52 			);
53 
54 	IF l_debug_level  > 0 THEN
55 	    oe_debug_pub.add(  'RETURN STATUS FROM CHECK_BOOKING_HOLDS: '||L_RETURN_STATUS ) ;
56 	END IF;
57 
58 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
59 		resultout := 'COMPLETE:ON_HOLD';
60 		OE_STANDARD_WF.Save_Messages;
61 		OE_STANDARD_WF.Clear_Msg_Context;
62 		return;
63 	ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
64 		-- start data fix project
65                 -- OE_STANDARD_WF.Save_Messages;
66 		-- OE_STANDARD_WF.Clear_Msg_Context;
67                 -- end data fix project
68 		app_exception.raise_exception;
69      END IF;
70 
71 	IF l_debug_level  > 0 THEN
72 	    oe_debug_pub.add(  'CALL BOOK_ORDER' ) ;
73 	END IF;
74 	OE_ORDER_BOOK_UTIL.Book_Order
75 			( p_api_version_number	=> 1.0
76 			, p_header_id			=> l_header_id
77 			, x_return_status		=> l_return_status
78 			, x_msg_count			=> l_msg_count
79 			, x_msg_data			=> l_msg_data
80 			);
81 	IF l_debug_level  > 0 THEN
82 	    oe_debug_pub.add(  'RETURN STATUS FROM BOOK_ORDER: '||L_RETURN_STATUS ) ;
83 	END IF;
84 
85 	IF l_return_status = FND_API.G_RET_STS_ERROR THEN
86 		resultout := 'COMPLETE:INCOMPLETE';
87 		OE_STANDARD_WF.Save_Messages;
88 		OE_STANDARD_WF.Clear_Msg_Context;
89 		return;
90 	ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
91 		-- start data fix project
92                 -- OE_STANDARD_WF.Save_Messages;
93 		-- OE_STANDARD_WF.Clear_Msg_Context;
94                 -- end data fix project
95 		app_exception.raise_exception;
96      END IF;
97 
98     	resultout := 'COMPLETE:COMPLETE';
99 	OE_STANDARD_WF.Clear_Msg_Context;
100     	return;
101 
102   end if; -- End for 'RUN' mode
103 
104   --
105   -- CANCEL mode - activity 'compensation'
106   --
107   -- This is an event point is called with the effect of the activity must
108   -- be undone, for example when a process is reset to an earlier point
109   -- due to a loop back.
110   --
111   if (funcmode = 'CANCEL') then
112 
113     -- your cancel code goes here
114     null;
115 
116     -- no result needed
117     resultout := 'COMPLETE';
118     return;
119   end if;
120 
121 
122   --
123   -- Other execution modes may be created in the future.  Your
124   -- activity will indicate that it does not implement a mode
125   -- by returning null
126   --
127 --  resultout := '';
128 --  return;
129 
130 exception
131   when others then
132     -- The line below records this function call in the error system
133     -- in the case of an exception.
134     wf_core.context('OE_Order_WF', 'Book_Order',
135                     itemtype, itemkey, to_char(actid), funcmode);
136     -- start data fix project
137     OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
138                                           p_itemtype => itemtype,
139                                           p_itemkey => itemkey);
140     OE_STANDARD_WF.Save_Messages;
141     OE_STANDARD_WF.Clear_Msg_Context;
142     -- end data fix project
143     raise;
144 END Book_Order;
145 
146 END OE_Book_WF;