Wednesday, September 9, 2015

Custom Web ADI (Upload)

After download now we will see how to upload records. We will use the same custom table we used in download.


Download ADI: Custom-web-adi-download



Before defining the integrator some perquisites are required. We need to define a packaged procedure which will be executed for every record of the excel. You can do validation on records and show error messages for the same.


Sample Code
create or replace package xxak_testadi_pkg
as
   procedure load_record (p_batch_no        in     number,
                          p_order_number    in     varchar2,
                          p_start_date      in     varchar2,
                          p_end_date        in     varchar2,
                          p_ba              in     varchar2,
                          p_status          in     varchar2
                          );
end xxak_testadi_pkg;
/

 -------

create or replace package body xxak_testadi_pkg
as
   procedure load_record (p_batch_no        in     number,
                          p_order_number    in     varchar2,
                          p_start_date      in     varchar2,
                          p_end_date        in     varchar2,
                          p_ba              in     varchar2,
                          p_status          in     varchar2
                         )
   as
      ve_order_exp   exception;
      pragma autonomous_transaction;
   begin
  
      if p_order_number = '99999999' then
         raise ve_order_exp;
      end if;
     --business validations can be added here
      insert into xxak_web_adi_downlaod_tbl
           values (p_order_number,
                   sysdate,
                   sysdate,
                   fnd_profile.value('USER_ID'),
                   fnd_profile.value('USER_ID'),
                   fnd_profile.value('LOGIN_ID'),
                   p_ba,
                   to_date(p_start_date,'DD/MM/RRRR'),
                   to_date(p_end_date,'DD/MM/RRRR'),
                   p_batch_no,
                   p_status
                   );
      --
      commit;
      --
   exception
      when ve_order_exp then
         raise_application_error (-20116,'Error - Invalid Order Number');
      when others  then
         raise_application_error (-20117,'Error - Cannot insert');
   end load_record;
   --
end xxak_testadi_pkg;
/

Responsibility: Desktop Integration Manager
> Create Integrator
XXAK: Test Upload ADI
XXAKTESTUPADI
Check the box for ‘Display in Create Document Page’
Add these three functions
Code:
BNE_ADI_DEFINE_MAPPING
BNE_CREATE_DOCUMENT
BNE_ADI_CREATE_DOCUMENT



Interface type here would be ‘API Procedure’

Package Name: xxak_testadi_pkg

Procedure/Function Name: load_record
API Returns : Error Message
Apply
You can click on ‘Update’ and change prompt and other details required
Skip ‘Create Content’
Create Uploader
Uploader: From Template
Create
Select check boxes as below
Skip ‘Create Importer’
Submit

Define Layout
Navigation: Desktop Integrator -> Define Layout -> Select the Integrator
Go > Create
Change the Placement to 'Line'
In order to generate a sequence number for column SEQ_NO, write sql in Default
Value field and choose SQL as Default Type
select xxak_test_adi_batch.NEXTVAL from dual

Next





Apply




Add a form function and add to specified responsibility menu
Responsibility: Application Developer
  > Application > Function





Type: SSWA servlet function
HTML Call: BneApplicationService










Parameter: bne:page=BneCreateDoc&bne:integrator=20003:XXAKTESTUPADI_XINTG&bne:layout=20003:XXAKTESTUPLOADADI


select integrator_app_id || ':' || integrator_code integrator
     , application_id || ':' || layout_code layouts
  from bne_layouts_b
 where integrator_code like 'XXAK%';



Save and Exit

Add this Function to the specified Menu

Now go to the respective responsibility and run the ADI


Create Document