Oracle Applications Script : Sample Script to Debug the Procedure, Packages Running At Backend

Posted by Jiltin     8 May, 2009    2,275 views   

For mission critical operations with big – complex PLSQL packages, we may need to know the path or the way the data is processed. In such case, it is very hard to debug the flow. I had such situation many times and it is easy to implement a simple solution using a debug log table for future review purpose. Make sure you delete or purge the table often and also create a proper index on this table to avoid performance issues later. This procedure can be global or inside a package. With oracle applications, you can have an entry in FND_LOOKUP_VALUES so that you can enable or disable debug on the fly by setting the lookup_type ( = ‘ERROR MESSAGE’).

Here is the sample code that I have used to capture online payment system. This is very handy and useful especially for direct online payment system to debug the unauthorized credit or system generated credit cards.

/*

Author: Jiltin

Expecting a table like this: Hence, you may need to create the table before compiling this procedure

create table XXCUS_ERROR_LOG (
        log_time        date,
        Program_step    number,
        Calling_Routine varchar2(255),
        Program_Message varchar2(255),
        ATTRIBUTE1      varchar2(255),
        ATTRIBUTE2      varchar2(255),
        ATTRIBUTE3      varchar2(255)
)

*/

PROCEDURE XXCUS_ERROR_PRC(
        PROGRAM_STEP     VARCHAR2,
       ,CALLING_ROUTINE  VARCHAR2
       ,PROGRAM_MESSAGE  VARCHAR2
       ,ATTRIBUTE1       VARCHAR2     – ERROR INDICATOR
       ,ATTRIBUTE2       VARCHAR2     – ERROR MESSAGE
       ,ATTRIBUTE3       VARCHAR2)    – LOCATION/SUCCESS/FAIL
IS
   PRAGMA AUTONOMOUS_TRANSACTION;
   l_log_enable_flag     VARCHAR2(1) := ‘N’;
BEGIN
   BEGIN
      SELECT ENABLED_FLAG
        INTO l_log_enable_flag
        FROM FND_LOOKUP_VALUES
       WHERE lookup_type = ‘ERROR MESSAGE’;
   EXCEPTION
      WHEN NO_DATA_FOUND THEN
         l_log_enable_flag := ‘N’;
   END;

   IF l_log_enable_flag = ‘Y’ THEN
      INSERT INTO XXCUS_ERROR_LOG
           VALUES(SYSDATE
                 ,Program_Step
                 ,Calling_Routine
                 ,Program_Message
                 ,ATTRIBUTE1
                 ,ATTRIBUTE2
                 ,ATTRIBUTE3);
   END IF;
   COMMIT;
EXCEPTION
   WHEN OTHERS THEN
      NULL;
END XXCUS_ERROR_PRC;

Usage sample

g_my_sql_code := 100;
    XXCUS_ERROR_PRC(g_my_sql_code,‘USER’,SYS_CONTEXT(‘USERENV’,‘CURRENT_USER’),NULL,NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 101;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_customer_number’,p_customer_number,NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 102;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_currency’,p_currency,NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 103;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_org_id’,to_char(p_org_id),NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 104;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_credit_Card_no’,encrypt_prc(p_credit_Card_no),NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 105;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_expiration_date’,to_char(p_expiration_date,‘DD-MON-YYYY’),NULL,p_customer_number‘_’v_tangible_id);
    g_my_sql_code := 106;
    XXCUS_ERROR_PRC(g_my_sql_code,‘Parameter’,‘p_payment_option’,p_payment_option,NULL,p_customer_number‘_’v_tangible_id);

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : 11i Scripts, Oracle Applications, Scripts Oracle Tags : ,

Comments
December 9, 2009

Thank you for sharing.. I will be downloading this cool plug in.. sure it will be usefull for my sites..
Thanks!

Posted by china phone
February 1, 2010

Account Security, you need to be allowed access to all of the possible accounts for miscellaneous cash (and the list can often include mo

Posted by abercromibe
Leave a comment

(required)

(required)