Infolinks

Friday 22 June 2012

Item Import Program Using API in 11i

Item Import Program Using API in 11i

We can use the below code to Submit the Item Import Program using API.

Code is tested in 11i.


 CREATE OR REPLACE PROCEDURE Item_import
 IS

 v_phase               VARCHAR2(240);
 v_status              VARCHAR2(240);
 v_request_phase   VARCHAR2(240);
 v_request_status  VARCHAR2(240);
 v_finished            BOOLEAN;
 v_message          VARCHAR2(240);
 l_request_id         NUMBER;

 BEGIN
 
   --We need to apps initialize before calling the import program
   --Apps Initialize is explained in another section. Check below link to know in detail
          Apps Initialize;

      l_request_id := Fnd_Request.submit_request (
                                application   => 'INV',
                               program        => 'INCOIN',
                              description     => NULL,
                              start_time      => SYSDATE,
                              sub_request   => FALSE,
                              argument1     => 1,     --Mode to run this request(Insert new cost information only)
                              argument2     => 1,     --Group ID option (All)
                              argument3     => 1,     -- Group ID Dummy
                             argument4     => 1,
                             argument5     => 1,
                             argument6     => <Group ID>,     -- Group ID passed in Interface table
                             argument7     => <1 or 2>          -- 1 for Create and 2 for Update
                       );                 
      COMMIT;
   
      IF  ( l_request_id = 0 ) THEN
         dbms_output.put_line( 'Submission of Import failed ');
      END IF;
      -- Wait for request to run the import Program to Finish
      v_finished := fnd_concurrent.wait_for_request (request_id      => l_request_id,
                                                     interval        => 60,
                                                     max_wait      => 0,
                                                     phase          => v_phase,
                                                     status          => v_status,
                                                     dev_phase    => v_request_phase,
                                                     dev_status   => v_request_status,
                                                     message      => v_message);

      dbms_output.put_line('Request Phase : '|| v_request_phase );
      dbms_output.put_line('Request Status : ' || v_request_status );

      --Testing end status
      IF ( UPPER(v_request_status) = 'NORMAL') THEN
          dbms_output.put_line( 'Submission of Item Import is Success ');
      ELSE
          dbms_output.put_line( 'Submission of Item Import failed ');
      END IF;
   
 EXCEPTION
    WHEN OTHERS THEN
         dbms_output.put_line( 'Submission of Import failed ');
 END ;
 /

No comments:

Post a Comment