SELECT DISTINCT
prh.creation_date req_creation_date,
prh.segment1 req_number,
gl.SEGMENT3 COST_CENTER,
hp.full_name REQUESTOR,
lp.full_name PREPARER_NAME,
gl.SEGMENT1 COMPANY,
cat.segment1 category,
(prl.unit_price* prl.quantity) requisition_amount,
prh.AUTHORIZATION_STATUS,
poh.segment1 po_number,
pv.vendor_name vendor,
poh.AUTHORIZATION_STATUS PO_STATUS,
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 0
) ||' BY ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 0
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 1
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 1
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 2
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 2
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 3
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 3
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 4
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 4
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 5
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 5
)
APPROVAL_FLOW
FROM
apps.PO_REQUISITION_HEADERS_ALL prh,
apps.PO_REQUISITION_LINES_ALL prl,
apps.PO_REQ_DISTRIBUTIONS_ALL prd,
apps.per_all_people_f hp ,
apps.per_all_people_f lp ,
apps.po_distributions_all pod,
apps.po_lines_all pol,
apps.po_headers_all poh,
apps.po_vendors pv,
apps.GL_CODE_COMBINATIONS GL,
apps.MTL_CATEGORIES CAT
WHERE
prh.org_id = 182
AND prh.segment1 = NVL(:REQ_NUMBER,prh.segment1)
AND prh.creation_date BETWEEN TRUNC(to_date(:P_FROM_DATE,
'YYYY/MM/DD HH24:MI:SS')) AND TRUNC(to_date(:P_TO_DATE,
'YYYY/MM/DD HH24:MI:SS'))
AND prh.preparer_id = NVL(:CREATED_BY,prh.preparer_id)
AND prh.REQUISITION_HEADER_ID = prl.REQUISITION_HEADER_ID
AND prl.REQUISITION_LINE_ID = prd.REQUISITION_LINE_ID
AND prh.preparer_id = hp.person_id
AND prl.to_person_id = lp.person_id
AND prd.distribution_id = pod.req_distribution_id (+)
AND pod.po_line_id = pol.po_line_id (+)
AND pod.PO_HEADER_ID = poh.PO_HEADER_ID (+)
AND poh.vendor_id = pv.vendor_id (+)
AND prd.code_combination_id = gl.code_combination_id
AND prl.category_id = cat.category_id
AND prh.AUTHORIZATION_STATUS <> 'SYSTEM_SAVED'
ORDER BY
prh.creation_date;
prh.creation_date req_creation_date,
prh.segment1 req_number,
gl.SEGMENT3 COST_CENTER,
hp.full_name REQUESTOR,
lp.full_name PREPARER_NAME,
gl.SEGMENT1 COMPANY,
cat.segment1 category,
(prl.unit_price* prl.quantity) requisition_amount,
prh.AUTHORIZATION_STATUS,
poh.segment1 po_number,
pv.vendor_name vendor,
poh.AUTHORIZATION_STATUS PO_STATUS,
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 0
) ||' BY ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 0
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 1
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 1
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 2
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 2
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 3
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 3
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 4
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 4
) ||' -> ' ||
(
SELECT app.action_code
FROM apps.PO_ACTION_HISTORY app
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.sequence_num = 5
) ||' -> ' ||
(
SELECT DISTINCT per.full_name
FROM apps.PO_ACTION_HISTORY app,
apps.PER_PEOPLE_V7 per,
apps.PER_ASSIGNMENTS_V7 dep
WHERE prh.REQUISITION_HEADER_ID = app.object_id (+)
AND app.employee_id = per.person_id(+)
AND per.person_id = dep.person_id(+)
AND sequence_num = 5
)
APPROVAL_FLOW
FROM
apps.PO_REQUISITION_HEADERS_ALL prh,
apps.PO_REQUISITION_LINES_ALL prl,
apps.PO_REQ_DISTRIBUTIONS_ALL prd,
apps.per_all_people_f hp ,
apps.per_all_people_f lp ,
apps.po_distributions_all pod,
apps.po_lines_all pol,
apps.po_headers_all poh,
apps.po_vendors pv,
apps.GL_CODE_COMBINATIONS GL,
apps.MTL_CATEGORIES CAT
WHERE
prh.org_id = 182
AND prh.segment1 = NVL(:REQ_NUMBER,prh.segment1)
AND prh.creation_date BETWEEN TRUNC(to_date(:P_FROM_DATE,
'YYYY/MM/DD HH24:MI:SS')) AND TRUNC(to_date(:P_TO_DATE,
'YYYY/MM/DD HH24:MI:SS'))
AND prh.preparer_id = NVL(:CREATED_BY,prh.preparer_id)
AND prh.REQUISITION_HEADER_ID = prl.REQUISITION_HEADER_ID
AND prl.REQUISITION_LINE_ID = prd.REQUISITION_LINE_ID
AND prh.preparer_id = hp.person_id
AND prl.to_person_id = lp.person_id
AND prd.distribution_id = pod.req_distribution_id (+)
AND pod.po_line_id = pol.po_line_id (+)
AND pod.PO_HEADER_ID = poh.PO_HEADER_ID (+)
AND poh.vendor_id = pv.vendor_id (+)
AND prd.code_combination_id = gl.code_combination_id
AND prl.category_id = cat.category_id
AND prh.AUTHORIZATION_STATUS <> 'SYSTEM_SAVED'
ORDER BY
prh.creation_date;
Thanks for sharing this blog. The content is beneficial and useful. Very informative post. Visit here to learn more about Data Mining companies and Data analytics Companies.
ReplyDelete