Query to find GL periods for a given legal entity:
select gp.period_name
from gl_ledger_norm_seg_vals bsv,gl_ledgers gl, gl_periods gp
where 1=1
AND Bsv.Legal_Entity_Id = :Legal Entity Id
And Bsv.Segment_Type_Code = 'B'
AND sysdate between nvl(bsv.start_date,sysdate-1) and nvl(bsv.end_date,sysdate+1)
And Gl.Object_Type_Code = 'L'
And Gl.Ledger_Category_Code = 'PRIMARY'
And Gl.Ledger_Id=Bsv.Ledger_Id
AND gp.period_set_name=gl.period_set_name
order by gp.start_date
;
Derive GL Start and End Dates..
select start_date,end_date
from gl_ledger_norm_seg_vals bsv,gl_ledgers gl, gl_periods gp
where 1=1
AND Bsv.Legal_Entity_Id = :p_Legal_entity_id
And Bsv.Segment_Type_Code = 'B'
AND sysdate between nvl(bsv.start_date,sysdate-1) and nvl(bsv.end_date,sysdate+1)
And Gl.Object_Type_Code = 'L'
And Gl.Ledger_Category_Code = 'PRIMARY'
And Gl.Ledger_Id=Bsv.Ledger_Id
AND gp.period_set_name=gl.period_set_name
and gp.period_name = :p_period_name
order by gp.start_date
;
select gp.period_name
from gl_ledger_norm_seg_vals bsv,gl_ledgers gl, gl_periods gp
where 1=1
AND Bsv.Legal_Entity_Id = :Legal Entity Id
And Bsv.Segment_Type_Code = 'B'
AND sysdate between nvl(bsv.start_date,sysdate-1) and nvl(bsv.end_date,sysdate+1)
And Gl.Object_Type_Code = 'L'
And Gl.Ledger_Category_Code = 'PRIMARY'
And Gl.Ledger_Id=Bsv.Ledger_Id
AND gp.period_set_name=gl.period_set_name
order by gp.start_date
;
Derive GL Start and End Dates..
select start_date,end_date
from gl_ledger_norm_seg_vals bsv,gl_ledgers gl, gl_periods gp
where 1=1
AND Bsv.Legal_Entity_Id = :p_Legal_entity_id
And Bsv.Segment_Type_Code = 'B'
AND sysdate between nvl(bsv.start_date,sysdate-1) and nvl(bsv.end_date,sysdate+1)
And Gl.Object_Type_Code = 'L'
And Gl.Ledger_Category_Code = 'PRIMARY'
And Gl.Ledger_Id=Bsv.Ledger_Id
AND gp.period_set_name=gl.period_set_name
and gp.period_name = :p_period_name
order by gp.start_date
;
No comments:
Post a Comment