DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_COMMON_WF_PKG

Source


1 PACKAGE BODY wip_common_wf_pkg AS
2 /*$Header: wipwfcmb.pls 115.15 2003/09/11 20:52:49 kboonyap ship $ */
3 
4 FUNCTION OSPEnabled RETURN BOOLEAN IS
5 begin
6 
7   -- if the 'WIP: Enable Outside Processing Workflows' is set to 'N'
8   -- do not start the workflow
9 
10   if(fnd_profile.value('WIP_OSP_WF') = WIP_CONSTANTS.NO) then
11         return FALSE;
12   else
13         return TRUE;
14   end if;
15 
16 end OSPEnabled;
17 
18 PROCEDURE SelectBuyer( itemtype  in varchar2,
19                        itemkey   in varchar2,
20                        actid     in number,
21                        funcmode  in varchar2,
22                        resultout out NOCOPY varchar2) is
23 
24   l_po_header_id number :=
25     wf_engine.GetItemAttrText( itemtype => itemtype,
26                                itemkey  => itemkey,
27                                aname    => 'PO_HEADER_ID');
28 
29   l_buyer       varchar2(100) := NULL;
30 
31 BEGIN
32 
33   if (funcmode = 'RUN') then
34 
35     l_buyer := wip_std_wf.GetBuyerLogin(l_po_header_id);
36 
37     if (l_buyer is not null) then
38       wf_engine.SetItemAttrText( itemtype => itemtype,
39                                  itemkey  => itemkey,
40                                  aname    => 'BUYER',
41                                  avalue   => l_buyer);
42       resultout := 'COMPLETE:WIP_FOUND';
43     else
44       resultout := 'COMPLETE:WIP_NOT_FOUND';
45     end if;
46 
47     return;
48   end if;
49 
50   if (funcmode = 'CANCEL') then
51     resultout := 'COMPLETE:';
52     return;
53   end if;
54 
55   if (funcmode = 'TIMEOUT') then
56     resultout := 'COMPLETE:';
57     return;
58   end if;
59 
60 EXCEPTION
61   when others then
62     wf_core.context('WIP_COMMON_WF_PKG',  'SelectBuyer',
63         itemtype, itemkey, actid, funcmode);
64     raise;
65 
66 END SelectBuyer;
67 
68 PROCEDURE SelectSupplierCNT( itemtype  in varchar2,
69                        itemkey   in varchar2,
70                        actid     in number,
71                        funcmode  in varchar2,
72                        resultout out NOCOPY varchar2) is
73 
74   l_po_header_id number :=
75     wf_engine.GetItemAttrText( itemtype => itemtype,
76                                itemkey  => itemkey,
77                                aname    => 'PO_HEADER_ID');
78 
79   l_supplier_contact    varchar2(100) := NULL;
80 
81 BEGIN
82 
83   if (funcmode = 'RUN') then
84 
85     l_supplier_contact :=
86          wip_std_wf.GetSupplierContactLogin(l_po_header_id);
87 
88     if (l_supplier_contact is not null) then
89       wf_engine.SetItemAttrText( itemtype => itemtype,
90                                  itemkey  => itemkey,
91                                  aname    => 'SUPPLIER_CONTACT',
92                                  avalue   => l_supplier_contact);
93       resultout := 'COMPLETE:WIP_FOUND';
94     else
95       resultout := 'COMPLETE:WIP_NOT_FOUND';
96     end if;
97 
98     return;
99   end if;
100   if (funcmode = 'CANCEL') then
101     resultout := 'COMPLETE:';
102     return;
103   end if;
104 
105   if (funcmode = 'TIMEOUT') then
106     resultout := 'COMPLETE:';
107     return;
108   end if;
109 
110 EXCEPTION
111   when others then
112     wf_core.context('WIP_COMMON_WF_PKG',  'SelectSupplierCN',
113         itemtype, itemkey, actid, funcmode);
114     raise;
115 
116 END SelectSupplierCNT;
117 
118 PROCEDURE SelectProdScheduler( itemtype  in varchar2,
119                        itemkey   in varchar2,
120                        actid     in number,
121                        funcmode  in varchar2,
122                        resultout out NOCOPY varchar2) is
123 
124   l_organization_id number :=
125     wf_engine.GetItemAttrText( itemtype => itemtype,
126                                itemkey  => itemkey,
127                                aname    => 'ORGANIZATION_ID');
128 
129   l_prod_scheduler      varchar2(80) := NULL;
130 
131 BEGIN
132 
133   if (funcmode = 'RUN') then
134 
135     l_prod_scheduler :=
136          wip_std_wf.GetProductionSchedLogin(l_organization_id);
137 
138     if (l_prod_scheduler is not null) then
139       wf_engine.SetItemAttrText( itemtype => itemtype,
140                                  itemkey  => itemkey,
141                                  aname    => 'PRODUCTION_SCHEDULER',
142                                  avalue   => l_prod_scheduler);
143       resultout := 'COMPLETE:WIP_FOUND';
144     else
145       resultout := 'COMPLETE:WIP_NOT_FOUND';
146     end if;
147 
148     return;
149   end if;
150 
151   if (funcmode = 'CANCEL') then
152     resultout := 'COMPLETE:';
153     return;
154   end if;
155 
156   if (funcmode = 'TIMEOUT') then
157     resultout := 'COMPLETE:';
158     return;
159   end if;
160 
161 EXCEPTION
162   when others then
163     wf_core.context('WIP_COMMON_WF_PKG',  'SelectProdScheduler',
164         itemtype, itemkey, actid, funcmode);
165     raise;
166 
167 END SelectProdScheduler;
168 
169 PROCEDURE SelectShippingManager( itemtype  in varchar2,
170                        itemkey   in varchar2,
171                        actid     in number,
172                        funcmode  in varchar2,
173                        resultout out NOCOPY varchar2) is
174 
175   l_organization_id number :=
176     wf_engine.GetItemAttrNumber( itemtype => itemtype,
177                                itemkey  => itemkey,
178                                aname    => 'ORGANIZATION_ID');
179 
180   l_ship_manager        varchar2(80) := NULL;
181 
182 BEGIN
183 
184   if (funcmode = 'RUN') then
185 
186     l_ship_manager :=
187          wip_std_wf.GetShipManagerLogin(l_organization_id);
188 
189     if (l_ship_manager is not null) then
190       wf_engine.SetItemAttrText( itemtype => itemtype,
191                                  itemkey  => itemkey,
192                                  aname    => 'SHIPPING_MANAGER',
193                                  avalue   => l_ship_manager);
194       resultout := 'COMPLETE:WIP_FOUND';
195     else
196       resultout := 'COMPLETE:WIP_NOT_FOUND';
197     end if;
198 
199     return;
200   end if;
201 
202   if (funcmode = 'CANCEL') then
203     resultout := 'COMPLETE:';
204     return;
205   end if;
206 
207   if (funcmode = 'TIMEOUT') then
208     resultout := 'COMPLETE:';
209     return;
210   end if;
211 
212 EXCEPTION
213   when others then
214     wf_core.context('WIP_COMMON_WF_PKG',  'SelectShippingManager',
215         itemtype, itemkey, actid, funcmode);
216     raise;
217 
218 END SelectShippingManager;
219 
220 
221 PROCEDURE SelectDefaultBuyer( itemtype  in varchar2,
222                        itemkey   in varchar2,
223                        actid     in number,
224                        funcmode  in varchar2,
225                        resultout out NOCOPY varchar2) is
226 
227   l_organization_id number :=
228     wf_engine.GetItemAttrNumber( itemtype => itemtype,
229                                itemkey  => itemkey,
230                                aname    => 'ORGANIZATION_ID');
231 
232   l_osp_item_id number :=
233     wf_engine.GetItemAttrNumber ( itemtype => itemtype,
234                                  itemkey  => itemkey,
235                                  aname    => 'OSP_ITEM_ID');
236 
237   l_default_buyer       varchar2(80) := NULL;
238 
239 BEGIN
240   if (funcmode = 'RUN') then
241 
242     l_default_buyer :=
243          wip_std_wf.GetDefaultBuyerLogin(p_organization_id => l_organization_id,
244                                          p_item_id => l_osp_item_id);
245 
246     if (l_default_buyer is not null) then
247       wf_engine.SetItemAttrText( itemtype => itemtype,
248                                  itemkey  => itemkey,
249                                  aname    => 'BUYER',
250                                  avalue   => l_default_buyer);
251       resultout := 'COMPLETE:WIP_FOUND';
252     else
253       resultout := 'COMPLETE:WIP_NOT_FOUND';
254     end if;
255 
256     return;
257   end if;
258 
259   if (funcmode = 'CANCEL') then
260     resultout := 'COMPLETE:';
261     return;
262   end if;
263 
264   if (funcmode = 'TIMEOUT') then
265     resultout := 'COMPLETE:';
266     return;
267   end if;
268 
269 EXCEPTION
270   when others then
271     wf_core.context('WIP_COMMON_WF_PKG',  'SelectDefaultBuyer',
272         itemtype, itemkey, actid, funcmode);
273     raise;
274 
275 END SelectDefaultBuyer;
276 
277 PROCEDURE OpenPO(p1    varchar2 default null,
278                  p2    varchar2 default null,
279                  p3    varchar2 default null,
280                  p4    varchar2 default null,
281                  p5    varchar2 default null,
282                  p11   varchar2 default null) IS
283 
284 l_param                 varchar2(240);
285 c_rowid                 varchar2(18);
286 l_session_id            number;
287 
288 BEGIN
289   return;
290   /*Comment out all the codes due to ATG compliance for MOD_PLSQL bug3138808*/
291 END OpenPO;
292 
293 PROCEDURE GetPOUrl(    itemtype        in varchar2,
294                         itemkey         in varchar2,
295                         actid           in number,
296                         funcmode        in varchar2,
297                         resultout       out NOCOPY varchar2) IS
298 l_po_distribution_id    number;
299 l_wip_entity_id         number;
300 l_operation_seq_num     number;
301 l_organization_id       number;
302 l_rep_schedule_id       number;
303 l_url                   varchar2(1000);
304 l_session_id            varchar2(300);
305 l_org_id                number;
306 BEGIN
307 
308   if (funcmode = 'RUN') then
309 
310      l_po_distribution_id := wf_engine.GetItemAttrNumber(
311                                 itemtype  => itemtype,
312                                 itemkey   => itemkey,
313                                 aname  => 'PO_DISTRIBUTION_ID');
314 
315      l_wip_entity_id := wf_engine.GetItemAttrNumber(
316                                 itemtype  => itemtype,
317                                 itemkey   => itemkey,
318                                 aname  => 'WIP_ENTITY_ID');
319 
320      l_operation_seq_num := wf_engine.GetItemAttrNumber(
321                                 itemtype  => itemtype,
322                                 itemkey   => itemkey,
323                                 aname  => 'WIP_OP_SEQ');
324 
325      l_organization_id := wf_engine.GetItemAttrNumber(
326                                 itemtype  => itemtype,
327                                 itemkey   => itemkey,
328                                 aname  => 'ORGANIZATION_ID');
329 
330      l_rep_schedule_id := wf_engine.GetItemAttrNumber(
331                                 itemtype  => itemtype,
332                                 itemkey   => itemkey,
333                                 aname  => 'REP_SCHEDULE_ID');
334 
335      l_org_id := wf_engine.GetItemAttrNumber(
336                                 itemtype  => itemtype,
337                                 itemkey   => itemkey,
338                                 aname  => 'ORG_ID');
339 
340      if l_org_id is not NULL then
341         l_url := icx_sec.jumpIntoFunction(
342                 p_application_id        => 178,
343                 p_function_code         => 'ICX_OPEN_PO',
344                 p_parameter1            => to_char(l_po_distribution_id),
345                 p_parameter2            => to_char(l_wip_entity_id),
346                 p_parameter3            => to_char(l_operation_seq_num),
347                 p_parameter4            => to_char(l_organization_id),
348                 p_parameter5            => to_char(l_rep_schedule_id),
349                 p_parameter11           => to_char(l_org_id) );
350      else
351          l_url := icx_sec.jumpIntoFunction(
352                 p_application_id        => 178,
353                 p_function_code         => 'ICX_OPEN_PO',
354                 p_parameter1            => to_char(l_po_distribution_id),
355                 p_parameter2            => to_char(l_wip_entity_id),
356                 p_parameter3            => to_char(l_operation_seq_num),
357                 p_parameter4            => to_char(l_organization_id),
358                 p_parameter5            => to_char(l_rep_schedule_id),
359                 p_parameter11           => NULL );
360      end if;
361 
362      wf_engine.SetItemAttrText (itemtype        => itemtype,
363                                 itemkey         => itemkey,
364                                 aname           => 'PO_NUM_URL',
365                                 avalue          => l_url );
366 
367      resultout := 'COMPLETE:';
368      return;
369   end if;
370 
371   if (funcmode = 'CANCEL') then
372     resultout := 'COMPLETE:';
373     return;
374   end if;
375 
376   if (funcmode = 'TIMEOUT') then
377     resultout := 'COMPLETE:';
378     return;
379   end if;
380 
381 EXCEPTION
382   when others then
383     wf_core.context('WIP_COMMON_WF_PKG',  'GetPOUrl',
384         itemtype, itemkey, actid, funcmode);
385     raise;
386 
387 END GetPOUrl;
388 
389 
390 END wip_common_wf_pkg;