Pages

Friday, January 31, 2014

Material Transaction Type Wise (/*Internal order issue*/) transaction details

/*Internal order issue*/
SELECT DISTINCT (mmt.transaction_date) trans_date,
                        mmt.organization_id org_id,
                        (SUBSTR (msib.segment1, 1, 1)) AS item_code_series,
                        gcc.segment2, gcc.segment3, gcc.segment4,
                        msib.segment1 AS item_code, mtt.transaction_type_name,
                        mta.base_transaction_value AS VALUE,
                        mta.primary_quantity AS quantity,
                        (mta.base_transaction_value / mta.primary_quantity
                        ) AS unit_rate,
                        ooha.order_number AS reference_number,
                        REGEXP_REPLACE (msib.description,
                                        '([^[:alnum:]])',
                                        ' '
                                       ) AS item_description,
                        msib.primary_uom_code AS uom, ood.organization_id,
                        ood.organization_code, ood.organization_name,
                        gcc.segment1, gcc.segment5, gcc.segment6,
                        ppa.segment1 AS project, pt.task_number AS task
                   FROM apps.oe_order_headers_all ooha,
                        apps.oe_order_lines_all oola,
                        apps.gl_code_combinations gcc,
                        apps.xla_ae_lines xal,
                        apps.xla_ae_headers xah,
                        apps.xla_transaction_entities_upg xteu,
                        apps.mtl_material_transactions mmt,
                        apps.mtl_transaction_accounts mta,
                        apps.mtl_transaction_types mtt,
                        apps.mtl_system_items_b msib,
                        apps.pa_projects_all ppa,
                        apps.pa_tasks pt,
                        apps.org_organization_definitions ood
                  WHERE 1 = 1
                    AND mtt.transaction_type_id = 34
                    AND ooha.header_id = oola.header_id
                    AND oola.line_id = mmt.trx_source_line_id
                    AND oola.inventory_item_id = mmt.inventory_item_id
                    AND oola.ship_from_org_id = mmt.organization_id
                    AND mta.primary_quantity >= 0
                    AND gcc.segment4 IN
                           ('3021000', '3021100', '3021200', '3021300',
                            '3021400', '3021500', '3021600', '3021610',
                            '3021700')
                    AND gcc.code_combination_id = xal.code_combination_id
                    AND xal.ae_header_id = xah.ae_header_id
                    AND xah.entity_id = xteu.entity_id
                    AND xteu.source_id_int_1 = mmt.transaction_id
                    AND mta.transaction_id = mmt.transaction_id
                    AND mta.organization_id = mmt.organization_id
                    AND ood.organization_id = mmt.organization_id
                    AND mta.organization_id = ood.organization_id
                    AND mmt.transaction_type_id = mtt.transaction_type_id
                    AND mmt.inventory_item_id = msib.inventory_item_id
                    AND mmt.organization_id = msib.organization_id
                    AND SUBSTR (msib.segment1, 1, 1) IN
                                ('1', '2', '3', '4', '5', '6', '7', '8', '9')
                    AND mmt.project_id = ppa.project_id(+)
                    AND mmt.task_id = pt.task_id(+)
                    AND ood.organization_id not in (102)
                    AND trunc(mmt.transaction_date) BETWEEN :p_f_date AND :p_t_date
                    AND ood.organization_id =
                                 NVL (:p_organization_id, ood.organization_id)
                    AND gcc.segment2 = NVL (:p_cost_center, gcc.segment2)
                    AND gcc.segment3 BETWEEN NVL (:p_from_department,
                                                  gcc.segment3
                                                 )
                                         AND NVL (:p_to_department,
                                                  gcc.segment3
                                                 )
                    AND gcc.segment4 = NVL (:p_account_code, gcc.segment4)
                    AND SUBSTR (msib.segment1, 1, 1) =
                            NVL (:p_item_series, SUBSTR (msib.segment1, 1, 1))
               ORDER BY msib.segment1

Material Transaction Type Wise (/*Move order issue*/) transaction details

