Архив

Архив раздела ‘Oracle e-Business Suite’

OEBS API: Добавляем счет на отделение поставщика

Скрипт добавления(назначения) счета на отделение заказчика.
В данном примере счета копируются из одного отделения в другое.

DECLARE
  p_org_id_from number := 111; 
  p_org_id_to   number := 112; 
  --
  l_payee_rec      iby_disbursement_setup_pub.payeecontext_rec_type;
  l_pay_instr_rec  iby_fndcpt_setup_pub.pmtinstrument_rec_type;  
  l_pay_assign_rec iby_fndcpt_setup_pub.pmtinstrassignment_rec_type;
  --
  x_assign_id           NUMBER;
  x_return_status       VARCHAR2(1);
  x_msg_count           NUMBER;
  x_msg_data            VARCHAR2(4000);
  x_response            apps.iby_fndcpt_common_pub.result_rec_type;  
BEGIN
  FND_MSG_PUB.initialize;
 
  fnd_global.apps_initialize(-1, 20639, 200); --Диспетчер кредиторов - Кредиторы
  
  for i in (
            SELECT sup.vendor_type_lookup_code
                 , sup.vendor_id
                 , ss.party_site_id
                 , ss2.party_site_id  party_site_id_to
                 , ss.vendor_site_id  vendor_site_id_from
                 , ss2.vendor_site_id vendor_site_id_to
                 , sup.party_id
                 , sup.segment1
                 , sup.vendor_name
                 , epa.org_id
                 , ss.vendor_site_code
                 , piu.order_of_preference priority
                 , eba.ext_bank_account_id
                 , eba.bank_id
                 , eba.branch_id
                 , eba.country_code
                 , eba.bank_account_name
                 , eba.bank_account_num
                 , eba.currency_code
                 , eba.foreign_payment_use_flag
                 , eba.payment_factor_flag
              FROM apps.ap_suppliers sup
                 , apps.ap_supplier_sites_all   ss
                 , apps.ap_supplier_sites_all   ss2
                 , apps.iby_external_payees_all epa
                 , apps.iby_pmt_instr_uses_all  piu
                 , apps.iby_ext_bank_accounts   eba
             WHERE sup.vendor_id     = ss.vendor_id
               AND ss.vendor_site_id = epa.supplier_site_id
               and ss2.vendor_id        = sup.vendor_id  
               and ss2.vendor_site_code = ss.vendor_site_code
               and ss2.org_id           = p_org_id_to
               AND epa.ext_payee_id  = piu.ext_pmt_party_id
               AND piu.instrument_id = eba.ext_bank_account_id
               AND epa.org_id    = p_org_id_from
               and not exists (select 1 
                               from apps.iby_external_payees_all epa1
                                  , apps.iby_pmt_instr_uses_all  piu1
                                  , apps.iby_ext_bank_accounts   eba1
                               where 1=1
                                     and epa1.supplier_site_id = ss2.vendor_site_id
                                     and epa1.ext_payee_id     = piu1.ext_pmt_party_id
                                     and piu1.instrument_id    = eba1.ext_bank_account_id
                                   and eba1.ext_bank_account_id = eba.ext_bank_account_id
                              )
                        
           )
  loop
    dbms_output.put_line('sup.vendor_id='||i.vendor_id);
 
    x_response := null;
    --    
    l_payee_rec.Party_Id         := i.party_id; 
    l_payee_rec.Payment_Function := 'PAYABLES_DISB';
    l_payee_rec.Party_Site_id    := i.party_site_id_to;
    l_payee_rec.Supplier_Site_id := i.vendor_site_id_to;
    l_payee_rec.Org_Id           := p_org_id_to;
    l_payee_rec.Org_Type         := 'OPERATING_UNIT';
    
    -- Instrument Record.
    l_pay_instr_rec.Instrument_Type := 'BANKACCOUNT';
    l_pay_instr_rec.Instrument_Id   := i.ext_bank_account_id;
          
    -- Assignment Record.
    l_pay_assign_rec.Instrument := l_pay_instr_rec;
    l_pay_assign_rec.Priority   := i.priority;
    l_pay_assign_rec.Start_Date := trunc(sysdate);    
    
    iby_disbursement_setup_pub.set_payee_instr_assignment(
        p_api_version        => 1.0,
        p_init_msg_list      => 'T',
        p_commit             => 'F',
        x_return_status      => x_return_status,
        x_msg_count          => x_msg_count,
        x_msg_data           => x_msg_data,
        p_payee              => l_payee_rec,
        p_assignment_attribs => l_pay_assign_rec,
        x_assign_id          => x_assign_id,
        x_response           => x_response);    
      
    dbms_output.put_line('x_return_status='||x_return_status);
    dbms_output.put_line('out_mesg.Result_Code     ='||x_response.Result_Code);
    dbms_output.put_line('out_mesg.Result_Category ='||x_response.Result_Category);
    dbms_output.put_line('out_mesg.Result_Message  ='||x_response.Result_Message);
   
    if x_return_status <> 'S' THEN
      fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
                                p_count   => x_msg_count,
                                p_data    => x_msg_data);
   
      dbms_output.put_line(chr(10)||'x_msg_count='||x_msg_count);
      if x_msg_count = 1 then
        dbms_output.put_line(x_msg_data);
      else
        FOR j IN 1 .. x_msg_count LOOP
          dbms_output.put_line(fnd_msg_pub.get(fnd_msg_pub.g_next,
                                               fnd_api.g_false));
        END LOOP;
      end if;
    end if;
    
  end loop;
  
  commit;
