Friday, 20 February 2026

GL Unapproved Batches With Approver Report

 GL Unapproved Batches With Approver Report


SELECT distinct

       Al1.Ledger_Id,

       Al1.Ledger_Name,

       Al1.Period_Mon_Yy Period,

       Al1.Batch_Name,

       Al1.Batch_User_Name,

       Al1.Batch_Creation_Date,   

       COUNT(Al1.Je_Line_Num) Je_Lines_Count,

--       Al2.Submitted_By_Name,

   Al1.Batch_User_Name Submitted_By_Name,

--       Al2.Approver_Name,

   Al2.full_name Approver_Name,

--       Al2.Begin_Date,

       Al2.action_date Begin_Date,

       Al1.Je_Batch_Id,

       Al1.Account_Combination Acct_Cd_Comb,

       Al1.Batch_Approval_Status,

       Al1.Batch_Apprv_Stat_Cd,

       Al1.Batch_Status,

       Al1.Batch_Status_Descr,

       Al1.Batch_User_Name Batch_User_Desc,

       Al1.Batch_User_Id Batch_User,

   sysdate timestamp

  FROM (SELECT Glh.Ledger_Id Ledger_Id,

               Glldg.Name Ledger_Name,

               Glh.Period_Name Period_Mon_Yy,

               Glcc.Concatenated_Segments Account_Combination,

               Glb.Name Batch_Name,

               Glb.Description Batch_Description,

               Glb.Status Batch_Status,

               Decode(Glb.Status,

                      'P',

                      'Posted',

                      'U',

                      'Unposted',

                      'S',

                      'Selected',

                      'I',

                      'In Process',

                      '-',

                      'Bad Rounding',

                      'AU',

                      'Unopened Period',

                      'B',

                      'Batch total violation',

                      'BF',

                      'Frozen or inactive budget',

                      'BU',

                      'Unopened budget year',

                      'C',

                      'Unopened reporting period',

                      'D',

                      'Unopened period',

                      'E',

                      'No journal entries',

                      'G',

                      'Bad supsense acct',

                      'H',

                      'Bad reserve acct',

                      'J',

                      'Journal total violation',

                      'K',

                      'Unbalanced IC JE',

                      'L',

                      'Unbalanced JE',

                      'M',

                      'Multiple problems',

                      'N',

                      'Bad interco acct',

                      'O',

                      'No reptg conversion info',

                      'T',

                      'Invalid conversion info',

                      'X',

                      'Unbalanced JE',

                      'Error') Batch_Status_Descr,

               Glb.Approval_Status_Code Batch_Apprv_Stat_Cd,

               Decode(Glb.Approval_Status_Code,

                      'A',

                      'Approved',

                      'I',

                      'In Process',

                      'J',

                      'Rejected',

                      'R',

                      'Required',

                      'V',

                      'Failed',

                      'N/A') Batch_Approval_Status,

               to_char(Glb.Creation_Date,'mm/dd/yyyy hh:mi:ss AM') Batch_Creation_Date, 

               --Fndu.UserName Batch_User_Id,

   pp.ATTRIBUTE3 Batch_User_Id,

   ppnf.display_name Batch_User_Name,

               --Fndu.Description Batch_User_Name,

               Glh.Name Header_Name,

               Glh.Description Header_Description,

               Glh.Status Je_Status_Flag,

               Glb.Posted_Date Posted_Date,

               Gll.Je_Line_Num Je_Line_Num,

               Glh.Je_Batch_Id Je_Batch_Id      

          FROM Gl_Ledgers               Glldg,

               Gl_Je_Headers            Glh,

               Gl_Je_Lines              Gll,

               Gl_Code_Combinations Glcc,

               Gl_Je_Batches            Glb,

               --Fnd_User                 Fndu,

   per_users pu,

   per_persons              pp,

   per_person_names_f       ppnf,

               gl_je_sources            gjs

         WHERE Glh.Ledger_Id = Glldg.Ledger_Id

           AND Glh.Je_Header_Id = Gll.Je_Header_Id

           AND Gll.Code_Combination_Id = Glcc.Code_Combination_Id

           AND Glh.Je_Batch_Id = Glb.Je_Batch_Id

           --AND Glb.Created_By = Fndu.User_Id

   and upper(Glb.Created_By) = upper(to_char(pu.Username))

   and ppnf.person_id(+) = pu.person_id

   and ppnf.person_id(+) = pp.person_id

   and ppnf.name_type     = 'GLOBAL'

   AND sysdate between  ppnf.effective_Start_Date AND ppnf.effective_End_Date

           and gjs.je_source_name = Glh.je_source

           and gjs.JOURNAL_APPROVAL_FLAG = 'Y'

           --and Glh.Period_Name = NVL(:P_PERIOD_NAME,Glh.Period_Name)

   AND ((COALESCE (NULL,:P_PERIOD_NAME) IS NULL)  OR (Glh.Period_Name IN (:P_PERIOD_NAME))   OR 'ALL' in (:P_PERIOD_NAME))

           --and Glcc.segment1 = NVL(:P_SEGMENT1,Glcc.segment1)

   AND ((COALESCE (NULL,:P_SEGMENT1) IS NULL)  OR (Glcc.segment1 IN (:P_SEGMENT1))   OR 'ALL' in (:P_SEGMENT1))

   --and Glldg.Name = NVL(:P_NAME,Glldg.Name)

   AND ((COALESCE (NULL,:P_NAME) IS NULL)  OR (Glldg.Name IN (:P_NAME))   OR 'ALL' in (:P_NAME))

           --and pu.UserName = NVL(:P_USERNAME,pu.UserName)

   AND ((COALESCE (NULL,:P_USERNAME) IS NULL)  OR (pu.UserName IN (:P_USERNAME))   OR 'ALL' in (:P_USERNAME))

           and Glb.Approval_Status_Code <> 'A') Al1,

