2012年10月1日 星期一

Can't find oracle_process_id in fnd_concurrent_requests with Oracle ERP 11.5.10.2 report

打開 Report Builder
1. Data Model => User Parameters => 定義 P_CONC_REQUEST_ID


Data Model => User Parameters => 定義 P_REQUEST_ID

2. Report => Report Triggers => Before Report
     SQL_TRACE;


Report => Report Triggers => After Report
     SRW.USER_EXIT('FND SRWEXIT');

3. Program Units => 定義 SQL_TRACE

PROCEDURE SQL_TRACE IS

   CURSOR c_program_id(p_request_id IN NUMBER) IS
  SELECT concurrent_program_id, nvl(enable_trace,'N')
  FROM apps.FND_CONCURRENT_REQUESTS
  WHERE REQUEST_ID = p_request_id;

  CURSOR get_audsid IS -- RC kpvs
  SELECT a.sid, a.serial#, b.spid FROM gv$session a,gv$process b
  WHERE audsid = userenv('SESSIONID')
  AND a.paddr = b.addr
  and a.inst_id= b.inst_id;


  CURSOR get_dbname IS
  SELECT name FROM gv$database;

  v_enable_trace apps.FND_CONCURRENT_PROGRAMS.enable_trace%TYPE;
  v_program_id apps.FND_CONCURRENT_PROGRAMS.concurrent_program_id%TYPE;
  v_sid gv$session.sid%TYPE;
  v_serial gv$session.serial#%TYPE;
  v_spid gv$process.spid%TYPE;
  v_name gv$database.name%TYPE;

BEGIN
 SRW.USER_EXIT('FND SRWINIT');
    SRW.MESSAGE( 1275, 'Report Version -> 616.4, LastUpdateDate -> 06/11/2003');

    OPEN c_program_id(:p_conc_request_id);
    FETCH c_program_id INTO v_program_id, v_enable_trace;
    CLOSE c_program_id;

    SRW.message( 1275, 'v_program_id -> '||v_program_id
    ||', v_enable_trace -> '||v_enable_trace
    ||', request_id -> '||:P_CONC_REQUEST_ID);

    IF v_enable_trace = 'Y' THEN

      OPEN get_audsid; -- RC kpvs
      FETCH get_audsid INTO v_sid, v_serial, v_spid;
      CLOSE get_audsid;

      OPEN get_dbname;
      FETCH get_dbname INTO v_name;
      CLOSE get_dbname;

      srw.message(1275,'TraceFile Name = '||lower(v_name)||'_ora_'||v_spid||'.trc');
      SRW.DO_SQL('ALTER SESSION SET EVENTS ''10046 trace name context forever, level 4''' );
    END IF;
EXCEPTION
  WHEN OTHERS THEN
    SRW.MESSAGE( 1275, 'Error during enabling the trace. ErrCode -> '||SQLCODE ||', ErrMesg -> '||SQLERRM );
END;

補充:
在Oracle論壇上有人是這麼做的:

1. before report trigger
add SRW.USER_EXIT('FND SRWINIT');
2. after report trigger
and SRW.USER_EXIT('FND SRWEXIT');
3. add a parameter P_CONC_REQUEST_ID in User PARAMETERS

沒有留言:

張貼留言