How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?

In this Document

  Goal
  Solution
  1: How do you enable trace for an API when executed from a SQL script outside
of Oracle Applications ?
  2: How do you get debug log for an API when executed from a SQL script outside
of Oracle Applications ?
  a) For Inventory APIs
  b) For Bills of Material & Engineering APIs
  c) For Advanced Product Catalog (APC / PIM / EGO) APIs
  References

APPLIES TO:

Oracle Inventory Management - Version 11.5.10.CU2 to 12.1.3 [Release 11.5.10 to 12.1]

Oracle Bills of Material - Version 11.5.10.2 to 12.1.3 [Release 11.5 to 12.1]

Oracle Engineering - Version 11.5.10.2 to 12.1.3 [Release 11.5 to 12.1]

Oracle Product Hub - Version 11.5.10.2 to 12.1.3 [Release 11.5 to 12.1]

Information in this document applies to any platform.

This document includes all versions of 11.5.10 and R12 and later

GOAL

This document addresses the below questions:

1. How do you enable trace for an API when executed from a SQL script outside of Oracle Applications ?

2. How to get the debug log for APIs  when executed from a SQL script outside of Oracle Applications ?

a) Inventory APIs

b) Bills of Material and Engineering APIs

c) Advanced Product Catalog (APC / EGO/ PIM) APIs

Note: Debug profiles are specific to modules, but,  trace can be enabled for any API by following the steps provided here.

SOLUTION

1: How do you enable trace for an API when executed from a SQL script outside of Oracle Applications ?

-- enable trace

ALTER SESSION SET EVENTS ‘10046 trace name context forever, level 12‘;

-- Set the trace file identifier, to locate the file on the server

ALTER SESSION SET TRACEFILE_IDENTIFIER = ‘API_TRACE‘;

-- Execute the API from the SQL script, in the same session.

EXEC <procedure name> ;

-- Once the API completes execution, disable trace

ALTER SESSION SET EVENTS ‘10046 trace name context off‘;

-- Locate the trace file based on the tracefile identifier

SELECT VALUE FROM V$PARAMETER WHERE NAME = ‘user_dump_dest‘;

-- Generate the tkprof of the trace file

tkprof <trace_File>.trc <tkprof>.out sys=no explain=apps/<apps pwd>


2: How do you get debug log for an API when executed from a SQL script outside of Oracle Applications ?

a) For Inventory APIs

i. Enable INV Debug profiles at User level for the user who would be running the API.

For example:

INV:Debug Trace = YES

INV:Debug level = 15

INV: Debug File = /tmp/invdbg_TAR.dbg

For more information, on INV Debug profiles, Please refer to Note 148651.1

ii. Add the below declarations to the sql script calling the API outside of Oracle Applications.

-- Declarations

l_user_id NUMBER := -1;

l_resp_id NUMBER := -1;

l_application_id NUMBER := -1;

l_user_name VARCHAR2(30) := ‘MFG‘;  -- user name

l_resp_name VARCHAR2(30) := ‘Inventory‘; -- responsibility name

iii. Add the below code before the API is called in the SQL script. This will initialize applications context, and will use the values of the debug profiles set for this user.

-- Get the user_id

SELECT user_id

INTO l_user_id

FROM fnd_user

WHERE user_name = l_user_name;

-- Get the application_id and responsibility_id

SELECT application_id, responsibility_id

INTO l_application_id, l_resp_id

FROM fnd_responsibility_vl

WHERE responsibility_name = l_resp_name;

FND_GLOBAL.APPS_INITIALIZE(l_user_id, l_resp_id, l_application_id); -- Mfg / Mfg & Dist Mgr / INV

dbms_output.put_line(‘Initialized applications context: ‘|| l_user_id || ‘ ‘|| l_resp_id ||‘ ‘|| l_application_id );

iv. Now, go ahead and execute the API from the SQL script, this willl create the debug log file with the file name as provided in the profile "INV: Debug File".

You can review step-by-step video here -  Video - Trace
and Debug INV API (2:00)
 

b) For Bills of Material & Engineering APIs

i. Initialize the below parameters to the API:

(...

p_debug => ‘Y‘,

p_output_dir => ‘/usr/tmp‘,   -- Directory from utl_file_dir

p_debug_filename => ‘bom_api_debug.log‘  -- Debug log filename

);

ii. Now run the API script or procedure created, This will create the debug log in the directory as mentioned in the parameters.

For example:

Bom_Bo_Pub.process_bom (p_bo_identifier => ‘BOM‘,

p_api_version_number => 1.0,

p_init_msg_list => TRUE,

p_bom_header_rec => l_bom_header_rec,

p_bom_revision_tbl => l_bom_revision_tbl,

p_bom_component_tbl => l_bom_component_tbl,

p_bom_ref_designator_tbl => l_bom_ref_designator_tbl,

p_bom_sub_component_tbl => l_bom_sub_component_tbl,

x_bom_header_rec => x_bom_header_rec,

x_bom_revision_tbl => x_bom_revision_tbl,

x_bom_component_tbl => x_bom_component_tbl,

x_bom_ref_designator_tbl => x_bom_ref_designator_tbl,

x_bom_sub_component_tbl => x_bom_sub_component_tbl,

x_return_status => l_return_status,

x_msg_count => l_msg_count ,

p_debug => ‘Y‘,

p_output_dir => ‘/usr/tmp‘,

p_debug_filename => ‘bom_api_debug.log‘

);

