Reports2017-11-18T12:27:27+00:00

GL Balance by Account

Description
Categories: Enginatics, Financials

select
z.*,
nvl(z.start_balance,0)+nvl(z.total,0) ytd
from
(
select
x.ledger,
x.&account_segment account,
(select ffvv.description from fnd_flex_values_vl ffvv where x.&account_segment=ffvv.flex_value and ffvv.flex_value_set_id=&flex_value_set_id) description,
nvl(x.period_name,'total') period_name,
max(x.start_balance) over (partition by x.&account_segment) start_balance,
x.amount
from
(
select
gl.name ledger,
gcc.&account_segment,
gps.period_name,
sum(decode(gps.start_period,'Y',nvl(gb.begin_balance_dr,0)-nvl(gb.begin_balance_cr,0))) start_balance,
sum(nvl(gb.period_net_dr,0)-nvl(gb.period_net_cr,0)) amount
from
gl_ledgers gl,
gl_period_statuses gps0,
(select decode(gps.period_num,min(gps.period_num) over (partition by gps.ledger_id, gps.application_id, gps.period_year),'Y') start_period, gps.* from gl_period_statuses gps) gps,
gl_balances gb,
gl_code_combinations gcc
where
gl.name=:ledger_name and
gps0.period_name=:period_name and
gb.actual_flag=decode(:actual_flag,'Actual','A','Budget','B','Encumbrance','E') and
1=1 and
gl.ledger_id=gps0.ledger_id and
gps0.application_id=101 and
gps0.application_id=gps.application_id and
gps0.ledger_id=gps.ledger_id and
gps0.period_year=gps.period_year and
gps0.period_num>=gps.period_num and
gps.ledger_id=gb.ledger_id and
gps.period_name=gb.period_name and
gl.currency_code=gb.currency_code and
gb.code_combination_id=gcc.code_combination_id and
gcc.summary_flag='N'
group by
grouping sets(
(gl.name, gcc.&account_segment),
(gl.name, gcc.&account_segment, gps.period_name)
)
) x
) y
pivot (
sum(y.amount)
for period_name in (
&pivot_columns
)
) z

Parameter Name SQL text Validation
Ledger
 
LOV
Period
 
LOV
Period
select
x.*
from
(
select
''''||gps.period_name||''' '||decode(gps.adjustment_period_flag,'Y','adj_')||to_char(gps.end_date,'mon_YYYY','nls_date_language=american')||',' pivot_text
from
gl_ledgers gl,
gl_period_statuses gps0,
gl_period_statuses gps
where
gl.name=:ledger_name and
gps0.period_name=:period_name and
1=1 and
gl.ledger_id=gps0.ledger_id and
gps0.application_id=101 and
gps0.application_id=gps.application_id and
gps0.ledger_id=gps.ledger_id and
gps0.period_year=gps.period_year and
gps0.period_num>=gps.period_num
order by
gps.effective_period_num
) x
union all
select '''total'' total' from dual
Ledger
select
fifs.flex_value_set_id
from
fnd_id_flex_segments_tl fifst,
fnd_id_flex_segments fifs
where
fifst.application_id=101 and
fifst.id_flex_code='GL#' and
fifst.id_flex_num=(select gl.chart_of_accounts_id from gl_ledgers gl where gl.name=:ledger_name) and
(lower(fifs.segment_name)='account' or lower(fifst.form_left_prompt)='account') and
fifst.language='US' and
fifst.application_id=fifs.application_id and
fifst.id_flex_code=fifs.id_flex_code and
fifst.id_flex_num=fifs.id_flex_num and
fifst.application_column_name=fifs.application_column_name
Ledger
select
fifs.application_column_name
from
fnd_id_flex_segments fifs,
fnd_id_flex_segments_tl fifst
where
fifs.application_id=101 and
fifs.id_flex_code='GL#' and
fifs.id_flex_num=(select gl.chart_of_accounts_id from gl_ledgers gl where gl.name=:ledger_name) and
fifs.application_id=fifst.application_id and
fifs.id_flex_code=fifst.id_flex_code and
fifs.id_flex_num=fifst.id_flex_num and
fifs.application_column_name=fifst.application_column_name and
fifst.language='US' and
(lower(fifs.segment_name)='account' or lower(fifst.form_left_prompt)='account')
Type
 
LOV