Example: nca_set_custom_dbtrace and nca_set_dbtrace_file_index

This example shows how to use nca_set_custom_dbtrace and nca_set_debtrace_file_index.

  1. Record a business process that enables DB trace.

  2. Find the DB trace file index ID.

  3. Create a function that captures the trace file index.

  4. Add function nca_set_custom_dbtrace with the function name immediately after the nca_connect_server function call.

1. Record a business process that enables DB trace

Example of a typical process:

/*enable trace*/
nca_set_window("Navigator - General Ledger, Vision Operations (USA)");
nca_menu_select_item("N", "Help;Diagnostics;Trace;Regular Trace");
nca_set_window("Enable Diagnostics");

nca_response_set_data("Enable Diagnostics", 
    "ORACLE Password:==>apps");

nca_response_press_ok("Enable Diagnostics");
nca_set_window("Note");
nca_popup_message_press("Note", "OK");
/*set file size unlimited*/
nca_set_window("Navigator - General Ledger, Vision Operations (USA)");nca_menu_select_item("N", 
    "Help;Diagnostics;Trace;Unlimited Trace File Size");

2. Find the DB trace file index ID

In this example it can be found in popup window Note:

FND_TRACE_ON (DIR=E:\myOracleServer\visdb\9.2.0\admin\VIS_quest\udump) (FILE_STRING=2184)
To get the file index use function nca_obj_get_info:
char buf[1024], fileindex[32];
...
nca_set_window("Note");
if (nca_obj_get_info("Note", "msg_text", buf) == E_OK)
{
    char *pStart = NULL, *pEnd = NULL;
    int iLength;
    pStart = (char*)strstr(buf, "FILE_STRING=");
    if (pStart) {
        pStart += strlen("FILE_STRING=");
        pEnd = (char*)strchr(pStart, ')');
        iLength = pEnd - pStart;
        strncpy(fileindex, pStart, iLength);
        fileindex[iLength] = '\0';
    }
}
nca_popup_message_press("Note", "OK");

3. Create a function that captures the trace file index

Check that the code for finding the db trace file index runs without error. Then create a separate function before the vuser_init function and cut and paste the trace code into the new function. In this example, the function is named enable_trace. In the new function, add a call to nca_set_dbtrace_file_index immediately after trace enabling. In this example, that is after the call nca_popup_message_press("Note", "OK") .

void enable_trace() {

    char buf[1024], fileindex[32];
    nca_set_window("Navigator - General Ledger, Vision Operations (USA)");
    nca_menu_select_item("N","Help;Diagnostics;Trace;Regular Trace");
    nca_set_window("Enable Diagnostics");
    nca_response_set_data("Enable Diagnostics", 
	        "ORACLE Password:==>apps");
    nca_response_press_ok("Enable Diagnostics");
    nca_set_window("Note");
    if (nca_obj_get_info("Note", "msg_text", buf) == E_OK) {
        char *pStart = NULL, *pEnd = NULL;
        int iLength;
        pStart = (char*)strstr(buf, "FILE_STRING=");
        if (pStart) {
            pStart += strlen("FILE_STRING=");
            pEnd = (char*)strchr(pStart, ')');
            iLength = pEnd - pStart;
            strncpy(fileindex, pStart, iLength);
            fileindex[iLength] = '\0';
        }
    }
    nca_popup_message_press("Note", "OK");
    nca_set_dbtrace_file_index(fileindex);
    /*set file size*/
    nca_set_window("Navigator - General Ledger, Vision Operations (USA)");
    nca_menu_select_item("N", "Help;Diagnostics;Trace;Unlimited Trace File Size");
}

4. Add function nca_set_custom_dbtrace with the function name immediately after the nca_connect_server call

nca_connect_server("myserver.com", "9000", "module=...");
nca_set_custom_dbtrace(enable_db_trace);