end;

Доп. информацию можно прочитать в ноте How to create bank account through API and associate to multiple supplier sites. [ID 1299614.1]

OEBS API: Добавление записи в lookup

Пример использования API для добавление записи в код поиска (lookup):

declare
 lx_rowid rowid;
begin
  for i in (select 'TEST'    as lookup_code,
                   'TEST'    as meaning,
                   null      as tag,
                   'TEST'    as descr,
                   sysdate   as start_date_active,
                   null      as end_date_active
              from dual t
            )
  loop
    -- Call the procedure
    fnd_lookup_values_pkg.insert_row(x_rowid               => lx_rowid,
                                     x_lookup_type         => 'LOOKUP_TYPE_NAME',
                                     x_security_group_id   => 0,
                                     x_view_application_id => 3,
                                     x_lookup_code         => i.lookup_code,
                                     x_tag                 => i.tag,
                                     x_attribute_category  => null,
                                     x_attribute1          => null,
                                     x_attribute2          => null,
                                     x_attribute3          => null,
                                     x_attribute4          => null,
                                     x_enabled_flag        => 'Y',
                                     x_start_date_active   => i.start_date_active,
                                     x_end_date_active     => i.end_date_active,
                                     x_territory_code      => null,
                                     x_attribute5          => null,
                                     x_attribute6          => null,
                                     x_attribute7          => null,
                                     x_attribute8          => null,
                                     x_attribute9          => null,
                                     x_attribute10         => null,
                                     x_attribute11         => null,
                                     x_attribute12         => null,
                                     x_attribute13         => null,
                                     x_attribute14         => null,
                                     x_attribute15         => null,
                                     x_meaning             => i.meaning,
                                     x_description         => i.descr,
                                     x_creation_date       => sysdate,
                                     x_created_by          => -1,
                                     x_last_update_date    => sysdate,
                                     x_last_updated_by     => -1,
                                     x_last_update_login   => -1);
  end loop;   
  commit;                                  
end;
/

API для обновления полномочий (RESPONSIBILITY)

25 Февраль 2013 Нет комментариев

Пример использования API для обновления даты действия полномочий

BEGIN
  FOR cr IN (SELECT * FROM fnd_responsibility_vl
             WHERE responsibility_key LIKE 'XX%'
            ) 
  LOOP
    fnd_responsibility_pkg.update_row(
            x_responsibility_id         => cr.responsibility_id,
            x_application_id            => cr.application_id,
            x_web_host_name             => cr.web_host_name,
            x_web_agent_name            => cr.web_agent_name,
            x_data_group_application_id => cr.data_group_application_id,
            x_data_group_id             => cr.data_group_id,
            x_menu_id                   => cr.menu_id,
            x_start_date                => to_date('01-01-1951','dd-mm-yyyy'),
            x_end_date                  => cr.end_date,
            x_group_application_id      => cr.group_application_id,
            x_request_group_id          => cr.request_group_id,
            x_version                   => cr.VERSION,
            x_responsibility_key        => cr.responsibility_key,
            x_responsibility_name       => cr.responsibility_name,
            x_description               => cr.description,
            x_last_update_date          => SYSDATE,
            x_last_updated_by           => fnd_global.user_id,
            x_last_update_login         => fnd_global.login_id);
  END LOOP;

  COMMIT;
END;
/

OAF R12 Developer’s guide

4 Декабрь 2012 1 комментарий

