[Home] [Help]
PACKAGE BODY: APPS.OKE_DELIVERABLE_BILLING_WF
Source
1 PACKAGE BODY OKE_DELIVERABLE_BILLING_WF AS
2 /* $Header: OKEWDVBB.pls 120.1 2005/06/24 10:36:53 ausmani noship $ */
3 --
4 -- Name : Create_Billing_Event
5 -- Pre-reqs : None
6 -- Function : This procedure creates a billing event in PA from
7 -- Workflow
8 --
9 --
10 -- Parameters :
11 -- IN : ItemType
12 -- ItemKey
13 -- ActID
14 -- FuncMode
15 -- OUT : ResultOut
16 --
17 -- Returns : None
18 --
19 PROCEDURE Create_Billing_Event
20 ( ItemType IN VARCHAR2
21 , ItemKey IN VARCHAR2
22 , ActID IN NUMBER
23 , FuncMode IN VARCHAR2
24 , ResultOut OUT NOCOPY VARCHAR2
25 ) IS
26
27 L_Deliverable_ID NUMBER;
28 L_Return_Status VARCHAR2(1);
29 L_Msg_Count NUMBER;
30 L_Msg_Data VARCHAR2(2000);
31 L_Event_ID NUMBER;
32 L_Event_Num NUMBER;
33 X_Event_ID NUMBER;
34
35 BEGIN
36
37 IF ( FuncMode = 'RUN' ) THEN
38
39 L_Event_ID := WF_Engine.GetItemAttrNumber
40 ( ItemType => ItemType
41 , ItemKey => ItemKey
42 , AName => 'EVENT_ID'
43 );
44
45 OKE_DELIVERABLE_BILLING_PVT.Create_Billing_Event
46 ( P_Commit => FND_API.G_TRUE
47 , P_Event_ID => L_Event_ID
48 , X_Event_ID => X_Event_ID
49 , X_Event_Num => L_Event_Num
50 , X_Return_Status => L_Return_Status
51 , X_Msg_Count => L_Msg_Count
52 , X_Msg_Data => L_Msg_Data
53 );
54
55 IF ( L_Return_Status <> FND_API.G_RET_STS_SUCCESS ) THEN
56 WF_Engine.SetItemAttrText
57 ( ItemType => ItemType
58 , ItemKey => ItemKey
59 , AName => 'ERRORTEXT'
60 , AValue => FND_MSG_PUB.Get(1 , p_encoded => FND_API.G_FALSE)
61 );
62
63 ResultOut := 'COMPLETE:F';
64 ELSE
65 ResultOut := 'COMPLETE:T';
66 END IF;
67
68 RETURN;
69
70 END IF;
71
72 IF ( FuncMode = 'CANCEL' ) THEN
73
74 ResultOut := '';
75 RETURN;
76
77 END IF;
78
79 IF ( FuncMode = 'TIMEOUT' ) THEN
80
81 ResultOut := '';
82 RETURN;
83
84 END IF;
85
86 EXCEPTION
87 WHEN OTHERS THEN
88 ResultOut := 'ERROR';
89 WF_Core.Context( 'OKE_DELIVERABLE_BILLING_WF'
90 , 'CREATE_BILLING_EVENT'
91 , ItemType , ItemKey , to_char(ActID) , FuncMode , ResultOut );
92 RAISE;
93
94 END Create_Billing_Event;
95
96
97 PROCEDURE Launch_Process
98 ( P_Deliverable_ID IN NUMBER
99 , P_Event_ID IN NUMBER
100 , P_Deliverable_Num IN VARCHAR2
101 , P_Event_Type IN VARCHAR2
102 , P_Event_Date IN DATE
103 , P_Project_Num IN VARCHAR2
104 , P_Task_Num IN VARCHAR2
105 , P_Organization IN VARCHAR2
106 , P_Description IN VARCHAR2
107 , P_Bill_Currency_Code IN VARCHAR2
108 , P_Unit_Price IN NUMBER
109 , P_Bill_Quantity IN NUMBER
110 , P_UOM_Code IN VARCHAR2
111 , P_Bill_Amount IN NUMBER
112 , P_Revenue_Amount IN NUMBER
113 , P_Item_Number IN VARCHAR2
114 , P_Doc_Type IN VARCHAR2
115 , P_Contract_Num IN VARCHAR2
116 , P_Order_Num IN VARCHAR2
117 , P_Line_Num IN VARCHAR2
118 , P_Chg_Request_Num IN VARCHAR2
119 , P_Bill_Of_Lading IN VARCHAR2
120 , P_Serial_Num IN VARCHAR2
121 , P_Fund_Ref1 IN VARCHAR2
122 , P_Fund_Ref2 IN VARCHAR2
123 , P_Fund_Ref3 IN VARCHAR2
124 ) IS
125
126 L_WF_Item_Type VARCHAR2(8) := 'OKEDLVBL';
127 L_WF_Item_Key VARCHAR2(240) := NULL;
128 L_WF_User_Key VARCHAR2(240) := NULL;
129 L_Format_Mask VARCHAR2(80);
130 l_org_id NUMBER;
131
132 cursor c_org is select authoring_org_id
133 from oke_k_headers_v h,oke_k_deliverables_b dts
134 where h.k_header_id=dts.k_header_id
135 and deliverable_id=p_deliverable_id;
136 BEGIN
137
138 L_WF_Item_Key := P_Event_ID || ':' ||
139 to_char(sysdate , 'DDMONRRHH24MISS');
140
141 L_Format_Mask := FND_CURRENCY.Get_Format_Mask( P_Bill_Currency_Code , 38 );
142
143 WF_Engine.CreateProcess( ItemType => L_WF_Item_Type
144 , ItemKey => L_WF_Item_Key
145 , Process => 'OKE_DELIVERABLE_BILLING'
146 );
147
148 WF_Engine.SetItemOwner( ItemType => L_WF_Item_Type
149 , ItemKey => L_WF_Item_Key
150 , Owner => FND_GLOBAL.User_Name
151 );
152
153 WF_Engine.SetItemUserKey( ItemType => L_WF_Item_Type
154 , ItemKey => L_WF_Item_Key
155 , UserKey => L_WF_Item_Key
156 );
157
158 open c_org;
159 fetch c_org into l_org_id;
160 close c_org;
161
162 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
163 , ItemKey => L_WF_Item_Key
164 , AName => 'ORG_ID'
165 , AValue => l_org_id );
166
167 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
168 , ItemKey => L_WF_Item_Key
169 , AName => 'DELIVERABLE_ID'
170 , AValue => P_Deliverable_ID );
171
172 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
173 , ItemKey => L_WF_Item_Key
174 , AName => 'EVENT_ID'
175 , AValue => P_Event_ID );
176
177 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
178 , ItemKey => L_WF_Item_Key
179 , AName => 'DELIVERABLE_NUM'
180 , AValue => P_Deliverable_Num );
181
182 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
183 , ItemKey => L_WF_Item_Key
184 , AName => 'PROJECT_NUM'
185 , AValue => P_Project_Num );
186
187 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
188 , ItemKey => L_WF_Item_Key
189 , AName => 'TASK_NUM'
190 , AValue => P_Task_Num );
191
192 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
193 , ItemKey => L_WF_Item_Key
194 , AName => 'BILL_ORGANIZATION'
195 , AValue => P_Organization );
196
197 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
198 , ItemKey => L_WF_Item_Key
199 , AName => 'BILL_CURRENCY_CODE'
200 , AValue => P_Bill_Currency_Code );
201
202 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
203 , ItemKey => L_WF_Item_Key
204 , AName => 'UOM'
205 , AValue => P_UOM_Code );
206
207 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
208 , ItemKey => L_WF_Item_Key
209 , AName => 'UNIT_PRICE'
210 , AValue => P_Unit_Price );
211
212 --
213 -- The following attribute is currency formatted for notifications only
214 --
215 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
216 , ItemKey => L_WF_Item_Key
217 , AName => 'UNIT_PRICE_FMT'
218 , AValue => to_char( P_Unit_Price , L_Format_Mask ) );
219
220 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
221 , ItemKey => L_WF_Item_Key
222 , AName => 'BILL_AMOUNT'
223 , AValue => P_Bill_Amount );
224
225 --
226 -- The following attribute is currency formatted for notifications only
227 --
228 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
229 , ItemKey => L_WF_Item_Key
230 , AName => 'BILL_AMOUNT_FMT'
231 , AValue => to_char( P_Bill_Amount , L_Format_Mask ) );
232
233 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
234 , ItemKey => L_WF_Item_Key
235 , AName => 'REVENUE_AMOUNT'
236 , AValue => P_Revenue_Amount );
237
238 --
239 -- The following attribute is currency formatted for notifications only
240 --
241 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
242 , ItemKey => L_WF_Item_Key
243 , AName => 'REVENUE_AMOUNT_FMT'
244 , AValue => to_char( P_Revenue_Amount , L_Format_Mask ) );
245
246 WF_ENGINE.SetItemAttrNumber( ItemType => L_WF_Item_Type
247 , ItemKey => L_WF_Item_Key
248 , AName => 'BILL_QTY'
249 , AValue => P_Bill_Quantity );
250
251 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
252 , ItemKey => L_WF_Item_Key
253 , AName => 'ITEM_NUM'
254 , AValue => P_Item_Number );
255
256 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
257 , ItemKey => L_WF_Item_Key
258 , AName => 'DOC_TYPE'
259 , AValue => P_Doc_Type );
260
261 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
262 , ItemKey => L_WF_Item_Key
263 , AName => 'DOC_NUM'
264 , AValue => P_Contract_Num );
265
266 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
267 , ItemKey => L_WF_Item_Key
268 , AName => 'ORDER_NUM'
269 , AValue => P_Order_Num );
270
271 --
272 -- Doc_Num_Dsp is a concatenation of Contract Number and Order
273 -- Number if applicable.
274 -- This attribute is for notifications only
275 --
276 IF ( P_Order_Num IS NULL ) THEN
277 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
278 , ItemKey => L_WF_Item_Key
279 , AName => 'DOC_NUM_DSP'
280 , AValue => P_Contract_Num );
281 ELSE
282 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
283 , ItemKey => L_WF_Item_Key
284 , AName => 'DOC_NUM_DSP'
285 , AValue => P_Contract_Num || '/' || P_Order_Num );
286 END IF;
287
288 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
289 , ItemKey => L_WF_Item_Key
290 , AName => 'LINE_NUM'
291 , AValue => P_Line_Num );
292
293 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
294 , ItemKey => L_WF_Item_Key
295 , AName => 'ITEM_DESCRIPTION'
296 , AValue => P_Description );
297
298 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
299 , ItemKey => L_WF_Item_Key
300 , AName => 'FUND_REF1'
301 , AValue => P_Fund_Ref1 );
302
303 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
304 , ItemKey => L_WF_Item_Key
305 , AName => 'FUND_REF2'
306 , AValue => P_Fund_Ref2 );
307
308 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
309 , ItemKey => L_WF_Item_Key
310 , AName => 'FUND_REF3'
311 , AValue => P_Fund_Ref3 );
312
313 WF_ENGINE.SetItemAttrDate( ItemType => L_WF_Item_Type
314 , ItemKey => L_WF_Item_Key
315 , AName => 'EVENT_DATE'
316 , AValue => P_Event_Date );
317
318 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
319 , ItemKey => L_WF_Item_Key
320 , AName => 'REQUESTOR'
321 , AValue => FND_GLOBAL.User_Name );
322
323 WF_ENGINE.SetItemAttrText( ItemType => L_WF_Item_Type
324 , ItemKey => L_WF_Item_Key
325 , AName => 'RECIPIENT'
326 , AValue => FND_GLOBAL.User_Name );
327
328 --
329 -- Start the Workflow Process
330 --
331 WF_ENGINE.StartProcess( ItemType => L_WF_Item_Type
332 , ItemKey => L_WF_Item_Key );
333
334
335 END Launch_Process;
336
337 END OKE_DELIVERABLE_BILLING_WF;