Thursday, April 25, 2013

Query to get Responsibilities Assigned with Particular Function

SELECT r.responsibility_name
  FROM fnd_responsibility_vl r, fnd_form_functions f
 WHERE f.function_name = < Function_Name>
   AND r.menu_id IN (SELECT     me.menu_id
                           FROM fnd_menu_entries me
                     START WITH me.function_id = f.function_id
                     CONNECT BY PRIOR me.menu_id = me.sub_menu_id)
   AND r.menu_id NOT IN (
                       SELECT frf.action_id
                         FROM fnd_resp_functions frf
                        WHERE frf.action_id = r.menu_id
                              AND frf.rule_type = 'M')
   AND f.function_id NOT IN (
                   SELECT frf.action_id
                     FROM fnd_resp_functions frf
                    WHERE frf.action_id = f.function_id

                          AND frf.rule_type = 'F');

Easy Way In Life....


There is a hard way to get what you want and there is an easy way. Which one would you like to choose? The answer is obvious, everybody wants the easy way, but most people are not even aware the easy way truly exists.
Most of us have been told, since the moment we were born, that in order to succeed in life, we have to work hard and struggle. It has been said"no pain, no gain". For most people, life is just a long series of struggles.
If that is what you feel, I have good news for you; there is an easy way, which leads to your ultimate destiny in the most stress free manner.
Listen carefully, because this is going to determine whether your life is fulfilling, happy and stress free, which means a high quality of living.
Here is the ultimate secret of the universe"Change the way you look at things and the things you look at will change."
Pay special attention to these words, and really think about what they mean.
Yes, I hear what you are saying. You have heard it a million times. Everybody knows it. 
If this is what you are thinking, I must warn you not to take these words lightly. I can tell you 90% of people read these words, and don't understand what they truly mean. You can tell by simply watching their lives. If you are not living a happy fulfilled life RIGHT NOW, I can tell you"you do not truly understand these words”. Then let's get down to the deep understanding of this golden rule of success.




How to Register Shell Script As Concurrent Program

Step 1:
Place the <name>.prog script under the bin directory for your applications top directory.

For example, call the script AD_DEMO.prog and place it under $CUSTOM_TOP/bin

Step 2:
Make a symbolic link from your script to $FND_TOP/bin/fndcpesr
For example, if the script is called AD_DEMO.prog use this: 


ln -s $FND_TOP/bin/fndcpesr AD_DEMO


This link should be named the same as your script without the .prog extension.

Put the link for your script in the same directory where the script is located.

Step 3:
Register the concurrent program, using an execution method of ‘Host’. Use the name of your script without the .prog extension as the name of the executable.

For the example above:
Use AD_DEMO


Step 4:
Your script will be passed at least 4 parameters, from $1 to $4.

$1 = orauser/pwd
$2 = userid(apps)
$3 = username,
$4 = request_id


Any other parameters you define will be passed in as $5 and higher.

Make sure your script returns an exit status also.

Wednesday, April 24, 2013

Procedure to Cancel AP Invoice

CREATE OR REPLACE PROCEDURE cvrd_cancel_ap_invoices (
   p_org_id          IN NUMBER,
   p_inv_date_from      DATE,
   p_inv_date_to        DATE
)
AS
   l_user_id                      NUMBER := apps.fnd_global.user_id;
   l_org_id                       NUMBER := apps.fnd_global.org_id;
   l_message_name                 VARCHAR2 (1000);
   l_invoice_amount               NUMBER;
   l_base_amount                  NUMBER;
   l_tax_amount                   NUMBER;
   l_temp_cancelled_amount        NUMBER;
   l_cancelled_by                 VARCHAR2 (200);
   l_cancelled_amount             NUMBER;
   l_cancelled_date               DATE;
   l_last_update_date             DATE;
   l_original_prepayment_amount   NUMBER;
   l_pay_curr_invoice_amount      NUMBER;
   l_boolean                      BOOLEAN;
   err_msg                        VARCHAR2 (2000);

   CURSOR invoice_cur
   IS
      SELECT   aia.invoice_id,
               aia.last_updated_by,
               aia.last_update_login,
               aia.set_of_books_id,
               aia.gl_date,
               aia.invoice_num
        FROM   apps.cvrd_ap_tax_inv_stg cat, apps.ap_invoices_all aia
       WHERE       cat.invoice_num = aia.invoice_num
               AND cat.org_id = aia.org_id
               AND cat.org_id = NVL (p_org_id, l_org_id)
               AND cat.status = 'N'
               AND cat.invoice_id = aia.invoice_id
               AND aia.payment_status_flag = 'N'
               AND aia.invoice_date BETWEEN p_inv_date_from AND p_inv_date_to;