Весьма полезные гайды по Oracle Application Framework (OAF)

Ноты на металинке:
Oracle Application Framework Developer’s Guide Release 12.1.3 [ID 1107973.1]
Oracle Application Framework Developer’s Guide Release 12.1.2 [ID 972774.1]
Oracle Application Framework Developer’s Guide Release 12.1.1 [ID 744832.1]

У кого нет доступа, тот может взять
Oracle Application Framework Developer’s Guide Release 12.1.3 по ссылкам:
Depositfiles
Google Docs

OEBS API: Обновляем альтернативное имя отделения поставщика

4 Декабрь 2012 Нет комментариев

Скрипт обновления альтернативного имени отделения поставщика.
В данном примере обнуляем альтернативное наименование.

SET SERVEROUTPUT ON SIZE 1000000
DECLARE
  x_return_status varchar2(1);
  x_msg_count     number;
  x_msg_data      varchar2(4000);
  --
  l_vendor_site_rec AP_VENDOR_PUB_PKG.r_vendor_site_rec_type;
  --
  l_success_count NUMBER := 0;
  l_failure_count NUMBER := 0;
  l_all_count     NUMBER := 0;  
BEGIN
  fnd_global.apps_initialize(1, 20639, 200); --Диспетчер кредиторов - Кредиторы

  l_success_count := 0;
  l_failure_count := 0;
  l_all_count     := 0;  
  -- цикл по отделениям
  for s in (select t.vendor_site_id from ap_supplier_sites_all t
            where 1=1
                  and t.vendor_site_code like '%XX%'
                  and vendor_site_code_alt is not null
           )
  loop
    l_all_count := l_all_count + 1;
    -- обнуляем альт.имя
    l_vendor_site_rec.VENDOR_SITE_CODE_ALT := chr(0);
    --
    ap_vendor_pub_pkg.update_vendor_site(p_api_version      => 1.0,
                                         p_init_msg_list    => fnd_api.g_true,
                                         p_commit           => fnd_api.g_false,
                                         p_validation_level => fnd_api.g_valid_level_full,
                                         x_return_status    => x_return_status,
                                         x_msg_count        => x_msg_count,
                                         x_msg_data         => x_msg_data,
                                         p_vendor_site_rec  => l_vendor_site_rec,
                                         p_vendor_site_id   => s.vendor_site_id);

    if (x_return_status <> 'S') then
      l_failure_count := l_failure_count + 1;
      fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
                                p_count   => x_msg_count,
                                p_data    => x_msg_data);
     
      if x_msg_count = 1 then
        dbms_output.put_line('ERROR vendor_site_id='||s.vendor_site_id
                             ||'"; '|| x_msg_data );
      else
        FOR j IN 1 .. x_msg_count LOOP
          x_msg_data := fnd_msg_pub.get(fnd_msg_pub.g_next,fnd_api.g_false);
          dbms_output.put_line('ERROR vendor_site_id='||s.vendor_site_id
                               ||'"; '|| x_msg_data );
        END LOOP;
      end if;
    else
      l_success_count := l_success_count + 1;
    end if;
      
  end loop; -- s

  dbms_output.put_line('+--------------------------------------+');    
  dbms_output.put_line('UPDATE INFORMATION');
  dbms_output.put_line('  All count      : '||l_all_count);
  dbms_output.put_line('  Update success : '||l_success_count);      
  dbms_output.put_line('  Update failure : '||l_failure_count);
  dbms_output.put_line('+--------------------------------------+');
  commit;
 
END;

OEBS API: Обновляем имя поставщика

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

Скрипт обновления имени и альтернативного имени поставщика.
Убираем лишние пробелы в конце и начале имени.

declare
  l_organization_rec  HZ_PARTY_V2PUB.ORGANIZATION_REC_TYPE;
  l_party_rec         HZ_PARTY_V2PUB.PARTY_REC_TYPE;
  x_profile_id        NUMBER;
  --
  l_success_count NUMBER := 0;
  l_failure_count NUMBER := 0;
  l_all_count     NUMBER := 0;
  --
  x_return_status VARCHAR2(1);
  x_msg_count     NUMBER;
  x_msg_data      VARCHAR2(4000);  
