Архив

Публикации с меткой ‘GLPPOSS’

OEBS Программа – проведение журналов SQLGL GLPPOSS

13 Ноябрь 2012 Нет комментариев

ОЕБС Пример вызова параллельной программы для проведения журналов

-- -----------------------------------------------------
-- Проведение журналов
-- -----------------------------------------------------
PROCEDURE post_journals(p_ledger_id NUMBER
                       ,p_group_id  NUMBER
                       ,p_period    VARCHAR2
                       ,p_rev       NUMBER
                       ,x_return_status OUT VARCHAR2
                       ,x_mess          OUT VARCHAR2)
IS
  l_request_id           INTEGER;
  l_posting_run_id       INTEGER;
  l_chart_of_accounts_id INTEGER;
  l_access_set_id        INTEGER;
BEGIN
  write_log('START POST_JOURNALS');
  x_return_status  := 'E';
  l_posting_run_id := gl_je_posting_s.nextval;
  IF (p_rev = 0) THEN
    UPDATE gl_je_batches b
       SET status               = 'S'
          ,approval_status_code = 'Z' -- пакет должен быть утвержден
          ,posting_run_id       = l_posting_run_id
     WHERE b.status = 'U'
       AND b.GROUP_ID = p_group_id;
  ELSIF (p_rev = 1) THEN
    UPDATE gl_je_batches b
       SET status               = 'S'
          ,approval_status_code = 'Z' -- пакет должен быть утвержден
          ,posting_run_id       = l_posting_run_id
     WHERE b.status = 'U'
       AND EXISTS
     (SELECT 1
              FROM gl_je_batches jb, gl_je_headers h, gl_je_headers hr
             WHERE jb.je_batch_id = h.je_batch_id
               AND h.je_header_id = hr.reversed_je_header_id
               AND (h.name LIKE G_JH_NAME_IN || '%' OR
                   h.name LIKE G_JH_NAME_OUT || '%')
               AND h.period_name = p_period
               AND h.ledger_id = p_ledger_id
               AND hr.je_batch_id = b.je_batch_id)
       AND 2 = 2;
  END IF;
  write_log('  UPDATE ' || SQL%ROWCOUNT || ' rows in GL_JE_BATCHES');
  IF (SQL%ROWCOUNT > 0) THEN
    --
    SELECT l.chart_of_accounts_id, a.access_set_id
      INTO l_chart_of_accounts_id, l_access_set_id
      FROM gl_ledgers l, gl_access_sets a
     WHERE 1 = 1
       AND l.ledger_id = p_ledger_id
       AND a.default_ledger_id = l.ledger_id
       AND a.chart_of_accounts_id = l.chart_of_accounts_id
       AND a.period_set_name = l.period_set_name
       AND a.accounted_period_type = l.accounted_period_type;
 
    l_request_id := fnd_request.submit_request(
                 application => 'SQLGL'
                ,program     => 'GLPPOSS'
                ,description => NULL
                ,start_time  => NULL
                ,sub_request => FALSE
                ,argument1   => p_ledger_id
                ,argument2   => TO_CHAR(fnd_profile.value('GL_ACCESS_SET_ID'))
                ,argument3   => l_chart_of_accounts_id
                ,argument4   => l_posting_run_id);
 
    COMMIT;
    
    IF l_request_id = 0 THEN
      x_mess := 'Ошибка при отправке запроса проводки журналов';
      RETURN;
    END IF;
    
    -- описание функции http://apps-oracle.ru/fnd_request_exec/#WAIT_CONCURRENT
    if NOT (wait_concur(l_request_id,x_mess)) then
      write_log(x_mess);
      RETURN;
    end if;

  END IF;
 
  x_return_status := 'S';
  write_log('END POST_JOURNALS' || chr(10));
  RETURN;
EXCEPTION
  WHEN OTHERS THEN
    x_mess := 'Ошибка при запуске запроса проводки журналов: ' || SQLERRM;
END;