http://generalledger-gl.blogspot.com/2017/02/budget-inquiry.html
PLSQL Query to Get Budget Inquiry
select
-- gjh.je_header_id
-- ,gjh.doc_sequence_value
gjh.default_effective_date
,
gjh.date_created
,
decode(gjh.status, 'P', 'Posted', 'U', 'Unposted') status
,
gjh.name
,
gjh.name
,
gjh.description h_description
,
decode(gjh.accrual_rev_status, 'R', 'Reversed', 'Not Reversed') revstatus
,
gjc.user_je_category_name
,
gjh.je_source
,
gjh.je_category
-- ,gjh.posting_acct_seq_value
,
gjh.currency_code
,
gjh.currency_conversion_type
,
gjh.currency_conversion_rate
,
gjh.currency_conversion_date
,
fu.user_name
,
fu.employee_id
,
gjl.je_line_num
-- ,gjl.code_combination_id
-- ,gcc.segment7 glcode
,
sum(gjl.entered_dr)
,
sum(gjl.entered_cr)
,
sum(gjl.accounted_dr)
,
sum(gjl.accounted_cr)
,
gjl.description
,
gcc.SEGMENT2 Loc
,
gcc.SEGMENT4 Account
/*,gcc.segment1||'-'||gcc.segment2||'-'||gcc.segment3||'-'||
gcc.segment4||'-'||gcc.segment5||'-'||gcc.segment6||'-'||gcc.segment7 code_comb*/
/* ,fs1.DESCRIPTION description1
,fs2.DESCRIPTION description2
,fs3.DESCRIPTION description3
,fs4.DESCRIPTION description4
,fs5.DESCRIPTION description5
,fs6.DESCRIPTION description6
,fs7.DESCRIPTION description7*/
/* ,fs1.DESCRIPTION ||'-'||fs2.DESCRIPTION ||'-'||fs3.DESCRIPTION||'-'||fs4.DESCRIPTION
||'-'||fs5.DESCRIPTION||'-'||fs6.DESCRIPTION||'-'||fs7.DESCRIPTION
Account_description*/
/*, (SELECT GLC.DESCRIPTION
FROM GL_JE_CATEGORIES_TL GLC
WHERE
GLC.JE_CATEGORY_NAME= gjh.JE_CATEGORY)
||'-'||gjh.doc_sequence_value doc_no2 ,
(SELECT GLC.DESCRIPTION
FROM GL_JE_CATEGORIES_TL GLC
WHERE
GLC.JE_CATEGORY_NAME= gjh.JE_CATEGORY) SSCRPT ,
(
select max( gir.SUBLEDGER_DOC_SEQUENCE_VALUE )
from
gl_import_references gir
,xla.xla_transaction_entities ent
,xla_ae_headers aeh
,xla_ae_lines ael
where
gjl.je_header_id = gir.je_header_id
and gjl.je_line_num = gir.je_line_num
and gjh.je_header_id = gir.je_header_id
and gir.gl_sl_link_id = ael.gl_sl_link_id
and gir.gl_sl_link_table = ael.gl_sl_link_table
and aeh.ae_header_id = ael.ae_header_id
and aeh.application_id = ael.application_id
and aeh.period_name = gjh.period_name
and aeh.entity_id = ent.entity_id
) SUBLEDGER_DOC_SEQUENCE_VALUE*/
from gl_je_headers gjh
,
gl_je_lines gjl
,
gl_code_combinations gcc
,
fnd_user fu
,
gl_je_categories gjc
,
fnd_flex_values_vl fs1
,
fnd_flex_values_vl fs2
,
fnd_flex_values_vl fs3
,
fnd_flex_values_vl fs4
,
fnd_flex_values_vl fs5
,
fnd_flex_values_vl fs6
,
fnd_flex_values_vl fs7
where 1 = 1
and GJH.ACTUAL_FLAG = 'B'
and gjl.ledger_id = 2021 --:P_Ledger_ID
and gjh.ledger_id = 2021 --:P_Ledger_ID
and gjh.je_header_id = gjl.je_header_id
and gjl.code_combination_id = gcc.code_combination_id
and gjh.created_by = fu.user_id
and gjh.je_category = gjc.je_category_name
and fs1.FLEX_VALUE = gcc.segment1
and fs1.FLEX_VALUE_SET_ID = 1013507
and fs2.FLEX_VALUE = gcc.segment2
and fs2.FLEX_VALUE_SET_ID = 1013508
and fs3.FLEX_VALUE = gcc.segment3
and fs3.FLEX_VALUE_SET_ID = 1013509
and fs4.FLEX_VALUE = gcc.segment4
and fs4.FLEX_VALUE_SET_ID = 1013510
and fs5.FLEX_VALUE = gcc.segment5
and fs5.FLEX_VALUE_SET_ID = 1013511
and fs6.FLEX_VALUE = gcc.segment6
and fs6.FLEX_VALUE_SET_ID = 1013512
and fs7.FLEX_VALUE = gcc.segment7
and fs7.FLEX_VALUE_SET_ID = 1013513
and gjh.je_category = nvl('&cat', gjh.je_category)
-- and gjh.je_source = nvl(:src,gjh.je_source)
-- and gjh.status = nvl(:sts,gjh.status)
and trunc(gjh.default_effective_date) between '&F_D' AND '&T_D'
-- and nvl(gjh.doc_sequence_value,0) between nvl(:v_f,0) and nvl(:v_t,9999999999999999999999999)
and gcc.SEGMENT2 between NVL('&From_Location', gcc.SEGMENT2) and
nvl('&TO_Location', gcc.segment2)
and gcc.SEGMENT4 between NVL('&From_Account', gcc.SEGMENT4) and
nvl('&TO_Account', gcc.segment4)
---and gjh.currency_code between NVL(:FROM_CCY, gjh.currency_code) and NVL(:TO_CCY,gjh.currency_code)
--AND FU.USER_ID=NVL(:P_USER_ID,FU.USER_ID)
--AND NVL(FU.FAX,'ALL')=NVL(:P_USER_SITE,NVL(FU.FAX,'ALL'))
group by --gjh.je_header_id
-- ,gjh.doc_sequence_value
gjh.default_effective_date
,
gjh.date_created
,
decode(gjh.status, 'P', 'Posted', 'U', 'Unposted')
,
gjh.name
,
gjh.name
,
gjh.description
,
decode(gjh.accrual_rev_status, 'R', 'Reversed', 'Not Reversed')
,
gjc.user_je_category_name
,
gjh.je_source
,
gjh.je_category
-- ,gjh.posting_acct_seq_value
,
gjh.currency_code
,
gjh.currency_conversion_type
,
gjh.currency_conversion_rate
,
gjh.currency_conversion_date
,
fu.user_name
,
fu.employee_id
,
gjl.je_line_num
-- ,gjl.code_combination_id
,
gjl.description
,
gcc.SEGMENT2
,
gcc.SEGMENT4
order by gjh.date_created, gjl.je_line_num --,gjl.accounted_dr,gjl.accounted_cr
PLSQL Query to Get Budget Inquiry
select
-- gjh.je_header_id
-- ,gjh.doc_sequence_value
gjh.default_effective_date
,
gjh.date_created
,
decode(gjh.status, 'P', 'Posted', 'U', 'Unposted') status
,
gjh.name
,
gjh.name
,
gjh.description h_description
,
decode(gjh.accrual_rev_status, 'R', 'Reversed', 'Not Reversed') revstatus
,
gjc.user_je_category_name
,
gjh.je_source
,
gjh.je_category
-- ,gjh.posting_acct_seq_value
,
gjh.currency_code
,
gjh.currency_conversion_type
,
gjh.currency_conversion_rate
,
gjh.currency_conversion_date
,
fu.user_name
,
fu.employee_id
,
gjl.je_line_num
-- ,gjl.code_combination_id
-- ,gcc.segment7 glcode
,
sum(gjl.entered_dr)
,
sum(gjl.entered_cr)
,
sum(gjl.accounted_dr)
,
sum(gjl.accounted_cr)
,
gjl.description
,
gcc.SEGMENT2 Loc
,
gcc.SEGMENT4 Account
/*,gcc.segment1||'-'||gcc.segment2||'-'||gcc.segment3||'-'||
gcc.segment4||'-'||gcc.segment5||'-'||gcc.segment6||'-'||gcc.segment7 code_comb*/
/* ,fs1.DESCRIPTION description1
,fs2.DESCRIPTION description2
,fs3.DESCRIPTION description3
,fs4.DESCRIPTION description4
,fs5.DESCRIPTION description5
,fs6.DESCRIPTION description6
,fs7.DESCRIPTION description7*/
/* ,fs1.DESCRIPTION ||'-'||fs2.DESCRIPTION ||'-'||fs3.DESCRIPTION||'-'||fs4.DESCRIPTION
||'-'||fs5.DESCRIPTION||'-'||fs6.DESCRIPTION||'-'||fs7.DESCRIPTION
Account_description*/
/*, (SELECT GLC.DESCRIPTION
FROM GL_JE_CATEGORIES_TL GLC
WHERE
GLC.JE_CATEGORY_NAME= gjh.JE_CATEGORY)
||'-'||gjh.doc_sequence_value doc_no2 ,
(SELECT GLC.DESCRIPTION
FROM GL_JE_CATEGORIES_TL GLC
WHERE
GLC.JE_CATEGORY_NAME= gjh.JE_CATEGORY) SSCRPT ,
(
select max( gir.SUBLEDGER_DOC_SEQUENCE_VALUE )
from
gl_import_references gir
,xla.xla_transaction_entities ent
,xla_ae_headers aeh
,xla_ae_lines ael
where
gjl.je_header_id = gir.je_header_id
and gjl.je_line_num = gir.je_line_num
and gjh.je_header_id = gir.je_header_id
and gir.gl_sl_link_id = ael.gl_sl_link_id
and gir.gl_sl_link_table = ael.gl_sl_link_table
and aeh.ae_header_id = ael.ae_header_id
and aeh.application_id = ael.application_id
and aeh.period_name = gjh.period_name
and aeh.entity_id = ent.entity_id
) SUBLEDGER_DOC_SEQUENCE_VALUE*/
from gl_je_headers gjh
,
gl_je_lines gjl
,
gl_code_combinations gcc
,
fnd_user fu
,
gl_je_categories gjc
,
fnd_flex_values_vl fs1
,
fnd_flex_values_vl fs2
,
fnd_flex_values_vl fs3
,
fnd_flex_values_vl fs4
,
fnd_flex_values_vl fs5
,
fnd_flex_values_vl fs6
,
fnd_flex_values_vl fs7
where 1 = 1
and GJH.ACTUAL_FLAG = 'B'
and gjl.ledger_id = 2021 --:P_Ledger_ID
and gjh.ledger_id = 2021 --:P_Ledger_ID
and gjh.je_header_id = gjl.je_header_id
and gjl.code_combination_id = gcc.code_combination_id
and gjh.created_by = fu.user_id
and gjh.je_category = gjc.je_category_name
and fs1.FLEX_VALUE = gcc.segment1
and fs1.FLEX_VALUE_SET_ID = 1013507
and fs2.FLEX_VALUE = gcc.segment2
and fs2.FLEX_VALUE_SET_ID = 1013508
and fs3.FLEX_VALUE = gcc.segment3
and fs3.FLEX_VALUE_SET_ID = 1013509
and fs4.FLEX_VALUE = gcc.segment4
and fs4.FLEX_VALUE_SET_ID = 1013510
and fs5.FLEX_VALUE = gcc.segment5
and fs5.FLEX_VALUE_SET_ID = 1013511
and fs6.FLEX_VALUE = gcc.segment6
and fs6.FLEX_VALUE_SET_ID = 1013512
and fs7.FLEX_VALUE = gcc.segment7
and fs7.FLEX_VALUE_SET_ID = 1013513
and gjh.je_category = nvl('&cat', gjh.je_category)
-- and gjh.je_source = nvl(:src,gjh.je_source)
-- and gjh.status = nvl(:sts,gjh.status)
and trunc(gjh.default_effective_date) between '&F_D' AND '&T_D'
-- and nvl(gjh.doc_sequence_value,0) between nvl(:v_f,0) and nvl(:v_t,9999999999999999999999999)
and gcc.SEGMENT2 between NVL('&From_Location', gcc.SEGMENT2) and
nvl('&TO_Location', gcc.segment2)
and gcc.SEGMENT4 between NVL('&From_Account', gcc.SEGMENT4) and
nvl('&TO_Account', gcc.segment4)
---and gjh.currency_code between NVL(:FROM_CCY, gjh.currency_code) and NVL(:TO_CCY,gjh.currency_code)
--AND FU.USER_ID=NVL(:P_USER_ID,FU.USER_ID)
--AND NVL(FU.FAX,'ALL')=NVL(:P_USER_SITE,NVL(FU.FAX,'ALL'))
group by --gjh.je_header_id
-- ,gjh.doc_sequence_value
gjh.default_effective_date
,
gjh.date_created
,
decode(gjh.status, 'P', 'Posted', 'U', 'Unposted')
,
gjh.name
,
gjh.name
,
gjh.description
,
decode(gjh.accrual_rev_status, 'R', 'Reversed', 'Not Reversed')
,
gjc.user_je_category_name
,
gjh.je_source
,
gjh.je_category
-- ,gjh.posting_acct_seq_value
,
gjh.currency_code
,
gjh.currency_conversion_type
,
gjh.currency_conversion_rate
,
gjh.currency_conversion_date
,
fu.user_name
,
fu.employee_id
,
gjl.je_line_num
-- ,gjl.code_combination_id
,
gjl.description
,
gcc.SEGMENT2
,
gcc.SEGMENT4
order by gjh.date_created, gjl.je_line_num --,gjl.accounted_dr,gjl.accounted_cr
No comments:
Post a Comment