begin
  
  fnd_global.apps_initialize(1, 20639, 200); --Диспетчер кредиторов - Кредиторы
  for i in (SELECT vendor_id, 
                   vendor_name, 
                   vendor_name_alt, 
                   party_id, 
                  (select hp.object_version_number 
                   from hz_parties hp where party_id = pv.party_id
                  ) as object_version_number
            FROM po_vendors pv
            WHERE 1=1
                  and (vendor_name like '% ' or vendor_name like ' %'
                      or vendor_name_alt like '% '
                      or vendor_name_alt like ' %')
            )
  loop
    l_all_count := l_all_count + 1;
    
    --dbms_output.put_line('vendor_id='||i.vendor_id);
    l_party_rec.party_id                          := i.party_id;
    l_organization_rec.organization_name          := trim(i.vendor_name);
    l_organization_rec.organization_name_phonetic := trim(i.vendor_name);
    l_organization_rec.party_rec                  := l_party_rec;
    HZ_PARTY_V2PUB.update_organization(p_init_msg_list               => FND_API.G_TRUE,
                                       p_organization_rec            => l_organization_rec,
                                   p_party_object_version_number => i.object_version_number,
                                       x_profile_id                  => x_profile_id,
                                       x_return_status               => x_return_status,
                                       x_msg_count                   => x_msg_count,
                                       x_msg_data                    => x_msg_data);
      
    --dbms_output.put_line(x_return_status);
    if (x_return_status <> 'S') then
      l_failure_count := l_failure_count + 1;
      fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
                                p_count   => x_msg_count,
                                p_data    => x_msg_data);
                                      
      if x_msg_count = 1 then
        dbms_output.put_line('ERROR vendor_id='||i.vendor_id
                             ||'; vendor_name="'||i.vendor_name||'"; '|| x_msg_data );
      else
        FOR j IN 1 .. x_msg_count LOOP
          x_msg_data := fnd_msg_pub.get(fnd_msg_pub.g_next,fnd_api.g_false);
          dbms_output.put_line('ERROR vendor_id='||i.vendor_id
                               ||'; vendor_name="'||i.vendor_name||'"; '|| x_msg_data );
        END LOOP;
      end if;
    else
      l_success_count := l_success_count + 1;
    end if;
      
  end loop;  
    
  dbms_output.put_line('+--------------------------------------+'); 
  dbms_output.put_line('Обновление поставщиков');   
  dbms_output.put_line('  Общее количество    : '||l_all_count);
  dbms_output.put_line('  Обновлено успешно   : '||l_success_count);      
  dbms_output.put_line('  Не удалось обновить : '||l_failure_count);
  dbms_output.put_line('+--------------------------------------+');    
  
  COMMIT;
                            
end;

OEBS API: Создание расчетного счета на отделении поставщика

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

Пример скрипта для создания расчетного счета на отделении поставщика:

DECLARE
  l_bank_acct_rec       apps.iby_ext_bankacct_pub.extbankacct_rec_type;
  out_mesg              apps.iby_fndcpt_common_pub.result_rec_type;
  l_acct                NUMBER;
  l_bank_id             NUMBER := 0; --!!! установить значение
  l_branch_id           NUMBER := 0; --!!!
  l_acct_owner_party_id NUMBER := 0; --!!!
  l_supplier_site_id    NUMBER := 0; --!!!
  l_party_site_id       NUMBER := 0; --!!!
  --
  x_return_status       VARCHAR2(1);
  x_msg_count           NUMBER;
  x_msg_data            VARCHAR2(4000);  
