Friday, October 30, 2015

Bank Details for Suppliers

Bank at Supplier Site level
-------------------------------

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
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 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
ORDER BY 1,3


Bank at Supplier level
------------------------

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
and aps.vendor_id = 2

Wednesday, October 28, 2015

Actual Usage of Date Functions

========== Extract Time Upto Miliseconds from Systimetsamp or current_timestamp===

select systimestamp ,
to_char(systimestamp,'HH24:MI:SS-FF') Systimestamp_ExtractMilisecond,
CURRENT_TIMESTAMP,
to_char(CURRENT_TIMESTAMP,'HH24:MI:SS-FF') Currtimestamp_ExtractMS from dual


=========financial year dates=============

SELECT TO_DATE ('01-APR-' || TO_CHAR (ADD_MONTHS (TRUNC (to_date(:p_from_date,'DD-MON-RRRR')),-12), 'YYYY'))  FY_START from dual

SELECT TO_DATE ('31-MAR-' || TO_CHAR (ADD_MONTHS (TRUNC (to_date(:p_from_date,'DD-MON-RRRR')),-1), 'YYYY') )  FY_end from dual  





How to get first day and last date of week, month, quarter, year in Oracle
--First day of current week(sunday)
select TRUNC(SYSDATE, 'Day') from dual;
--FIRST DAY OF CURRENT FINANCIAL YEAR
select ('01-APR-' || TO_CHAR (sysdate-1, 'YYYY'))  from dual
--First day of next week(sunday)
select TRUNC(SYSDATE+7 , 'Day') from dual;
--First day of previous week(sunday)
select TRUNC(SYSDATE-7 , 'Day') from dual;
--First day of current month
select TRUNC(SYSDATE , 'Month') from dual;
--First day of previous month
select TRUNC(TRUNC(SYSDATE , 'Month')-1 , 'Month') from dual;
--First day of next month
select TRUNC(LAST_DAY(SYSDATE)+1 , 'Month') from dual;
--First day of current year
select TRUNC(SYSDATE , 'Year') from dual;
--First day of previous year
select TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year') from dual;
--First day of next year
select ADD_MONTHS(TRUNC(SYSDATE , 'Year'),12) from dual;
-- First Day of Current quater
select TRUNC(SYSDATE , 'Q') from dual;
--  First Day of Previous Quarter
select ADD_MONTHS(TRUNC(SYSDATE , 'Q'),-3) from dual;
--  First Day of Next Quarter
select ADD_MONTHS(TRUNC(SYSDATE , 'Q'),3) from dual;


-------first date of previous 3 months

 select ADD_MONTHS(LAST_DAY(TRUNC(TRUNC(to_date(sysdate,'DD-MON-RRRR') , 'Month')-1 , 'Month')),-3)+1 from dual


--Last day of current week(sunday)
select TRUNC(SYSDATE, 'Day')+6 from dual;
--Last day of next week(sunday)
select TRUNC(SYSDATE+7 , 'Day')+6 from dual;
--Last day of previous week(sunday)
select TRUNC(SYSDATE-7 , 'Day')+6 from dual;
--Last day of current month
select LAST_DAY(TRUNC(SYSDATE , 'Month')) from dual;
--Last day of previous month
select LAST_DAY(TRUNC(TRUNC(SYSDATE , 'Month')-1 , 'Month')) from dual;
--Last day of next month
select LAST_DAY(TRUNC(LAST_DAY(SYSDATE)+1 , 'Month')) from dual;
--Last day of current year
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Year'),11)) from dual;
--Last day of previous year
select LAST_DAY(ADD_MONTHS(TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year'),11)) from dual;
--Last day of next year
select LAST_DAY(ADD_MONTHS(TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year'),-13)) from dual;
-- Last Day of Current quater
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Q'),2)) from dual;
--  Last Day of Previous Quarter
select TRUNC(SYSDATE , 'Q')-1 from dual;
--  Last Day of Next Quarter
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Q'),5)) from dual;
 

Monday, October 26, 2015

What is the purpose of MO_GLOBAL.SET_POLICY_CONTEXT?


 To Retrieve Rows From Table / Views Or Synonym For An ORG_ID

For example View are : PO_HEADERS, AP_INVOICES

To fetch data from these View , we have to use Procedure
mo_global.set_policy_context(p_access_code,p_org_id);

This procedure has two parameters
p_access_mode
Pass a value "S" in case you want your current session to work against Single ORG_ID
Pass a value of "M" in case you want your current session to work against multiple ORG_ID's


For R12

p_org_id
Only applicable if p_access_mode is passed value of "S"
For Example:

begin
mo_global.set_policy_context('S',722);
end;

Above code will fetch only the rows belongs to org id 722

begin
mo_global.init('AR');
end;


begin
mo_global.set_policy_context('M',Null);
end;


Above code will fetch dat for multiorg's irrespective of operating units.


For 11i


begin
fnd_client_info.set_org_context(ORG_ID);

end;

Tuesday, October 20, 2015

Use of INSTR and SUBSTR Functions

INSTR ---------------------(string to search, search pattern [, start [,occurrence]])

SUBSTR------------------ (original string, begin [,how far])

---------------------Data Till First Space--------------------------


SELECT substr(Name,1,instr(Name,' ',1,1)-1) from hr_operating_units
 
select substr('Oracle welcomes',1,instr('Oracle welcomes',' ',1,1)-1) from dual;

select substr('Oracle welcomes you',1,instr('Oracle welcomes you',' ',1,2)-1) from dual;------------------Data Till Second Sapce


Apache Server Bounce Steps , to take application restart



1.       Login as apps user
2.       Go to /appsuat/APPSUAT/inst/apps/UATQA_WEBoracleqa/admin/scripts
3.       Execute ./ adapcctl.sh stop
4.       Check for apache process: ps –ef | grep –I http | grep applqa | wc –l (It should return 1)
5.       Start apache service ./adapcctl.sh start

Displaying image / picture dynamically in XML Publisher (BI Tools) RTF template

Below two examples will demonstrate displaying image dynamically in XML publisher in Microsoft Office 2007 and onwards version.

Displaying Company logo image dynamically in XML Publisher (BI Tools) in RTF Template :

  1. Insert any dummy placeholder image in RTF template (Insert a Picture)
  2. Right click on image and click “Size” then goto “AltText” tab and enter dynamic path in “Alternative Text” field  e.g. url:{concat(‘${OA_MEDIA}’,’/XX_Logo.jpg’)}.
$OA_MEDIA path TOP is actual path in Oracle App instance where images are stored . DBA may help to get $OA_MEDIA Top path to upload XX_Logo.jpg file.

Displaying signature dynamically in XML Publisher (BI tools) RTF template

  1. Insert any dummy placeholder image in RTF template (Insert  a Picture)
  2. Right click on image and click “Size” then goto “AltText” tab and enter dynamic path in “Alternative Text” field  e.g. url:{concat(‘${OA_MEDIA}/XX_buyer_’,/PO_DATA/DOCUMENT_BUYER_FIRST_NAME ,’_’,/PO_DATA/DOCUMENT_BUYER_LAST_NAME ,’.jpg’)}
$OA_MEDIA path TOP is actual path in Oracle App instance where images are stored. DBA may help to get $OA_MEDIA Top path to upload buyer’s signature file. Below examples will demonstrate displaying image dynamically in XML publisher in Microsoft Office 2003 which obsolete in MS office 2007 and onward versions.
Dynamic Image loading in XML publisher / BI tools
Dynamic Image loading in XML publisher / BI tools

How to Add a New Legal Entity, Ledger and Operating Unit for a New Country

ow to Add a New Legal Entity, Ledger and Operating Unit for a New Country [ID 1064366.1]
  Solution
     Step 1 - Set Up Country Geography Hierarchy in TCA
     Step 2 - Create a Legal Entity
     Step 3 - Validate Legal Entity, Establishment and Registration
     Step 4 - Set up a Ledger for the new Legal Entity
     Step 5 - Set Up an Operating Unit
     Step 6 - Associate the Operating Unit with the Legal Establishment
     Step 7 - Run Replicate Seed Data

 References Applies to:
Oracle Legal Entity Configurator - Version: 12.0 and later   [Release: 12.0 and later ]
Oracle E-Business Tax - Version: 12.0 and later    [Release: 12.0 and later]
Oracle General Ledger - Version: 12.0 and later    [Release: 12.0 and later]
Oracle Human Resources - Version: 12.0 and later    [Release: 12.0 and later]

Information in this document applies to any platform.
Goal
E-Business Tax Information Center > EBTax Integration With EBS Modules > Legal Entity Manager > Note 1064366.1
This note was authored to provide a detailed example of the steps required to add a new Legal Entity to an existing instance.  The scenario covered is the addition of a new country to an already configured application environment. 

The original onus for this note was to provide expanded guidance for a customer attempting to configure E-Business Tax for Canada using Case Study Note 577996.1.  The steps documented within this note should also hold true for other scenarios outside of E-Business Tax.  Note that this is not intended to serve as a comprehensive note on setting up Legal Entities, Ledgers and Operating units.  Rather this is attempting to show how these objects are linked together and in doing so, remove some of the potential confusion that exists when performing this setup using the various implementation manuals for HR, GL, Legal Entity and Tax.
Solution
Step 1 - Set Up Country Geography Hierarchy in TCA

Refer to Note 554492.1 for details.  This step is required so that you can select the State/province from the list of values when defining your Address.

Step 2 - Create a Legal Entity
Create legal entities with minimum required information using the Create Legal Entity page.

If you create a legal entity from an existing organization, the country, organization name, and organization number are defaulted from the organization. In this case, the organization number is not updatable even if the HZ: Generate Party Number profile option is set to No.

When you create a legal entity, the main establishment is created automatically. The legal entity territory, name, address, effective date, and other information are defaulted to the main establishment. The establishment inherits the registration number of the legal entity only if the establishment does not have it own number.

Responsibility -  Legal Entity Manager
Navigation - "Create a Legal Entity"

Enter the required fields (See example below)

Territory: The territory where the legal entity is registered. This list displays territories at the country level and shows only territories for which the identifying jurisdiction has been defined. Therefore, the territory determines the identifying jurisdiction to which the legal entity needs to register. The territory also determines the context for the information that needs to be displayed in the General Information region.  For Canada the BIN number is one such field

How To Add New Legal Entity Registration Code For Countries That Are Not Available In The List?

For example there is no Registration Code available for country China.

Solution
Please follow the steps below to add a Registration Code for China or any other country that is
not listed in the LOV when defining Jurisdictions.

1) Log in to the responsibility 'Application Developer'.
2) Go to Menu (Application > Lookups > XLE Lookups).
3) Query for the Lookup Type XLE_REG_CODE.
4) Add a new Lookup Code for the country of your choice.
5) Save the record.
6) Bounce Apache.
7) Now log into the responsibility 'Legal Entity Manager'
8) Go to Jurisdictions (Setup > Jurisdictions)
9) Define the new Jurisdiction for the Country and select your Reg Cod from LOV.

NOTE:   These steps may also be required in order for the country to appear in the LOV for territories.  For example:  Vietnam must be added to the XLE_REG_CODE in order for the legal entity to be created.

Organization Number: The organization number is a number used to identify organizations. This field is displayed only when the HZ: Generate Party Number profile option is set to No. In this case, the main establishment organization number is built as a concatenation of the legal entity organization number and ETB (establishment). Otherwise it is not displayed and is generated automatically. For example, if the legal entity organization number entered is 12536, the establishment's organization number will be 12536ETB.

Legal Entity Identifier: The identification number used to uniquely identify the legal entity. It is displayed only when the LE: Generate Legal Entity Identifier profile option set to No and you must enter it manually. If this option is set to Yes, the legal entity identifier is generated automatically based on the International  Organization for Standardization (ISO) code of the country of registration, plus the registration number of the identifying jurisdiction, which qualifies an entity to be a legal entity in that particular territory.

For example:
Example
Territory: Singapore
ISO Country Code: SG

Registration number of the identifying jurisdiction (RCN number) = 23231 (this is a user enterable field)
If the profile option is set to Yes, the legal entity identifier will be SG23231, otherwise you are required to enter the legal entity identifier manually. If you enter an identifier that is not unique, an error message will be displayed.

Registration Number: The identifying jurisdiction determines the prompt for the registration number (in the U.S., the EIN/TIN). The Establishment registration prompt is displayed if it is defined for the identifying jurisdiction. In this case the main establishment is created with this registration number. The registration
number must be unique within a jurisdiction.

