Sunday, 25 August 2019

Query to find the Log of open - closure of period between given date range in Oracle Apps R12

SELECT ps.application_id, 
       (SELECT application_name 
        FROM   fnd_application_tl 
        WHERE  LANGUAGE = Userenv('LANG') 
               AND application_id = ps.application_id) Application, 
       (SELECT user_name 
        FROM   fnd_user 
        WHERE  user_id = ps.last_updated_by)           user_name, 
       ps.set_of_books_id, 
       sob.name                                        set_of_books, 
       -- fnd.product_code,  
       NULL                                            Organization_Name, 
       ps.period_name, 
       ps.start_date                                   period_start_date, 
       ps.end_date                                     period_end_date, 
       NULL                                            CLOSE_DATE, 
       ps.last_update_date, 
       Decode (ps.closing_status, 'O', 'O - Open', 
                                  'C', 'C - Closed', 
                                  'Never Opened')      period_status 
FROM   gl_period_statuses ps, 
       gl_sets_of_books sob, 
       fnd_application_vl fnd 
WHERE  ps.application_id IN ( 201, 101, 401, 200, 222 ) ----PO,GL,AP,INV,AR   
       AND sob.set_of_books_id = ps.set_of_books_id 
       AND fnd.application_id = ps.application_id 
       AND ps.adjustment_period_flag = 'N' 
       AND ps.closing_status IN ( 'O', 'C' ) 
       AND Trunc(ps.start_date) >= '01-JAN-2019' 
       AND Trunc(ps.end_date) <= '30-JUN-2019' 
UNION ALL --For Inventory Periods
SELECT 401                                                    application_id, 
       (SELECT application_name 
        FROM   fnd_application_tl 
        WHERE  LANGUAGE = Userenv('LANG') 
               AND application_id = 401)                      Application, 
       (SELECT user_name 
        FROM   fnd_user 
        WHERE  user_id = oap.last_updated_by)                 user_name, 
       (SELECT set_of_books_id 
        FROM   org_organization_definitions 
        WHERE  organization_id = oap.organization_id)         set_of_books_id, 
       (SELECT gsb.name 
        FROM   org_organization_definitions ood, 
               gl_sets_of_books gsb 
        WHERE  ood.set_of_books_id = gsb.set_of_books_id 
               AND ood.organization_id = oap.organization_id) set_of_books, 
       (SELECT ood.organization_name 
        FROM   org_organization_definitions ood 
        WHERE  ood.organization_id = oap.organization_id)     Organization_Name, 
       oap.period_name, 
       oap.start_date, 
       oap.end_date, 
       oap.close_date, 
       oap.last_update_date, 
       status 
FROM   org_acct_periods_v oap 
WHERE  1 = 1 
       AND Trunc(oap.start_date) >= '01-JAN-2019' 
       AND Trunc(oap.end_date) <= '30-JUN-2019' 
ORDER  BY 1, 
          2, 
          7; 

No comments:

Post a Comment