BEGIN
  FND_MSG_PUB.initialize;
  
  fnd_global.apps_initialize(1, 20639, 200); --Диспетчер кредиторов - Кредиторы

  l_bank_acct_rec.bank_id               := l_bank_id; 
  l_bank_acct_rec.branch_id             := l_branch_id;
  l_bank_acct_rec.country_code          := 'RU';
  l_bank_acct_rec.bank_account_name     := '3321615678101831567890';
  l_bank_acct_rec.bank_account_num      := 3321615678101831567890;
  l_bank_acct_rec.acct_owner_party_id   := l_acct_owner_party_id;
  l_bank_acct_rec.currency              := 'RUB';
  l_bank_acct_rec.object_version_number := 1.0;
  l_bank_acct_rec.start_date            := sysdate;
  l_bank_acct_rec.foreign_payment_use_flag := 'Y';
  l_bank_acct_rec.payment_factor_flag      := 'N';

  apps.iby_ext_bankacct_pub.create_ext_bank_acct(p_api_version       => 1.0,
                                                 p_init_msg_list     => 'F',
                                                 p_ext_bank_acct_rec => l_bank_acct_rec,
                                                 p_association_level => 'SS',
                                                 p_supplier_site_id  => l_supplier_site_id,
                                                 p_party_site_id     => l_party_site_id,
                                                 p_org_id            => 82,
                                                 p_org_type          => 'OPERATING_UNIT',
                                                 x_acct_id           => l_acct,
                                                 x_return_status     => x_return_status,
                                                 x_msg_count         => x_msg_count,
                                                 x_msg_data          => x_msg_data,
                                                 x_response          => out_mesg);
  COMMIT;  
                                 
  dbms_output.put_line('x_return_status='||x_return_status);
  dbms_output.put_line('out_mesg.Result_Code     ='||out_mesg.Result_Code);
  dbms_output.put_line('out_mesg.Result_Category ='||out_mesg.Result_Category);
  dbms_output.put_line('out_mesg.Result_Message  ='||out_mesg.Result_Message);
  
  if x_return_status <> 'S' THEN
    fnd_msg_pub.count_and_get(p_encoded => fnd_api.g_false,
                              p_count   => x_msg_count,
                              p_data    => x_msg_data);
                                
    dbms_output.put_line(chr(10)||'x_msg_count='||x_msg_count);
    if x_msg_count = 1 then
      dbms_output.put_line(x_msg_data);
    else
      FOR i IN 1 .. x_msg_count LOOP
        dbms_output.put_line(fnd_msg_pub.get(fnd_msg_pub.g_next,
                                             fnd_api.g_false));
      END LOOP;
    end if;    
  end if;
end;

OEBS API: Создание поставщика и отделения

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

OEBS Пример использования API для создания поставщика и отделения поставщика:

declare
  l_vendor_rec      AP_VENDOR_PUB_PKG.r_vendor_rec_type;
  l_vendor_site_rec AP_VENDOR_PUB_PKG.r_vendor_site_rec_type;
  x_vendor_id       number;
  x_party_id        number;
  x_vendor_site_id  number;
  x_party_site_id   number;
  x_location_id     number;
  l_party_site_id   number;
  --
  x_return_status VARCHAR2(1);
  x_msg_count     NUMBER;
  x_msg_data      VARCHAR2(4000);
begin
  l_vendor_rec.SEGMENT1     := '1234575';
  l_vendor_rec.VENDOR_NAME  := 'MYTESTSUPPLIER2';
  l_vendor_rec.SUMMARY_FLAG := 'N';
  l_vendor_rec.ENABLED_FLAG := 'Y';

  AP_VENDOR_PUB_PKG.Create_Vendor(p_api_version   => 1,
                                  x_return_status => x_return_status,
                                  x_msg_count     => x_msg_count,
                                  x_msg_data      => x_msg_data,
                                  p_vendor_rec    => l_vendor_rec,
                                  x_vendor_id     => x_vendor_id,
                                  x_party_id      => x_party_id);

  if (x_return_status <> 'S') then
    dbms_output.put_line('ERROR in supplier creation');
    dbms_output.put_line('--------------------------------------');
  
    if x_msg_count = 1 then
      dbms_output.put_line(x_msg_data);
    else
      FOR i IN 1 .. x_msg_count LOOP
        dbms_output.put_line(fnd_msg_pub.get(fnd_msg_pub.g_next,
                                             fnd_api.g_false));
      END LOOP;
    end if;
  else
  
    l_vendor_site_rec.vendor_id            := x_vendor_id;
    l_vendor_site_rec.VENDOR_SITE_CODE     := 'MYHOME';
    l_vendor_site_rec.org_id               := 82;
    l_vendor_site_rec.COUNTRY              := 'RU';
    l_vendor_site_rec.ADDRESS_LINE1        := 'Lenina';
    l_vendor_site_rec.PURCHASING_SITE_FLAG := 'Y';
    l_vendor_site_rec.PAY_SITE_FLAG        := 'Y';
  
    AP_VENDOR_PUB_PKG.Create_Vendor_Site(p_api_version     => 1,
                                         x_return_status   => x_return_status,
                                         x_msg_count       => x_msg_count,
                                         x_msg_data        => x_msg_data,
                                         p_vendor_site_rec => l_vendor_site_rec,
                                         x_vendor_site_id  => x_vendor_site_id,
                                         x_party_site_id   => x_party_site_id,
                                         x_location_id     => x_location_id);
  
    if (x_return_status <> 'S') then
      dbms_output.put_line('ERROR in supplier site creation');
      dbms_output.put_line('--------------------------------------');
    
      if x_msg_count = 1 then
        dbms_output.put_line(x_msg_data);
      else
        FOR i IN 1 .. x_msg_count LOOP
          dbms_output.put_line(fnd_msg_pub.get(fnd_msg_pub.g_next,
                                               fnd_api.g_false));
        END LOOP;
      end if;
    else
      dbms_output.put_line('Supplier Site Created!');
    end if;
  
  end if;
  
  commit;
