Showing posts with label xle. Show all posts
Showing posts with label xle. Show all posts

Tuesday, 19 July 2016

Query to find GL periods for a given legal entity

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

                ;

Query to find legal entity,registration and address details


Query to find legal entity details

SELECT xep.name,                                          -- Legal Entity Name
       xjv.registration_code_le registration_code,        -- Registration Code
       xr.registration_number,                          -- Registration Number
          DECODE (hl.address_line_1, NULL, '', hl.address_line_1 || ', ')
       || DECODE (hl.address_line_2, NULL, '', hl.address_line_2 || ', ')
       || DECODE (hl.address_line_3, NULL, '', hl.address_line_3 || ', ')
       || DECODE (hl.town_or_city, NULL, '', hl.town_or_city || ', ')
       || DECODE (hl.region_2, NULL, '', hl.region_2 || ', ')
       || DECODE (hl.postal_code, NULL, '', hl.postal_code || ', ')
       || DECODE (ftv.territory_short_name,
                  NULL, '',
                  ftv.territory_short_name)
          Address --Address
  FROM xle_registrations xr,
       xle_jurisdictions_vl xjv,
       hr_locations hl,
       fnd_territories_vl ftv,
       xle_entity_profiles xep
 WHERE     1 = 1
       AND xep.legal_entity_id = :legal_entity_id
       AND xr.source_table = 'XLE_ENTITY_PROFILES'
       AND xr.source_id = xep.legal_entity_id
       AND xjv.jurisdiction_id = xr.jurisdiction_id
       AND hl.location_id = xr.location_id
       AND ftv.territory_code = hl.country
       AND SYSDATE BETWEEN NVL (xr.effective_from, SYSDATE - 1)
                       AND NVL (xr.EFFECTIVE_TO, SYSDATE + 1);