/*Move order issue*/
SELECT DISTINCT (mmt.transaction_date) trans_date,
                        mmt.organization_id org_id,
                        (SUBSTR (msib.segment1, 1, 1)) AS item_code_series,
                        gcc.segment2, gcc.segment3, gcc.segment4,
                        msib.segment1 AS item_code, mtt.transaction_type_name,
                        mta.base_transaction_value AS VALUE,
                        mta.primary_quantity AS quantity,
                        (mta.base_transaction_value / mta.primary_quantity
                        ) AS unit_rate,
                        DECODE (mtt.transaction_type_id,
                                63, mtrh.request_number,
                                mmt.transaction_id
                               ) AS reference_number,
                        REGEXP_REPLACE (msib.description,
                                        '([^[:alnum:]])',
                                        ' '
                                       ) AS item_description,
                        msib.primary_uom_code AS uom, ood.organization_id,
                        ood.organization_code, ood.organization_name,
                        gcc.segment1, gcc.segment5, gcc.segment6,
                        ppa.segment1 AS project, pt.task_number AS task
                   FROM apps.mtl_txn_request_headers mtrh,
                        apps.gl_code_combinations gcc,
                        apps.xla_ae_lines xal,
                        apps.xla_ae_headers xah,
                        apps.xla_transaction_entities_upg xteu,
                        apps.mtl_material_transactions mmt,
                        apps.mtl_transaction_accounts mta,
                        apps.mtl_transaction_types mtt,
                        apps.mtl_system_items_b msib,
                        apps.pa_projects_all ppa,
                        apps.pa_tasks pt,
                        apps.org_organization_definitions ood
                  WHERE 1 = 1
                    AND mtt.transaction_type_id = 63
                    AND mta.primary_quantity >= 0
                    AND mtrh.request_number = mmt.transaction_source_id
                    AND mtrh.transaction_type_id = mmt.transaction_type_id
                    AND mtrh.organization_id = mmt.organization_id
                    AND gcc.segment4 IN
                           ('3021000', '3021100', '3021200', '3021300',
                            '3021400', '3021500', '3021600', '3021610',
                            '3021700')
                    AND gcc.code_combination_id = xal.code_combination_id
                    AND xal.ae_header_id = xah.ae_header_id
                    AND xah.entity_id = xteu.entity_id
                    AND xteu.source_id_int_1 = mmt.transaction_id
                    AND mta.transaction_id = mmt.transaction_id
                    AND mta.organization_id = mmt.organization_id
                    AND ood.organization_id = mmt.organization_id
                    AND mta.organization_id = ood.organization_id
                    AND mmt.transaction_type_id = mtt.transaction_type_id
                    AND mmt.inventory_item_id = msib.inventory_item_id
                    AND mmt.organization_id = msib.organization_id
                    AND SUBSTR (msib.segment1, 1, 1) IN
                                ('1', '2', '3', '4', '5', '6', '7', '8', '9')
                    AND mmt.project_id = ppa.project_id(+)
                    AND mmt.task_id = pt.task_id(+)
                    AND ood.organization_id not in (102)
                    AND trunc(mmt.transaction_date) BETWEEN :p_f_date AND :p_t_date
                    AND ood.organization_id =
                                 NVL (:p_organization_id, ood.organization_id)
                    AND gcc.segment2 = NVL (:p_cost_center, gcc.segment2)
                    AND gcc.segment3 BETWEEN NVL (:p_from_department,
                                                  gcc.segment3
                                                 )
                                         AND NVL (:p_to_department,
                                                  gcc.segment3
                                                 )
                    AND gcc.segment4 = NVL (:p_account_code, gcc.segment4)
                    AND SUBSTR (msib.segment1, 1, 1) =
                            NVL (:p_item_series, SUBSTR (msib.segment1, 1, 1))
               ORDER BY msib.segment1

Material Transaction Type Wise(/*Wip issue*/ ) transaction details