end;

OEBS Программа – сторнирование журналов SQLGL GLPREV

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

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

-- -------------------------------------------------------------------------------
-- Сторнирование журнала
PROCEDURE reverse_journals(x_return_status OUT VARCHAR2
                          ,x_mess          OUT VARCHAR2) 
IS
  TYPE t_integers IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
  l_request_ids   t_integers;
  l_result        BOOLEAN := TRUE;
  l_access_set_id NUMBER;
BEGIN
  write_log('START REVERSE_JOURNALS');
  x_return_status := 'E';
  l_access_set_id := fnd_profile.value('GL_ACCESS_SET_ID');
  FOR c_je IN (SELECT jh.je_header_id
                     ,jh.rowid        AS row_id
                     ,jh.name         AS journal_name
                     ,b.name          AS batch_name
                 FROM gl.gl_je_headers jh, gl_je_batches b
                WHERE 1 = 1
                  AND jh.je_batch_id = b.je_batch_id
                     --
                  AND jh.ledger_id = G_LEDGER_ID
                  AND jh.je_source = G_JE_SOURCE_NAME
                  AND jh.je_category = G_JE_CATEGORY_NAME
                  AND jh.period_name = P_PERIOD_NAME
                  AND (b.name LIKE g_bath_name_in || '%' OR
                      b.name LIKE g_bath_name_out || '%')
                  AND (jh.name LIKE g_jh_name_in || '%' OR
                      jh.name LIKE g_jh_name_out || '%')
                  AND ( --Неотсторнированные журналы
                       (jh.accrual_rev_status IS NULL AND
                 -- сторно на сторно на сторно ...
                       jh.reversed_je_header_id IS NULL) OR 
                       (jh.accrual_rev_status IS NULL AND
                       jh.reversed_je_header_id IS NOT NULL AND
                       MOD((SELECT COUNT(*)
                              FROM gl_je_headers jh0
                             START WITH jh0.je_header_id = jh.je_header_id
                            CONNECT BY jh0.je_header_id = PRIOR
                                       jh0.reversed_je_header_id)
                           ,2) != 0))
                ORDER BY jh.je_header_id)
  LOOP
    write_log('  Сторнирование журнала "' || c_je.journal_name ||
           '" из пакета "' || c_je.batch_name || '"');
    UPDATE gl_je_headers
       SET accrual_rev_flag             = 'Y'
          ,accrual_rev_period_name      = P_PERIOD_NAME
          ,accrual_rev_change_sign_flag = 'Y'
          ,accrual_rev_effective_date   = SYSDATE
     WHERE ROWID = c_je.row_id;
    --
    l_request_ids(l_request_ids.COUNT + 1) :=
     fnd_request.submit_request(application => 'SQLGL'
                                ,program     => 'GLPREV'
                                ,description => NULL
                                ,start_time  => NULL
                                ,sub_request => FALSE
                                ,argument1   => l_access_set_id
                                ,argument2   => c_je.je_header_id);
    COMMIT;
    IF l_request_ids(l_request_ids.COUNT) = 0 THEN
      write_log('Ошибка при отправке параллельного запроса Сторнирование журналов.');
      l_request_ids.DELETE(l_request_ids.COUNT);
      l_result := FALSE;
      --exit;
    END IF;
  END LOOP;
  --
  WHILE l_request_ids.COUNT > 0
  LOOP
    -- описание функции http://apps-oracle.ru/fnd_request_exec/#WAIT_CONCURRENT
    if NOT (wait_concur(l_request_ids(l_request_ids.FIRST),x_mess)) then
      write_log(x_mess);
      l_result := FALSE;
      exit;
    end if;
    l_request_ids.DELETE(l_request_ids.FIRST);
  END LOOP;
  write_log('END REVERSE_JOURNALS' || chr(10));
  --
  IF l_result THEN
    x_return_status := 'S';
    x_mess          := 'Сторнирование журналов завершено успешно.';
    RETURN;
  ELSE
    x_return_status := 'E';
    x_mess          := 'Сторнирование журналов завершено с ошибками. '||x_mess;
    RETURN;
  END IF;
  --
END reverse_journals;

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;