I am trying to create a report for giving the approval limits based on the organisation that employees work for however have hit a problem I think possibly with the way the data is set up in our organization but I can't seem to find a way around it. The report needs to display the employee (from per_all_people_f), their job (from per_jobs), their approval limit (from po_control_rules) and the name of the control group (from po_control_groups_all). You need to go through the table 'po_position_controls_all' in order to link per_jobs to po_control_rules and its this table I think which is causing the issue because of a one-many relationship between jobs and control groups.
The below SQL:
select PJ.JOB_ID, PJ.name, PPCA.CONTROL_GROUP_ID, PPCA.ORG_ID, PCR.AMOUNT_LIMIT, PCGA.CONTROL_GROUP_NAME, PCGA.ORG_ID
from APPS.PER_JOBS PJ
inner join APPS.PO_POSITION_CONTROLS_ALL PPCA on PPCA.JOB_ID = PJ.JOB_ID
inner join APPS.PO_CONTROL_RULES PCR on PCR.CONTROL_GROUP_ID = PPCA.CONTROL_GROUP_ID
inner join APPS.PO_CONTROL_GROUPS_ALL PCGA on PCGA.CONTROL_GROUP_ID = PPCA.CONTROL_GROUP_ID
and PJ.name = 'Job A'
and PPCA.CONTROL_FUNCTION_ID = 1
and PCR.OBJECT_CODE = 'DOCUMENT_TOTAL'
and PCGA.ENABLED_FLAG = 'Y'
Gives a result like this: (I have simplified the data and note that there are many jobs and UP TO 3 approval groups per job (as we have 3 organisations but there may be one or 2))
JOB_ID | NAME | CONTROL_GROUP_ID | ORG_ID | AMOUNT_LIMIT | CONTROL_GROUP_NAME | ORG_ID_1
1 | Job A | 11 | 1 | 100 | Approval Level 100 | 1
1 | Job A | 12 | 2 | 200 | Approval Level 200 | 2
1 | Job A | 13 | 3 | 300 | Approval Level 300 | 3
Now I am guessing although haven't looked in to it yet that the way it works in the application when approving a PO it will see which org the PO is for (a column in the PO tables) so cross referencing that with the job id of the approver it will be able to get a single "amount limit" they can approve up to however in the report I don't have this context so if I have some employee data like this:
Employee Name | JOB_ID | Who they approve PO's for (org)
Bob | 1 | 1,2
Paul | 1 | 1
Harry | 1 | 3
Terry | 1 | 2
If i write a query for my report no matter what "org_id" I supply it (for PPCA or PCGA) it will always return all 4 employees, however I want to be able to get back that for org 1 Bob and Paul approve them (with a limit of 100) and for org 2 Bob and Terry approve (with a limit of 200) and for org 3 Harry approves (with a limit of 300)
Edited by: pnj on 15-Nov-2012 07:17
Hi pskumar, thanks for your reply. Unfortunately the orgnaization_id in per_all_assignments_f is populated by the business unit which the 3 different organisations are under. Basically (other than looking at a person's responsbilities which doesnt have an organization_id on either) there doesn't seem to be way of establishing who works for each organization. I've seen some trends, like their address, or their cost centre but it isn't accurate enough.
I am unsure of the organization setuo you are mentioning. Normally when you create a approval group the organization gets populated will be same as the ones you get in people assignment form isn't it? These are of HR organization type. So ideally the organization_id in per_all_people_f and PO_POSITION_CONTROLS_ALL should match. I am sorry if this is isn't useful.
I'm not 100% sure myself what it is here, am quite new to e-business suite/schema. No organization id on per_all_people_f though, there is a business_group_id, which matches that in per_assignments but not the org ids in the PO_POSITION_CONTROLS_ALL table.
can you post the results of these two:
select business_group_id, organization_id, job_id, position_id from per_all_assignments_f where assignment_id=
select org_id, organization_id from PO_POSITION_CONTROLS_ALL where job_id= and position_id=