/*Wip issue*/
SELECT DISTINCT (mmt.transaction_date) trans_date,
                        mmt.organization_id org_id,
                        (SUBSTR (msib.segment1, 1, 1)) AS item_code_series,
                        gcc.segment2, gcc.segment3, gcc.segment4,
                        msib.segment1 AS item_code, mtt.transaction_type_name,
                        mta.base_transaction_value AS VALUE,
                        mta.primary_quantity AS quantity,
                        (mta.base_transaction_value / mta.primary_quantity
                        ) AS unit_rate,
                        TO_CHAR (we.wip_entity_name) AS reference_number,
                        REGEXP_REPLACE (msib.description,
                                        '([^[:alnum:]])',
                                        ' '
                                       ) AS item_description,
                        msib.primary_uom_code AS uom, ood.organization_id,
                        ood.organization_code, ood.organization_name,
                        gcc.segment1, gcc.segment5, gcc.segment6,
                        ppa.segment1 AS project, pt.task_number AS task
                   FROM apps.gl_code_combinations gcc,
                        apps.xla_ae_lines xal,
                        apps.xla_ae_headers xah,
                        apps.xla_transaction_entities_upg xteu,
                        apps.mtl_material_transactions mmt,
                        apps.mtl_transaction_accounts mta,
                        apps.mtl_transaction_types mtt,
                        apps.mtl_system_items_b msib,
                        apps.fnd_flex_values ffv,
                        apps.wip_requirement_operations wro,
                        apps.wip_entities we,
                        apps.pa_projects_all ppa,
                        apps.pa_tasks pt,
                        apps.org_organization_definitions ood
                  WHERE 1 = 1
                    AND mtt.transaction_type_id = '35'
                    AND wro.wip_entity_id = mmt.transaction_source_id
                    AND mta.primary_quantity >= 0
                    AND wro.inventory_item_id = msib.inventory_item_id
                    AND wro.organization_id = msib.organization_id
                    AND wro.segment1 = msib.segment1
                    AND we.wip_entity_id = wro.wip_entity_id
                    AND we.organization_id = wro.organization_id
                    AND gcc.segment4 IN
                           ('3021000', '3021100', '3021200', '3021300',
                            '3021400', '3021500', '3021600', '3021610',
                            '3021700')
                    AND gcc.code_combination_id = xal.code_combination_id
                    AND ffv.flex_value = gcc.segment4
                    AND xal.ae_header_id = xah.ae_header_id
                    AND xah.entity_id = xteu.entity_id
                    AND xteu.source_id_int_1 = mmt.transaction_id
                    AND mta.transaction_id = mmt.transaction_id
                    AND mta.organization_id = mmt.organization_id
                    AND ood.organization_id = mmt.organization_id
                    AND mta.organization_id = ood.organization_id
                    AND mmt.transaction_type_id = mtt.transaction_type_id
                    AND mmt.inventory_item_id = msib.inventory_item_id
                    AND mmt.organization_id = msib.organization_id
                    AND SUBSTR (msib.segment1, 1, 1) IN
                                ('1', '2', '3', '4', '5', '6', '7', '8', '9')
                    AND mmt.project_id = ppa.project_id(+)
                    AND mmt.task_id = pt.task_id(+)
                    AND ood.organization_id not in (102)
                    AND trunc(mmt.transaction_date) BETWEEN :p_f_date AND :p_t_date
                    AND ood.organization_id =
                                 NVL (:p_organization_id, ood.organization_id)
                    AND gcc.segment2 = NVL (:p_cost_center, gcc.segment2)
                    AND gcc.segment3 BETWEEN NVL (:p_from_department,
                                                  gcc.segment3
                                                 )
                                         AND NVL (:p_to_department,
                                                  gcc.segment3
                                                 )
                    AND gcc.segment4 = NVL (:p_account_code, gcc.segment4)
                    AND SUBSTR (msib.segment1, 1, 1) =
                            NVL (:p_item_series, SUBSTR (msib.segment1, 1, 1))
               ORDER BY msib.segment1

To get data for Misc Receipt

SELECT ood.organization_code,
mmt.inventory_item_id Item_id,
msi.segment1 item_name,
mmt.creation_date,
mmt.transaction_quantity,
mmt.transaction_date,
mtt.transaction_type_name,
mmt.*
FROM mtl_material_transactions mmt,
     mtl_system_items msi,
     mtl_transaction_types mtt,
     org_organization_definitions ood
WHERE     msi.inventory_item_id = mmt.inventory_item_id
and mmt.organization_id = ood.organization_id
      AND mmt.organization_id = msi.organization_id
      AND mmt.transaction_type_id IN (100001, 100002)
      AND mtt.transaction_type_id = mmt.transaction_type_id
      AND TRUNC (mmt.transaction_date) BETWEEN :f AND :t
      AND mmt.organization_id = 81
ORDER BY mmt.transaction_date

(Payroll) To get element wise details query

