Oracle R12 Check the GL Period open or close

DECLARE

v_gl_period_status     NUMBER;
v_err_msg              VARCHAR2(100);

BEGIN
   SELECT 1
     INTO v_gl_period_status
     FROM gl_period_statuses a, fnd_application_vl b
    WHERE     1 = 1
          AND a.set_of_books_id = :P_set_of_books_id
          AND b.application_short_name = 'SQLGL'
          AND a.application_id = b.application_id
          AND :p_invoice_date BETWEEN a.start_date
                                  AND NVL (a.end_date, SYSDATE)
          AND NVL (a.adjustment_period_flag, 'X') = 'N'
          AND NVL (a.closing_status, '1') = 'O';
EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
      v_err_msg := 'GL PERIOD NOT OPEN';
      v_gl_period_status := 0;
      DBMS_OUTPUT.PUT_LINE (v_err_msg);
   WHEN OTHERS
   THEN
      v_err_msg := 'GL PERIOD ERR ' || SQLERRM;
      v_gl_period_status := 0;
      DBMS_OUTPUT.PUT_LINE (v_err_msg);
END;