1 PACKAGE BODY OE_RLM_WF as
2 /* $Header: OEXWRLMB.pls 120.0 2005/06/01 02:21:33 appldev noship $ */
3
4
5 procedure CHECK_AUTHORIZE_TO_SHIP(
6 itemtype in varchar2,
7 itemkey in varchar2,
8 actid in number,
9 funcmode in varchar2,
10 resultout in out nocopy varchar2 /* file.sql.39 change */
11 )
12 is
13 l_line_id NUMBER := NULL;
14 l_header_id NUMBER := NULL;
15 l_msg_count NUMBER := 0;
16 l_msg_data VARCHAR2(2000);
17 l_result_out VARCHAR2(30);
18 l_return_status VARCHAR2(30);
19 l_wf_item VARCHAR2(8);
20 l_wf_activity VARCHAR2(30);
21 l_authorized_to_ship_flag VARCHAR2(1);
22 l_line_rec oe_order_pub.line_rec_type;
23 --
24 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
25 --
26 begin
27 --
28 -- RUN mode - normal process execution
29 --
30 if (funcmode = 'RUN') then
31
32 OE_STANDARD_WF.Set_Msg_Context(actid);
33
34 -- Retrieving the order header_id/line_id based on the current
35 -- workflow(itemtype)
36 IF itemtype = 'OEOL' THEN
37
38 l_line_id := to_number(itemkey);
39 oe_line_util.query_row
40 (p_line_id => l_line_id
41 ,x_line_rec => l_line_rec );
42
43 OE_MSG_PUB.set_msg_context(
44 p_entity_code => 'LINE'
45 ,p_entity_id => l_line_rec.line_id
46 ,p_header_id => l_line_rec.header_id
47 ,p_line_id => l_line_rec.line_id
48 ,p_order_source_id => l_line_rec.order_source_id
49 ,p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
50 ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
51 ,p_orig_sys_shipment_ref => l_line_rec.orig_sys_shipment_ref
52 ,p_change_sequence => l_line_rec.change_sequence
53 ,p_source_document_type_id => l_line_rec.source_document_type_id
54 ,p_source_document_id => l_line_rec.source_document_id
55 ,p_source_document_line_id => l_line_rec.source_document_line_id );
56
57 /* SELECT header_id
58 INTO l_header_id
59 FROM oe_order_lines
60 WHERE line_id = l_line_id; */
61
62 l_header_id := l_line_rec.header_id;
63 IF l_debug_level > 0 THEN
64 oe_debug_pub.add( 'HEADERID:' || TO_CHAR ( L_HEADER_ID ) ) ;
65 END IF;
66
67 -- Retrieving internal name and itemtype of the parent process.
68 -- XX Do we need this
69 /*
70 SELECT PARENT.ACTIVITY_ITEM_TYPE, PARENT.ACTIVITY_NAME
71 INTO l_wf_item, l_wf_activity
72 FROM WF_ITEM_ACTIVITY_STATUSES IAS,
73 WF_PROCESS_ACTIVITIES CHILD,
74 WF_PROCESS_ACTIVITIES PARENT
75 WHERE CHILD.INSTANCE_ID = actid
76 AND CHILD.PROCESS_ITEM_TYPE = PARENT.ACTIVITY_ITEM_TYPE
77 AND CHILD.PROCESS_NAME = PARENT.ACTIVITY_NAME
78 AND PARENT.INSTANCE_ID = IAS.PROCESS_ACTIVITY
79 AND IAS.ITEM_TYPE = itemtype
80 AND IAS.ITEM_KEY = itemkey;
81 */
82 BEGIN
83 SELECT nvl(AUTHORIZED_TO_SHIP_FLAG, 'Y')
84 into l_authorized_to_ship_flag
85 FROM oe_order_lines
86 WHERE line_id = l_line_id;
87
88 IF l_debug_level > 0 THEN
89 oe_debug_pub.add( 'AUTHORIZED_TO_SHIP_FLAG:'||L_AUTHORIZED_TO_SHIP_FLAG ) ;
90 END IF;
91 if l_authorized_to_ship_flag = 'Y' then
92 resultout := 'COMPLETE:Y';
93 else
94 resultout := 'COMPLETE:N';
95 end if;
96
97 EXCEPTION
98 WHEN NO_DATA_FOUND THEN
99 IF l_debug_level > 0 THEN
100 oe_debug_pub.add( 'NO DATA FOUND FOR AUTHORIZED_TO_SHIP_FLAG' ) ;
101 END IF;
102 resultout := 'INCOMPLETE:N';
103 raise program_error;
104 WHEN OTHERS THEN
105 IF l_debug_level > 0 THEN
106 oe_debug_pub.add( 'ERROR FOR AUTHORIZED_TO_SHIP_FLAG' ) ;
107 END IF;
108 resultout := 'INCOMPLETE:N';
109 raise program_error;
110 END;
111
112
113 return;
114
115 END IF; -- end for the itemtype check
116 end if; -- End for 'RUN' mode
117 --
118 -- CANCEL mode - activity 'compensation'
119 --
120 -- This is an event point is called with the effect of the activity must
121 -- be undone, for example when a process is reset to an earlier point
122 -- due to a loop back.
123 --
124 if (funcmode = 'CANCEL') then
125
126 -- your cancel code goes here
127 null;
128
129 -- no result needed
130 resultout := 'COMPLETE';
131 return;
132 end if;
133
134
135 --
136 -- Other execution modes may be created in the future. Your
137 -- activity will indicate that it does not implement a mode
138 -- by returning null
139 --
140 -- resultout := '';
141 -- return;
142
143 exception
144 when others then
145 -- The line below records this function call in the error system
146 -- in the case of an exception.
147 wf_core.context('OE_RLM_WF', 'CHECK_AUTHORIZE_TO_SHIP',
148 itemtype, itemkey, to_char(actid), funcmode);
149 -- start data fix project
150 OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
151 p_itemtype => itemtype,
152 p_itemkey => itemkey);
153 OE_STANDARD_WF.Save_Messages;
154 OE_STANDARD_WF.Clear_Msg_Context;
155 -- end data fix project
156 raise;
157 end CHECK_AUTHORIZE_TO_SHIP;
158
159
160
161 END OE_RLM_WF;