select distinct to_number(papf.employee_number) as employee_number, papf.full_name,
prrv.result_value as amount, '' as numbers, null cumulative, null as org,
null as attrib1, null as attrib2, null as attrib3, null as attrib4, to_number(rownum) as slno
from
apps.per_all_people_f papf,
apps.per_all_assignments_f paaf,
apps.pay_assignment_actions paa,
apps.pay_payroll_actions ppa,
apps.hr_all_organization_units haou,
apps.pay_consolidation_sets pcs,
apps.pay_run_results prr,
apps.pay_run_result_values prrv,
apps.pay_input_values_f pivf,
apps.pay_input_values_f_tl pivft,
apps.pay_element_types_f petf,
apps.pay_element_classifications_tl pect
where
papf.person_id = paaf.person_id
and papf.EFFECTIVE_END_DATE = paaf.EFFECTIVE_END_DATE
and paaf.ASSIGNMENT_ID = paa.ASSIGNMENT_ID
and ppa.payroll_action_id = paa.payroll_action_id
and paaf.ORGANIZATION_ID = haou.ORGANIZATION_ID
and ppa.CONSOLIDATION_SET_ID = pcs.CONSOLIDATION_SET_ID
and paa.ASSIGNMENT_ACTION_ID = prr.ASSIGNMENT_ACTION_ID
and prr.RUN_RESULT_ID = prrv.RUN_RESULT_ID
and prrv.INPUT_VALUE_ID = pivf.INPUT_VALUE_ID
and pivf.ELEMENT_TYPE_ID = petf.ELEMENT_TYPE_ID
and petf.CLASSIFICATION_ID = pect.CLASSIFICATION_ID
and petf.ELEMENT_TYPE_ID = prr.ELEMENT_TYPE_ID
and pivf.INPUT_VALUE_ID = pivft.INPUT_VALUE_ID
and upper(haou.name) like upper('%'||:p_organization||'%')
--and prrv.result_value <> '0'
and ppa.payroll_id in (61, 63)
and pivft.name = 'Pay Value'
AND pivf.uom in ('M')
and papf.employee_number = nvl(:p_employee_number, papf.employee_number)
and pcs.consolidation_set_name = NVL (:p_payroll_type, pcs.consolidation_set_name)
and to_char(ppa.effective_date, 'MON-YY') = :p_from_date  
and pect.classification_id = nvl(:p_classification_name, pect.classification_id)
and petf.element_type_id = nvl(:p_element_name,petf.element_type_id)
order by employee_number;

(Payroll') To Get employee earnings and deduction

SELECT DISTINCT petf.reporting_name, prrv.result_value,
                  prrv.run_result_id, prrv.input_value_id,
                  papf.employee_number
             FROM pay_element_types_f petf,
                  pay_element_classifications_tl pect,
                  apps.pay_run_results prr,
                  pay_run_result_values prrv,
                  pay_input_values_f pivf,
                  pay_assignment_actions paa,
                  pay_payroll_actions ppa,
                  apps.pay_consolidation_sets pcs,
                  per_all_assignments_f paaf,
                  per_all_people_f papf,
                  per_grades_tl pgt,
                  apps.hr_all_organization_units haou
            WHERE prr.element_type_id = petf.element_type_id
              AND papf.effective_end_date = paaf.effective_end_date
              AND pivf.element_type_id = petf.element_type_id
              AND petf.classification_id = pect.classification_id
              AND papf.employee_number = NVL (:p_employee_number, papf.employee_number)
              AND upper(haou.name) like upper('%'||:p_organization_name||'%')
              and rtrim(substr(pgt.name,1,instr(pgt.name,'.')),'.')               nvl('Staff',rtrim(substr(pgt.name,1,instr(pgt.name,'.')),'.'))
              AND ppa.effective_date BETWEEN :p_from_date AND :p_to_date
              AND pivf.NAME = 'Pay Value'
              AND pivf.uom = 'M'
              AND pect.classification_id IN (84, 97, 98, 99, 102, 104, 106, 112, 125)
              AND petf.reporting_name NOT LIKE '%Not%to%print%'
              AND pcs.consolidation_set_name = NVL (:p_payroll_type, pcs.consolidation_set_name)
              AND prrv.run_result_id = prr.run_result_id
              AND haou.NAME LIKE ('FAC%')
              AND PPA.PAYROLL_ID IN (61, 63)
              AND prrv.input_value_id = pivf.input_value_id
              AND paaf.assignment_id = paa.assignment_id
              AND paa.assignment_action_id = prr.assignment_action_id
              AND ppa.payroll_action_id = paa.payroll_action_id
              AND pcs.consolidation_set_id = ppa.consolidation_set_id
              AND papf.person_id = paaf.person_id
              AND pgt.grade_id = paaf.grade_id
              AND haou.organization_id = paaf.organization_id
              AND prrv.result_value <> '0')
      GROUP BY reporting_name,result_value,RUN_RESULT_ID

Payroll process table flow diagram