The following lines contain the word 'select', 'insert', 'update' or 'delete':
PROCEDURE update_action_history (p_action_code IN VARCHAR2,
p_recipient_id IN NUMBER,
p_note IN VARCHAR2,
p_po_header_id IN NUMBER,
p_current_id IN NUMBER,
p_doc_type IN po_action_history.OBJECT_TYPE_CODE%TYPE,
p_doc_subtype IN po_action_history.OBJECT_SUB_TYPE_CODE%TYPE,
p_approval_path_id IN po_action_history.APPROVAL_PATH_ID%TYPE, --
p_draft_id IN NUMBER,
p_draft_type IN VARCHAR2); -- PAR Approval
Old tax select:
SELECT nvl(sum(nonrecoverable_tax), 0)
INTO l_tax_amt
FROM po_lines pol,
po_distributions pod
WHERE pol.po_header_id = l_document_id
AND pod.po_line_id = pol.po_line_id;
SELECT sum( round (POD.nonrecoverable_tax *
decode(quantity_ordered,
NULL,
--Bug16222308 Handling the quantity zero on distribution
(nvl(POD.amount_ordered,0) - nvl(POD.amount_cancelled,0)) / decode ( nvl(POD.amount_ordered, 1),0,1,nvl(POD.amount_ordered, 1) ) ,
(nvl(POD.quantity_ordered,0) - nvl(POD.quantity_cancelled,0)) / decode ( nvl(POD.quantity_ordered, 1),0,1, nvl(POD.quantity_ordered, 1) )
) / X_min_acct_unit
) * X_min_acct_unit
)
INTO l_tax_amt
FROM po_lines pol,
po_distributions pod
WHERE pol.po_header_id = l_document_id
AND pod.po_line_id = pol.po_line_id;
SELECT sum( round (POD.nonrecoverable_tax *
decode(quantity_ordered,
NULL,
--Bug16222308 Handling the quantity zero on distribution
(nvl(POD.amount_ordered,0) - nvl(POD.amount_cancelled,0)) / decode ( nvl(POD.amount_ordered, 1),0,1,nvl(POD.amount_ordered, 1) ) ,
(nvl(POD.quantity_ordered,0) - nvl(POD.quantity_cancelled,0)) / decode ( nvl(POD.quantity_ordered, 1),0,1, nvl(POD.quantity_ordered, 1) )
),
X_precision
)
)
INTO l_tax_amt
FROM po_lines pol,
po_distributions pod
WHERE pol.po_header_id = l_document_id
AND pod.po_line_id = pol.po_line_id;
SELECT pol.line_num,
msi.concatenated_segments,
pol.item_revision,
pol.item_description,
-- pol.unit_meas_lookup_code, -- bug 2401933.remove
nvl(muom.unit_of_measure_tl, pol.unit_meas_lookup_code), -- bug 2401933.add
pol.quantity,
pol.unit_price,
nvl(pol.amount, pol.quantity * pol.unit_price),
pol.CLM_OPTION_NUM,
po2.LINE_NUM_DISPLAY --Base line num
-- ,pol.contract_type
,lkp1.description
,pol.LINE_NUM_DISPLAY
FROM po_lines_all pol, --CLM Apprvl
po_lines_all po2, -- CLM Apprvl
po_lookup_codes lkp1,
mtl_system_items_kfv msi,
mtl_units_of_measure muom, -- bug 2401933.add
financials_system_parameters fsp
WHERE pol.po_header_id = v_document_id
AND lkp1.lookup_code(+) = pol.contract_type
AND lkp1.lookup_type(+) = decode(pol.order_type_lookup_code,
'QUANTITY', 'PO_FEDERAL_CONTRACT_TYPES_QTY',
'PO_FEDERAL_CONTRACT_TYPES_AMT')
AND pol.item_id = msi.inventory_item_id(+)
AND NVL(msi.organization_id, fsp.inventory_organization_id) =
fsp.inventory_organization_id
/* Bug 2299484 fixed. prevented the canceled lines to be displayed
in notifications.
*/
AND NVL(pol.cancel_flag,'N') = 'N'
AND muom.unit_of_measure (+) = pol.unit_meas_lookup_code -- bug 2401933.add
AND pol.CLM_BASE_LINE_NUM = po2.PO_LINE_ID(+)
ORDER BY pol.LINE_NUM_DISPLAY;
SELECT pol.line_num,
msi.concatenated_segments,
pol.item_revision,
pol.item_description,
-- pol.unit_meas_lookup_code, -- bug 2401933.remove
nvl(muom.unit_of_measure_tl, pol.unit_meas_lookup_code), -- bug 2401933.add
pol.quantity,
pol.unit_price,
nvl(pol.amount, pol.quantity * pol.unit_price),
pol.CLM_OPTION_NUM,
po2.LINE_NUM_DISPLAY --Base line num
-- ,pol.contract_type
,lkp1.description
,pol.LINE_NUM_DISPLAY
FROM po_lines_draft_all pol, --CLM Apprvl
po_lines_draft_all po2, -- CLM Apprvl
po_lookup_codes lkp1,
mtl_system_items_kfv msi,
mtl_units_of_measure muom, -- bug 2401933.add
financials_system_parameters fsp
WHERE pol.po_header_id = v_document_id
AND nvl(pol.draft_id, -1) = nvl(v_draft_id, -1)
AND lkp1.lookup_code(+) = pol.contract_type
AND lkp1.lookup_type(+) = decode(pol.order_type_lookup_code,
'QUANTITY', 'PO_FEDERAL_CONTRACT_TYPES_QTY',
'PO_FEDERAL_CONTRACT_TYPES_AMT')
AND pol.item_id = msi.inventory_item_id(+)
AND NVL(msi.organization_id, fsp.inventory_organization_id) =
fsp.inventory_organization_id
/* Bug 2299484 fixed. prevented the canceled lines to be displayed
in notifications.
*/
AND NVL(pol.cancel_flag,'N') = 'N'
AND muom.unit_of_measure (+) = pol.unit_meas_lookup_code -- bug 2401933.add
AND pol.CLM_BASE_LINE_NUM = po2.PO_LINE_ID(+)
ORDER BY pol.LINE_NUM_DISPLAY;
SELECT pll.shipment_num,
msi.concatenated_segments,
pol.item_revision,
pol.item_description,
-- Bug 2401933.start
-- nvl(pll.unit_meas_lookup_code, pol.unit_meas_lookup_code)
-- unit_meas_lookup_code,
nvl(muom.unit_of_measure_tl, pol.unit_meas_lookup_code),
-- Bug 2401933.end
pll.quantity,
nvl(pll.price_override, pol.unit_price) unit_price,
hrl.location_code,
ood.organization_name,
pll.need_by_date,
pll.promised_date,
pll.shipment_type,
--Bug 4950850 Added pll.amount
--Bug 5563024 AMOUNT NOT SHOWN FOR A RELEASE SHIPMENT IN APPROVAL NOTIFICATION.
nvl(pll.amount, nvl(pll.price_override, pol.unit_price) * pll.quantity)
FROM po_lines_all pol, -- CLM apprvl
po_line_locations_all pll, -- CLM apprvl
mtl_system_items_kfv msi,
hr_locations_all hrl,
hz_locations hz,
org_organization_definitions ood,
mtl_units_of_measure muom, -- Bug 2401933.add
financials_system_parameters fsp
where PLL.PO_RELEASE_ID = v_document_id
and PLL.po_line_id = POL.po_line_id
and PLL.ship_to_location_id = HRL.location_id (+)
and PLL.ship_to_location_id = HZ.location_id (+)
and PLL.ship_to_organization_id = OOD.organization_id
and pol.item_id = msi.inventory_item_id(+)
and NVL(msi.organization_id, fsp.inventory_organization_id) =
fsp.inventory_organization_id
/* Bug 2299484 fixed. prevented the canceled shipments to be displayed
in notifications.
*/
AND NVL(PLL.cancel_flag,'N') = 'N'
AND muom.unit_of_measure (+) = pol.unit_meas_lookup_code -- Bug 2401933.add
order by Shipment_num asc;
SELECT 'Y' into l_clm_document
FROM po_headers_all h,
po_doc_style_headers s
WHERE h.po_header_id = l_document_id
AND h.style_id = s.style_id
AND Nvl(s.clm_flag,'N') = 'Y';
SELECT poh.SEQUENCE_NUM,
per.FULL_NAME,
polc.DISPLAYED_FIELD,
poh.ACTION_DATE,
poh.NOTE,
poh.OBJECT_REVISION_NUM,
poh.employee_id, /* bug 2788683 */
poh.created_by /* bug 2788683 */
from po_action_history poh,
per_all_people_f per, -- Bug 3404451
po_lookup_codes polc
where OBJECT_TYPE_CODE = v_doc_type_code
and poh.object_sub_type_code = v_doc_sub_type_code
and poh.action_code = polc.lookup_code
and POLC.LOOKUP_TYPE IN ('APPROVER ACTIONS','CONTROL ACTIONS')
and per.person_id(+) = poh.employee_id /* bug 2788683 */
and trunc(sysdate) between per.effective_start_date(+)
and per.effective_end_date(+)
and OBJECT_ID = v_document_id
UNION ALL
SELECT poh.SEQUENCE_NUM,
per.FULL_NAME,
NULL,
poh.ACTION_DATE,
poh.NOTE,
poh.OBJECT_REVISION_NUM,
poh.employee_id, /* bug 2788683 */
poh.created_by /* bug 2788683 */
from po_action_history poh,
per_all_people_f per -- Bug 3404451
where OBJECT_TYPE_CODE = v_doc_type_code
and poh.object_sub_type_code = v_doc_sub_type_code
and poh.action_code is null
and per.person_id(+) = poh.employee_id /* bug 2788683 */
and trunc(sysdate) between per.effective_start_date(+)
and per.effective_end_date(+)
and OBJECT_ID = v_document_id
order by 1 desc;
/* if action history is updated by vendor
* show vendor true name(vendor name)
* else action history is updated by buyer
* show buyer's true name
*/
IF l_employee_id_tbl(i) IS NULL THEN
BEGIN --
SELECT fu.user_name,
hp.party_name
INTO l_user_name,
l_party_name
FROM fnd_user fu,
hz_parties hp
WHERE hp.party_id = fu.customer_id
AND fu.user_id = l_created_by_tbl(i);
/* if action history is updated by vendor
* show vendor true name(vendor name)
* else action history is updated by buyer
* show buyer's true name
*/
IF l_employee_id_tbl(i) IS NULL THEN
BEGIN --
SELECT fu.user_name, hp.party_name
INTO l_user_name, l_party_name
FROM fnd_user fu,
hz_parties hp
WHERE hp.party_id = fu.customer_id
AND fu.user_id = l_created_by_tbl(i);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'funcmode : '||funcmode);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_action : '||l_action);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'Document_ID : '||l_po_header_id);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'Draft_id : '||l_draft_id);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_doc_type : '||l_doc_type);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_doc_sub_type : '||l_doc_sub_type);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_draft_type : '||l_draft_type);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_origsys : '||l_origsys);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_new_recipient_id : '||l_new_recipient_id);
SELECT original_recipient,
Decode(MORE_INFO_ROLE, NULL, RECIPIENT_ROLE,MORE_INFO_ROLE)
INTO l_original_recipient, l_current_recipient_role
FROM wf_notifications
WHERE
notification_id = WF_ENGINE.context_nid
AND ( MORE_INFO_ROLE IS NOT NULL OR RECIPIENT_ROLE <> ORIGINAL_RECIPIENT );
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_original_recipient : '||l_original_recipient);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_current_recipient_role : '||l_current_recipient_role);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'Before executing update_action_history');
update_action_history(p_action_code => l_action,
p_recipient_id => l_new_recipient_id,
p_note => WF_ENGINE.CONTEXT_USER_COMMENT,
p_po_header_id => l_po_header_id,
p_current_id => l_current_recipient_id,
p_doc_type => l_doc_type,
p_doc_subtype => l_doc_sub_type,
p_approval_path_id => NULL, --
p_draft_id => l_draft_id,
p_draft_type => l_draft_type);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'After executing update_action_history');
SELECT fu.USER_ID
INTO l_responder_id
FROM fnd_user fu,
wf_notifications wfn
WHERE wfn.notification_id = l_nid
AND wfn.original_recipient = fu.user_name;
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_respond_action_text: ' || l_respond_action_text);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_orgid: ' || l_orgid);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_forward_to_username_response: ' || l_forward_to_username_response);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_forward_to_username: ' || l_forward_to_username);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_preparer_id: ' || l_preparer_id ||
', x_user_id: ' || x_user_id);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,
'l_preparer_id: ' || l_preparer_id ||
', x_CanOwnerApproveFlag: ' || x_CanOwnerApproveFlag);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
** Here the logic to update the action code in action history.
** The insert action is still performed in PO_DOCUMENT_ACTION_UTIL.handle_auth_action_history.
*/
l_progress := '006 PO_WF_PO_NOTIFICATION.post_approval_notif';
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
** Update action history for APPROVE_AND_FORWARD
** even when the forward-to person is invalid.
*/
IF (l_respond_action_text in ('APPROVE','APPROVE_AND_FORWARD'))
OR (l_respond_action_text = 'FORWARD' AND l_is_forward_valid = TRUE) THEN
IF l_respond_action_text = 'FORWARD' THEN
l_action := 'FORWARD';
l_progress := '007 start to update action history';
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_action : ' || l_action ||
', l_po_header_id: ' || l_po_header_id ||
', l_draft_id: ' || l_draft_id ||
', l_draft_type: ' || l_draft_type ||
', l_current_recipient_id: ' || l_current_recipient_id);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,'l_note: ' || l_note);
update_action_history(p_action_code => l_action,
p_recipient_id => NULL,
p_note => l_note,
p_po_header_id => l_po_header_id,
p_current_id => l_current_recipient_id,
p_doc_type=> l_doc_type,
p_doc_subtype => l_doc_sub_type,
p_approval_path_id => l_approval_path_id,
p_draft_id => l_draft_id,
p_draft_type => l_draft_type); -- PAR Approval
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
select type_name
from po_document_types_tl tl, FND_LANGUAGES fl
where fl.nls_language = p_language
and tl.LANGUAGE = fl.language_code
and tl.document_type_code = p_doc_type
and tl.document_subtype = p_doc_subtype;
select type_name
from po_document_types
where document_type_code = p_doc_type
and document_subtype = p_doc_subtype;
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
Deleted the previous code and revamped it.
*/
--
l_document_id := PO_WF_UTIL_PKG.GetItemAttrNumber
(itemtype => itemtype,
itemkey => itemkey,
aname => 'DOCUMENT_ID');
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
SELECT language_code
INTO l_language_code
FROM fnd_languages
WHERE nls_language = l_language;
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
select message_text
into l_msg_text
from fnd_new_messages fm,fnd_languages fl
where fm.message_name = 'PO_WF_NOTIF_REQUIRES_APPROVAL'
and fm.language_code = fl.language_code
and fl.nls_language = l_language
and fm.application_id = 201; -- Include application_id to better use PK index
select message_text
into l_msg_text
from fnd_new_messages fm,fnd_languages fl
where fm.message_name = 'PO_WF_NOTIF_REQUIRES_REVIEW'
and fm.language_code = fl.language_code
and fl.nls_language = l_language
and fm.application_id = 201;
select message_text
into l_msg_text
from fnd_new_messages fm,fnd_languages fl
where fm.message_name = 'PO_WF_NOTIF_REQUIRES_ESIGN'
and fm.language_code = fl.language_code
and fl.nls_language = l_language
and fm.application_id = 201;
/* DEBUG */ PO_WF_DEBUG_PKG.insert_debug(itemtype,itemkey,l_progress);
l_progress:='000'; PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_log_head||':'||l_progress || 'Notification Type = ' || p_notification_type);
l_progress:='010'; PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_log_head||':'||l_progress||' Authorization Status = '||l_authorization_status);
PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_log_head||':'||l_progress||':FALSE');
PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_log_head||':'||l_progress||':TRUE');
PO_WF_DEBUG_PKG.insert_debug(p_itemtype,p_itemkey,l_log_head||':'||SQLERRM);
PROCEDURE update_action_history (p_action_code IN VARCHAR2,
p_recipient_id IN NUMBER,
p_note IN VARCHAR2,
p_po_header_id IN NUMBER,
p_current_id IN NUMBER,
p_doc_type IN po_action_history.OBJECT_TYPE_CODE%TYPE,
p_doc_subtype IN po_action_history.OBJECT_SUB_TYPE_CODE%TYPE,
p_approval_path_id IN PO_ACTION_HISTORY.APPROVAL_PATH_ID%TYPE, --
p_draft_id IN NUMBER,
p_draft_type IN VARCHAR2) --PAR Approval
IS
pragma AUTONOMOUS_TRANSACTION;
SELECT max(sequence_num)
INTO l_sequence_num
FROM PO_ACTION_HISTORY
WHERE object_id = l_document_id
AND object_type_code = p_doc_type
AND object_sub_type_code = l_doc_sub_type;
SELECT object_revision_num,
approval_path_id,
request_id,
program_application_id,
program_date,
program_id
INTO l_object_revision_num,
l_approval_path_id,
l_request_id,
l_program_application_id,
l_program_date,
l_program_id
FROM PO_ACTION_HISTORY
WHERE object_id = l_document_id
AND object_type_code = p_doc_type
AND object_sub_type_code = l_doc_sub_type
AND employee_id = p_current_id
AND ACTION_CODE IS NULL
AND rownum =1;
UPDATE PO_ACTION_HISTORY
SET last_update_date = sysdate,
last_updated_by = fnd_global.user_id,
last_update_login = fnd_global.login_id ,
action_date = sysdate,
action_code = p_action_code,
note = p_note,
approval_path_id = nvl(p_approval_path_id, l_approval_path_id), --
offline_code = NULL
WHERE employee_id = p_current_id
AND object_id = l_document_id
AND object_type_code = p_doc_type
AND object_sub_type_code = l_doc_sub_type
AND action_code IS NULL;
INSERT INTO PO_ACTION_HISTORY
(object_id,
object_type_code,
object_sub_type_code,
sequence_num,
last_update_date,
last_updated_by,
employee_id,
action_code,
action_date,
note,
object_revision_num,
last_update_login,
creation_date,
created_by,
request_id,
program_application_id,
program_id,
program_date,
approval_path_id,
offline_code,
program_update_date
)
VALUES (l_document_id,
p_doc_type,
l_doc_sub_type,
l_sequence_num + 1,
sysdate,
fnd_global.user_id,
p_recipient_id,
NULL,
NULL,
NULL,
l_object_revision_num,
fnd_global.login_id,
sysdate,
fnd_global.user_id,
l_request_id,
l_program_application_id,
l_program_id,
l_program_date,
l_approval_path_id,
NULL,
sysdate);
wf_core.context('PO_WF_PO_NOTIFICATION','update_action_history',l_progress,sqlerrm);