【OracleEBS】 科目餘額SQL

Iven_lin發表於2024-04-07

select gb.period_year 會計年度,
       gb.period_name 會計期間,
       gcck.concatenated_segments 科目程式碼,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment1) 公司,
       '',
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment2) 成本中心,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment3) 會計科目,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment4) 子科目,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment5) 產品段,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment6) 片區,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             '',
                                             gcck.segment7) 備用,
       gb.begin_balance_dr - gb.begin_balance_cr 期初餘額,
       gb.period_net_dr 本期借方發生,
       gb.period_net_cr 本期貸方發生,
       nvl(gb.period_net_dr, 0) - nvl(gb.period_net_cr, 0) 本期淨額,
       nvl(gb.begin_balance_dr, 0) + nvl(gb.period_net_dr, 0) -
       nvl(gb.begin_balance_cr, 0) - nvl(gb.period_net_cr, 0) 期末餘額
  from gl.gl_balances gb, gl_code_combinations_kfv gcck
 where gb.code_combination_id = gcck.code_combination_id
   and gb.currency_code = 'CNY'
   and gcck.summary_flag = 'N'
   and gb.actual_flag = 'A'
   AND gb.period_name = '2010-11'
   AND gcck.concatenated_segments like '02.021200.6501.%.0000.0000.000'

相關文章