(SELECT    to_char( MAX(action_date),'mm/dd/yyyy hh:mi:ss AM') action_date, 

                                      MAX(TRIM(ppnf.full_name)) full_name, 

      gja.je_batch_id,

    gja.action_code

                        FROM      gl_je_action_log   gja,

                      per_users          pu,

                                      per_person_names_f ppnf

                            WHERE     LOWER(gja.user_id) = LOWER(pu.username (+))

                    AND       pu.person_id       = ppnf.person_id

                    AND       ppnf.name_type     = 'GLOBAL'

AND sysdate between  ppnf.effective_Start_Date AND ppnf.effective_End_Date

AND       gja.action_code <> 'APPROVED'

AND    gja.action_date =

       (

              SELECT Max(gja1.action_date)

              FROM   gl_je_action_log gja1

              WHERE  1 = 1

              AND    gja1.action_code <> 'CREATED'

              AND    gja1.je_batch_id = gja.je_batch_id

  )

GROUP BY  gja.je_batch_id,

  gja.action_code) Al2

WHERE Al1.Je_Batch_Id = Al2.je_batch_id(+)

--and Al1.Batch_Apprv_Stat_Cd = NVL(:P_BATCH_APP,Al1.Batch_Apprv_Stat_Cd)

 AND ((COALESCE (NULL,:P_BATCH_APP) IS NULL)  OR (Al1.Batch_Apprv_Stat_Cd IN (:P_BATCH_APP))   OR 'ALL' in (:P_BATCH_APP))

  

 GROUP BY Al1.Ledger_Id,

          Al1.Ledger_Name,

          Al1.Period_Mon_Yy,

          Al1.Batch_Name,

          Al1.Batch_User_Name,

          Al1.Batch_Creation_Date,

          --Al2.Submitted_By_Name,

          Al2.full_name,

          Al2.action_date,

          Al1.Je_Batch_Id,

          Al1.Account_Combination,

          Al1.Batch_Approval_Status,

          Al1.Batch_Apprv_Stat_Cd,

          Al1.Batch_Status,

          Al1.Batch_Status_Descr,

          Al1.Batch_User_Name,

          Al1.Batch_User_Id

 ORDER BY 2

 

No comments: