Monday, February 29, 2016

To find password for Oracle Applications R12

THIS WORKS WITH ORACLE R12
Here is a wonderful oracle seeded Procedure fnd_web_sec.get_guest_username_pwd which will help us to find out user password.
This will be handy for consultants in resolving the issues. Please use with this care and dont misuse this.
To achieve this we need to create a small package and run a query which I wrote below
Step# 1
Login as Apps user in database
Create the below package specifiations
CREATE OR REPLACE PACKAGE get_pwd
AS
   FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
      RETURN VARCHAR2;
END get_pwd;
Step#2 
Create the below package body
CREATE OR REPLACE PACKAGE BODY get_pwd
AS
   FUNCTION decrypt (KEY IN VARCHAR2, VALUE IN VARCHAR2)
      RETURN VARCHAR2
   AS
      LANGUAGE JAVA
      NAME 'oracle.apps.fnd.security.WebSessionManagerProc.decrypt(java.lang.String,java.lang.String) return java.lang.String';
END get_pwd;
Step#3
Execute the below query with your user name
SELECT usr.user_name,
       get_pwd.decrypt
          ((SELECT (SELECT get_pwd.decrypt
                              (fnd_web_sec.get_guest_username_pwd,
                               usertable.encrypted_foundation_password
                              )
                      FROM DUAL) AS apps_password
              FROM fnd_user usertable
             WHERE usertable.user_name =
                      (SELECT SUBSTR
                                  (fnd_web_sec.get_guest_username_pwd,
                                   1,
                                     INSTR
                                          (fnd_web_sec.get_guest_username_pwd,
                                           '/'
                                          )
                                   - 1
                                  )
                         FROM DUAL)),
           usr.encrypted_user_password
          ) PASSWORD
  FROM fnd_user usr
 WHERE usr.user_name = :user_name;

Friday, February 26, 2016

Generate XML using HTP.PRINT

declare
  CURSOR emp_cursor IS
 SELECT emp_name, dep_name
 FROM  emp;
BEGIN
  HTP.PRINT('<html>');
  HTP.PRINT('<head>');
  HTP.PRINT('<meta http-equiv="Content-Type" content="text/html">');
  HTP.PRINT('<title>List of Employees</title>');
  HTP.PRINT('</head>');
  HTP.PRINT('<body TEXT="#000000" BGCOLOR="#FFFFFF">');
  HTP.PRINT('<h1>List of Employees</h1>');
  HTP.PRINT('<table width="40%" border="1">');
  HTP.PRINT('<tr>');
  HTP.PRINT('<th align="left">Last Name</th>');
  HTP.PRINT('<th align="left">First Name</th>');
  HTP.PRINT('</tr>');
  FOR emp_record IN emp_cursor LOOP
    HTP.PRINT('<tr>');
    HTP.PRINT('<td>' || emp_record.emp_name  || '</td>');
    HTP.PRINT('<td>' || emp_record.dep_name || '</td>');
  END LOOP;
  HTP.PRINT('</table>');
  HTP.PRINT('</body>');
  HTP.PRINT('</html>');
END;

Generate XML using SQL

 SELECT XMLConcat(XMLElement("html"
                                ,XMLElement("GenericInfo"
                                           ,XMLElement("VendorSite"
                                                      ,XMLElement("Attribute1"
                                                                 ,'chidam')
                                                      ,XMLElement("Attribute2"
                                                                 ,'raja')
                                                     )),                                                          
                                XMLConcat(XMLElement("body"
                                           ,XMLElement("EftUserNumber"
                                                      ,'test1')
                                           ,XMLElement("VendorPayGroup"
                                                      ,'test2')
                                           ,XMLElement("ExtBankName"
                                                      ,'test3'))))) from dual

Concurrent programs attached with Data Definitions in R12

SELECT DISTINCT fat.application_name application_name,
                fat.application_short_name appl_short_name,
                fcpt.user_concurrent_program_name concurrent_program_name,
                fcp.concurrent_program_name concurrent_program_short_name,
                fcp.output_file_type output_type,
                fe.executable_name executable_name,
                flv.meaning execution_method_type,
                fat1.application_name executable_application_name,
                fat1.application_short_name executable_appl_short_name,
                xddt.data_source_name data_definition_name,
                xtb.template_code template_code,
                xtb.template_type_code template_type,
                xl.file_content_type file_content, xl.file_name rtf_file_name,
                (SELECT user_name
                   FROM fnd_user
                  WHERE user_id = xtb.created_by) creation_user
           FROM fnd_concurrent_programs_tl fcpt,
                fnd_concurrent_programs fcp,
                fnd_executables fe,
                fnd_application_vl fat,
                fnd_application_vl fat1,
                fnd_lookup_values flv,
                xdo_ds_definitions_tl xddt,
                xdo_templates_b xtb,
                xdo_lobs xl
          WHERE fcp.concurrent_program_id = fcpt.concurrent_program_id
            AND fat.application_id = fcpt.application_id
            AND fcp.executable_id = fe.executable_id
            AND fcp.executable_application_id = fe.application_id
            AND fat1.application_id = fe.application_id
            AND xddt.data_source_code(+) = fcp.concurrent_program_name
            AND flv.lookup_type(+) = 'CP_EXECUTION_METHOD_CODE'
            AND flv.LANGUAGE = 'US'
            AND flv.lookup_code(+) = fe.execution_method_code
            AND xtb.data_source_code(+) = xddt.data_source_code
            AND xl.lob_code(+) = xtb.template_code
            AND xl.lob_type(+) = 'TEMPLATE_SOURCE'
            AND flv.enabled_flag = 'Y'
            --AND fcp.output_file_type=’XML’
            AND fcp.enabled_flag = 'Y'
            AND xddt.LANGUAGE = 'US'
            AND fcpt.LANGUAGE = 'US'
            AND NVL (flv.end_date_active, SYSDATE) >= SYSDATE
            AND fcpt.user_concurrent_program_name =
                   'Russia Payment Transaction Acknowledgment Report'
                                                  --:p_concurrent_program_name

Monday, February 22, 2016

Reset application user password in R12 in backend

set serveroutput on;
declare
  v_user_name    varchar2(30) := upper('user_name');
  v_new_password varchar2(30) := 'welcome';
  v_status       boolean;
begin
  v_status := fnd_user_pkg.ChangePassword(username    => v_user_name,
                                          newpassword => v_new_password);
  if v_status = true then
    dbms_output.put_line('The password reset successfully for the User:' ||
                         v_user_name);
    commit;
  else
    DBMS_OUTPUT.put_line('Unable to reset password due to' || SQLCODE || ' ' ||
                         SUBSTR(SQLERRM, 1, 100));
    rollback;
  END if;
end;

Add Sysadmin responsibility in Backend R12

-- Check the attached responsiblity

Select b.user_name, c.responsibility_name, a.START_DATE, a.END_DATE
from fnd_user_resp_groups_direct a, fnd_user b, fnd_responsibility_tl c
where a.user_id = b.user_id
and a.responsibility_id = c.responsibility_id
and b.user_name='USERNAME'

add sysadmin responsibility in backend

BEGIN
  fnd_user_pkg.addresp('user_name',
                       'SYSADMIN',
                       'SYSTEM_ADMINISTRATOR',
                       'STANDARD',
                       'Add Responsibility to USER using pl/sql',
                       SYSDATE,
                       SYSDATE + 100);
  COMMIT;
  DBMS_OUTPUT.put_line('Responsibility Added Successfully');
EXCEPTION
  WHEN OTHERS THEN
    DBMS_OUTPUT.put_line(' Responsibility is not added due to ' || SQLCODE ||
                         SUBSTR(SQLERRM, 1, 100));
    ROLLBACK;
END;

Friday, February 5, 2016

All Supplier Invoice amounts converted into USD

Select /*+ PARRALLEL(ai,16) */ invoice_num,invoice_amount,
 DECODE(ai.invoice_currency_code,
             'USD',
             ai.invoice_amount,
             NVL(gdr.conversion_rate, 1) * ai.invoice_amount) USD_Amnt
    from apps.ap_invoices_all       ai,
         apps.gl_daily_rates        gdr
   where  gdr.from_currency = ai.invoice_currency_code
     AND gdr.to_currency = 'USD'
     AND gdr.conversion_type = ai.exchange_rate_type
     and trunc(gdr.conversion_date) = trunc(ai.invoice_date)
     and =1
   

Supplier Payment Method

The field IBY_EXTERNAL_PAYEES_ALL.DEFAULT_PAYMENT_METHOD_CODE is updated only when a payee is created. This is automatically updated and there is no UI for this field.
If a user updates the default payment method at supplier or supplier site level, then the payment method is updated in the IBY_EXT_PARTY_PMT_MTHDS.PAYMENT_METHOD_CODE.

Column IBY_EXTERNAL_PAYEES_ALL.DEFAULT_PAYMENT_METHOD_CODE is never used for any kind of defaulting. It just serves as a place holder for AP supplied
parameters and populated only at the time of creating payee, remains dormant thereafter.

Actual default payment method is evaluated from active records of table IBY_EXT_PARTY_PMT_MTHDS where it is filtered by the primary_flag (should be 'Y') and by the external payee id of the Site,AddressOU,Address,Supplier
level payee (in the order of preference).


Tuesday, February 2, 2016

Supplier Header level bank account in R12

SELECT HZP.PARTY_NAME "VENDOR NAME"
, APS.SEGMENT1 "VENDOR NUMBER"
, IEB.BANK_ACCOUNT_NUM "ACCOUNT NUMBER"
, IEB.BANK_ACCOUNT_NAME "ACCOUNT NAME"
, IEB.BANK_ACCOUNT_TYPE "Bank Account Type" 
, HZPBANK.PARTY_NAME "BANK NAME"
, HOPBRANCH.BANK_OR_BRANCH_NUMBER "BANK NUMBER"
, HZPBRANCH.PARTY_NAME "BRANCH NAME"
, HOPBRANCH.BANK_OR_BRANCH_NUMBER "BRANCH NUMBER" 
, HZPBANK.address1 "Bank Address"
, HZPBANK.country "Bank Country"
, HZPBANK.city "Bank City"
, HZPBANK.Postal_Code
, NVL(HZPBANK.state, HZPBANK.province) "State/Province"
FROM apps.HZ_PARTIES HZP
, apps.AP_SUPPLIERS APS
, apps.IBY_EXTERNAL_PAYEES_ALL IEP
, apps.IBY_PMT_INSTR_USES_ALL IPI
, apps.IBY_EXT_BANK_ACCOUNTS IEB
, apps.HZ_PARTIES HZPBANK
, apps.HZ_PARTIES HZPBRANCH
, apps.HZ_ORGANIZATION_PROFILES HOPBANK
, apps.HZ_ORGANIZATION_PROFILES HOPBRANCH
WHERE HZP.PARTY_ID = APS.PARTY_ID
AND IEP.PAYEE_PARTY_ID = HZP.PARTY_ID
AND IEP.EXT_PAYEE_ID = IPI.EXT_PMT_PARTY_ID
AND IPI.INSTRUMENT_ID = IEB.EXT_BANK_ACCOUNT_ID
AND IEB.BANK_ID = HZPBANK.PARTY_ID
AND IEB.BANK_ID = HZPBRANCH.PARTY_ID
AND HZPBRANCH.PARTY_ID = HOPBRANCH.PARTY_ID
AND HZPBANK.PARTY_ID = HOPBANK.PARTY_ID
and IEP.SUPPLIER_SITE_ID is null

Supplier Site Level Bank Accounts in R12

SELECT HZP.PARTY_NAME "VENDOR NAME"
, APS.SEGMENT1 "VENDOR NUMBER"
, ASS.VENDOR_SITE_CODE "SITE CODE"
, IEB.BANK_ACCOUNT_NUM "ACCOUNT NUMBER"
, IEB.BANK_ACCOUNT_NAME "ACCOUNT NAME"
, IEB.BANK_ACCOUNT_TYPE "Bank Account Type"
, HZPBANK.PARTY_NAME "BANK NAME"
, HOPBRANCH.BANK_OR_BRANCH_NUMBER "BANK NUMBER"
, HZPBRANCH.PARTY_NAME "BRANCH NAME"
, HOPBRANCH.BANK_OR_BRANCH_NUMBER "BRANCH NUMBER"
, HZPBANK.address1 "Bank Address"
, HZPBANK.country "Bank Country"
, HZPBANK.city "Bank City"
, HZPBANK.Postal_Code
, NVL(HZPBANK.state, HZPBANK.province) "State/Province"
FROM apps.HZ_PARTIES HZP
, apps.AP_SUPPLIERS APS
, apps.HZ_PARTY_SITES SITE_SUPP
, apps.AP_SUPPLIER_SITES_ALL ASS
, apps.IBY_EXTERNAL_PAYEES_ALL IEP
, apps.IBY_PMT_INSTR_USES_ALL IPI
, apps.IBY_EXT_BANK_ACCOUNTS IEB
, apps.HZ_PARTIES HZPBANK
, apps.HZ_PARTIES HZPBRANCH
, apps.HZ_ORGANIZATION_PROFILES HOPBANK
, apps.HZ_ORGANIZATION_PROFILES HOPBRANCH,
apps.HR_OPERATING_UNITS hou
WHERE HZP.PARTY_ID = APS.PARTY_ID
AND HZP.PARTY_ID = SITE_SUPP.PARTY_ID
AND SITE_SUPP.PARTY_SITE_ID = ASS.PARTY_SITE_ID
AND ASS.VENDOR_ID = APS.VENDOR_ID
AND IEP.PAYEE_PARTY_ID = HZP.PARTY_ID
AND IEP.PARTY_SITE_ID = SITE_SUPP.PARTY_SITE_ID
AND IEP.SUPPLIER_SITE_ID = ASS.VENDOR_SITE_ID
AND IEP.EXT_PAYEE_ID = IPI.EXT_PMT_PARTY_ID
AND IPI.INSTRUMENT_ID = IEB.EXT_BANK_ACCOUNT_ID
AND APS.VENDOR_TYPE_LOOKUP_CODE NOT   IN ('EMPLOYEE', 'INTERCO','CONTRACTOR')
AND IEB.BANK_ID = HZPBANK.PARTY_ID
AND IEB.BANK_ID = HZPBRANCH.PARTY_ID
AND HZPBRANCH.PARTY_ID = HOPBRANCH.PARTY_ID
AND HZPBANK.PARTY_ID = HOPBANK.PARTY_ID
and hou.organization_id=ass.org_id
AND hou.name in ('AU_604990')

Price List Query for Item

 SELECT qph.list_header_id,        qph.name,        qph.description,        qphh.start_date_active,        qphh.currency_code,        q...