[Home] [Help]
PACKAGE BODY: APPS.ICX_PO_REQS_CANCEL_SV
Source
1 PACKAGE BODY icx_po_reqs_cancel_sv AS
2 /* $Header: ICXRQCNB.pls 115.3 99/07/17 03:22:56 porting ship $*/
3
4
5 /*===========================================================================
6
7 PROCEDURE NAME: update_web_reqs_status
8
9 Parameters:
10 x_req_header_id - req header to be cancelled
11 x_req_line_id - leave null for now (we only support cancel
12 at header level; UPS will want line level)
13 x_agent_id - leave null; not used (kept for consistency)
14 x_req_doc_subtype = 'REQUISITION'
15 x_req_doc_subtype = po_requistion_headers.type_lookup_code
16 x_req_control_action = 'CANCEL'
17 x_req_control_reason - user entered reason for cancel
18 x_req_control_date - date of cancellation (pass sysdate
19 if not specified by user)
20 x_encumbrance_flag - pass null (not used for now)
21 x_oe_installed_flag - pass null (not used for now)
22
23 x_req_control_error_rc - return code; only filled in
24 if there is an error
25
26 ===========================================================================*/
27
28 PROCEDURE update_web_reqs_status
29 (X_req_header_id IN NUMBER,
30 X_req_line_id IN NUMBER,
31 X_agent_id IN NUMBER,
32 X_req_doc_type IN VARCHAR2,
33 X_req_doc_subtype IN VARCHAR2,
34 X_req_control_action IN VARCHAR2,
35 X_req_control_reason IN VARCHAR2,
36 x_req_control_date IN date,
37 X_encumbrance_flag IN VARCHAR2,
38 X_oe_installed_flag IN VARCHAR2,
39 X_req_control_error_rc IN OUT VARCHAR2) IS
40
41
42 X_progress VARCHAR2(3) := NULL;
43 X_req_header_auth_status PO_REQUISITION_HEADERS.authorization_status%TYPE := NULL;
44 X_req_action_history_code PO_ACTION_HISTORY.action_code%TYPE := NULL;
45 X_supply_action VARCHAR2(50) := NULL;
46 X_supply_id NUMBER;
47
48 BEGIN
49
50 -- dbms_output.put_line('Enter update_reqs_status');
51
52 X_progress := '000';
53 X_req_control_error_rc := 'N';
54
55
56 SELECT authorization_status
57 INTO X_req_header_auth_status
58 FROM PO_REQUISITION_HEADERS
59 WHERE requisition_header_id = X_req_header_id;
60
61
62 /*
63 ** Call maintain_supply to set:
64 ** 1. Req header: quantity in mtl_supply to 0 for a given req header
65 ** 2. Req line: quantity in mtl_supply to 0 for a given req line.
66 **
67 ** DEBUG: The maintain_supply used in this server package is
68 ** for testing. It should be moved to the maintain_supply server
69 ** package when it is ready.
70 */
71
72
73 X_progress := '010';
74 IF X_req_header_auth_status = 'APPROVED' THEN
75
76 IF X_req_line_id IS NULL THEN
77 X_supply_action := 'Remove_Req_Supply';
78 X_supply_id := X_req_header_id;
79 ELSE
80 X_supply_action := 'Remove_Req_Line_Supply';
81 X_supply_id := X_req_line_id;
82 END IF;
83
84 icx_po_reqs_cancel_sv.icx_maintain_supply (X_supply_action,
85 X_supply_id,
86 X_req_control_error_rc);
87
88 END IF;
89
90
91 X_progress := '020';
92 UPDATE PO_REQUISITION_LINES
93 SET cancel_flag = 'Y',
94 cancel_date = nvl(X_req_control_date, cancel_date),
95 cancel_reason = nvl(X_req_control_reason, cancel_reason)
96 WHERE requisition_header_id = X_req_header_id
97 AND nvl(cancel_flag, 'N') IN ('N', 'I')
98 AND nvl(closed_code, 'OPEN') <> 'FINALLY CLOSED';
99
100
101 X_req_action_history_code := NULL;
102
103 IF SubStr(X_req_control_action,1,6) = 'CANCEL' THEN
104 X_req_action_history_code := SubStr(X_req_control_action,1,6);
105 ELSE
106 X_req_action_history_code := X_req_control_action;
107 END IF;
108
109
110 X_progress := '030';
111 UPDATE PO_REQUISITION_HEADERS
112 SET authorization_status = 'CANCELLED'
113 WHERE requisition_header_id = X_req_header_id;
114
115 IF X_req_action_history_code IS NOT NULL THEN
116
117 IF X_req_header_auth_status = 'IN PROCESS' OR
118 X_req_header_auth_status = 'PRE-APPROVED' THEN
119 po_forward_sv1.update_action_history (X_req_header_id,
120 X_req_doc_type,
121 NULL,
122 X_req_action_history_code,
123 X_req_control_reason,
124 fnd_global.user_id,
125 null);
126 ELSE
127
128 po_forward_sv1.insert_action_history (X_req_header_id,
129 X_req_doc_type,
130 X_req_doc_subtype,
131 NULL,
132 X_req_action_history_code,
133 sysdate,
134 X_agent_id,
135 NULL,
136 X_req_control_reason,
137 NULL,
138 NULL,
139 NULL,
140 NULL,
141 NULL,
142 NULL,
143 fnd_global.user_id,
144 null);
145 END IF;
146
147
148 END IF;
149
150 -- dbms_output.put_line('Exit update_reqs_status');
151
152
153 EXCEPTION
154 WHEN OTHERS THEN
155 po_message_s.sql_error('update_reqs_status', x_progress, sqlcode);
156 RAISE;
157
158 END update_web_reqs_status;
159
160
161 /*===========================================================================
162
163 PROCEDURE NAME: maintain_supply
164
165 ===========================================================================*/
166
167 PROCEDURE icx_maintain_supply
168 (X_supply_action IN VARCHAR2,
169 X_supply_id IN NUMBER,
170 X_req_control_error_rc IN OUT VARCHAR2) IS
171
172 X_progress VARCHAR2(3) := NULL;
173
174 BEGIN
175
176 -- dbms_output.put_line('Enter maintain_supply');
177 X_req_control_error_rc := '';
178
179 IF X_supply_action = 'Remove_Req_Supply' THEN
180 X_progress := '005';
181
182 /*
183 ** Sets the req quantity in mtl_supply to 0 for a given req header.
184 */
185
186 UPDATE MTL_SUPPLY
187 SET quantity = 0,
188 change_flag = 'Y'
189 WHERE supply_type_code = 'REQ'
190 AND req_header_id = X_supply_id;
191
192
193 ELSIF X_supply_action = 'Remove_Req_Line_Supply' THEN
194 X_progress := '010';
195
196 /*
197 ** Sets the req quantity in mtl_supply to 0 for a given req line.
198 */
199
200 UPDATE mtl_supply
201 SET quantity = 0,
202 change_flag = 'Y'
203 WHERE supply_type_code = 'REQ'
204 AND req_line_id = X_supply_id;
205 END IF;
206
207 -- dbms_output.put_line('Exit maintain_supply');
208
209 EXCEPTION
210 WHEN NO_DATA_FOUND THEN
211 X_req_control_error_rc := '';
212 WHEN OTHERS THEN
213 X_req_control_error_rc := 'Y';
214 po_message_s.sql_error('maintain_supply', x_progress, sqlcode);
215 RAISE;
216
217 END icx_maintain_supply;
218
219
220 END icx_po_reqs_cancel_sv;
221