Sunday, 8 November 2015

How to Turn On "About This Page" In Oracle R12

Set Following Profile Options as Required at User or Site

Personalize Self-Service Defn = YES
FND: Personalization Region Link Enabled = YES
Disable Self-Service Personal = NO (Only at Site)
FND: Diagnostics = Yes

Now bounce the Apache Server. Login to application, you can see the About This Page Link on all web pages.

Oracle Cursor and Trigger

Cursor: cursor is a private sql work area. Every sql statement executed by oracle server has an individual cursor associated with it.
Cursor are two types
1.Implicit cursor
2.Explicit cursor
Implicit cursor: Implicit cursors are declared by pl/sql implicitly at the time of DML statement and select statement in pl/sql including queries that returns single row.
Cursor have four attributes
1. SQL%ROWCOUNT
2. SQL%ISOPEN
3. SQL%NOTFOUND
4. SQL%FOUND

SQL%ROWCOUNT-Basically it returns  number. means number of rows affected by present sql statement.
SQL%ISOPEN-Always evalutes false because implicit cursor automatically closed after execution of sql statement.
SQL%FOUND-Always evalutes true because one or more rows are affected by recent sql statement
SQL%NOTFOUND-Always evalutes true when no rows are affected by present sql statement.

Example of explicit cursor
DECLARE
v_empno employees.employee_id%TYPE;
v_name employees.last_name%TYPE;
CURSOR emp_cur IS
SELECT employee_id,last_name FROM employees
BEGIN
OPEN emp_cur;
LOOP
FETCH emp_cur INTO v_empno,v_name ;
EXIT WHEN emp_cur%ROWCOUNT>10 OR
emp_cur%NOTFOUND;

DBMS_OUTPUT.PUT_LINE('employee_id:'||TO_CHAR(v_empno) || 'employee_name:'||'v_name');

END LOOP;
CLOSE emp_cur;
END;

Trigger Trigger is pl/sql block or procedure that is associated with table,view,schema and database. Execute immediately when particular event take place.
There are two types of trigger
1.Application trigger: Fires automatically when event occurs with particular application.
2.Database trigger: Fires when data such as DML oparation occured at that time.
DML triggers are two types
   1.Statementlevel trigger
   2.Rowlevel trigger

Statement level trigger -Statement level trigger means trigger body execute once for the triggering event.this is default.A statement level trigger fire once even no rows are affected at all.
Row level- Trigger body execute once for each row affected by triggering event.if no rows are affected in that case trigger body not executed.

Trigger example:
CREATE OR REPLACE TRIGGER secure_emp
BEFORE INSERT ON employees
BEGIN
TO_CHAR(SYSDATE,'DY')IN('SUN','SAT') OR TO_CHAR((SYSDATE,'HH24:MI')NOT BETWEEN '08:00' AND '18:00')THEN
RAISE_APPLICATION_ERROR(-20253,'u may insert employee information at business hrs');
END;

How to Load Oracle Workflow definition

The Workflow Definitions Loader is called WFLOAD and can be found in: $FND_TOP/bin

By default it can be used the following ways.
To upload:      WFLOAD apps/pwd 0 Y UPLOAD file.wft
To force:         WFLOAD apps/pwd 0 Y FORCE file.wft
To download: WFLOAD apps/pwd 0 Y DOWNLOAD file.wft ITEMTYPE1 [ITEMTYPE2...ITEMTYPEn]
To upgrade:    WFLOAD apps/pwd 0 Y UPGRADE file.wft

You can use a concurrent program to load process definitions. Run Workflow Definitions Loader concurrent program

What is NOCOPY hint?

Prior to Oracle 8i there were three types of parameter-passing options to procedures and functions:
    * IN: parameters are passed by reference
    * OUT: parameters are implemented as copy-out
    * IN OUT: parameters are implemented as copy-in/copy-out

The technique of OUT and IN OUT parameters was designed to protect original values of them in case exceptions were raised so that changes could be rolled back. Because a copy of the parameter set was made rollback could be done. However this method imposed significant CPU and memory overhead when the parameters were large data collections for example PL/SQL Table or VARRAY types.

With the new NOCOPY option OUT and IN OUT parameters are passed by reference which avoids copy overhead. However parameter set copy is not created and in case of an exception rollback cannot be performed and the original values of parameters cannot be restored.

Here is an example of using the NOCOPY parameter option:

TYPE Note IS RECORD( Title VARCHAR2(15), Created_By VARCHAR2(20), Created_When DATE, Memo VARCHAR2(2000));
TYPE Notebook IS VARRAY(2000) OF Note;
CREATE OR REPLACE PROCEDURE Update_Notes(Customer_Notes IN OUT NOCOPY Notebook) IS BEGIN ...END;

ORACLE APPS FAQ -1

1. How to register a report?
a) Register concurrent à Program à executable
b) Register concurrent à program à Define
c) Attach it to appropriate request group security à responsibility à Request
d) FTP RDF in respective top/report/US

2. How to CREATE a VALUE SET? What are the different types of value sets?
Enter Application à Validation à Set
Types of value set
a) Independent
b) Dependent
c) Table
d) Pair
e) SPECIAL DELIVERY translate dependent
f) Translatable independent

3. Name few types of execution method in concurrent program executable
a) Oracle reports
b) Sql * Plus
c) Host
d) Java stored procedure
e) Pl/sql stored procedure
f) SQL * Loader
g) Spawned
h) Java CCP
i) Multilanguage function
j) Immediate
k) Request set stage function

4. How to register a form?
a) Define Application à form
b) Define Application à function à give link to form defined in step I
c) Go to Application à menu à Attach function to menu
d) FTP from to AU_TOP, generate it and copy to respective TOP

5. What are the steps to develp a form>
a) Copy appstand.fmh, Template.FMB, required pll in local directory
b) Change the registry for pll path. Save template.fmb as the new form name from name and start developing the form
c) FTP form in AU_TOP and generate fmb using f60gen and copy.fmx in respective top/forms/us directory

6. what is the use of custom.pll?
Custom.pll is used for customizations such as form, enforcing business riles and disabling fields that are not required for site without modifying standard apps forms.

7. How to PROGRAMATICALLY submit the request?
a) with the help of standard API Find_Request. Submit_request

8. What is request set?
With the help of request set we can submit several requests together using multiple execution paths. Its collection of concurrent programs like reports procedures grouped together.

9. What are user exists in reports? What are user exist available in apps?
a) A user exit is a program written and then linked in to the report builder executable user exist are written when content need to be passed from report builder to that pgm, which performs some function and then returns control to report builder.

1. FND SRWINIT, FND SRWEXIT, FND FORMAT_CURRENCY, FND FLEXIDVAL, FND FLEXSQL.

10. What is the API used for file I/o operation ? or which API is used to write to request log and request output?
a) fnd_file.put_line (Fnd_file.log, ‘message’);
b) fnd_file.put_line (fnd_file.out. ‘message’);

11. how do I programmatically capture application user_id?
Fnd_profile.value (‘user_id’) or fnd_global.user_id.

12. what are flexfields?
A flexfield is a field made up of segments . each segment has a name and a set of valid values. There are two types of ff’s: key ff, DFF

13. Which are the 2 parameters required to be defined when a program is registered as pl/sql stored procedure
ERRBUF, RETCODE

14. can we register executable/concurrent program programmatically then how?
Yes we can. It can be done with standard package fnd_program, fnd_program.executable, fnd_program.register.

15. what changes need to be made if a setup is changed from a single org to multi org?
Org_id should be added as a parameter in a report and report should be run for specific org_id only

16. What are sub functions? How is it different from from?
A sub function is a securable subset of a forms functionally
a) forms appear in a navigator window and can be navigated to sub functions do not appear in the navigator window and cant be navigated to
b) forms can exist on this own sub functions can only be called by ____ embodied within a form, they cant exist on their own

17. what is message dictionary?
Message dictionary allows defining messages which can be used in application without hard coding them into forms or programs.

18. What is the token in concurrent à program à parameters window?
For a parameter in an oracle report program, they keyword is parameter specified here. The value is case sensitive for example P_CUSTOMER_NO

19. What are different validation defaults types and default value in current à program à parameter window?
a) constant
b) profile
c) SQL statement
d) Segment

20. I have a concurrent program that involves lot of inserts and updates on a huge basis where do I specify rollback segment etc
concurrent ->program->session control

21. How do I change the priority of my concurrent program?
Log on as system admin concurrent à program à program à priority, enter numerical value in this field so it will take the request which has higher priority.

22. What is incompatibility?
When a program or list of programs is defined as incompatible means that defined program is not compatible with incompatible program list and cant run simultaneously in same conflict domain.

23. What is data group?
A data group defines the mapping b/w oracle applications and oracle ID’s. A data group determines oracle database accounts a responsibilities forms, concurrent programs, and reports connect to

Oracle Apps SET - 2

1. What are alert in D2k forms?
An alert is a model window that displays a message notifying of some application condition. For example, do you want to save changes? Are you sure u want to exit? Or customer name can’t be bland ….

2. What is property class?
A property class is an object that contains a list of properties and their settings. Other objects can be based on property class. An object based on a property class can inherit the setting of any property in the class that makes sense for that object.

3. What is the difference b/w property class and visual attribute?
Visual attributes only for the visual properties of the item like font, color, whereas property class is for all the possible properties of objects.

4. What is an LOV?
LOV is a scrollable popup window that provides the use with selection list.

5. What are record groups and what are its types?
a) A record group is an internal form builder data structure that has a column/row framework similar to a database table.
b) Query record group – associated select statement
c) Non query Record group – doesn’t have query but can be changed programmatically.
d) Static record group – cant be changed programmatically.

6. What is restricted built_ins?
Any built_ins subprogram that initiates navigation is restricted. This includes subprograms that move the input focus from one item to another and those that involve database transactions. Restricted build_ins are not allowed in trigger that fire in response to internal navigation.

7. What are categories of trigger?
a) block – processing triggers. Related to record mgmt in a block eg: when clear block.
b) Interface event triggers : interface event triggers fire in response to events that occur in the form interface eg: when button pressed. When checkbox changed.
c) Master_detail triggers : from builder generates master/detail triggers automatically when a master/detail relation is defined b/w blocks. This is to enforce co-ordination b/w 2 blocks. For example, on clear details.
d) Message handling triggers : message handling triggers fire in response to default messaging events. To trap or recover an error. Eg on_error, on_message
e) Navigational triggers : navigational triggers fire in response to navigational events. For instance clicking on a text item from another block eg: pre block, post text item, when new item instance.
f) Query_item trigger : Eg; pre query and post query
g) Transactional triggers : Fire in response to events that occur as a form interacts with the database. Eg: on_delete, pre_commit
h) Validation trigger : when form validated data in item or record e: when validate item.

8. What is the sequence of events fired while cursor moves from an item from i1st block to an item in 2nd block?
When validate item of that item A
Post_text_item of A
When validate record
Post record
Post block
Pre block
Pre record
Pre text item
When_new_block_instance
When_new_Record_Instance
When_new_item_instance

9. what are types of canvas?
a) Content : The default specifies that the canvas should occupy the entire content area of the window to which it is assigned.
b) Stacked : Specifies that the canvas should be displayed in its window at the same time as the window’s content canvas. They are usually displayed programmatically and overlay some portion of the content view displayed in the same window
c) Vertical toolbar canvas : specifies that the canvas should be displayed as a vertical toolbar under the menu bar of the window.
d) Horizontal toolbar canvas : specifies that the canvas should be displayed as a horizontal toolbar at the left side of the window to which it is assigned.

10. How do I attach menu to a form?
Form à properties à functional à menu source à File
Forms à Properties à functional à menu module à name of menu (main menu

11. What are 2 types of data blocks object?
a) Data blocks : data blocks are associated with data within a database. Data blocks can be based on database table, views, procedure or transactional triggers.
b) Control blocks : in contrast a control block is not associated with the database and the item in or control block do not relate to table columns within a database.

12. How do I dynamically change the title of window?
a) set_window_property built-in

13. Name few system variables in forms?
A system variable is a form builder variable that keeps track of an internal form builder state. For example, system.Block_status, system, mode, system.from_status.

14. How to attach reports in oracle application?
The steps are as follows:
a) Design you report
b) Generate the executable file of the report.
c) Move the executable as well as source file to the appropriate products folder.
d) Register the report as concurrent executable
e) Define the concurrent program for the executable registered
f) Add the concurrent program to the request group of the responsibility

15. What are different report triggers and what is their firing sequence?
There are fiver report trigger:
a) Before report
b) After report
c) Before parameter form
d) After parameter form
e) Between pages
The firing sequence for report trigger is
Before parameter form – After parameter form – before report – between pages – after report.

16. What is the use of cursors in PL/SQL? What is REF Cursor?
The cursor is used to handle multiple row query in PL/SQL. Oracle uses implicit cursors to handle its queries. Oracle uses unnamed memory spaces to store data used in implicit cursors, with REF cursors you can define a cursor variable, which will point to that memory space and can be used like pointers in our 3GL’s

17. What is record group?
Record group are used with LOV’s to hold SQL query for your list of values. The record group can contain static data as well it can access dates from database tables through sql queries

18. What is flexfield? What are DFF& KFF?
In oracle application field made up of segments each segment has Assigned name and a set of valid values. oracle application uses flexfield to capture into about your organization

19. What are Autonomous Transaction? Give Scenario where you have used Autonomous transaction In your report ?
An Autonomous transaction is an independent transaction started by another transaction , the main transaction ,Autonomous transaction lets you suspend the main transaction do SQL operations ,commit or rollback those operation then resume the main transaction Once started an autonomous transaction fully independent .It shares no locks ,resources .or commit dependencies with the main transaction so ,you can log events increment retry counters ,and soon even if the main transaction rolls back More important, Autonomous transaction help you build modules reusable software component . for example Stored procedures can start and finish autonomous transaction there own .A calling application need not know about a procedures autonomous operations, and the procedures need not know about the application transaction content.

Scenario: you can use autonomous transaction in your report for writing error message in your database table.

20. What is the use of trigger in the form?
Triggers are used in forms for event handling u can write PL/SQL code in trigger to respond to a particular event occurred in your forms like when user presses a button or when he commits the form

The different types to triggers available I forms are
a)Key Trigger
b)Navigational Trigger
c)Transaction triggers
d)Message Triggers
e)Error triggers
f)Query triggers

21. What is the use of temp table and interface table ?
Temporary table are used in I/F programs to hold the intermediate data. The data is loaded into temporary first and then after validation through the PL/SQL program, the data is loaded into the interface table

22. What are the steps to register concurrent program in APPS?
The steps to register the concurrent prom in APPS are follows
a)Register the prom as concurrent prom for the executable
b)Define the concurrent prom for the executable registered
c)Add the concurrent program to the request group of the responsibilities

23. How to pass parameters to a report ? Do you have to register them with AOL?
U can define parameters in the define concurrent prom form there is no need to register the parameters with AOL .But you may have to register the value sets for those parameters

24. Do you have to register feeder program of interface to AOL?
Yes, U have to register the feeder program as concurrent prom to APPS

25. What are the forms customization steps
Steps are as follows
a)Copy the “Template fmb”1 and “Appstand.fmb” from AU_top/Forms/us. Put it in custom directory .
the Libraries(FNDSQF,APPCORE,APPDAYPK,GLOBE,CUSTOM,JE,JA,VERT)are automatically attached
b)Create/open new forms .then customise
c)save this form in corresponding module.

26. How to use flexfield In report?
There are two ways to use flexfield in reports one is to use the views(table name+`_kfv`or `_dfv`) created by apps, and use the concatenated segment column that holds the concatenated segments of the key or descriptive flexfield
(or)
To use the FND user exits provided by apps

27. what is KFF, DFF?
KFF : # unique identifiers, storing key into # used for entering and displaying key into
For example oracle general uses a KFF called Accounting flex field to uniquely identify a general account. 

Oracle Apps Reports FAQ

1.How many types of Columns are there in Reports6i?
There are three types of Columns. Formula Column, summary column, placeholder column.

2.Can you have more than one layout in One Report?
It is possible to have more than one layout in one report by using additional layout option in Layout Editor.

3.Can you run Report without Parameter Form?
Yes it is possible to run the report without parameter form by setting the PARAM value to Null

4.What are the minimum number of groups required for a matrix report?
The minimum of groups required for a matrix report are 4


5.Which of the following Option is valid for Panel/Print Order Property in Report Builder?
Across Down/Down Across

6.What is default Unit of Measurement in Report?
Default Unit of measurement is Inch.

7.How many types of Parameters are available in Reports?
There are two types of Parameters available in Reports
One is System Parameter and another is User Parameter.

8.What is the purpose of PlaceHolder Column in Report?
A column for which you set the datatype and value in PL/SQL that you define.

9.What is the purpose of Summary Column in Reports?
A performs a computation on another column's data.

10.What is the purpose of Formula Columns?
A column performs a user-defined computation on another column(s) data, including placeholder columns.

11.Which of the following Procedures displays message number and text that you specify?
SRW.MESSAGE
This procedure displays a message with the message number and text that you specify.  The message is displayed in the format below.  After the message is raised and you accept it, the report execution will continue.

12.What are bind variables?
Variable  that are used to replace a single value in SQL or PL/SQL, such as a character string, number, or date.  Specifically, bind references may be used to replace expressions in SELECT, WHERE, GROUP BY, ORDER BY, HAVING, CONNECT BY, and START WITH clauses of queries.  Bind references may not be referenced in FROM clauses or in place of reserved words or clauses.

13.Can lexical reference be made in PL/SQL statement?
No

14.Following of which trigger will fire first?
   1. Between Pages
   2. After Parameter Form
   3. Before Parameter Form
   4. Before Reprort
Answer : C

15. Is there a way to change the same format mask in a lot of fields in one step?
Select all the Items and change the format mask for all the item once.

What is $FLEX$ and $PROFILES$?

$FLEX$ and $PROFILES$ are Special Variables in oracle Apps environment and are used to hold values at runtime. Whenever we are working with value sets, we will be using both of these for modifying the data fetched, for basing the values of a parameter on the other parameter and also fetching the Profile Option values.

To segregate this based on the functionality
$FLEX$: Used for basing the value of a parameter on another parameter.
$PROFILES$: used for fetching the data stored in the specified profile option value which is currently active.

Where is it used?

Both these variables are used in the Parameter form of a Concurrent Program and are used at the Where Clause window in the value set of Table type.

Syntax:

:$FLEX$.previous_value_set_name

Important:

    * $FLEX$ must always be in capitals.
    * A ':' must precede the declaration of $FLEX$.
    * The previous value set name must have already been assigned and saved on a different parameter.


:$PROFILES$.Profile_option_name

Important:

    * $PROFILES$ must be always in capitals.
    * ':' must always precede the declaration.
    * Profile option name is the Profile Name and not to be confused with the User profile Name.

How to Call OAF Page from Workflow Email Notification

In R12  below error will occur if you try to open an OAF Page URL link directly.

You are trying to access a page that is no longer active. The referring page may have come from a previous session. Please select Home to Proceed.

Note: When you call a standard page this error won't appear. This happens only when you try to open a custom page.

Below are the steps to resolve the error:
1.Open the custom page in Jdev and select the PageLayoutRN. In the property inspector set the Security Mode to selfSecured.
2.Set the rendered property to ${oa.FunctionSecurity.}
Eg: ${oa.FunctionSecurity.XXCUSTPG}
Note: Your user id should have access to the custom page function.
3.In your workflow procedure generate the  OA page URL with the below function and set the workflow attribute with the generated URL.

lc_url:= FND_RUN_FUNCTION.get_run_function_url(p_function_id => 53637,
p_resp_appl_id => null,
p_resp_id => null,
p_security_group_id => 0,
p_parameters =>'PARAM1='||p_lease_id,--'&'||'LeaseId=784',
p_override_agent => null,
p_org_id => null,
p_lang_code => null,
p_encryptParameters => false);

Now you should be able to open the OAF page from workflow email notification.

Wednesday, 21 October 2015

Purchase order (PO) types



  • Standard Purchase order: This type of PO is used when you know the Item, Price, Delivery Schedule and payment terms. Most of the time Standard PO is used to fulfill sporadic demands or say demand coming once or twice a year. In this type of PO you are committing a purchase of item/s with particular quantity and particular price at particular shipment schedule.
For example
    • Purchasing for any specific event happening in Company
    • Where purchasing item/s is one time job.
  • Planned Purchase Order (PPO): This type of PO is used when you are not sure about the exact delivery schedules but other details are quite clear (like Item, Quantity, Price, approximate Delivery Schedule and Payment Term). For PPO Need-By-Date has to be entered, but this date will be treated as tentative date only. Once you are sure about the delivery schedule you create releases against this PPO with detailed delivery schedule. In this type of PO you are committing a purchase of item/s with particular quantity and particular price but with tentative shipment schedule. When you make a release, you are committing the delivery also.
For example
    • You need 1200 notebooks yearly, so you can raise PPO with quantity 1200 and in shipment details you can have shipment schedule as per your need (Say 12 shipments with 100 quantity each). This will be tentative schedule, you need to generate a release as and when you need the good and supplier will provide you material.
  • Blanket Purchase Order: This kind of PO is used when are not sure about quantity, price, delivery schedule. As soon as you select PO type as Blanket Purchase Agreement the fields for quantity  gets disabled. Blanket PO can be based on max agreed amount. Exact quantity Delivery Schedule and price will be informed to supplier by creating Blanket releases against blanket PO. You can have different ‘Price Breaks’ and specify the quantity / discount / effectively details. In this type of PO you are not committing your supplier at the time of creating PO, all the commitments are done when release is sent.
For Example:
    • A car manufacturer needs dashboard for each vehicle and it is purchased from selective suppliers only. But demand for dashboard is not clear. In this case Blanket PO is used and whenever demand comes, releases are sent to supplier.
  • Contract Purchase Order: This type of PO is used when you are not sure even about the item which need to be purchased J. The only information that you provide in a Contract PO is supplier, supplier site, payment terms and agreement control details (header part only). Standard PO are created by referring the Contract PO when some thing is to be purchased against the Contract PO from that supplier.
For example:
    • You need to import many items to run your business, but you don’t have Import/Export license. In this case you create Contract PO with supplier who has Import/Export license and whenever you need something to be imported, you generate standard PO referring the Contract PO for that Item/s.
Out of above 4 types you can add only Blanket and Contract POs in Approved Supplier List (ASL).

Thursday, 8 October 2015

Difference between truncate and delete command


Truncate verse Delete command in oracle

If you want to delete all the rows in a table, TRUNCATE TABLE is faster than DELETE.
DELETE physically removes rows one at a time and records each deleted row in the transaction log. TRUNCATE TABLE deallocates all pages associated with the table. For This reason, TRUNCATE TABLE is faster and requires less transaction log space than DELETE. TRUNCATE TABLE is functionally equivalent to DELETE with no WHERE clause, but TRUNCATE TABLE cannot be used with tables referenced by foreign keys. BOTH DELETE and TRUNCATE TABLE make the space occupied by the deleted rows available for the storage of new data.
 
Truncate just resets the high-water mark. It does not delete any rows. If you delete rows, then whatever you have specified regarding the referential integrity will be done (ON DELETE SET NULL, or ON DELETE  CASCADE, or the default which is to return ORA-02292 if the referential integrity constraint would be violated) whereas TRUNCATE just returns ORA-02266 if you have any enabled foreign key constraints referencing the  table, even if the tables are empty.

Schema : It is the schema to contain the trigger. If you omit schema, Oracle creates the trigger in your own schema.

TABLE : specifies the schema and name of the table to be truncated. you can truncate index-organized tables. This table cannot be part of a cluster.

When you truncate a table, Oracle also automatically deletes all data in the table's indexes.

SNAPSHOT LOG : specifies whether a snapshot log defined on the table to be preserved or purged when the table is truncated. This clause allows snapshot master tables to be reorganized through export/import without affecting the ability of primary-key snapshots defined on the master to be fast refreshed. To support continued fast refresh of primary-key snapshots the snapshot log must record primary-key information. For more information about snapshot logs and the TRUNCATE command, see Oracle8 Replication.

PRESERVE : - specifies that any snapshot log should be preserved when the master table is truncated.

PURGE : - specifies that any snapshot log should be purged when the master table is truncated.

CLUSTER : - specifies the schema and name of the cluster to be truncated. You can only truncate an indexed cluster, not a has cluster.

when you truncate a cluster, oracle also automatically deletes all data in the cluster's tables' indexes.

DROP STORAGE :- deallocates the space from the deleted rows from the table or cluster. This space can subsequently be used by other objects in the tablespace. This is the default. The DROP STORAGE option deallocates all but the space specified by the table's MINEXTENTS parameter.

RESUE STORAGE : retains the space from the deleted rows allocated to the table or cluster. Storage values are not reset to the values when the table or cluster was created. This space can subsequently be used only by new data in the table or cluster resulting from inserts or updates.

The DROP STORAGE and REUSE STORAGE options also apply to the space freed by the data deleted from associated indexes.

Deleting rows with the TRUNCATE command is also more convenient than dropping and re-creating a table because dropping and re-creating:

invalides the table's dependent objects, while truncating does not

requires you to regrant object privileges on the table, while truncating does not requires you to re-create the table's indexes, integrity constraints, and triggers and respecify its STORAGE parameters, while truncating does not

Note:

when you truncate a table, the storage parameter NEXT is changed to be the size of the last extent deleted from the segment in the process of truncation.

Restrictions

when you truncate a table,NEXT is automatically reset to the last extend deleted.

you cannot individually truncate a table that is part of a cluster. you must either truncate the cluster,delete all rows from the table,or drop and re-create the table.

You cannot truncate the parent table of an enabled referential integrity constraint. You must disable the constraint before truncating the table. (An exception is that you may truncate the table if the integrity constraint is self-referential.)

You cannot rollback a TRUNCATE statement.
 
 
Autonomous Transaction is a new feature in ORACLE. It allows setting up independent transactions that can be called from within other transactions. It lets you suspend the main transaction (without committing or rolling back), perform some DML operations, commit or rollback those operations (without any effect on the main transaction), and then return to the main transaction.
 
A pragma is a directive to the PL/SQL compiler. Pragmas pass information to the compiler, they are processed at compile time but do not execute.
 
A transaction is a Logical unit of work that compromises one or more SQL statements executed by a single User.
 
The SGA is a shared memory region allocated by the oracle that contains Data and control information for one oracle instance.
 

    P/L SQL Tables / Arrays

PL/SQL tables are declared in the declaration portion of the block. A table is a composite data type in PL/SQL. PL/SQL tables can have one column and a primary key neither of which can be named.
The column can be any scalar type but primary key should be a BINARY_INTEGER data type.
 
Rules for PL/SQL Tables:
1.  A loop must be used to insert values into a PL/SQL Table.
2. You cannot use the Delete command to delete the contents of PL/SQL Table. You must assign an empty table to the PL/SQL table being deleted.
 
2.  You cannot use the Delete command to delete the contents of PL/SQL

External Bank Import Process


Process of importing external bank account data in R12

Oracle supports many Open Interface Programs for importing data from any third party systems. For importing bank account information Oracle provides interface programs named ‘Customer Interface’ for importing Customer bank accounts and ‘Supplier Open Interface/Supplier site interface ’ for importing Supplier bank accounts.
This document helps in understanding the process of importing the external bank accounts data for customers or suppliers.

Importing Supplier bank accounts

The data to be imported is to be inserted in the interface tables first. After inserting the data in the interface tables,the ‘Supplier Open Interface Import’ program is run for inserting the data in the R12 tables.An important point to be noted with regard to the supplier bank accounts – the bank accounts data related to the suppliers can only be imported along with the supplier or supplier site. The bank account details cannot be imported individually. After creating the supplier or supplier site, the bank account can only be added from the user interface.
The supplier bank accounts can be assigned at the Supplier or Supplier Site or Address or Address Operating Unit level from the user interface. The import program supports assigning Supplier bank accounts at Supplier or at Supplier Site level only.
The main interface tables used for importing Suppliers, Supplier sites and Bank accounts data are as follows -
AP_SUPPLIERS_INT
IBY_TEMP_EXT_BANK_ACCTS.

AP_SUPPLIER_SITES_INT

The following scenarios are covered in this document –
a) Importing the bank account at Supplier level along with Supplier data
b) Importing the bank account at site level along with Supplier and Supplier site
i. Importing bank account at site along with supplier and site details.
ii. Importing bank account along with supplier site for an existing Supplier.
c) Importing the bank accounts for Employee type Supplier
The detailed steps for each of the scenarios have been mentioned below.
Importing the bank account at Supplier level along with Supplier data

Please follow the below mentioned steps for importing the bank account at supplier level.
Step 1 –
Insert the Suppliers data in the interface table AP_SUPPLIERS_INT.
Step 2 –
While inserting the data in the table AP_SUPPLIERS_INT, the data in the column
VENDOR_INTERFACE_ID should be generated sequentially. This is the unique identifier for
records in this table
The column AP_SUPPLIERS_INT.VENDOR_INTERFACE_ID is used to link the supplier with
the respective site or bank account details.
The sequence AP_SUPPLIERS_INT_S is used to generate the sequential number.
Step 3 –
The bank account details should be inserted in the interface table
IBY_TEMP_EXT_BANK_ACCTS
Step 4 –
While inserting the data in the table IBY_TEMP_EXT_BANK_ACCTS, as the bank account data is being assigned at supplier level, the column IBY_TEMP_EXT_BANK_ACCTS.CALLING_APP_UNIQUE_APP_REF1 should be updated
with the value from its corresponding suppliers
AP_SUPPLIERS_INT.VENDOR_INTERFACE_ID
Step 5 –
While inserting the data in IBY_TEMP_EXT_BANK_ACCTS and AP_SUPPLIERS_INT, the value for the column ‘Status’ should be updated as ‘NEW’ (case sensitive) in both the tables.After inserting the data in the tables AP_SUPPLIERS_INT and IBY_TEMP_EXT_BANK_ACCTS the data is ready to be imported.
Step 6 –
Navigate to the Payables >> Other: Requests >> Run -‘Submit Request’. The following screen is displayed.


Step 7 –
Select ‘Single Request’ and select ‘OK’ button.
concurrent program name : supplier open interface import
Step 8
In the request name, search and select the program with name ‘Supplier Open Interface
Step 9 –
Navigate to the parameters LOV and select the options based on the imported data.
Step 10 –
Parameters: Batch size indicates the number of records to be imported in one import program.
The default value is 1000 and can be modified.
Step 11 –
Parameters: Print exceptions only indicate whether the log file should contain only the exception
details. Default value is ‘No’ and can be modified to ‘Yes’.
Step 12 –
Parameters: Debug switch indicate whether the log file should contain the debug details. Default
value is ‘No’ and can be modified to ‘Yes’.
Step 13 –
Parameters: Trace switch indicate whether the trace file of the program should be generated.
Default value is ‘No’ and can be modified to ‘Yes’.
Step 14 –
Import options LOV: Default value is ‘All’. If the program is to import only the records with the
status ‘New’, select the option ‘New’. If the program is run to import only the rejected
transactions of the earlier run, select the option ‘Rejected’. If the request program is to import all
the records in the table, select the option ‘All’.

Step 15 –
Select ‘Submit’ button.
Step 16 –
The program ‘Supplier Open Interface Import’ automatically calls the ‘Create external bank
account’ (IBY_EXT_BANKACCT_PUB.CREATE_EXT_BANK_ACCT) program and imports
the bank accounts data related to the supplier.
On successful import of the records the column ‘Status’ will be updated from ‘NEW’ to
‘PROCESSED’. If a record is not imported due to any error, the field will be updated as
‘REJECTED’.
Step 17 –
To track the status of the request program, navigate to the ‘View requests’ screen
Step 18 –
When the Phase column shows ‘Completed’ and the status column shows ‘Normal’, select the
‘View Output’ button to know the number of records that have been imported.
Step 19 –
Select the ‘View Log’ button to go through the error messages if any.
After Successful import of Supplier/Supplier Site with the bank account details, following IBY Tables are
being populated.
IBY_EXTERNAL_PAYEES_ALL: A record is created in this table with Payee id (equivalent to
HZ_PARTIES.PARTY_ID).

IBY_EXT_BANK_ACCOUNTS: A record is inserted in this table with the bank account details
provided in IBY_TEMP_EXT_BANK_ACCTS.

IBY_PMT_INSTR_USES_ALL: For every external bank account created, a record is inserted in this
table. This table also holds relationship between External Payee and External Bank Account
Note:
2) While importing the bank account along with the supplier, if there is some error in the bank account
details, the supplier data will only be created without the bank details.
3) Bank account can be created without bank and branch details if the bank is not used for making
international payments. In other words bank account will be created without the bank and branch if
Bank_id and Branch_id is not inserted in IBY_TEMP_EXT_BANK_ACCTS table and
FOREIGN_PAYMENT_USE_FLAG is ‘No’.

Importing the bank account at site level along with Supplier and Supplier site

While importing the bank details for a supplier site, there are two scenarios –
a) Importing bank account at site along with supplier and site details.
b) Importing bank account along with supplier site for an existing Supplier.

Importing Bank account at site along with supplier and site details.

The additional interface table for storing the supplier sites data is AP_SUPPLIER_SITES_INT.
Step 1 –
Insert the data in the AP_SUPPLIERS_INT and AP_SUPPLIER_SITES_INT.
Step 2 –
While inserting the data in the table AP_SUPPLIERS_INT, the data in the column VENDOR_INTERFACE_ID should be generated sequentially. This is the unique identifier for records in this table In the scenario, VENDOR_INTERFACE_ID is used to link the supplier with the  respective site details
Step 3 –
While inserting data in the table AP_SUPPLIER_SITES_INT, the column AP_SUPPLIER_SITES_INT.VENDOR_INTERFACE_ID should be filled in with the
respective suppliers record value of the AP_SUPPLIER_INT.VENDOR_INTERFACE_ID
Step 4 –
Insert the bank account details in the interface table IBY_TEMP_EXT_BANK_ACCTS.
Step 5 –
As the bank account data is being assigned at supplier site level, while inserting the data in the table IBY_TEMP_EXT_BANK_ACCTS, the column IBY_TEMP_EXT_BANK_ACCTS.CALLING_APP_UNIQUE_APP_
REF2 should be updated with AP_SUPPLIER_SITES_INT.VENDOR_SITE_INTERFACE_ID.
VENDOR_SITE_INTERFACE_ID helps in linking the bank details with its corresponding Supplier site.
Step 6 –
While inserting the data in AP_SUPPLIERS_INT, AP_SUPPLIER_ SITES_INT and
IBY_TEMP_EXT_BANK_ACCTS, the value for the column ‘Status’ should be updated as ‘NEW’.
After inserting the data in the tables AP_SUPPLIERS_INT, AP_SUPPLIER_SITES_INT and IBY_TEMP_EXT_BANK_ACCTS the data is ready to be imported.
Step 7 –
Navigate to the Payables >> Other: Requests >> Run -‘Submit Request’ screen and run the program with name ‘Supplier Open Interface Import’.
The other steps to run the ‘Supplier Open Interface Import’ are same as explained for importing Bank accounts details at supplier level.

Importing bank account along with supplier site for an existing Supplier

The interface table for storing the supplier sites data is AP_SUPPLIER_SITES_INT and the bank account data is IBY_TEMP_EXT_BANK_ACCTS.
Step 1 –
Insert the data in the AP_SUPPLIER_SITES_INT.
Step 2 –
While inserting the data in the AP_SUPPLIER_SITES_INT, the column VENDOR_ID
should be updated with the respective supplier for which the supplier site is being created.
The column VENDOR_ID is used to link the supplier with the respective Supplier site details.
Step 3 –
The bank account details should be inserted in the interface table IBY_TEMP_EXT_BANK_ACCTS.
Step 4 –
As the bank account data is being assigned at supplier site level, while inserting the data  in the IBY_TEMP_EXT_BANK_ACCTS the column ‘CALLING_APP_UNIQUE_APP_REF2' should be updated with the respective  VENDOR_SITE_INTERFACE_ID.
The field AP_SUPPLIER_ SITES_INT is used to link the supplier site with the respective  bank account details.
Step 5 –
While inserting the data in AP_SUPPLIER_ SITES_INT and IBY_TEMP_EXT_BANK_ACCTS, the value for the column ‘Status’ should be updated as ‘NEW’.
After inserting the data in the tables AP_SUPPLIER_ SITES_INT and IBY_TEMP_EXT_BANK_ACCTS the data is ready to be imported.
Step 6 –
Navigate to the Payables >> Other: Requests >> Run -‘Submit Request’ screen and run
the program with name ‘Supplier Sites Open Interface Import’.
The other steps to run the ‘Supplier Open Interface Import’ are same as explained for importing Bank
accounts details at supplier level.
 Importing the bank accounts for Employee type Supplier

External bank account can be imported for Employee type suppliers while importing the supplier data for the employee.

Prerequisite


Employee record should have been created in the HR.

The interface tables for storing the supplier, supplier site and the bank account details remain the same - AP_SUPPLIER_SITES_INT, AP_SUPPLIER_SITES_INT and IBY_TEMP_EXT_BANK_ACCTS respectively.
Step 1 –
Insert the data in the AP_SUPPLIERS_INT.
Step 2 –
As the data is inserted for an employee type of supplier, the AP_SUPPLIER_INT.EMPLOYEE_ID should be updated with employee Id and VENDOR_TYPE_LOOKUP_CODE should be updated as ‘EMPLOYEE’.
Step 3 –
Insert the data in the AP_SUPPLIER_SITES_INT.
Step 4 –
As the data is imported for an employee type supplier, the AP_SUPPLIER_SITES_INT.VENDOR_SITE_CODE should be updated as ‘HOME’ or ‘OFFICE’ or ‘PROVISIONAL’ (please note that values are case sensitive and should be
given in capitals).
Step 5 –
Insert the bank account details in the interface table IBY_TEMP_EXT_BANK_ACCTS.
Step 6 –
As the bank account data is being assigned at supplier site level, while inserting the data in the table IBY_TEMP_EXT_BANK_ACCTS, the column IBY_TEMP_EXT_BANK_ACCTS.CALLING_APP_UNIQUE_APP_

REF2 should be updated with AP_SUPPLIER_SITES_INT.VENDOR_SITE_INTERFACE_ID.

VENDOR_SITE_INTERFACE_ID helps in linking the bank details with its
corresponding Supplier site.
Step 7 –
Navigate to the Payables >> Other: Requests >> Run -‘Submit Request’ screen and run the program with name ‘Supplier Open Interface Import’.
The other steps to run the ‘Supplier Open Interface Import’ are same as explained for importing Bank
accounts details at supplier level.

Normalization in oracle

Normalization / De-Normalization

Normalization: It's the process of efficiently organizing data in a database. There are two goals of the normalization process: eliminate redundant data ( for example, storing the same data in more than one table) and ensure data dependencies make sense (only storing related data in a table). Both of these are worthy goals as they reduce the amount of space a database consumes and ensure that data is logically stored.
Eliminat Repeating Groups - Make a separate table for each set of related attributes, and give each table a primary key.
Eliminate Redundant Data - If an attribute depends on only part of a multi-valued key, remove it to a separate table.
Eliminate Columns Not Dependent On Key - If attributes do not contribute to a description of the key, remove them to a separate table.
Isolate Independent Multiple Relationships - No table may contain two or more 1:n or n:m relationships that are not directly related.
Isolate Semantically Related Relationships - There many be practical constrains on information that justify separating logically related many-to-many relationships
1st Normal Form (1NF)
Def : A table (relation) is in 1NF if
    1. There are no duplicated rows in the table.
    2. Each cell is single-valued (i.e., there are no repeating groups or arrays).
    3. Entries in a column (attribute,field) are of the same kind.
      1. Note : The order of the rows is immaterial; the order of the columns is immaterial.
        Note: The requirement that there be no duplicated rows in the table means that the table has a key (although the key might be made up of more than one column - even, possibly, of all the columns).
        2nd Normal Form (2NF)
        Def: A table is in 2NF if it is in 1NF and if all non-key attributes are dependent on all of the key.
        Note : Since a partial dependency occurs when a non-key is dependent on only a part of the (composite) key, the definition of 2NF is sometimes phrased as, "A table is in 2NF if it is in 1NF and if it has no partial dependencies."
        3rd Normal Form (3NF)
        Def: A table is in 3NF if it is in 2NF and if it has no transitive dependencies.
        Boyce-Codd Normal Form (BCNF)
        Def: A table is in BCNF if it is in 3NF and if every determinant is a candidate key.
        4th Normal Form (4NF)
        Def: A table is in 4NF if it is in BCNF and if it has no multi-valued dependencies.
        5th Normal Form (5NF)
        Def: A table is in 5NF, also called "Project-Join Normal Form" (PJNF), if it is in 4NF and if every join dependency in the table is a consequence of the candidate keys of the table.
        Domain-Key Normal Form (DKNF)
        Def: A table is in DKNF if every constraint on the table is a logical consequence of the definition of keys and domains.

        De-Normalization :
        Denormalization is a technique to move from higher to lower normal forms of database modeling in order to speed up database access. you may apply Denormalization in the process of deriving a physical data model from a logical form.

      AME Setup

       

      Steps for AP Invoice Approval AME setup


      Step 1: Navigation to Profile options
      System Administrator àProfile à system
      Setup 2 :  Enter Application and Profile details and Press Find Button.
       

      Step 3 : Change the AME Installed Value to YES as shown below
       
      Step 4 : Change to Payables Responsibilty and  Navigate to Payables Options

       
       
      
      
      Step 5 : Enter the Operating Unit Name.
      Step 6 :  Navigate to Approval Tab and Enable  ‘Use Invoice Approval Workflow ‘ as shown below
       
      Step 7: Switch to Approvals  Management Business Analyst Responsibility .
       
       Step 8 :  Enter the Transaction  Type as  ‘ Payables Invoice Approval 
       
      Step 9: Press the Approval Groups Button as shown above Screen shot.
      Create the Approval Group with the Below Values
      In the Query I have written the function which will return the Accounting Manager in the Test instance.
      
      
      Step 10: Navigate to Action Types  Button.
      And select Action type as Pre Chain of Authority Approvals as shown below
       
      You will get the Action value as ‘Require pre-approval from OSD Account Manager Approval

      Step 11 : Create a Rule by following below Steps ,
      a)      Enter the Name of the Rule  Example :  osd Approval Management Approval,Rule  type : Combination : List Creation, Item Class : Header as shownbelow
      a)      As there are no Conditions , press the next button.
      b)      Select the Action Type as ‘Pre Chain of Authority Approvals’  and Action as ‘pre-approval from OSD Account Manager Approval’ .
      Step 4 : Finish 
      Completion of AME Setup
      Step 12 : Navigate to Payables Manager
      Create An invoice by Entering the Header and line Information.

      Entering the Line Information.
       
       
       

      Now By Pressing  the Distribution  Button.
      Enter the Distribution Level details as shown below  screen shot.
       
      Once the Account is Generated.
      àNavigate to Invoice page Actions .
      Enable the Check box Validate and press OK button
       
      
      Create the Account by Enabling the Create Accounting check box and   Final and press OK   from the Above Screen.
      Once the Account is Generated Run the ‘Invoice Approval Workflow’  .
      Navigation : view à Requests
      Parameters :
      Supplier Name ,Invoice Num .
       
      Once the Program complete successfully, follow the below steps
      Navigate : Reports à View Invoice  Approval History
      You will get the Account Manager  details for the Invoice  and the notification will be sent to the Approver.
      CREATE OR REPLACE FUNCTION XX_GET_APPROVER( p_invoice_id IN NUMBER )
          RETURN VARCHAR
        IS
          l_person_id      NUMBER        := 0 ;
          l_count          NUMBER        := 0;
          V_OPERATING_UNIT VARCHAR2(2000):=NULL;
          V_ORG_ID         NUMBER        := 0;
          l_return_val     VARCHAR2(200) := NULL;
        BEGIN
          BEGIN
            SELECT COUNT(*)
           INTO l_count
            FROM ap_invoices_all ail,
              ap_suppliers aps
              --    po_lookup_codes plc
            Where Ail.Vendor_Id              = Aps.Vendor_Id
            And NVL(Aps.Vendor_Type_Lookup_Code,'XYZ') <>'OUTSOURCING'
      --      AND aps.vendor_type_lookup_code <>'OUTSOURCING'   
              -- and aps.vendor_type_lookup_code = plc.lookup_code
            AND ail.invoice_type_lookup_code IN ('PREPAYMENT', 'STANDARD','MIXED')
            AND ail.invoice_id                = p_invoice_id;
            --   and plc.lookup_type <> 'VENDOR TYPE' ;
          EXCEPTION
          WHEN OTHERS THEN
            DBMS_OUTPUT.PUT_LINE('Invoice does not exist :');
          END;
          DBMS_OUTPUT.PUT_LINE('Invoice does not exist l_count :'||l_count);
          IF l_count >= 1 THEN
            BEGIN
              SELECT org_id
              INTO V_ORG_ID
              FROM ap_invoices_ALL
              WHERE invoice_id=p_invoice_id;
            EXCEPTION
            WHEN OTHERS THEN
              DBMS_OUTPUT.PUT_LINE('Invoice orgid does not exist :');
            END;
            DBMS_OUTPUT.PUT_LINE('Org id Value :'||v_org_id);
            BEGIN
              SELECT name
              INTO V_OPERATING_UNIT
              FROM hr_operating_units
              WHERE organization_id=v_org_id;
            EXCEPTION
            WHEN OTHERS THEN
              DBMS_OUTPUT.PUT_LINE('operating unit does not exist :');
            END;
            DBMS_OUTPUT.PUT_LINE('Org id Value :'||V_OPERATING_UNIT);
            BEGIN
              IF v_operating_unit LIKE 'operations' THEN
                SELECT paf1.person_id
                INTO l_person_id
                FROM HR_ALL_POSITIONS_F HAPF,
                  PER_JOBS PJB ,
                  PER_ALL_PEOPLE_F PAF1,
                  FND_USER FU ,
                  PER_ALL_ASSIGNMENTS_F PAAF
                WHERE SUBSTR(HAPF.name,INSTR(HAPF.name,'.',1)+1,15)='Account Manager'
                AND PJB.NAME                                       ='Manager'
                AND PAAF.PERSON_ID                                 =PAF1.PERSON_ID
                AND HAPF.JOB_ID                                    = PJB.JOB_ID
                AND PAAF.JOB_ID                                    =PJB.JOB_ID
                AND PAAF.POSITION_ID                               =HAPF.POSITION_ID
                AND (sysdate BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE)
                AND (sysdate BETWEEN paf1.effective_start_date AND paf1.effective_end_date)
                AND PAAF.JOB_ID            =HAPF.JOB_ID
                AND FU.EMPLOYEE_ID         =PAF1.PERSON_ID
                AND rownum                 =1
                AND SUBSTR(HAPF.name,1,2) IN
                  (SELECT FLEX_VALUE
                  FROM FND_FLEX_VALUE_SETS FFVS,
                    FND_FLEX_VALUES FFV ,
                    FND_FLEX_VALUES_TL FFVT
                  WHERE FFVS.FLEX_VALUE_SET_ID=FFV.FLEX_VALUE_SET_ID
                  AND FFV.FLEX_VALUE_ID       =FFVT.FLEX_VALUE_ID
                  AND FFVT.LANGUAGE           ='US'
                  AND FLEX_VALUE_SET_NAME     ='operations_Company'
                  AND FFVT.DESCRIPTION        ='Operations'
                  );
              elsif v_operating_unit='glass' THEN
                SELECT paf1.person_id
                INTO l_person_id
                FROM HR_ALL_POSITIONS_F HAPF,
                  PER_JOBS PJB ,
                  PER_ALL_PEOPLE_F PAF1,
                  FND_USER FU ,
                  PER_ALL_ASSIGNMENTS_F PAAF
                WHERE SUBSTR(HAPF.name,INSTR(HAPF.name,'.',1)+1,15)='Account Manager'
                AND PJB.NAME                                       ='Accountant' --'Manager'
                AND PAAF.PERSON_ID                                 =PAF1.PERSON_ID
                AND HAPF.JOB_ID                                    = PJB.JOB_ID
                AND PAAF.JOB_ID                                    =PJB.JOB_ID
                AND PAAF.POSITION_ID                               =HAPF.POSITION_ID
                AND (sysdate BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE)
                AND (sysdate BETWEEN paf1.effective_start_date AND paf1.effective_end_date)
                AND PAAF.JOB_ID            =HAPF.JOB_ID
                AND FU.EMPLOYEE_ID         =PAF1.PERSON_ID
                AND rownum                 =1
                AND SUBSTR(HAPF.name,1,2) IN
                  (SELECT FLEX_VALUE
                  FROM FND_FLEX_VALUE_SETS FFVS,
                    FND_FLEX_VALUES FFV ,
                    FND_FLEX_VALUES_TL FFVT
                  WHERE FFVS.FLEX_VALUE_SET_ID=FFV.FLEX_VALUE_SET_ID
                  AND FFV.FLEX_VALUE_ID       =FFVT.FLEX_VALUE_ID
                  AND FFVT.LANGUAGE           ='US'
                  AND FLEX_VALUE_SET_NAME     ='Company'
                  AND FFVT.DESCRIPTION        ='glass'
                  );
              Elsif v_operating_unit LIKE 'suretech' THEN
                SELECT paf1.person_id
                INTO l_person_id
                FROM HR_ALL_POSITIONS_F HAPF,
                  PER_JOBS PJB ,
                  PER_ALL_PEOPLE_F PAF1,
                  FND_USER FU ,
                  PER_ALL_ASSIGNMENTS_F PAAF
                WHERE SUBSTR(HAPF.name,INSTR(HAPF.name,'.',1)+1,15)='Account Manager'
                AND PJB.NAME                                       ='Manager'
                AND PAAF.PERSON_ID                                 =PAF1.PERSON_ID
                AND HAPF.JOB_ID                                    = PJB.JOB_ID
                AND PAAF.JOB_ID                                    =PJB.JOB_ID
                AND PAAF.POSITION_ID                               =HAPF.POSITION_ID
                AND (sysdate BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE)
                AND (sysdate BETWEEN paf1.effective_start_date AND paf1.effective_end_date)
                AND PAAF.JOB_ID            =HAPF.JOB_ID
                AND FU.EMPLOYEE_ID         =PAF1.PERSON_ID
                AND rownum                 =1
                AND SUBSTR(HAPF.name,1,2) IN
                  (SELECT FLEX_VALUE
                  FROM FND_FLEX_VALUE_SETS FFVS,
                    FND_FLEX_VALUES FFV ,
                    FND_FLEX_VALUES_TL FFVT
                  WHERE FFVS.FLEX_VALUE_SET_ID=FFV.FLEX_VALUE_SET_ID
                  AND FFV.FLEX_VALUE_ID       =FFVT.FLEX_VALUE_ID
                  AND FFVT.LANGUAGE           ='US'
                  AND FLEX_VALUE_SET_NAME     ='child_Company'
                  And Ffvt.Description        ='child'
                  ); 
              Elsif v_operating_unit='master' THEN
                SELECT paf1.person_id
                INTO l_person_id
                FROM HR_ALL_POSITIONS_F HAPF,
                  PER_JOBS PJB ,
                  PER_ALL_PEOPLE_F PAF1,
                  FND_USER FU ,
                  PER_ALL_ASSIGNMENTS_F PAAF
                WHERE SUBSTR(HAPF.name,INSTR(HAPF.name,'.',1)+1,15)='Account Manager'
                AND PJB.NAME                                       ='Manager'
                AND PAAF.PERSON_ID                                 =PAF1.PERSON_ID
                AND HAPF.JOB_ID                                    = PJB.JOB_ID
                AND PAAF.JOB_ID                                    =PJB.JOB_ID
                AND PAAF.POSITION_ID                               =HAPF.POSITION_ID
                AND (sysdate BETWEEN PAAF.EFFECTIVE_START_DATE AND PAAF.EFFECTIVE_END_DATE)
                AND (sysdate BETWEEN paf1.effective_start_date AND paf1.effective_end_date)
                AND PAAF.JOB_ID            =HAPF.JOB_ID
                AND FU.EMPLOYEE_ID         =PAF1.PERSON_ID
                AND rownum                 =1
                AND SUBSTR(HAPF.name,1,2) IN
                  (SELECT FLEX_VALUE
                  FROM FND_FLEX_VALUE_SETS FFVS,
                    FND_FLEX_VALUES FFV ,
                    FND_FLEX_VALUES_TL FFVT
                  WHERE FFVS.FLEX_VALUE_SET_ID=FFV.FLEX_VALUE_SET_ID
                  AND FFV.FLEX_VALUE_ID       =FFVT.FLEX_VALUE_ID
                  AND FFVT.LANGUAGE           ='US'
                  AND FLEX_VALUE_SET_NAME     ='master_Company'
                  AND FFVT.DESCRIPTION        ='master'
                  );
              ELSE
                l_person_id:=0;
              END IF;
            EXCEPTION
            WHEN OTHERS THEN
              l_person_id :=0;
            END;
            DBMS_OUTPUT.PUT_LINE('person id Value :'||l_person_id);
          ELSE
            l_person_id :=0;
          END IF;
          DBMS_OUTPUT.PUT_LINE('Invoice does not exist l_person_id :'||l_person_id);
          l_return_val := 'person_id:' ||TO_CHAR(l_person_id);
          RETURN (l_return_val);
        EXCEPTION
        WHEN OTHERS THEN
          l_person_id :=0;
          Return (L_Return_Val);
        End XX_Get_Approver;