how to extract Oracle Fixed Asset Projection report query

Oracle projection report concurrent request, it runs in two parts. The first part builds a table of projection info. The second part is a spawned job that prints the report. 
Register a concurrent request that only runs the first part and use sql against the temporary table that is generated.

-- This code assumes fadeprn_temp exists - this is a copy of any fa_proj_interim_x table
-- P1 = Book
-- P2 = Period

DECLARE
   req_id         NUMBER;
    req_id1         NUMBER;
   output_file    UTL_FILE.file_type;
   errbuf         VARCHAR2 (240);
   v_context      VARCHAR2 (100);
   v_phase_code   VARCHAR2 (5);
   v_stmt_str     VARCHAR2 (2000);

-- Report generator
   CURSOR c1
   IS
      SELECT      'Comp_'
               || c.segment1
               || ','
               || 'Dept_'
               || c.segment3
               || ','
               || 'FY'
               || SUBSTR (f.fiscal_year, 3, 2)
               || ','
               || SUBSTR (UPPER (f.period_name), 1, 3)
               || ','
               || SUM (f.depreciation) DATA
          FROM fadeprn_temp f, gl_code_combinations c
         WHERE c.code_combination_id = f.code_combination_id
      GROUP BY c.segment1, c.segment3, f.period_name, f.fiscal_year;
BEGIN
delete from fadeprn_temp;
commit ;
   -- Set program's context
   fnd_global.apps_initialize (user_id           => 0,             -- sysadmin
                               resp_id           => 20420,
                                                    -- SYSADMIN responsibility
                               resp_appl_id      => 1        -- Application ID
                              );
   mo_global.set_policy_context ('S', 81);
   fnd_global.set_nls_context ('AMERICAN');
   -- Submit Depreciation Projection program
   req_id :=
      fnd_request.submit_request
            (application      => 'OFA',
             program          => 'FAPROJ',
             description      => NULL,
             start_time       => SYSDATE,
             sub_request      => NULL,
             argument1        => 'GC_FA_Calendar',
                                    -- This value is specific to your FA setup
             argument2        => '&2',
             argument3        => 6,
             argument4        => 'AED',
             argument5        => '&1'
            );
   COMMIT;
   DBMS_OUTPUT.put_line ('Request ID = ' || req_id);



   IF (req_id = 0)
   THEN
      errbuf := SUBSTR (fnd_message.get, 1, 240);
      DBMS_OUTPUT.put_line ('Error = ' || errbuf);
   ELSE
      -- Wait for job to complete
      LOOP
         SELECT phase_code
           INTO v_phase_code
           FROM fnd_concurrent_requests
          WHERE request_id = req_id;

         EXIT WHEN v_phase_code = 'C';
         DBMS_LOCK.sleep (15);
      END LOOP;

      -- Populate temp table
       DBMS_OUTPUT.put_line ('Insert start');
      EXECUTE IMMEDIATE    'insert into fadeprn_temp '
                        || 'select * from FA_PROJ_INTERIM_V'
                        || ' Where Request_id= ' || req_id;
DBMS_OUTPUT.put_line ('Insert Done');
      -- Create output file
--      output_file := UTL_FILE.fopen ('DEPRNCSV', 'deprn.csv', 'W');

--      FOR c1rec IN c1
--      LOOP
--         UTL_FILE.put_line (output_file, c1rec.DATA);
--      END LOOP;

--      UTL_FILE.fclose (output_file);

      -- Delete FA_PROJ_INTERIM table
--      EXECUTE IMMEDIATE 'drop table FA_PROJ_INTERIM_' || req_id;
   END IF;
   commit ;
END;
/

Comments

Popular posts from this blog

Oracle Shipping Network SQL Query

Oracle Ar Invoice Numbering Sequence alter to avoid missing in between by cache

Advance Supply Chaining Scripts - ASCP Full Pegging Concept Script