Oracle EBS R12 Outbound Interface Example

 CREATE OR REPLACE PROCEDURE XX_INV_ITEMS_OUT (Errbuf       OUT varchar2,

                                         Retcode      OUT varchar2,

                                         p_id      IN     number)

AS

   CURSOR c1

   IS

      SELECT   msi.segment1 item,

               msi.inventory_item_id Itemid,

               msi.description itemdesc,

               msi.primary_uom_code Uom,

               ood.organization_name name,

               ood.organization_id id,

               mc.segment1 || ',' || mc.segment2 Category

        FROM   mtl_system_items_b msi,

               org_organization_definitions ood,

               mtl_item_categories mic,

               mtl_categories mc

       WHERE       msi.organization_id = ood.organization_id

               AND msi.inventory_item_id = mic.inventory_item_id

               AND msi.organization_id = mic.organization_id

               AND mic.category_id = mc.category_id

               AND msi.purchasing_item_flag = 'Y'

               AND msi.organization_id = p_id;


   x_id      UTL_FILE.file_type;

   l_count   number (5) DEFAULT 0 ;

BEGIN

   x_id :=

      UTL_FILE.fopen ('/u01/install/APPS/temp/EBSDB', 'InvItem.csv', 'W');


   --select * from v$parameter where name like '%utl_file%'

   FOR x1 IN c1

   LOOP

      l_count := l_count + 1;

      UTL_FILE.put_line (

         x_id,

            x1.item

         || ','

         || x1.itemid

         || ','

         || x1.itemdesc

         || ','

         || x1.uom

         || ','

         || x1.name

         || ','

         || x1.id

         || ','

         || x1.category

      );

   END LOOP;


   UTL_FILE.fclose (x_id);

   Fnd_file.Put_line (

      Fnd_file.output,

      'No of Records transfered to the data file :' || l_count

   );

   Fnd_File.Put_line (fnd_File.Output, ' ');

   Fnd_File.Put_line (

      fnd_File.Output,

      'Submitted User name  ' || Fnd_Profile.VALUE ('USERNAME')

   );

   Fnd_File.Put_line (fnd_File.Output, ' ');

   Fnd_File.Put_line (

      fnd_File.Output,

      'Submitted Responsibility name ' || Fnd_profile.VALUE ('RESP_NAME')

   );

   Fnd_File.Put_line (fnd_File.Output, ' ');

   Fnd_File.Put_line (fnd_File.Output, 'Submission Date :' || SYSDATE);

EXCEPTION

   WHEN UTL_FILE.invalid_operation

   THEN

      fnd_file.put_line (fnd_File.LOG, 'invalid operation');

      UTL_FILE.fclose_all;

   WHEN UTL_FILE.invalid_path

   THEN

      fnd_file.put_line (fnd_File.LOG, 'invalid path');

      UTL_FILE.fclose_all;

   WHEN UTL_FILE.invalid_mode

   THEN

      fnd_file.put_line (fnd_File.LOG, 'invalid mode');

      UTL_FILE.fclose_all;

   WHEN UTL_FILE.invalid_filehandle

   THEN

      fnd_file.put_line (fnd_File.LOG, 'invalid filehandle');

      UTL_FILE.fclose_all;

   WHEN UTL_FILE.read_error

   THEN

      fnd_file.put_line (fnd_File.LOG, 'read error');

      UTL_FILE.fclose_all;

   WHEN UTL_FILE.internal_error

   THEN

      fnd_file.put_line (fnd_File.LOG, 'internal error');

      UTL_FILE.fclose_all;

   WHEN OTHERS

   THEN

      fnd_file.put_line (fnd_File.LOG, 'other error');

      UTL_FILE.fclose_all;

END xx_INV_Out1;

/

Comments

Popular posts from this blog

Oracle APPS Creating Buy One Get One Free Modifier

Oracle R12 Project Interface & APIs

SQL query to find pending PO for approval in Oracle EBS R12