Legal Address: The address a legal entity uses to register with a legal authority. A legal entity may use different addresses for different authorities and hence, may have more than one registered address. This legal address must be located within the territory entered.

Place Of Registration: Optionally enter the place of the legal entity registration.

Inception Date Optionally enter the date of legal entity registration (creation). It can be on or before the system date and on or after legal entity's inception date but must not be a future date.

 Once the above information is entered, select "Save and add details"

Refer to Note 1104887.1 for instructions on how to configure the Address Format used for the Legal Address.


Step 3 - Validate Legal Entity, Establishment and Registration
After saving the legal entity record will be displayed as follows.

Note that in this test instance the organization number was updated.  This occurred because we have our system configured to automatically generated an organization number.

 Make sure the Registration was properly created

 Make sure the Legal Establishment was properly created


Step 4 - Set up a Ledger for the new Legal Entity
Responsibility- General Ledger Super User
Navigation - Setup : Financials : Accounting Setup Manager : Accounting Setups

Select "Create Accounting Setup" then "Add Another Row"
Select the Legal Entity created in step 2
Create the new ledger (step 1 shown below, steps 2-4 not shown)


Once finished, make sure the ledger status (circled in red) is showing with a green checkbox.  This is required in order for the next step to begin.


Refer to the Financials Implementation Guide, page 3-29 for more details on each of the configuration settings available when setting up a ledger.

Step 5 - Set Up an Operating Unit
An Operating Unit can be defined from many different responsibilities.  For this example we are using the seeded "Receivables Manager" responsibility.

Responsibility:  Receivables Manager
Navigation:  Setup : System : Organizations : Organizations

Enter the operating unit information as indicated below.  Note that you select the Location defined in the Legal Entity setup.

Once saved and with the cursor on "Operating Unit", select "Others" and then "Operating Unit Information"

Select the data as indicated below


Step 6 - Associate the Operating Unit with the Legal Establishment
Responsibility: Legal Entity Manager

From the LE manager screen, click to view the legal entity created in step 2.  Select the "Establishments" tab and then "View Details"

Once you have the establishments page open select "Associate Business Entities" and then "Update"
Add a row under "Operating Units" to link the legal establishment with the operating unit.


Step 7 - Run Replicate Seed Data
At this point the minimum setup requirements are completed.  Proceed with running replicate seed data and continue with the remainder of your implementation/configuration.

Replicate Seed Data sets defaults in the system for an operating unit after it is created

To see how to run replicate seed data, Refer to Note 134385.1 How to Run the Replicate Seed Data Program

For more details on the purpose of the seed data program refer to Note 274974.1 What Effect Does "Replicate Seed Data" concurrent request have on Appls?


References
NOTE:1104887.1 - How to Setup a Legal Address Using HR Address Formats in R12 Legal Entity Configurator
NOTE:577996.1 - Case Study: Setup R12 E-Business Tax (EBTax) for Canada: Includes 2010 HST Changes

Friday, October 16, 2015

How To Use Decode in PL SQL

DECLARE
l_maths number;
l_eng number;
l_hindi number;
l_sci number;
l_soc number;
l_san number;
l_tot_mars number;
mark_percent number;
grade number :=100;
BEGIN

select maths,eng,hindi,sci,soc,san,tot_mars into l_maths,l_eng,l_hindi,l_sci,l_soc,l_san,l_tot_mars
from student where stud_id = :v_stud_id;

mark_percent := l_tot_mars/ 600;

 CASE
  
   when (mark_percent >= 75) then             dbms_output.put_line('Excellent');
   when mark_percent <=75 and mark_percent >=60 then dbms_output.put_line('Very good');
   when mark_percent <=60 and mark_percent >=50 then dbms_output.put_line('Well done');
   when mark_percent <=50 and mark_percent >=40 then dbms_output.put_line('You passed');
   when mark_percent <=40 and mark_percent >=35 then dbms_output.put_line('Better try again');
   else dbms_output.put_line('No such grade');
   END CASE;

END stud_pro;

Clear BNE Cache for WebADI Changes

It Sometime happens that WebAdi Changes doesn't reflect once migrated in controlled instances. Here are the quick steps(Generally perfor...