GL Trial Balance - Expanded

Description
Categories: BI Publisher
Imported from BI Publisher
Description: Expanded Trial Balance
Application: General Ledger
Source: Trial Balance - Expanded (XML)
Short Name: GLYRLBGE_XML
DB package: GL_GLYRLBGE_XMLP_PKG
Run GL Trial Balance - Expanded and other Oracle EBS reports with Blitz Report™ on our demo environment
select 
 -- null                                   ACCOUNT,
  --null                                      COMPANY,
  fnd_flex_xml_publisher_apis.process_kff_combination_1('accounting_segment', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'VALUE')                                   ACCOUNT,
  fnd_flex_xml_publisher_apis.process_kff_combination_1('balancing_segment', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_BALANCING', 'Y', 'VALUE')									COMPANY,
  substr(fnd_flex_xml_publisher_apis.process_kff_combination_1('accounting_segment', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'VALUE'),1,3)                 Groups,
  substr(fnd_flex_xml_publisher_apis.process_kff_combination_1('accounting_segment', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'VALUE'),1,2)                 Sub_Class,
  substr(fnd_flex_xml_publisher_apis.process_kff_combination_1('accounting_segment', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'VALUE'),1,1)                 Class,
decode(:P_CURRENCY_TYPE, 
'T', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'S', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'E', sum(decode(bl.translated_flag, 
     'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0),
          decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0))))
                             BEGIN_DR,
decode(:P_CURRENCY_TYPE, 
'T',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'S',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'E',  sum(decode(bl.translated_flag, 
      'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),
           decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0))))
                                BEGIN_CR,
decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr_beq,0),0))))
                                PER_DR,
decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr_beq,0),0))))
                                PER_CR,
decode(:P_CURRENCY_TYPE, 
'T', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'S', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'E', sum(decode(bl.translated_flag, 
     'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0),
          decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0))))
+ decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr_beq,0),0))))
                  END_DR,
decode(:P_CURRENCY_TYPE, 
'T',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'S',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'E',  sum(decode(bl.translated_flag, 
      'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),
           decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0))))
+ decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr_beq,0),0))))
                       END_CR,
decode(:P_CURRENCY_TYPE, 
'T', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'S', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'E', sum(decode(bl.translated_flag, 
     'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0),
          decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0))))
+ decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr_beq,0),0))))
- (decode(:P_CURRENCY_TYPE, 
'T',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'S',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'E',  sum(decode(bl.translated_flag, 
      'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),
           decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0))))
+ decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_cr_beq,0),0)))))
               NET,
max(LR.TARGET_LEDGER_name)                   LEDGER_NAME_H, 
	--GL_GLYRLBGE_XMLP_PKG.c_bal_lpromptformula(:C_BAL_LPROMPT) C_BAL_LPROMPT, 
	fnd_flex_xml_publisher_apis.process_kff_combination_1('disp_company', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_BALANCING', 'Y', 'VALUE') DISP_COMPANY, 
	fnd_flex_xml_publisher_apis.process_kff_combination_1('company_name', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_BALANCING', 'Y', 'DESCRIPTION') COMPANY_NAME, 
	GL_GLYRLBGE_XMLP_PKG.comp_net_crformula(:COMP_NET) COMP_NET_CR, 
	fnd_flex_xml_publisher_apis.process_kff_combination_1('bal_secure', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_BALANCING', 'Y', 'SECURITY') BAL_SECURE, 
	GL_GLYRLBGE_XMLP_PKG.cl_net_crformula(:CL_NET) CL_NET_CR, 
	GL_GLYRLBGE_XMLP_PKG.sc_net_crformula(:SC_NET) SC_NET_CR, 
	GL_GLYRLBGE_XMLP_PKG.gr_net_crformula(:GR_NET) GR_NET_CR, 
	fnd_flex_xml_publisher_apis.process_kff_combination_1('account_desc', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'DESCRIPTION') ACCOUNT_DESC, 
	fnd_flex_xml_publisher_apis.process_kff_combination_1('account_value', 'SQLGL', 'GL#', CC.CHART_OF_ACCOUNTS_ID, NULL, CC.CODE_COMBINATION_ID, 'GL_ACCOUNT', 'Y', 'VALUE') ACCOUNT_VALUE, 
GL_GLYRLBGE_XMLP_PKG.zero_indicatorformula(
decode(:P_CURRENCY_TYPE, 
'T',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'S',  decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
      -1,
      abs(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),0)
      + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))
      - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
'E',  sum(decode(bl.translated_flag, 
      'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),
           decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
           -1,
           abs(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),0)
           + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)
           - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)))) ,
decode(:P_CURRENCY_TYPE, 
'T', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'S', decode(sign(sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0))),
     1,
     sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)) 
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),0)
     + sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0))
     - sum(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)),
'E', sum(decode(bl.translated_flag, 
     'R', decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr,0),0),
          decode(sign(decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0)),
          1,
          decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0) 
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_cr_beq,0),0),0)
          + decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)
          - decode(bl.period_name,:FIRST_PERIOD_NAME,nvl(bl.begin_balance_dr_beq,0),0)))),
decode(:P_CURRENCY_TYPE, 
'T',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'S',sum(decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0)),
'E',sum(decode(bl.translated_flag, 
    'R',decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr,0),0),
        decode(bl.period_name,:P_PERIOD_NAME,nvl(bl.period_net_dr_beq,0),0