http://generalledger-gl.blogspot.com/2016/10/intralocation-plsql-query-location.html
IntraLocation PLSQL Query (Location Differences in one JV)
select distinct ff.DOC_SEQUENCE_VALUE,
ff.JE_CATEGORY,
gca.SEGMENT1 Company,
gca.SEGMENT2 Location
,
gca.SEGMENT3 Department,
gca.SEGMENT4 Account,
gca.SEGMENT5 Project,
gca.SEGMENT6 InterCompany,
gca.SEGMENT7 Future1,
gca.SEGMENT8 Furture2,
A.JE_LINE_NUM,
A.ACCOUNTED_DR,
A.ACCOUNTED_CR
from gl_je_lines A,
gl_je_lines B,
gl_code_combinations gca,
gl_code_combinations gcb,
gl_je_headers ff
where A.JE_HEADER_ID = b.JE_HEADER_ID
and A.CODE_COMBINATION_ID = gca.CODE_COMBINATION_ID
and b.CODE_COMBINATION_ID = gcb.CODE_COMBINATION_ID
and ff.JE_HEADER_ID = A.JE_HEADER_ID
and gca.SEGMENT2 != gcb.SEGMENT2
and ff.LEDGER_ID = 2021
and ff.ACTUAL_FLAG = 'A'
and ff.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
order by ff.DOC_SEQUENCE_VALUE
#############################################################################
select distinct A.Doc_Sequence_Value,
A.User_Je_Category_Name,
A.DEFAULT_EFFECTIVE_DATE,
A.a_Period,
A.DESCRIPTION,
A.Je_Line_Num,
A.Segment1,
A.Segment2,
A.Segment3,
A.Segment4,
A.Segment5,
A.Segment6,
A.Segment7,
A.Segment8,
a.accounted_dr,
a.accounted_cr
from (select --count(*)
kk.JE_HEADER_ID,
kk.DOC_SEQUENCE_VALUE,
kk.PERIOD_NAME,
jj.JE_LINE_NUM,
kk.LEDGER_ID
,
kk.DEFAULT_EFFECTIVE_DATE,
kk.PERIOD_NAME A_Period,
jj.DESCRIPTION
,
gc.user_je_category_name,
kk.JE_CATEGORY,
jj.ACCOUNTED_DR,
jj.ACCOUNTED_CR,
gcc.SEGMENT1,
gcc.SEGMENT2,
gcc.SEGMENT3,
gcc.SEGMENT4,
gcc.SEGMENT5,
gcc.SEGMENT6,
gcc.SEGMENT7,
gcc.SEGMENT8
from gl_je_headers kk,
gl_je_lines jj,
gl_code_combinations gcc,
gl_je_categories gc
where kk.JE_HEADER_ID = jj.JE_HEADER_ID
and gcc.CODE_COMBINATION_ID = jj.CODE_COMBINATION_ID
and gc.je_category_name = kk.JE_CATEGORY
and jj.LEDGER_ID = kk.LEDGER_ID
and jj.PERIOD_NAME = kk.PERIOD_NAME
and kk.LEDGER_ID = 2021
and jj.STATUS = 'P'
and kk.STATUS = 'P'
and kk.ACTUAL_FLAG = 'A'
and kk.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
--and kk.DOC_SEQUENCE_VALUE=16000001
) A,
(select --count(*)
g1.JE_HEADER_ID,
g1.DOC_SEQUENCE_VALUE,
g1.PERIOD_NAME,
j1.JE_LINE_NUM,
g1.ledger_id,
g1.DEFAULT_EFFECTIVE_DATE,
g1.PERIOD_NAME B_Period,
j1.DESCRIPTION
,
y1.user_je_category_name,
g1.JE_CATEGORY,
j1.ACCOUNTED_DR,
j1.ACCOUNTED_CR,
gc1.SEGMENT1,
gc1.SEGMENT2,
gc1.SEGMENT3,
gc1.SEGMENT4,
gc1.SEGMENT5,
gc1.SEGMENT6,
gc1.SEGMENT7,
gc1.SEGMENT8
from gl_je_headers g1,
gl_je_lines j1,
gl_code_combinations gc1,
gl_je_categories y1
where g1.JE_HEADER_ID = j1.JE_HEADER_ID
and gc1.CODE_COMBINATION_ID = j1.CODE_COMBINATION_ID
and y1.je_category_name = g1.JE_CATEGORY
and j1.LEDGER_ID = g1.LEDGER_ID
and j1.PERIOD_NAME = g1.PERIOD_NAME
and j1.LEDGER_ID = 2021
and j1.STATUS = 'P'
and g1.STATUS = 'P'
and g1.ACTUAL_FLAG = 'A'
--and g1.DOC_SEQUENCE_VALUE=16000001
and g1.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
) B
where A.Segment2 != b.segment2
and A.JE_HEADER_ID = b.je_header_id
and A.USER_JE_CATEGORY_NAME = b.user_je_category_name
and A.a_Period = B.b_Period
and A.Ledger_Id = b.ledger_id
order by A.Doc_Sequence_Value, a.je_line_num
IntraLocation PLSQL Query (Location Differences in one JV)
select distinct ff.DOC_SEQUENCE_VALUE,
ff.JE_CATEGORY,
gca.SEGMENT1 Company,
gca.SEGMENT2 Location
,
gca.SEGMENT3 Department,
gca.SEGMENT4 Account,
gca.SEGMENT5 Project,
gca.SEGMENT6 InterCompany,
gca.SEGMENT7 Future1,
gca.SEGMENT8 Furture2,
A.JE_LINE_NUM,
A.ACCOUNTED_DR,
A.ACCOUNTED_CR
from gl_je_lines A,
gl_je_lines B,
gl_code_combinations gca,
gl_code_combinations gcb,
gl_je_headers ff
where A.JE_HEADER_ID = b.JE_HEADER_ID
and A.CODE_COMBINATION_ID = gca.CODE_COMBINATION_ID
and b.CODE_COMBINATION_ID = gcb.CODE_COMBINATION_ID
and ff.JE_HEADER_ID = A.JE_HEADER_ID
and gca.SEGMENT2 != gcb.SEGMENT2
and ff.LEDGER_ID = 2021
and ff.ACTUAL_FLAG = 'A'
and ff.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
order by ff.DOC_SEQUENCE_VALUE
select distinct A.Doc_Sequence_Value,
A.User_Je_Category_Name,
A.DEFAULT_EFFECTIVE_DATE,
A.a_Period,
A.DESCRIPTION,
A.Je_Line_Num,
A.Segment1,
A.Segment2,
A.Segment3,
A.Segment4,
A.Segment5,
A.Segment6,
A.Segment7,
A.Segment8,
a.accounted_dr,
a.accounted_cr
from (select --count(*)
kk.JE_HEADER_ID,
kk.DOC_SEQUENCE_VALUE,
kk.PERIOD_NAME,
jj.JE_LINE_NUM,
kk.LEDGER_ID
,
kk.DEFAULT_EFFECTIVE_DATE,
kk.PERIOD_NAME A_Period,
jj.DESCRIPTION
,
gc.user_je_category_name,
kk.JE_CATEGORY,
jj.ACCOUNTED_DR,
jj.ACCOUNTED_CR,
gcc.SEGMENT1,
gcc.SEGMENT2,
gcc.SEGMENT3,
gcc.SEGMENT4,
gcc.SEGMENT5,
gcc.SEGMENT6,
gcc.SEGMENT7,
gcc.SEGMENT8
from gl_je_headers kk,
gl_je_lines jj,
gl_code_combinations gcc,
gl_je_categories gc
where kk.JE_HEADER_ID = jj.JE_HEADER_ID
and gcc.CODE_COMBINATION_ID = jj.CODE_COMBINATION_ID
and gc.je_category_name = kk.JE_CATEGORY
and jj.LEDGER_ID = kk.LEDGER_ID
and jj.PERIOD_NAME = kk.PERIOD_NAME
and kk.LEDGER_ID = 2021
and jj.STATUS = 'P'
and kk.STATUS = 'P'
and kk.ACTUAL_FLAG = 'A'
and kk.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
--and kk.DOC_SEQUENCE_VALUE=16000001
) A,
(select --count(*)
g1.JE_HEADER_ID,
g1.DOC_SEQUENCE_VALUE,
g1.PERIOD_NAME,
j1.JE_LINE_NUM,
g1.ledger_id,
g1.DEFAULT_EFFECTIVE_DATE,
g1.PERIOD_NAME B_Period,
j1.DESCRIPTION
,
y1.user_je_category_name,
g1.JE_CATEGORY,
j1.ACCOUNTED_DR,
j1.ACCOUNTED_CR,
gc1.SEGMENT1,
gc1.SEGMENT2,
gc1.SEGMENT3,
gc1.SEGMENT4,
gc1.SEGMENT5,
gc1.SEGMENT6,
gc1.SEGMENT7,
gc1.SEGMENT8
from gl_je_headers g1,
gl_je_lines j1,
gl_code_combinations gc1,
gl_je_categories y1
where g1.JE_HEADER_ID = j1.JE_HEADER_ID
and gc1.CODE_COMBINATION_ID = j1.CODE_COMBINATION_ID
and y1.je_category_name = g1.JE_CATEGORY
and j1.LEDGER_ID = g1.LEDGER_ID
and j1.PERIOD_NAME = g1.PERIOD_NAME
and j1.LEDGER_ID = 2021
and j1.STATUS = 'P'
and g1.STATUS = 'P'
and g1.ACTUAL_FLAG = 'A'
--and g1.DOC_SEQUENCE_VALUE=16000001
and g1.DEFAULT_EFFECTIVE_DATE > '01-JUL-2016'
) B
where A.Segment2 != b.segment2
and A.JE_HEADER_ID = b.je_header_id
and A.USER_JE_CATEGORY_NAME = b.user_je_category_name
and A.a_Period = B.b_Period
and A.Ledger_Id = b.ledger_id
order by A.Doc_Sequence_Value, a.je_line_num
No comments:
Post a Comment