BEGIN
   apps.fnd_file.put_line (
      apps.fnd_file.LOG,
      'Calling API ap_cancel_pkg.ap_cancel_single_invoice to Cancel Invoice'
   );

   FOR l_inv_rec IN invoice_cur
   LOOP
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              ' Invoice Number:' || l_inv_rec.invoice_num);
      DBMS_OUTPUT.put_line (' Invoice Number:' || l_inv_rec.invoice_num);
      l_boolean :=
         ap_cancel_pkg.ap_cancel_single_invoice (
            p_invoice_id                   => l_inv_rec.invoice_id,
            p_last_updated_by              => l_inv_rec.last_updated_by,
            p_last_update_login            => l_inv_rec.last_update_login,
            p_set_of_books_id              => l_inv_rec.set_of_books_id,
            p_accounting_date              => l_inv_rec.gl_date,
            p_period_name                  => NULL,
            p_message_name                 => l_message_name,
            p_invoice_amount               => l_invoice_amount,
            p_base_amount                  => l_base_amount,
            p_tax_amount                   => l_tax_amount,
            p_temp_cancelled_amount        => l_temp_cancelled_amount,
            p_cancelled_by                 => l_cancelled_by,
            p_cancelled_amount             => l_cancelled_amount,
            p_cancelled_date               => l_cancelled_date,
            p_last_update_date             => l_last_update_date,
            p_original_prepayment_amount   => l_original_prepayment_amount,
            p_check_id                     => NULL,
            p_pay_curr_invoice_amount      => l_pay_curr_invoice_amount,
            p_calling_sequence             => NULL
         );
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              ' l_message_name => ' || l_message_name);
      DBMS_OUTPUT.put_line ('l_message_name => ' || l_message_name);
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              ' l_invoice_amount => ' || l_invoice_amount);
      DBMS_OUTPUT.put_line ('l_invoice_amount => ' || l_invoice_amount);
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              'l_cancelled_by => ' || l_cancelled_by);
      DBMS_OUTPUT.put_line ('l_cancelled_by => ' || l_cancelled_by);
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              'l_cancelled_amount => ' || l_cancelled_amount);
      DBMS_OUTPUT.put_line ('l_cancelled_amount => ' || l_cancelled_amount);
      apps.fnd_file.put_line (apps.fnd_file.LOG,
                              'l_cancelled_date => ' || l_cancelled_date);
      DBMS_OUTPUT.put_line ('l_cancelled_date => ' || l_cancelled_date);

      ---To update Staging table with appropriate message
      BEGIN
         IF l_boolean
         THEN
            apps.fnd_file.put_line (
               apps.fnd_file.LOG,
               'Successfully Cancelled the Invoice => '
               || l_inv_rec.invoice_num
            );
            DBMS_OUTPUT.put_line('Successfully Cancelled the Invoice => '
                                 || l_inv_rec.invoice_num);

            UPDATE   bolinf.cvrd_ap_tax_inv_stg cat
               SET   cat.status = 'C'
             WHERE   cat.invoice_id = l_inv_rec.invoice_id
                     AND cat.invoice_num = l_inv_rec.invoice_num;
         ELSE
            apps.fnd_file.put_line (
               apps.fnd_file.LOG,
               'Failed to Cancel the Invoice => ' || l_inv_rec.invoice_num
            );
            DBMS_OUTPUT.put_line (
               'Failed to Cancel the Invoice => ' || l_inv_rec.invoice_num
            );

            UPDATE   bolinf.cvrd_ap_tax_inv_stg cat
               SET   cat.status = 'E', cat.MESSAGE = l_message_name
             WHERE   cat.invoice_id = l_inv_rec.invoice_id
                     AND cat.invoice_num = l_inv_rec.invoice_num;
         END IF;

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            err_msg := 'Failed to update the staging table status' || SQLERRM;
            apps.fnd_file.put_line (apps.fnd_file.LOG, err_msg);
            DBMS_OUTPUT.put_line (err_msg);
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      err_msg := 'Error in Procedure block' || SQLERRM;
      apps.fnd_file.put_line (apps.fnd_file.LOG, err_msg);
      DBMS_OUTPUT.put_line (err_msg);

END cvrd_cancel_ap_invoices;