You can review step-by-step video here -  Video
Trace and Debug ECO API (2:00) 

c) For Advanced Product Catalog (APC / PIM / EGO) APIs

i. Initialize the below parameters to the API:

(...

p_debug_level => 3   -- 0 - No debug, 3 - finest debug information

);

ii. Now run the API script or procedure created, This will create the debug log in the directory (as in ‘utl_file_dir‘ DB parameter, for ex: /usr/tmp)

For example:

 EGO_USER_ATTRS_DATA_PUB.PROCESS_USER_ATTRS_DATA(

l_api_version

, l_object_name

, l_attributes_row_table

, l_attributes_data_table

, l_pk_column_name_value_pairs

, l_class_code_name_value_pairs

, l_user_privileges_on_object

, l_entity_id

, l_entity_index

, l_entity_code

, l_debug_level

, l_init_error_handler

, l_write_to_concurrent_log

, l_init_fnd_msg_list

, l_log_errors

, l_add_errors_to_fnd_stack

, l_commit

, x_failed_row_id_list

, x_return_status

, x_errorcode

, x_msg_count

, x_msg_data

);

时间: 2024-08-29 13:01:22

How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?的相关文章

【转】 C#学习笔记14——Trace、Debug和TraceSource的使用以及日志设计

[转] C#学习笔记14--Trace.Debug和TraceSource的使用以及日志设计 Trace.Debug和TraceSource的使用以及日志设计   .NET Framework 命名空间 System.Diagnostics 包含用于跟踪执行流程的 Trace.Debug 和 TraceSource 类,以及用于分析代码的 Process.EventLog 和 PerformanceCounter 类. 跟踪是一种在应用程序运行时监视其执行情况的方式.当开发 .NET Frame

Trace和Debug主要用法

#region 日志记录 //System.Diagnostics.Trace.Listeners.Clear(); //System.Diagnostics.Trace.AutoFlush = true; //System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(@"E:\Programme\工作\MyPraticeWork\TestDemo\TESTdemo\TESTdemo

Oracle Inventory Management Application Program Interface ( APIs) (Doc ID 729998.1)

In this Document Goal Solution References APPLIES TO: Oracle Inventory Management - Version 12.0.0 and later Information in this document applies to any platform. This document includes all versions R12.x.x and later. ***Checked for relevance on 22-O

Oracle Inventory Management Application Program Interface ( APIs)

In this Document   Goal   Solution   References APPLIES TO: Oracle Inventory Management - Version 12.0.0 and later Information in this document applies to any platform. This document includes all versions R12.x.x and later. ***Checked for relevance o

Oracle Bills of Material and Engineering Application Program Interface (APIs)

In this Document Goal   Solution   1. Sample Notes for BOM APIs   2. Datatypes used in these APIs   3. Limitations / ERs   References APPLIES TO: Oracle Bills of Material - Version 12.0.0 to 12.1.3 [Release 12 to 12.1] Oracle Engineering - Version 12

SQL SERVER 2008升级到SP4后,服务无法启动

为了提高SQL性能和安全性,2号给客户升级SQL 2008 SP4补丁,升级过程中一切顺利.但重启服务器后,发现SQL服务无法启动,事件日志引出此错误: 由于升级步骤'sqlagent100_msdb_upgrade.sql'遇到错误598(状态1,严重性25),因此数据库'master'的脚本级别升级失败. 尝试恢复模板MASTER数据库,修复安装,升级修复都无法解决,后在网上找方案,发现在SQL启动参数中加 ;-T902参数可以启动SQL,并且能成功登录SMSS,步骤如下: Enable t

Enable a SQL Server Trace Flag Globally on Linux

https://www.mssqltips.com/sql-server-tip-category/226/sql-server-on-linux// Microsoft has recently released SQL Server to run on Linux servers. Sometimes we need to enable a trace flag globally on SQL Server and in this tip I will demonstrate how to

android debug:stack trace

使用 ps 命令查看 目标进程的 pid,比如说是 1200,然后 kill -3 1200 在 /data/anr/traces.txt 中就能找到 进程 1200 中各线程的 stack trace android debug:stack trace,布布扣,bubuko.com

如何利用RMAN Debug和10046 Trace来诊断RMAN问题?

学习转摘:https://blogs.oracle.com/Database4CN/entry/%E5%A6%82%E4%BD%95%E5%88%A9%E7%94%A8rman_debug%E5%92%8C10046_trace%E6%9D%A5%E8%AF%8A%E6%96%ADrman%E9%97%AE%E9%A2%98 介绍一下如何对RMAN的问题做debug. 我们借助于下面这个场景,说明如何Debug RMAN 问题. 在11.2.0.4上,物理备库上执行归档备份时,出现了下面的错误: