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

Source: Internet
Author: User
Tags apc

In this Document

Goal
Solution
1:how does the enable trace for an API when executed from a SQL script outside of Oracle applications?
2:how do I get debug log for the API when executed from a SQL script outside of Oracle applications?
A) for Inventory APIs
b) for Bills of Material & Engineering APIs
c) for the 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 does the enable trace for an API when executed from a SQL script outside of Oracle applications?

2. How do I 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 is specific to modules, but, trace can is enabled for any API by following the steps provided here.

Solution1:how do-enable trace for a APIs when executed from a SQL script outside of Oracle applications?--enable TR Ace
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 I get debug log for an API when executed from a SQL script outside of Oracle applications? a) for Inventory AP Is

I. Enable INV Debug Profiles at user level for the user who would is 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, 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 (+): = ' MFG '; --User name
L_resp_name VARCHAR2 (+): = ' Inventory '; --Responsibility Name


Iii. ADD The below code before the API is called in the SQL script. This would initialize applications context, and would 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 Prov IDed in the "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 would create the debug log in the directory as mentioned in the Param Eters.

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 the 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 would 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
);

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.