<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7204324636212178469</id><updated>2012-02-21T07:04:06.783-08:00</updated><title type='text'>How to... in Oracle EBS</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>15</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-1759521479507145009</id><published>2009-10-25T23:11:00.000-07:00</published><updated>2010-11-19T23:20:07.882-08:00</updated><title type='text'>The simplest way of turning SQL queries to Excel reports in Oracle EBS</title><content type='html'>&lt;div style="TEXT-ALIGN: center"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/SufZOKplGOI/AAAAAAAAAI4/lW566nxHBoE/s1600-h/enlarge.jpg"&gt;&lt;/a&gt;&lt;div style="TEXT-ALIGN: center"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/SuVEpuaZjGI/AAAAAAAAAIw/jifB-E0faB4/s1600-h/uncheck.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SuVEDt_s7JI/AAAAAAAAAIo/8vKQHqixuHk/s1600-h/file+types.jpg"&gt;&lt;/a&gt;&lt;/span&gt;&lt;div style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Over the years of working with Oracle EBS I was highly frustrated with its sluggish reporting. Oracle is a great transactional system but it is often underutilized when it comes to aiding decision making. Throughout most of my career if one needed a report, Oracle Report Builder was required. This tool provides good flexibility but is extremely cumbersome to work with, and most of the time needed to write a report is used for servicing the need of the Oracle Report Builder rather than focusing on the data itself. Anybody who encountered the ‘&lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color:black;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;rep-1212 object&lt;/span&gt;&lt;span style="font-size:+0;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;is not fully enclosed by its enclosing object&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;’ error can fully appreciate that. To create a report was always a big project that usually took several days of development and then the output was provided in a text format which was not easy to read or manipulate.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;With XML publisher things become a little easier at least in the way of the output. One could finally create a report that provides a nice graphical format or that opens directly in Excel. Unfortunately the XML still has to be generated by Oracle Reports or some other tool, which usually requires creating and placing the RDF report file on the server,  developing a template in RTF with a special MS add-on, then uploading it trough the front end and associating it with a report. Lots of servicing the needs of development tools and way too complex for me, and very annoying if I don't have the UNIX access. When the sales manager asks me for a report that &lt;/span&gt;&lt;span style="font-size:+0;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;shows sales figures broken down by sales territories and time periods, I need to give him that report in 2 hours rather than tell him that:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;- it is a week long development project&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;-  we can only submit a budget for its approval next week &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;- if it gets approved in the next 2 weeks we can start development and testing&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;- after a month or so he can have his already outdated report and he can ask for a change request to add some additional columns he didn't think about in the first place .... &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family: Arial; "&gt;If you are on a hosted platform it may be significantly more difficult than that.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;How can a company be successful if they can't instantly react to the changing business environment? &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Simply, I needed an easy and quick way to create required reports in Excel, right out of Oracle. There are tools out there that enable that, such as Discoverer or OBIEE, but then they require a few months long development project to put them into place and create underlying data objects, servicing them when they are installed, and most difficult of all – they require user adoption. I have seen companies, where despite of having those tools, users moved away from them towards the solution I describe below because it was so much more convenient. They don’t want to learn another application separate from EBS where they have to to go to each time they want their report. Ideally, it should be just another concurrent request that provides nicely formatted Excel report. And not a CSV file.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;I looked for a tool like that for several years and found none, so decided to create one myself.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;It is called Excel-Out, takes SQL query as an IN parameter to provide a nicely formatted output that opens directly in Excel. Creating a new report is as simple as copying the concurrent request and pasting a new query into it.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Here is a demonstration of my tool hosted on the more4apps web site&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" &gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;a href="http://www.more4apps.com/Demonstrations/Video+Demonstrations/Excel-Out.html"&gt;http://www.more4apps.com/Demonstrations/Video+Demonstrations/Excel-Out.html&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;Click on the below icon when viewing the demo, to go to full screen format. It is much easier to watch it that way.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="COLOR: rgb(0,0,238); webkit-text-decorations-in-effect: underlinefont-family:Georgia, serif;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5397521515826976994" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 329px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SufZOKplGOI/AAAAAAAAAI4/lW566nxHBoE/s400/enlarge.jpg" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;The tool is really only a concurrent request based on a PL/SQL package and you should be able to install it in 5 minutes. The package parses the query and converts it into native Excel format, so all the report outputs open directly in Excel. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;Now, new report development and deployment can take only as much time as it takes to develop the query, and other than having TOAD or other SQL tool, no development environment is required. No user learning curve either.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;To install it you need to run 2 scripts.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;The first one is different depending on whether you are on 11i or R12. It can be found here:&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a href="http://www.more4apps.com/installation-scripts/"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;http://www.more4apps.com/installation-scripts/&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Put all the installation files (all that end with sql, plbs and plbb) into the bin directory of your oracle home and then run the R12_install.sql (or install.sql for the 11i or earlier versions) script from your SQL client. &lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;The second script is not release specific and it can be downloaded here:&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a href="http://www.more4apps.com/downloads?ProdID=5273"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;http://www.more4apps.com/downloads?ProdID=5273&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;To get to the download page you need to register, which is to satisfy my curiosity on who is downloading it. Every time you register I get an e-mail. This is also the only way for me to email you back.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Like with the first installation script, put all the installation files into your bin directory of your Oracle home and run the eo_install.sql&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;This script will install the concurrent request Excel-Out.&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;You can find the concurrent request by going to &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;System Administrator -&gt; Concurrent -&gt; Program -&gt; Define&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="COLOR: rgb(0,0,238); webkit-text-decorations-in-effect: underlinefont-family:Georgia, serif;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5396789107684129922" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 265px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SuU_GZs1vII/AAAAAAAAAII/4iRigjL_IHM/s400/Excel-out.JPG" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="color:#0000ee;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Now you can add it to the System Administrator Reports request group and it is ready to run as a report.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="color:#0000ee;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="color:#0000ee;"&gt;&lt;span class="Apple-style-span" style="COLOR: rgb(0,0,0)"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/SuVAfUqSqLI/AAAAAAAAAIQ/4HhpvKsDVos/s1600-h/Request+group.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5396790635339622578" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 260px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SuVAfUqSqLI/AAAAAAAAAIQ/4HhpvKsDVos/s400/Request+group.jpg" border="0" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;When the report completes click on the Output and it will open directly in Excel&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="COLOR: rgb(0,0,238); webkit-text-decorations-in-effect: underlinefont-family:Georgia, serif;"&gt;&lt;img id="BLOGGER_PHOTO_ID_5396792343640244914" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 228px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SuVCCwk5grI/AAAAAAAAAIY/FIMD0IuyHMo/s400/output.jpg" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Now, depending on your operating system and the version of browser and Excel, the output window may not open at all, due to your security settings.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;To fix this follow the 3 steps below:&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;1. Turn off all the pop-up blockers or hold CTRL key when opening the output to bypass them. If you are not sure on how to do that, check the online  user manual. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;2. Add the application URL to your trusted sites. Check the user manual for details.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;3. Go to My Computer -&gt; Folder options&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="webkit-text-decorations-in-effect: underline"&gt;&lt;img id="BLOGGER_PHOTO_ID_5396793874576374306" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 188px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SuVDb3wg-iI/AAAAAAAAAIg/z_kwc2wA_Dg/s400/folder+options.jpg" border="0" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Go go File Types tab, select file type &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;XLS&lt;/span&gt;&lt;/span&gt; and click on Advanced&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-family:Georgia, serif;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SuVEDt_s7JI/AAAAAAAAAIo/8vKQHqixuHk/s1600-h/file+types.jpg"&gt;&lt;img id="BLOGGER_PHOTO_ID_5396794559150484626" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 352px; CURSOR: pointer; HEIGHT: 400px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SuVEDt_s7JI/AAAAAAAAAIo/8vKQHqixuHk/s400/file+types.jpg" border="0" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Different options are checked there depending on your Excel version. &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="TEXT-ALIGN: left"&gt;&lt;span class="Apple-style-span" style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="COLOR: rgb(0,0,238); webkit-text-decorations-in-effect: underlinefont-family:Georgia, serif;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;img id="BLOGGER_PHOTO_ID_5396795212097490018" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: pointer; HEIGHT: 387px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SuVEpuaZjGI/AAAAAAAAAIw/jifB-E0faB4/s400/uncheck.jpg" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;Uncheck&lt;/span&gt;&lt;/span&gt; all &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;checkboxes&lt;/span&gt;&lt;/span&gt;. This will cause Excel to open in a separate window,rather than embedded in the browser.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;If you are on Excel 2007 you may get an annoying pop-up message that your file format does not match the extension. This message has no significance other than being annoying but if you want to suppress it check &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;metalink&lt;/span&gt;&lt;/span&gt; notes 780817.1 and 759410.1 or the online user manual.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Now your report should be running smoothly. Keep the Excel-Out as your template but copy it and update the query sitting in parameter 991 to get a brand new report. When you copy this report into a new one do not change the application. It needs to stay as Application Object Library, even if you assign this report to request groups in different modules.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Watch the 5 minutes demonstration video or check the screenshots in the user manual on how to create query parameters, especially the section on dates. When creating dates as parameters you need to format them with fnd_date.date_to_cannonical. When you output dates they will work in your default  format, but for user convenience it is better to format them with with to_char(date,'dd-mon-yyyy') or any other format the users are used to. Check out the dates in the seeded Excel-Out report.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;Don't hesitate to ask me a question if you get stuck at any point.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;Most of the issues are due to an invalid query. Check the concurrent request log, it displays your query after all the parameters were substituted for actual values Run it directly from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;SQL&lt;/span&gt;&lt;/span&gt; to see if it works.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;This is a 45 days trial version. After that time it will still work but limit the output to 70 rows.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="font-family:Arial;"&gt;&lt;span class="Apple-style-span" style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-1759521479507145009?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/1759521479507145009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/simplest-way-of-turning-sql-queries-to.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/1759521479507145009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/1759521479507145009'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/simplest-way-of-turning-sql-queries-to.html' title='The simplest way of turning SQL queries to Excel reports in Oracle EBS'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_URNIWGqb_4g/SufZOKplGOI/AAAAAAAAAI4/lW566nxHBoE/s72-c/enlarge.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-3914066335894148921</id><published>2009-10-25T00:01:00.000-07:00</published><updated>2009-11-27T12:57:06.048-08:00</updated><title type='text'>Create and SFTP files with a concurrent request</title><content type='html'>The standard FTP package include the EBS installation allows you to send files to remote servers. FTP is not a secure protocol and it is increasingly replaced with SFTP. There is no handy out-of-the-box package to handle SFTP from PL/SQL.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I have created one that creates a file based on a query passed as an IN parameter, and then SFTPs it to a remote server. The file created form the query contains both the column headers and rows, delimited by a separator selected as a parameter of the concurrent request. Since the query, separator, and destination directory are variables, this can be used as an universal package for interfacing via SFTP.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This works if you are authenticated by an authentication key for your server and user so you son't have to log to the remote server using username and password. &lt;/div&gt;&lt;div&gt;Here is an example on the authentication key setup:&lt;/div&gt;&lt;div&gt;&lt;a href="http://myracle.wordpress.com/2009/06/01/automating-sftp-between-two-servers/"&gt;http://myracle.wordpress.com/2009/06/01/automating-sftp-between-two-servers/&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Make sure that the authentication key includes all the UNIX users that you use on both the test and prod servers.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Before you go into the below code there some things you need to check:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt; this solution will work on database 10.2.0.4 or higher. It will not work on DB 9. You may be able to make it work on lower versions of 10G, but that will require heavy DB patching. The most common issue in lower 10G versions is the UNIX job getting hanged.&lt;/li&gt;&lt;li&gt;you must grant CREATE JOB and CREATE EXTERNAL JOB to the APPS user. I have seen the grant properly executed and the job would work fine for SYS user but still hang up on APPS user. The only fix it to upgrade to latest 10.2.0.4 with all proper patches.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;Here is the code, optimized to have it run as a PL/SQL concurrent request from Oracle EBS.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;procedure  SFTP_FILE( &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      ERRBUF OUT VARCHAR2, &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      RETCODE OUT NUMBER,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      p_separator in varchar2 ,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      p_dir       in varchar2 ,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      p_desdir    in varchar2,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      p_filename  in varchar2,  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      p_query     in varchar2,                                    ,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      parameter1  in varchar2 default null,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      parameter2  in varchar2 default null,&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      parameter3  in varchar2 default null&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                      )&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                                       &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;is&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_output        utl_file.file_type;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_theCursor     integer default dbms_sql.open_cursor;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_desc_tab   dbms_sql.desc_tab;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_columnValue   varchar2(2000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_status        integer;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_colCnt        number default 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_separator     varchar2(10) default '';&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_cnt           number default 0;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_query         varchar2(2000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_program       varchar2(50);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_descTbl       dbms_sql.desc_tab;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_database      varchar2(20);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_conn          UTL_TCP.connection;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_filename      varchar2(200);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    v_to_file      varchar2(2000);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    status         number;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;begin&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;select name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;into  l_database&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;from v$database;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this part is to prevent accidental execution of the flie upload from a test server&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;if l_database='PROD' then&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- the file can be comma, pipe or any other speparator delimited. This depends on the delimiter user selects&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- in the concurrent request parameter when submitting the job&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;l_separator :=p_separator;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this is the file name, it is taken from the IN parameters. Its first 9 characters are always replaced with &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- current date so the concurrent request can be scheduled to run daily&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;l_filename:=to_char(sysdate,'yyyymmdd')||substr(p_filename,9,length(p_filename));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this is the actual query that will be used to build the file that needs to be SFTP-ed&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- you could just write it here but I pass it as a parameter, and have a custom from where &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- i can adjust it in the application front end&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;l_query:=p_query; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- if you want to manipulate the query for each run and add addtional AND conditions&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- there can be passed for the concurrent request parameters 1-3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- those parameters can have default values&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this is more convenient than changing the source query each tim&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;e.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    l_query:=l_query||' '||parameter1||' '||parameter2||' '||parameter3;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- write to the concurrent request log to see the parameters and the passed query&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    Fnd_File.Put_Line(Fnd_File.LOG,'l_query = '||l_query);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    Fnd_File.Put_Line(Fnd_File.LOG,'p_separator = '||p_separator);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    Fnd_File.Put_Line(Fnd_File.LOG,'p_dir = '||p_dir);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    Fnd_File.Put_Line(Fnd_File.LOG,'l_filename = '||l_filename);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- I have taken core of this part for asktom.oracle com&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- it writes the headers and lines of the query into a delimited file&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- p_dir is directory where the file will be written &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- the directory is passed as the request parameter&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- make sure the request has the write privilege to that directory&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- if you do not have any specific directory in mind you can use one of the directories returned by&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;--select value from v$parameter where name='utl_file_dir'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  l_output := utl_file.fopen( p_dir, l_filename, 'w' );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;      dbms_sql.parse(  l_theCursor,  l_query, dbms_sql.native );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  -- the separator is passed as variable  l_separator variable to ensure flexibility of the solution&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       for i in 1 .. l_colCnt loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;           utl_file.put( l_output,   l_descTbl(i).col_name||l_separator );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;          dbms_sql.define_column( l_theCursor, i, l_columnValue, 4000 );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       end loop;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       utl_file.new_line( l_output );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       l_status := dbms_sql.execute(l_theCursor);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;      while ( dbms_sql.fetch_rows(l_theCursor) &gt; 0 ) loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;          for i in 1 .. l_colCnt loop&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;               dbms_sql.column_value( l_theCursor, i, l_columnValue );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;               utl_file.put( l_output,  l_columnValue||l_separator );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;           end loop;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;           utl_file.new_line( l_output );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       end loop;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       dbms_sql.close_cursor(l_theCursor);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       utl_file.fclose( l_output );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;   -- write to the concurrent request output&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   fnd_file.put_line( FND_FILE.OUTPUT,'Your file '||l_filename ||' has been successfully created in staging directory at '||p_dir);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  -- most likely this part will work only if you have database 10.2.0.4 or higher&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  -- it will not work on 9 on any database lower than 10G&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; --dbms_scheduler will start an OS (UNIX) job directly from the PL/SQL session&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- depending on yout database configuration the session can use different names to log in into UNIX&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- most likely it will be a user called oracle&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; --if the database has out-of-the-box configuration the user used to log in to UNIX is called 'nobody'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- the nobody user does not have sufficient permissions to execute shell scripts&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- each instance (TEST, DEV, PROD, is most likely to be set up with a different UNIX user)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- take that into consideration when testing&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- create sftp.sh file with the following syntax &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;--#!/bin/bash&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;--scp $1 $2 &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- $1 and $2 are parameters that will be passed by DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; dbms_scheduler.create_job(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    job_name=&gt;'SFTP_UPLOAD',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    job_type=&gt;'executable',&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    number_of_arguments =&gt; 2, &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    job_action=&gt;'/u01/oracle/PROD/xx/sftp.sh',--this is a sample directory where the sftp shell script resides&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    enabled=&gt;FALSE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- make sure that  the file sftp.sh has proper permissions so &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- the oracle (or any other user that the database uses to log in into UNIX)  can execute it&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; -- test it by opening an UNIX session and executing the file from the command prompt&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;job_name =&gt; 'SFTP_UPLOAD'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;,argument_position =&gt; 1&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;,argument_value =&gt; p_dir||'/'||l_filename&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE(&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;job_name =&gt; 'SFTP_UPLOAD'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;,argument_position =&gt; 2&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;,argument_value =&gt; p_desdir&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;dbms_scheduler.enable('SFTP_UPLOAD'); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- write to the output of the concurrent request  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;fnd_file.put_line( FND_FILE.OUTPUT,'scp '|| p_dir||'/'||l_filename ||' '||p_desdir);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;fnd_file.put_line( FND_FILE.OUTPUT,'Connection to remote server has been successfully established');&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- check if the job has successfuly completed&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;select status ,nvl(substr(additional_info,1,32000), 'SUCCESS')&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;into r_status, r_additional_info&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;from  USER_SCHEDULER_JOB_RUN_DETAILS where job_name='SFTP_UPLOAD'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;and  log_date = (select max(log_date) from USER_SCHEDULER_JOB_RUN_DETAILS where job_name='SFTP_UPLOAD');&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;if r_status &lt;&gt; 'SUCCEEDED' then &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- complete the concurrent request with warning if the job did not complete with success&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;l_completion:=fnd_concurrent.set_completion_status('WARNING','The SFTP process may have failed. Check the destination server to see if the file has been uploaded. '||r_additional_info);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;else &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   fnd_file.put_line( FND_FILE.OUTPUT,'File upload success' );&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   End if;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this is the end of the IF from the beginning of the package. It checks for the test database&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  else&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;Fnd_File.Put_Line(Fnd_File.OUTPUT,'This is a test database, no action was taken'); &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;end if;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   EXCEPTION&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;when others then&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; Fnd_File.Put_Line(Fnd_File.OUTPUT,SQLERRM);  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;end ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;END;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-3914066335894148921?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/3914066335894148921/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/create-and-sftp-files-with-concurrent.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/3914066335894148921'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/3914066335894148921'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/create-and-sftp-files-with-concurrent.html' title='Create and SFTP files with a concurrent request'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-8573913097542761215</id><published>2009-10-24T00:01:00.000-07:00</published><updated>2010-04-08T12:58:10.404-07:00</updated><title type='text'>How to automatically send an EBS XML Publisher document by email</title><content type='html'>&lt;div style="text-align: left;"&gt;One of my clients was preparing quotes in EBS. The quote resulted in a PDF document prepared by an XML publisher based concurrent request. They were printing the quote and faxing it to the customer. It was pretty cumbersome process because they had to print it, then pick it up from the printer and only then fax it. When the fax was presented to the decision making executive it did not have the professional appeal of the nicely prepared colorful quote. But after all Oracle EBS is one of the leading enterprise systems so it should offer a way of emailing the documents automatically to the clients, shouldn’t it?&lt;/div&gt;  &lt;p class="MsoNormal"&gt;Well, not really…&lt;/p&gt;  &lt;p class="MsoNormal"&gt;I started browsing trough metalink and user forums on how to have an output of a concurrent request emailed from either a workflow or a nice button right on the quote and I found nothing. It seems like there were no good ways to do that so I had to build myself one.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Here is what needed to be done:&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="1" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l1 level1 lfo1;tab-stops:list .5in"&gt;&lt;b&gt;Modify      the quote workflow and to add the 'concurrent request execution' &lt;/b&gt; and 'wait for the request completion' into the flow. This is added after a special event such      as the quote approval.&lt;/li&gt;  &lt;li class="MsoNormal" style="mso-list:l1 level1 lfo1;tab-stops:list .5in"&gt;&lt;b&gt;Identify      the directory &lt;/b&gt;where the concurrent request file, usually with the PDF or Excel output, is dumped and the name of      the specific file itself&lt;/li&gt;  &lt;li class="MsoNormal" style="mso-list:l1 level1 lfo1;tab-stops:list .5in"&gt;&lt;b&gt;Write      a PL/SQL package that puts the file into a BLOB&lt;/b&gt; and attach that package to      a workflow attribute of a document type. &lt;/li&gt;  &lt;li class="MsoNormal" style="mso-list:l1 level1 lfo1;tab-stops:list .5in"&gt;&lt;b&gt;Use API from &lt;/b&gt;&lt;st1:place&gt;&lt;b&gt;PO&lt;/b&gt;&lt;/st1:place&gt;&lt;b&gt; emailing to create ad hoc role&lt;/b&gt;. Workflow      will not mail anything just to an e-mail address, it has to be mailed to a      performer. &lt;/li&gt;  &lt;li class="MsoNormal" style="mso-list:l1 level1 lfo1;tab-stops:list .5in"&gt;&lt;b&gt;Create      a notification and a message&lt;/b&gt;. Create a message attribute and point it to      the global attribute with the PL/SQL BLOB containing the PDF file into the      body of the message. This will create an attachment to your e-mail      containing the PDF file. Assign the notification to a performer role      created in the previous step.&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;This gets a bit more complex when your application and database run on 2 different servers. Your PL/SQL logic will not be able to get a file that resides on a different server. You can resolve it either by creating a link on the DB server  to point to a directory on the application server, or FTP the file from the application server using the standard FTP package. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="1" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo2;tab-stops:list .5in"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Modify the quote workflow and to add the concurrent request execution. &lt;span class="Apple-style-span" style="font-weight: normal; "&gt;Add      the ‘Execute Concurrent Program’ (EXECUTECONCPROG) function to your      workflow. This function can be found under the seeded ‘Concurrent Manager      Functions’ (FNDCMSTD) item type. Go to the Node Attributes and&lt;span style="mso-spacerun:yes"&gt;  &lt;/span&gt;specify:&lt;/span&gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left:117.0pt;text-indent:-117.0pt;mso-text-indent-alt: -.25in;mso-list:l0 level3 lfo2;tab-stops:list 117.0pt"&gt;&lt;span style="mso-list:Ignore"&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;                                                               &lt;/span&gt;i.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;            &lt;/span&gt;&lt;/span&gt;Application Short Name -Short name of the application to which the concurrent program is registered.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:117.0pt;text-indent:-117.0pt;mso-text-indent-alt: -.25in;mso-list:l0 level3 lfo2;tab-stops:list 117.0pt"&gt;&lt;span style="mso-list:Ignore"&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;                                                             &lt;/span&gt;ii.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;            &lt;/span&gt;&lt;/span&gt;Program Short Name -Short name of the concurrent program to run. You will find this in the program definition screen.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:117.0pt;text-indent:-117.0pt;mso-text-indent-alt: -.25in;mso-list:l0 level3 lfo2;tab-stops:list 117.0pt"&gt;&lt;span style="mso-list:Ignore"&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;                                                            &lt;/span&gt;iii.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;            &lt;/span&gt;&lt;/span&gt;Number of Arguments -Number of arguments required for the concurrent program.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:117.0pt;text-indent:-117.0pt;mso-text-indent-alt: -.25in;mso-list:l0 level3 lfo2;tab-stops:list 117.0pt"&gt;&lt;span style="mso-list:Ignore"&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;                                                           &lt;/span&gt;iv.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;            &lt;/span&gt;&lt;/span&gt;Item Attribute Name- Name of the item attribute to store the concurrent program request ID. This is very important as it will be used to determine the name and location of the output file. In this example I use the REQUEST_ID as the attribute name.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:117.0pt;text-indent:-117.0pt;mso-text-indent-alt: -.25in;mso-list:l0 level3 lfo2;tab-stops:list 117.0pt"&gt;&lt;span style="mso-list:Ignore"&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;                                                             &lt;/span&gt;v.&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;            &lt;/span&gt;&lt;/span&gt;Argument1, Argument2,...Argument100--Value of each concurrent program argument, ordered to match the correct syntax of the concurrent program. Up to 100 arguments are allowed, but you should only specify as many argument values as you define in the Number of Arguments activity attribute.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="2" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo2;tab-stops:list .5in"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Identify the directory. &lt;/span&gt;The      directory where the output is located and the file name can be queried      from FND_CONC_REQ_OUTPUTS table, using the concurrent request id&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="3" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo2;tab-stops:list .5in"&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;Write a PL/SQL package that puts the file into a BLOB. &lt;/span&gt;This      is where the hard part starts. First we need to create a workflow      attribute of a document type:&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;In theory we can create an attribute of a ‘Document’ type and populate it by a PL/SQL code referenced in the Value field of the attribute definition&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://1.bp.blogspot.com/_URNIWGqb_4g/SuKrKD-4knI/AAAAAAAAAIA/rq6DD81Bb7s/s400/Attribute.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396063492899377778" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 268px; " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;The syntax would include the itemtype and itemkey as variables&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;PLSQLBLOB:XX_ATTACHMENT.GET_DOCUMENT/'||itemtype||'|'||itemkey&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;It worked for me only if I passed the itemkey and itemtype as static values but never as variables. To work around that I left the value blank and populated it with a workflow function executed just after the concurrent request output. Here is the sample code:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;PROCEDURE SET_ATTACHMENT_ID&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;IS&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;BEGIN&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;(itemtype&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;actid&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;in number,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;funcmode&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;resultout in out nocopy varchar2)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;wf_engine.setitemattrdocument&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;(itemtype=&gt;itemtype&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;, itemkey=&gt;itemkey&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;, aname=&gt;'ATTACHMENT'&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;, documentid =&gt; 'PLSQLBLOB:XX_ATTACHMENT.GET_DOCUMENT/'||itemtype||'|'||itemkey);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;END;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;Now that we instructed workflow to populate the document attribute with the PL/SQL document it is time to define the execution of the document itself. Before I go to the execution package&lt;span style="mso-spacerun:yes"&gt;  &lt;/span&gt;XX_ATTACHMENT.GET_DOCUMENT there is one pre-requisite step:&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;The directory where the output files are stored needs to be created in the database as the directory variable recognizable by PL/SQL. This is achieved with the following command &lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.5in"&gt;CREATE OR REPLACE DIRECTORY ‘CONC_OUTPUT’ AS ‘operating system path here’. You can find the path in the FND_CONC_REQ_OUTPUTS table.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.5in"&gt;Make sure the directory you are creating has all the proper permissions so the file can be accessed&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;Now we can go to the body that will get the concurrent request file put it into BLOB and associate with the workflow attribute&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;PROCEDURE &lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;GET_DOCUMENT&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;( &lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;document_id in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;display_type in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;document in out NOCOPY BLOB,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;document_type in out NOCOPY varchar2) &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;IS&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_itemtype&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;varchar2(200);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;varchar2(200);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_request_id&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;fnd_conc_req_outputs.concurrent_request_id%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;src_lob&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;BFILE;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;dest_lob BLOB;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_lob_len INTEGER;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_offset NUMBER := 1; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_buffer&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;       &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;RAW(20);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_buffer_size&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;BINARY_INTEGER := 20;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_FILEISOPEN INTEGER;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_FILEEXISTS INTEGER;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;get_file_name fnd_conc_req_outputs.file_name%TYPE;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;BEGIN&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- since I put the itemtype/itemkey as the document ID this will get the item type out of it &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_itemtype := substr(document_id,1,instr(document_id,'|')-1);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- this part will get the itemkey&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_itemkey := substr(document_id,instr(document_id,'|')+1,length(document_id)-2);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- itemkey and itemtype are needed to get the value of the concurrent request id&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_request_id:=&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;Wf_Engine.GetItemAttrText( itemtype =&gt; v_itemtype,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                                      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; v_itemkey,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                                   &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;aname&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; 'REQUEST_ID',&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                               &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;ignore_notfound =&gt; FALSE); &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;--which is needed to get the file name &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;SELECT substr(file_name,instr(file_name,'/',-1,1)+1,length(file_name))&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;INTO get_file_name&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;FROM fnd_conc_req_outputs &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WHERE concurrent_request_id = v_request_id;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;src_lob&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;:= BFILENAME('CONC_OUTPUT', get_file_name);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;   &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- now that we know the file name and location we can load it to BLOB&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span class="apple-converted-space"&gt;&lt;span style="border:none windowtext 1.0pt; mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;DBMS_LOB.CREATETEMPORARY(dest_lob, TRUE, DBMS_LOB.SESSION);&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;DBMS_LOB.OPEN(src_lob, DBMS_LOB.LOB_READONLY);&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;DBMS_LOB.LoadFromFile( DEST_LOB =&gt; dest_lob,&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                     SRC_LOB &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; src_lob,&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                         &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;AMOUNT  &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; DBMS_LOB.GETLENGTH(src_lob) );&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="line-height:13.5pt"&gt;&lt;span style=" border:none windowtext 1.0pt;mso-border-alt:none windowtext 0in;padding:0in"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;span class="apple-converted-space"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;DBMS_LOB.CLOSE(src_lob);&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;pre&gt;&lt;tt&gt;&lt;span style="font-family:Arial;"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- Set the MIME type as a part of the document_type in the workflow attribute&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family:Arial;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/pre&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;document_type := 'application/pdf' || ';name=' || get_file_name;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- write the BLOB to the workflow attribute&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;dbms_lob.copy(document, dest_lob, dbms_lob.getlength(dest_lob));&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;END;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;The PDF output file has been located and added as a workflow attribute in the form of BLOB.&lt;/p&gt;  &lt;p class="MsoNormal" style="margin-left:.25in"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="4" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo2;tab-stops:list .5in"&gt;&lt;b&gt;Use API from &lt;/b&gt;&lt;st1:place&gt;&lt;b&gt;PO&lt;/b&gt;&lt;/st1:place&gt;&lt;b&gt; emailing to create ad hoc role&lt;/b&gt;. Now we      have the file but still don’t have the role where we can email it. Here is      a package that uses the standard API to add the ad hoc role based on the      email address:&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;PROCEDURE SET_PERFORMER_ROLE&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;(itemtype&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;actid&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;in number,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;funcmode&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;in varchar2,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;resultout in out nocopy varchar2)&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;IS&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_to_email varchar2(300);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_header_id number;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_adhocuser_lang WF_LANGUAGES.NLS_LANGUAGE%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_adhocuser_territory WF_LANGUAGES.NLS_TERRITORY%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_performer&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_USERS.NAME%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_add&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_USERS.EMAIL_ADDRESS%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_display_name&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_USERS.DISPLAY_NAME%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_performer_prof WF_USERS.NAME%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_add_prof&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_USERS.EMAIL_ADDRESS%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_display_name_prof&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_USERS.DISPLAY_NAME%TYPE;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_performer_exists number;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_notification_preference varchar2(20) := 'MAILHTM2'; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_when_to_archive varchar2(80);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_archive_result varchar2(2);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;BEGIN&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- Here I am getting the email address from a workflow attribute where I put it in one of my prior steps.&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;Depending on your flow you can use a query here to get it&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_to_email:= WF_ENGINE.GETITEMATTRTEXT( itemtype =&gt; itemtype,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; itemkey,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;aname&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; 'EMAIL_TO'),&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;ignore_notfound =&gt; FALSE);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- I took a shortcut here and fixed the language to US to simplify my code&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;SELECT wfl.nls_language, wfl.nls_territory INTO l_adhocuser_lang, l_adhocuser_territory&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;FROM wf_languages wfl -- fnd_languages_vl flv&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WHERE wfl.code ='US'; --flv.language_code AND flv.nls_language = L_contact language;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;            &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;     &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;--* Bug 2989951. AdHocUser Name should be concatenation of the E-mail Address and the language */&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_performer := v_to_email||'.'||l_adhocuser_lang;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_performer := upper(l_quote_email_performer);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_display_name := l_quote_email_performer;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;select count(*) into l_performer_exists&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;from wf_users where name = l_quote_email_performer;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;/* Bug 2864242 The wf_local_users table is obsolete after the patch 2350501. So used the&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;wf_users view instead of wf_local_users table */&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;         &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;if (l_performer_exists = 0) then&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- This is the actual API call to add the ad hoc user&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;to WF_ROLES&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- Pass in the correct adhocuser language and territory for CreateAdHocUser and SetAdhocUserAttr instead of null&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- if&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;a doesn’t &lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;exists it will create it&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_DIRECTORY.CreateAdHocUser(l_quote_email_performer, l_display_name, l_adhocuser_lang, l_adhocuser_territory, null, l_notification_preference, v_to_email, null, 'ACTIVE', null);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;else&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;  &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- If a role with this email address already exists then find it &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;WF_DIRECTORY.SETADHOCUSERATTR(l_quote_email_performer, l_display_name, l_notification_preference, l_adhocuser_lang, l_adhocuser_territory,&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;           &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;v_to_email, null);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;end if;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;wf_engine.SetItemAttrText ( itemtype&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; itemtype,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;itemkey&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; itemkey,&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;aname&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;     &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt; 'EMAIL_RECIPIENT_ROLE'),&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;avalue&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;=&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;l_quote_email_performer);&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                          &lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;          &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;        &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;resultout:='COMPLETE:SUCCESS';&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                             &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;                                    &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#3366FF;"&gt;END;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;In the above package I picked the email from&lt;span style="mso-spacerun:yes"&gt;  &lt;/span&gt;'EMAIL_TO' attribute and created a role from it which I assigned to the 'EMAIL_RECEIPIENT_ROLE' attribute. &lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;ol style="margin-top:0in" start="5" type="1"&gt;  &lt;li class="MsoNormal" style="mso-list:l0 level1 lfo2;tab-stops:list .5in"&gt;&lt;b&gt;Create a notification and a message&lt;/b&gt;.&lt;/li&gt; &lt;/ol&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Create Notification. In the Node tab select the performer from the item attribute from the previous step&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SuKqL5-CtzI/AAAAAAAAAH4/taeLxNepQGI/s1600-h/Notification+recipient.JPG"&gt;&lt;img src="http://2.bp.blogspot.com/_URNIWGqb_4g/SuKqL5-CtzI/AAAAAAAAAH4/taeLxNepQGI/s400/Notification+recipient.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396062425059604274" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 268px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Create a message&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://3.bp.blogspot.com/_URNIWGqb_4g/SuKpqymzNMI/AAAAAAAAAHw/qbDLTu8DIEE/s400/Message+body.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396061856147387586" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 267px; " /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;The &amp;amp;MESSAGE_ATTACHMENT attribute is included in the message body and needs to be defined and a message attribute sourced from the global attribute that contains our BLOB with the PDF quote&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SuKpTpbNdSI/AAAAAAAAAHo/ncR8IcixU9U/s1600-h/Message+attribute+def.JPG"&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SuKpTpbNdSI/AAAAAAAAAHo/ncR8IcixU9U/s400/Message+attribute+def.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396061458545866018" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 219px; height: 41px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/_URNIWGqb_4g/SuKo0a5MiNI/AAAAAAAAAHg/0xX9nZFN7_U/s400/Message+attribute.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396060922069158098" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 264px; " /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;When creating attribute select its type as ‘Document’ and mark the ‘Attach Content’ checkbox. Point the value of the attribute to the global attribute containing the BLOB. This will create attachment to the email with the PDF or Excel document, depending on what your XML Publisher request generated.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Now attach your message to the notification that already has the performer created from the email address.&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;Here is how the addition to your workflow would look like&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/_URNIWGqb_4g/SuKoZXr0fvI/AAAAAAAAAHY/gPRtuHDbj_w/s400/workflow.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5396060457351282418" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 70px; " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="mso-spacerun:yes"&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-8573913097542761215?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/8573913097542761215/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/how-to-send-ebs-document-by-email.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/8573913097542761215'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/8573913097542761215'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/10/how-to-send-ebs-document-by-email.html' title='How to automatically send an EBS XML Publisher document by email'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_URNIWGqb_4g/SuKrKD-4knI/AAAAAAAAAIA/rq6DD81Bb7s/s72-c/Attribute.JPG' height='72' width='72'/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-5770616144543449113</id><published>2009-07-10T06:00:00.000-07:00</published><updated>2009-07-10T06:00:08.357-07:00</updated><title type='text'>Find query behind the Form or OA Framework page</title><content type='html'>&lt;div&gt;&lt;span class="Apple-style-span"   style="  font-weight: bold; font-family:arial;font-size:24px;"&gt;FORMS&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The simplest way to find a query in a form is to go to&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Help -&gt; Diagnostics -&gt; Examine  from the navigation toolbar&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;select SYSTEM block&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and LAST_QUERY field&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbiOZVMMuI/AAAAAAAAAHI/ERBBvD_F90I/s1600-h/1.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 266px;" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbiOZVMMuI/AAAAAAAAAHI/ERBBvD_F90I/s400/1.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717543749595874" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This approach has the disadvantage that it only shows the last query run by the form while there can be multiple queries run in different blocks.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;To see a query in a block, first check the name of the block. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbiLzXyA_I/AAAAAAAAAHA/KLI2sBwdx5w/s1600-h/2.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 238px;" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbiLzXyA_I/AAAAAAAAAHA/KLI2sBwdx5w/s400/2.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717499200177138" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now go to Help -&gt; Diagnostics -&gt; Item&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SlbiAmTBEjI/AAAAAAAAAGw/WsjzZz_Rfs8/s1600-h/3.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 237px;" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlbiAmTBEjI/AAAAAAAAAGw/WsjzZz_Rfs8/s400/3.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717306711970354" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Change the Object to 'Block'&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and in 'Object1' select the name of the block.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The 'Value' field will automatically display the query that was run to retrieve the data in the block.  &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/Slbh69SyxMI/AAAAAAAAAGo/t22FuG4pVoE/s1600-h/4.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 277px;" src="http://2.bp.blogspot.com/_URNIWGqb_4g/Slbh69SyxMI/AAAAAAAAAGo/t22FuG4pVoE/s400/4.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717209805833410" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  font-weight: bold; font-family:arial;font-size:24px;"&gt;OA FRAMEWORK&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:6;"&gt;&lt;span class="Apple-style-span"  style="font-size:24px;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The OA framework is not as flexible as Forms, but there is still a way to see the queries run by OA framework pages.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Forst set the prodile FND: Diagnostics to Yes for  your user.&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="font-family:arial;font-size:6;"&gt;&lt;span class="Apple-style-span"  style="font-size:24px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now, when you log to any JSP page you will see 'About Page' in the bottom left corner.&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" font-weight: normal;font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/Slbh4f1VxrI/AAAAAAAAAGg/hy2I_LET008/s1600-h/5.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 214px; height: 143px;" src="http://3.bp.blogspot.com/_URNIWGqb_4g/Slbh4f1VxrI/AAAAAAAAAGg/hy2I_LET008/s400/5.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717167537931954" /&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Click on it and then click on 'Expand all' as on the picture below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/Slbh1vpRvnI/AAAAAAAAAGY/7iqhF4_lAQM/s1600-h/6.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 299px; height: 279px;" src="http://4.bp.blogspot.com/_URNIWGqb_4g/Slbh1vpRvnI/AAAAAAAAAGY/7iqhF4_lAQM/s400/6.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717120242695794" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;When you scroll down you will see the views on which the records are based&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbhyPtF8SI/AAAAAAAAAGQ/uTaGA5p1Yfg/s1600-h/7.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 275px; height: 141px;" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlbhyPtF8SI/AAAAAAAAAGQ/uTaGA5p1Yfg/s400/7.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717060129157410" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Click on the view name to see the query.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlbhvFN6MVI/AAAAAAAAAGI/kYFoe_aFWMY/s1600-h/8.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 303px;" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlbhvFN6MVI/AAAAAAAAAGI/kYFoe_aFWMY/s400/8.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5356717005774401874" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-5770616144543449113?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/5770616144543449113/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/find-query-behind-form-or-oa-framework.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5770616144543449113'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5770616144543449113'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/find-query-behind-form-or-oa-framework.html' title='Find query behind the Form or OA Framework page'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_URNIWGqb_4g/SlbiOZVMMuI/AAAAAAAAAHI/ERBBvD_F90I/s72-c/1.JPG' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-377930318179233869</id><published>2009-07-09T10:37:00.000-07:00</published><updated>2009-07-09T10:37:01.109-07:00</updated><title type='text'>Switch a single segment in before insert trigger for an account combination</title><content type='html'>&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Some time ago I had an interesting problem in AP. The withholding tax distribution in AP was automatically created based on the tax rules, but the tax distribution was sourced from the tax setups and was inflexible. We wanted to have the last segment (intercompany) of the tax distribution equal to the last segment of the AP line distribution, so we could split the taxes between the companies, the same way that we were splitting expenses.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;To resolve the problem I have created a BEFORE INSERT trigger on the AP_DISTRIBUTIONS_ALL table which called a custom function that:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;1.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Translated the expense line CCID into the segment combination&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;2.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Translated the tax CCID to the segment combination&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;3.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Determined the last segment in the line combination &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;4.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Replaced the last segment  of the tax combination with the last segment of the expense line combination. &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;5.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Translate the new segment combination into a CCID. &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The last part proved to be tricky because the CCID for the new combination may or may not exist and I didn’t want to get into building a logic that would check it. In addition to that there was always risk that an invalid combination can be created, so it had to be validated against GL cross validation rules. Under other circumstances I might have used account generator workflow but I wanted to keep it as simple as possible since it was done in a database trigger and too much code could affect the performance.  This was resolved with a call to &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND_FLEX_EXT.get_ccid('SQLGL','GL#', v_coa_id,fnd_date.date_to_canonical(sysdate),v_tax_combination);&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;which &lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;retrieved the combination if it existed&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;created it if it didn’t&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;validated it against GL cross validation rules&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Lets translate the above points into APIs used:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;1.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND_FLEX_EXT.get_segs('SQLGL', 'GL#',v_coa_id,p_CCID)  -- concatenated tax account&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;2.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND_FLEX_EXT.get_segs('SQLGL', 'GL#',v_coa_id, il.DIST_CODE_COMBINATION_ID) – concatenated expense account&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;3.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND_FLEX_EXT.breakup_segments(concatenated_segs =&gt; v_tax_combination&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                      &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; ,delimiter =&gt; '.'&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                           &lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;,segments =&gt; v_tax_array); -- number of segments&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;4.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_array(last_segment):=v_line_array(last_segment); -- switch last segment of the tax segments array to last segment of the expense array&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;5.&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND_FLEX_EXT.get_ccid('SQLGL','GL#', v_coa_id, fnd_date.date_to_canonical(sysdate), v_tax_combination); --recreate the new array as CCID. This is returned to the before insert trigger and entered into the table.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For reference here is the actual package body that I used:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CREATE OR REPLACE package body APPS.XX_TAX AS&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Function MATCH_INTERCO_SEGMENT&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(p_CCID IN NUMBER,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;p_invoice_id IN NUMBER,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;p_line_type in Varchar2,&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;p_tax_name varchar2&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;) return number&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;IS&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_new_account number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_coa_id number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_combination varchar2(100);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_line_combination varchar2(100);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_array FND_FLEX_EXT.SegmentArray;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_line_array FND_FLEX_EXT.SegmentArray;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;o_number_of_segments number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;V_ERROR VARCHAR2(2000);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Begin &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- get the chart of accounts&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;select gls.chart_of_accounts_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;into v_coa_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;from financials_system_parameters fsp, gl_sets_of_books gls &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;where fsp.set_of_books_id = gls.set_of_books_id;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- get the combination from the ccid&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_combination := fnd_flex_ext.get_segs('SQLGL', 'GL#',v_coa_id,p_CCID) ;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;commit;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- this returns the number of segments but also feeds the segments to the v_tax_array&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;o_number_of_segments:=FND_FLEX_EXT.breakup_segments(concatenated_segs =&gt; v_tax_combination&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                               ,delimiter =&gt; '.'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                               ,segments =&gt; v_tax_array);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- get the account combination for the invoice expense line that has the tax group with the tax for our tax line&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- this logic is specific to the withholding tax and establishes link between the tax and the expe&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;nse line&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;select fnd_flex_ext.get_segs('SQLGL', 'GL#',v_coa_id,il.DIST_CODE_COMBINATION_ID)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;into v_line_combination&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;from ap_invoice_distributions_all il, AP_AWT_GROUPS ag, AP_AWT_GROUP_TAXES at,  AP_TAX_CODES tc&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;where 1=1&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and il.AWT_GROUP_ID=ag.group_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and ag.group_id=AT.GROUP_ID&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and tc.name=at.tax_name&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and at.org_id=fnd_profile.value('ORG_ID')&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and at.org_id=tc.org_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;--and tc.tax_id=p_tax_code_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and tc.name=p_tax_name &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and il.invoice_id=p_invoice_id&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and rownum=1; -- this is in case if they are more than one line with the same tax group. The first line is sufficient.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- this returns the number of segments but also feeds the segments to the v_line_array&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;o_number_of_segments:=FND_FLEX_EXT.breakup_segments(concatenated_segs=&gt;v_line_combination&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                               ,delimiter=&gt;'.'&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;                               ,segments =&gt; v_line_array);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_array(o_number_of_segments):=v_line_array(o_number_of_segments); &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- last segment of the tax combination is switched to the last segment of the line combination&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_tax_combination:=FND_FLEX_EXT.concatenate_segments(o_number_of_segments,v_tax_array,'.'); &lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;concatenate the new combination into string&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_new_account:=FND_FLEX_EXT.get_ccid('SQLGL','GL#', v_coa_id,fnd_date.date_to_canonical(sysdate),v_tax_combination);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;return v_new_account;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;EXCEPTION&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;When others then &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;-- in case of failure return the original account&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;v_new_account:=p_CCID;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;return v_new_account;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;END XX_TAX;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/span&gt;&lt;p&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-377930318179233869?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/377930318179233869/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/switch-single-segment-in-before-insert.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/377930318179233869'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/377930318179233869'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/switch-single-segment-in-before-insert.html' title='Switch a single segment in before insert trigger for an account combination'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-3826040206426010470</id><published>2009-07-08T19:52:00.000-07:00</published><updated>2009-07-08T19:58:53.736-07:00</updated><title type='text'>How to find a report</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;Quite often business users ask me on how to get some specific data from Oracle. Before I start sketching any functional design for a new report, I check the list of all concurrent requests in Oracle to see if there isn't already one available. When I do find it, it is difficult to determine the &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_0"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;responsibility&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; where it is &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;assigned&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; to. To work around this &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;inconvenience&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; I prepare the below query that lists all the reports containing a specific string in the name, &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_3"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;their&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_4"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;responsibilities&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; and application. Quite often this makes &lt;/span&gt;&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_5"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;life&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; a bit easier.&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;select resp.responsibility_name,&lt;/div&gt;&lt;div&gt;pr.user_concurrent_program_name,&lt;/div&gt;&lt;div&gt;ex.executable_name,&lt;/div&gt;&lt;div&gt;ex.application_name&lt;/div&gt;&lt;div&gt;from FND_EXECUTABLES_FORM_V ex,&lt;/div&gt;&lt;div&gt;FND_CONCURRENT_PROGRAMS_VL pr,&lt;/div&gt;&lt;div&gt;FND_REQUEST_GROUP_UNITS rgu,&lt;/div&gt;&lt;div&gt;FND_REQUEST_GROUPS rg,&lt;/div&gt;&lt;div&gt;FND_RESPONSIBILITY_VL resp&lt;/div&gt;&lt;div&gt;where 1=1&lt;/div&gt;&lt;div&gt;and pr.executable_id=ex.executable_id&lt;/div&gt;&lt;div&gt;and rgu.request_group_id=rg.request_group_id&lt;/div&gt;&lt;div&gt;and rgu.request_unit_id=pr.concurrent_program_id&lt;/div&gt;&lt;div&gt;and resp.request_group_id=rg.request_group_id&lt;/div&gt;&lt;div&gt;and pr.user_concurrent_program_name  like  '%Invoice Audit%'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This will not work if the report is assigned to a menu function, rather than the responsibility.&lt;/span&gt;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-3826040206426010470?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/3826040206426010470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/how-to-find-report.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/3826040206426010470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/3826040206426010470'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/how-to-find-report.html' title='How to find a report'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-8311843818816313301</id><published>2009-07-07T22:08:00.000-07:00</published><updated>2009-08-18T11:56:04.084-07:00</updated><title type='text'>How to create a price list based on item cost - Part II, Intercompany Price List in Oracle</title><content type='html'>&lt;span style="font-size:85%;"&gt;In my previous post I described how to create a price list based on cost. Why would we want to have a price list based on cost? From my experience there are 2 common scenarios where this comes handy:&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;RMA price list for obsolete items that are no longer priced, but customers keep returning them.&lt;/span&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;span style="font-size:85%;"&gt;For intercompany transactions where the transfer price between organizations is cost plus markup, and it would be cumbersome to have a manually maintained price list where all the costs are already defined.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;The RMA situation is not that common, but all multinational companies have intercompany transfers. I have seen one company where the number of internal price list lines exceeded 180,000 while the regular sales price lists had only 42,000. They could no longer maintain it and had to write custom concurrent requests to do it for them. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;The beauty of the below solution is that it requires no customizations and it will price all intercompany transactions based on ‘Cost + markup’ logic, with no maintenance required at all.&lt;br /&gt;To begin with, I recommend creating separate responsibility for Intercompany pricing, to keep the IC and Sales price lists, modifiers, formulas, qualifiers and modifiers separate. This is not required, as alternatively you can set up the relevant profile options on a dedicated user level, separate responsibility is by far a cleaner solution. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Go to Application Developer -&gt; Profiles and check the responsibility checkboxes for the below:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrXigiOPI/AAAAAAAAAFM/ffQy6ONvIQo/s1600-h/1.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953540250614002" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 201px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrXigiOPI/AAAAAAAAAFM/ffQy6ONvIQo/s400/1.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrNfUrrzI/AAAAAAAAAE8/5avwtTLYQ0c/s1600-h/2.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953367596904242" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 208px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrNfUrrzI/AAAAAAAAAE8/5avwtTLYQ0c/s400/2.JPG" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt; Now create your custom responsibility&lt;br /&gt;(N) System Administrator -&gt; Security -&gt; Responsibility -&gt; Define&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlQrKaDVCmI/AAAAAAAAAE0/OWFSlNll58c/s1600-h/3.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953314642332258" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 175px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_URNIWGqb_4g/SlQrKaDVCmI/AAAAAAAAAE0/OWFSlNll58c/s400/3.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Set the QP: Pricing Transaction Entity and QP: Source System Code profiles on the Responsibility Level.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrFKx4g6I/AAAAAAAAAEs/Xekbc7VJCn4/s1600-h/4.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953224643281826" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 78px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrFKx4g6I/AAAAAAAAAEs/Xekbc7VJCn4/s400/4.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Add the responsibility to your user. You have successfully set up your tools to begin working with Intercompany Pricing.&lt;br /&gt;In addition to the above, set the following profiles on the site level&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;- CST: Transfer Pricing Option - Yes, Price As Incoming Cost (read more about other settings)&lt;br /&gt;- INV: Advanced Pricing for Inter-Org Transfers - Yes&lt;br /&gt;- INV:Advanced Pricing for Intercompany Invoice - Yes&lt;br /&gt;- INV: Always suffix inter-Company AP Invoice number – Yes (optional)&lt;br /&gt;- INV: Inter-Organization Currency Conversion – Corporate&lt;br /&gt;- INV: Intercompany Currency Conversion - Corporate&lt;br /&gt;- INV:Intercompany Invoice for Internal Orders – Yes (optional)&lt;br /&gt;&lt;br /&gt;Set up shipping networks in inventory responsibility.&lt;br /&gt;Log into the Intercompany Pricing responsibility -&gt; Setup -&gt; Attribute Management -&gt; Attribute Linking and Mapping. Select Intercompany Transaction as the Pricing Entity and Pricing Context, then map the same COST attributes here as for the Order Fulfillment Entity in the previous post.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrCPG4TSI/AAAAAAAAAEk/-2kb0_taihM/s1600-h/5.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953174265482530" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 255px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrCPG4TSI/AAAAAAAAAEk/-2kb0_taihM/s400/5.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQq6NIlV2I/AAAAAAAAAEU/q0yfVAgiM7E/s1600-h/6.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355953036296804194" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 198px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQq6NIlV2I/AAAAAAAAAEU/q0yfVAgiM7E/s400/6.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Map both pricing attributes using the PL/SQL logic, the same as in previous post.&lt;br /&gt;For cost:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;cst_cost_api.get_item_cost(1, INV_IC_ORDER_PUB.G_LINE.INVENTORY_ITEM_ID, OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID,NULL,NULL)&lt;br /&gt;Note that record OE_ORDER_PUB.G_LINE in Intercompany pricing entity is replaced with INV_IC_ORDER_PUB.G_LINE&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;For Exchange Rate:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;gl_currency_api.get_rate(CSD_COST_ANALYSIS_UTIL.get_GLCurrencyCode(qa_moac_pkg.derive_ou_id(INV_IC_ORDER_PUB..G_LINE.SHIP_FROM_ORG_ID)),'USD', sysdate,'Corporate')&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:100%;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;The 'USD' needs to be replaced with the currency of the intercompany transactions for your installation.&lt;br /&gt;&lt;br /&gt;This will work on R12 as long as you don’t use Global Purchase Agreements nor have Oracle Process Manufacturing enabled for any of your organizations that do intercompany pricing. In those cases you will need to use additional logic, which I am omitting here to keep the case simple. As I mentioned in my previous post additional coding may be needed for 11i where the qa_moac_pkg.derive_ou_id function does not exist.&lt;br /&gt;After you are done mapping run the Build Attribute Mapping Rules Concurrent request .&lt;br /&gt;I think that all of the above should be seeded, but it isn’t. The enhancement requests to do so are sitting out on metalink for the last couple of years. On top of that the All Items Product Attribute is not mapped for the ‘Intercompany Transaction’ pricing entity. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;Lets fix this obvious omission.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQq20MaSKI/AAAAAAAAAEM/ZrzKMIDqv0k/s1600-h/7.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952978062362786" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 121px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQq20MaSKI/AAAAAAAAAEM/ZrzKMIDqv0k/s400/7.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Press Link Attributes button.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlQqzeQavsI/AAAAAAAAAEE/Ei-nsJQPrl4/s1600-h/8.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952920633982658" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 202px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlQqzeQavsI/AAAAAAAAAEE/Ei-nsJQPrl4/s400/8.JPG" border="0" /&gt;&lt;/a&gt; &lt;a href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlQqXHkWBrI/AAAAAAAAADs/1DXEP0h2M_w/s1600-h/9.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952433507206834" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 269px; TEXT-ALIGN: center" alt="" src="http://1.bp.blogspot.com/_URNIWGqb_4g/SlQqXHkWBrI/AAAAAAAAADs/1DXEP0h2M_w/s400/9.JPG" border="0" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;Run Build Attribute Mapping request again.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;Now that all the core setups are done lets create an Intercompany pricing formula.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQtJ3jSUVI/AAAAAAAAAFc/GKdNEz8BcZw/s1600-h/10.JPG"&gt;&lt;/a&gt;&lt;img id="BLOGGER_PHOTO_ID_5355955504404386130" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 283px; TEXT-ALIGN: center" alt="" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlQtJ3jSUVI/AAAAAAAAAFc/GKdNEz8BcZw/s400/10.JPG" border="0" /&gt; &lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;Because this formula is created in the Intercompany Pricing responsibility, it is visible, but not updateable in the regular Oracle Pricing Manager or any OM responsibility With the formula ready we can create the Intercompany Price List.&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;a href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlQqTsrx0iI/AAAAAAAAADk/BKBBQ6XlHUM/s1600-h/11.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952374751023650" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 169px; TEXT-ALIGN: center" alt="" src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlQqTsrx0iI/AAAAAAAAADk/BKBBQ6XlHUM/s400/11.JPG" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:85%;"&gt;Make sure to list all basic units of measure that can be transacted. In the above example I had 4.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;Note the Pricing Transaction Entity for your price list. It will not be usable in Order Management or any other sales applications.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQqNQojKeI/AAAAAAAAADc/9q_bdAb-fuo/s1600-h/12.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952264142072290" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 173px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQqNQojKeI/AAAAAAAAADc/9q_bdAb-fuo/s400/12.JPG" border="0" /&gt;&lt;/a&gt; &lt;/div&gt;&lt;div&gt;&lt;span style="font-size:85%;"&gt;There is a bug in EBS, that Oracle Support did not fix since I first discovered it in 2006. While the sales applications residing in Order Fulfillment Pricing Entity do not see the Intercompany Transactions Entity, the opposite is not true and regular sales Price lists are visible in the Intercompany Transactions entity. To work around this problem assign precedence =1 to your intercompany price list lines.&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQqJuWGVfI/AAAAAAAAADU/pJoxCjdSWDQ/s1600-h/13.JPG"&gt;&lt;img id="BLOGGER_PHOTO_ID_5355952203398272498" style="DISPLAY: block; MARGIN: 0px auto 10px; WIDTH: 400px; CURSOR: hand; HEIGHT: 156px; TEXT-ALIGN: center" alt="" src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlQqJuWGVfI/AAAAAAAAADU/pJoxCjdSWDQ/s400/13.JPG" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;There is another bug that prevents an Internal Order form being booked if the Intercompany price list is not assigned to the Internal Order type. To work around it assign it to the Internal Order type and also to the internal customer/customer site on the customer definition. From the logical perspective this is not really needed since the intercompany pricing is done by the Trip Stop interface which happens AFTER the order is booked and shipped and all the prices on the intercompany order are dummy values.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;Now that you have your intercompany price list set up, you can create Internal Requisitions, Internal Sales Orders, ship them, create Intercompany AP and AR invoices and never worry about updating your intercompany price list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;The Global Purchase Agreement, transfers originating from multi node transactions, and different markups between different organizations, including logical nodes can be also set up to work, but this is a too long topic to cover in this post.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-8311843818816313301?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/8311843818816313301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/intercompany-price-list-in-oracle.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/8311843818816313301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/8311843818816313301'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/intercompany-price-list-in-oracle.html' title='How to create a price list based on item cost - Part II, Intercompany Price List in Oracle'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_URNIWGqb_4g/SlQrXigiOPI/AAAAAAAAAFM/ffQy6ONvIQo/s72-c/1.JPG' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-2030161939903487059</id><published>2009-07-05T23:46:00.000-07:00</published><updated>2009-10-21T18:29:44.482-07:00</updated><title type='text'>How to create a price list based on item cost - Part I</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_URNIWGqb_4g/SlGfaUpNkbI/AAAAAAAAACU/MHsKsPjlhyw/s1600-h/2.JPG"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGfKpizacI/AAAAAAAAACM/TB7TvmUakSA/s1600-h/1.JPG"&gt;&lt;/a&gt;&lt;/span&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;To create a price list that has prices of all items based on the item cost plus markup you could use the standard functionality to copy the costs into prices and create a price list that has a cost plus markup. While it works, it is not very flexible and as cost changes and new items are added the price list requires constant attention and manual updates.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Instead doing that you can create a price list that has only one line for ALL ITEMS and dynamically sources the current cost and applies markup at the moment of the actual transaction. This does not require any maintenance, other than updating the costs which is done by the costing department anyway. This approach consists of 3 steps:&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Map the item cost as a pricing attribute&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Use the pricing attribute to create a dynamic pricing formula that adds markup&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Create ALL ITEMS price list and assign the pricing formula there.&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;  &lt;p class="MsoListParagraphCxSpLast" style="margin-left:.75in;mso-add-space:auto; text-indent:-.25in;mso-list:l1 level1 lfo2"&gt;&lt;b&gt;&lt;span style="line-height: 115%;mso-bidi-mso-bidi-theme-font:minor-latinfont-family:Calibri;"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;1.&lt;/span&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="line-height:115%"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Mapping the cost as a pricing attribute&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;I could utilize the standard Pricing Attribute context, but I recommend adding a separate one for better transparency. You can later build upon it and create additional attributes such as Material Cost, Overhead cost etc.&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Setup -&gt; Attribute Management -&gt; Context and Attributes&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGfKpizacI/AAAAAAAAACM/TB7TvmUakSA/s1600-h/1.JPG"&gt;&lt;img src="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGfKpizacI/AAAAAAAAACM/TB7TvmUakSA/s400/1.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355236437219568066" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 157px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Select a column for attribute mapping, i.e. PRICING_ATTRIBUTE1 and a numeric value set such as Number_15. Do not select the seeded ‘Number’ value set as it is not numeric.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/_URNIWGqb_4g/SlGfaUpNkbI/AAAAAAAAACU/MHsKsPjlhyw/s400/2.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355236706487210418" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 50px; " /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now that we have our new pricing context defined go to &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Setup -&gt; Attribute Management -&gt; Context and Attributes&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGflrNPHVI/AAAAAAAAACc/C2uPC-_KK_U/s1600-h/3.JPG"&gt;&lt;img src="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGflrNPHVI/AAAAAAAAACc/C2uPC-_KK_U/s400/3.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355236901522447698" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 255px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now, map the attributes on line level only.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlGfytT6OzI/AAAAAAAAACk/AkPfdz-O26E/s400/4.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355237125425609522" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 204px; " /&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In the ‘Global Object Name’ field you can see the name of the record structure that has all the variables that can be used when deriving the price. In this case it is OE_ORDER_PUB.G_LINE&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;You can go to the package definition of OE_ORDER_PUB and see what fields the G_LINE record contains&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_URNIWGqb_4g/SlGgEUGqwMI/AAAAAAAAACs/IEal_Xj-ycg/s1600-h/5.JPG"&gt;&lt;img src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlGgEUGqwMI/AAAAAAAAACs/IEal_Xj-ycg/s400/5.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355237427896828098" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 222px; " /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SlGfytT6OzI/AAAAAAAAACk/AkPfdz-O26E/s1600-h/4.JPG"&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SlGflrNPHVI/AAAAAAAAACc/C2uPC-_KK_U/s1600-h/3.JPG"&gt;&lt;/a&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now, if I just typed&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE.UNIT_COST in the User Value String then my pricing attribute would return the unit cost and it would be usable. The problem with this approach is that it is limited to Order Management and the UNIT_COST field is not always populated even there.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Lets take a more generic approach that should work for any record type.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In my previous post I used the &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;cst&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;_cost_api.get_item_cost(1,inventory_item_id, organization_id,NULL,NULL)&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function to get the cost of any item.&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;I will paste this function directly into the ‘User Value String’ of the pricing attribute mapping. The &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="color:#000000;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;in&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;ventory_item_id and organization_id need to be substituted by the&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE variables:&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Nvl(cst&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;_cost_api.get_item_cost(1,&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; OE_ORDER_PUB.G_LINE.INVENTORY_ITEM_ID&lt;/span&gt;&lt;span style="line-height: 115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;, &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID&lt;/span&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;,NULL,NULL),0)&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The NVL prevents the pricing engine to error out when no cost is defined. Depending on the situation, you may want it to error out.&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This is what needs to be pasted into the ‘User Value String’ field. &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now, go to Tools and select the ‘Build Attribute Mapping’ to complete the definition&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style=" line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This would work fine, except that my shipping warehouse can be in USD and my order in EUR. Since the cost is always returned in the currency of the set of books of the warehouse the above expression needs to be multiplied by the exchange rate that you can also get from my previous post:&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;gl_currency_api.get_rate(from_currency_code,to_currency_code, conversion_date, Conversion_type)&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;For transparency it is better to source the exchange rate as a separate pricing attribute such as CONV_RATE and then multiply them in the pricing formula&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now, TO_CURRENCY_CODE&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;is OE_ORDER_PUB.G_HDR.TRANSACTIONAL_CURR_CODE&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Note that I took currency from the header record, which is also populated at runtime.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Conversion date is &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE. PRICING_DATE&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;And conversion type is fixed such as ‘Corporate’&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The only remaining parameter is&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;Trebuchet MS&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:#333333;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;from_currency_code&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;To find the operating&lt;/span&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;unit of the shipping warehouse in R12 use the below function:&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight: whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;qa_moac_pkg&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%; mso-bidi-background:white; mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%; mso-bidi-background:white; mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;derive_ou_id&lt;/span&gt;&lt;/span&gt;&lt;span style=" line-height:115%;mso-bidi- background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID).&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Let me know if you find a relevant function in 11i. The ones I found are either not public, or they are not available to every installation, such as the Indian localization function &lt;/span&gt;&lt;span style=" line-height:115%;mso-bidi- background:white;mso-highlight:whitefont-family:Courier;color:olive;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;jai_cmn_utils_pkg&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;get_operating_unit&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:red;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;'anything'&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;,&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; SHIP_FROM_ORG_ID&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-font-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;. &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In 11i you may have end up writing your own function.&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now that the operating unit of the shipping warehouse is known, the &lt;/span&gt;&lt;span style="line-height:115%; mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CSD_COST_ANALYSIS_UTIL&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;get_GLCurrencyCode&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-font-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%; Arial&amp;quot;,&amp;quot;sans-serif&amp;quot;;font-family:&amp;quot;;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;function can be used to derive the from_currency. The full expression is: &lt;/span&gt;&lt;/span&gt;&lt;span style="font-family:&amp;quot;;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight: whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;CSD_COST_ANALYSIS_UTIL&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%;mso-bidi-background: white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height: 115%;mso-bidi-background: white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;get_GLCurrencyCode&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi- background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;qa_moac_pkg&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:black;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;derive_ou_id&lt;/span&gt;&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID&lt;/span&gt;&lt;span style="line-height:115%;mso-bidi-background:white;mso-highlight:whitefont-family:Courier;color:blue;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The complete expression that finds the conversion rate between the shipping warehouse and the order operating unit is :&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family:&amp;quot;;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;gl_currency_api.get_rate(&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;CSD_COST_ANALYSIS_UTIL.get_GLCurrencyCode(qa_moac_pkg.derive_ou_id(OE_ORDER_PUB.G_LINE.SHIP_FROM_ORG_ID)),&lt;/p&gt;  &lt;p class="MsoNormal"&gt;OE_ORDER_PUB.G_HDR.TRANSACTIONAL_CURR_CODE,&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="font-family:&amp;quot;;"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;sysdate,&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="font-family:&amp;quot;;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;'Corporate')&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Create and map the Conversion Rate Pricing Attribute the same way as Item Cost.&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:7;"&gt;&lt;span class="Apple-style-span"  style="font-size:48px;"&gt;&lt;span class="Apple-style-span"  style=" color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; font-size:16px;"&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlGgakhGbpI/AAAAAAAAAC0/f3M7jynRULY/s400/6.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355237810259783314" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 268px; " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%;mso-bidi-font-family:Courier;color:black;"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now that have both item cost and the conversion rate defined we can build our Pricing Formula&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoListParagraph" style="margin-left:.75in;mso-add-space:auto; text-indent:-.25in;mso-list:l1 level1 lfo2"&gt;&lt;b&gt;&lt;span style="line-height: 115%;mso-bidi-mso-bidi-theme-font:minor-latinfont-family:Calibri;"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;2.&lt;/span&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="line-height:115%"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Pricing Formula&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Pricing Formula -&gt; Formula setup&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SlGgxU9ni6I/AAAAAAAAAC8/L6IgGpotDG0/s400/7.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5355238201221417890" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 192px; " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Go to Tools -&gt; Build Formula Package&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;br /&gt;&lt;/p&gt;  &lt;p class="MsoListParagraph" style="margin-left:.75in;mso-add-space:auto; text-indent:-.25in;mso-list:l1 level1 lfo2"&gt;&lt;b&gt;&lt;span style="line-height: 115%;mso-bidi-mso-bidi-theme-font:minor-latinfont-family:Calibri;"&gt;&lt;span&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;3.&lt;/span&gt;&lt;span style="font:7.0pt &amp;quot;Times New Roman&amp;quot;"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;      &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span style="line-height:115%"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Price List&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoListParagraph" style="margin-left:.75in;mso-add-space:auto; text-indent:-.25in;mso-list:l1 level1 lfo2"&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal; line-height: normal; color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="line-height: normal; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The Price list needs to be defined for all base units of measure.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;img src="http://3.bp.blogspot.com/_URNIWGqb_4g/SlGhN3K4WnI/AAAAAAAAADE/LFivkBQV62c/s400/8.JPG" /&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;b&gt;&lt;span style="line-height: 18px; "&gt;&lt;o:p&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;/p&gt;&lt;p class="MsoListParagraph" style="margin-left: 0.75in; text-indent: -0.25in; "&gt;&lt;span class="Apple-style-span" style="line-height: 18px; "&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-weight: normal; line-height: normal; color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal"&gt;&lt;span style="line-height:115%"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now the price list is ready to be used.&lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-2030161939903487059?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/2030161939903487059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/how-to-create-price-list-based-on-item.html#comment-form' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2030161939903487059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2030161939903487059'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/07/how-to-create-price-list-based-on-item.html' title='How to create a price list based on item cost - Part I'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_URNIWGqb_4g/SlGfKpizacI/AAAAAAAAACM/TB7TvmUakSA/s72-c/1.JPG' height='72' width='72'/><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-2760352577636300026</id><published>2009-06-17T10:47:00.000-07:00</published><updated>2009-06-17T10:47:00.390-07:00</updated><title type='text'>Querying values in foreign currencies</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here is the &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;API&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; you need to use to query the conversion rate between 2 currencies for a specific date.&lt;/span&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;gl_currency_api.get_rate(from_currency_code,to_currency_code, conversion_date, Conversion_type)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In a query it would look like this:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;select&lt;/div&gt;&lt;div&gt; gl_currency_api.get_rate('USD','EUR', sysdate, 'Corporate') &lt;/div&gt;&lt;div&gt;from dual&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Now we can combine that with the cost queries from the previous post to get the value of on-hand quantities in any warehouse in the EUR currency:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;select msi.segment1 item,&lt;/div&gt;&lt;div&gt;sob.currency_code warehouse_currency,&lt;/div&gt;&lt;div&gt; cst_cost_api.get_item_cost(1,moq.inventory_item_id, moq.organization_id,NULL,NULL) cost,&lt;/div&gt;&lt;div&gt;  gl_currency_api.get_rate(sob.currency_code,'EUR', sysdate, 'Corporate') conversion_rate,&lt;/div&gt;&lt;div&gt;  cst_cost_api.get_item_cost(1,moq.inventory_item_id, moq.organization_id,NULL,NULL)* &lt;/div&gt;&lt;div&gt;  gl_currency_api.get_rate(sob.currency_code,'EUR', sysdate, 'Corporate') cost_in_eur&lt;/div&gt;&lt;div&gt;from &lt;/div&gt;&lt;div&gt;gl_sets_of_books sob,&lt;/div&gt;&lt;div&gt;mtl_organizations mo,&lt;/div&gt;&lt;div&gt;mtl_onhand_quantities moq,&lt;/div&gt;&lt;div&gt;mtl_system_items_b msi&lt;/div&gt;&lt;div&gt;where&lt;/div&gt;&lt;div&gt;mo.set_of_books_name=sob.name&lt;/div&gt;&lt;div&gt;and moq.organization_id=mo.organization_id&lt;/div&gt;&lt;div&gt;and moq.organization_id=msi.organization_id&lt;/div&gt;&lt;div&gt;and moq.inventory_item_id=msi.inventory_item_id&lt;/div&gt;&lt;div&gt;and mo.organization_code='M1'&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;gl&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;_currency_&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;api&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;.get_rate will return exception if the exchange rate is not defined for the day.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-2760352577636300026?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/2760352577636300026/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/querying-values-in-foreign-currencies.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2760352577636300026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2760352577636300026'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/querying-values-in-foreign-currencies.html' title='Querying values in foreign currencies'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-5880833156484656557</id><published>2009-06-16T10:16:00.000-07:00</published><updated>2009-06-16T10:16:00.797-07:00</updated><title type='text'>How to find item cost</title><content type='html'>&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;Another&lt;/span&gt; common issue when &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_1"&gt;writing&lt;/span&gt; queries is getting an item cost.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Here are the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_2"&gt;APIs&lt;/span&gt; to use in queries:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;For discrete manufacturing:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;cst&lt;/span&gt;_cost_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;api&lt;/span&gt;.get_item_cost(1,inventory_item_id, organization_id,NULL,NULL)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;here is a sample query:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;select segment1 item,&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;cst&lt;/span&gt;_cost_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;api&lt;/span&gt;.get_item_cost(1,inventory_item_id, organization_id,NULL,NULL) cost&lt;/div&gt;&lt;div&gt; from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;mtl&lt;/span&gt;_system_items_b&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you are in an &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;OPM&lt;/span&gt; organization the above won't work and instead you need to call &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;select &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_9"&gt;msi&lt;/span&gt;.segment1 item,&lt;/div&gt;&lt;div&gt;  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;GMF&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;CMCOMMON&lt;/span&gt;.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;cmpt&lt;/span&gt;_cost( inventory_item_id,  organization_id,  &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;sysdate&lt;/span&gt;, &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;cmm&lt;/span&gt;.cost_type_id ,0) cost&lt;/div&gt;&lt;div&gt; from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;mtl&lt;/span&gt;_system_items_b &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;msi&lt;/span&gt;, CM_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;MTHD&lt;/span&gt;_MST &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;cmm&lt;/span&gt;&lt;/div&gt;&lt;div&gt; where &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;cmm&lt;/span&gt;.cost_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;mthd&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;desc&lt;/span&gt;='Standard Cost'&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-5880833156484656557?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/5880833156484656557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-find-item-cost.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5880833156484656557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5880833156484656557'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-find-item-cost.html' title='How to find item cost'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-6146452794478051770</id><published>2009-06-15T21:59:00.000-07:00</published><updated>2009-06-15T22:16:43.118-07:00</updated><title type='text'>How to query key flexfields</title><content type='html'>&lt;span class="Apple-style-span"  style="font-size:small;"&gt;It is quite common that in Oracle Applications you need to write queries listing specific account combinations.  The problem with that is that the account combinations are stored as their ids and you have to go to the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;GL&lt;/span&gt;_CODE_COMBINATIONS table to find the specific segments and concatenate them one by one. &lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Easy to do but always waste of time. Moreover, each &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;EBS&lt;/span&gt; install has a different number of segments and query written for one client needs to be rewritten for &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;another&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Well, not any more. There are Oracle &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;APIs&lt;/span&gt; that allow you to get the complete combination as a string by passing the &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;CCID&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here is the syntax:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;fnd&lt;/span&gt;_flex_ext.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_6"&gt;segs&lt;/span&gt;('&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_7"&gt;SQLGL&lt;/span&gt;', '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_8"&gt;GL&lt;/span&gt;#', chart_of_accounts_id, code_combination_id) &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now, if you are on &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_9"&gt;release&lt;/span&gt; 12 and want to have the concatenated combination descriptions you can also run this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_10"&gt;xla&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_11"&gt;oa&lt;/span&gt;_functions_pkg.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_12"&gt;ccid&lt;/span&gt;_description (chart_of_accounts_id, code_combination_id) &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Here is a sample query:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;select &lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_13"&gt;fnd&lt;/span&gt;_flex_ext.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_14"&gt;segs&lt;/span&gt;(  '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_15"&gt;SQLGL&lt;/span&gt;',&lt;/div&gt;&lt;div&gt;                        '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_16"&gt;GL&lt;/span&gt;#',&lt;/div&gt;&lt;div&gt;                        (select chart_of_accounts_id &lt;/div&gt;&lt;div&gt;                        from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_17"&gt;GL&lt;/span&gt;_SETS_OF_BOOKS &lt;/div&gt;&lt;div&gt;                        where name='Vision Operations (USA)'),&lt;/div&gt;&lt;div&gt;                        code_combination_id) account,&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_18"&gt;xla&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_19"&gt;oa&lt;/span&gt;_functions_pkg.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_20"&gt;ccid&lt;/span&gt;_description(&lt;/div&gt;&lt;div&gt;                        (select chart_of_accounts_id&lt;/div&gt;&lt;div&gt;                        from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_21"&gt;GL&lt;/span&gt;_SETS_OF_BOOKS&lt;/div&gt;&lt;div&gt;                        where name='Vision Operations (USA)'),&lt;/div&gt;&lt;div&gt;                        Code_combination_id) description&lt;/div&gt;&lt;div&gt;from &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_22"&gt;GL&lt;/span&gt;_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_23"&gt;JE&lt;/span&gt;_LINES&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;The &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_24"&gt;fnd&lt;/span&gt;_flex_ext.get_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_25"&gt;segs&lt;/span&gt; call is universal and will work for any key &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_26"&gt;flexfield&lt;/span&gt;. Here is  the &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_27"&gt;syntax&lt;/span&gt; for HR position &lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_28"&gt;hierarchies&lt;/span&gt;:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_29"&gt;FND&lt;/span&gt;_FLEX_EXT.GET_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_30"&gt;SEGS&lt;/span&gt;('PER', '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_31"&gt;POS&lt;/span&gt;', id_flex_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_32"&gt;num&lt;/span&gt;, position_definition_id)&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;and here is a sample query:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt; select&lt;/div&gt;&lt;div&gt;             &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_33"&gt;FND&lt;/span&gt;_FLEX_EXT.GET_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_34"&gt;SEGS&lt;/span&gt;('PER', '&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_35"&gt;POS&lt;/span&gt;', id_flex_&lt;span class="blsp-spelling-error" id="SPELLING_ERROR_36"&gt;num&lt;/span&gt;, position_definition_id) position_definition&lt;/div&gt;&lt;div&gt;             from per_position_definitions&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-6146452794478051770?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/6146452794478051770/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-query-key-flexfields.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/6146452794478051770'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/6146452794478051770'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-query-key-flexfields.html' title='How to query key flexfields'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-2697379159294831087</id><published>2009-06-09T10:05:00.000-07:00</published><updated>2009-06-09T10:05:00.750-07:00</updated><title type='text'>OM Defaulting rules Part 2</title><content type='html'>&lt;span class="Apple-style-span"  style=" ;font-family:'Times New Roman';"&gt;&lt;div style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; width: auto; font: normal normal normal 100%/normal Georgia, serif; text-align: left; "&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I worked on a project once where we had different lines of products maintained by different product managers across several sales territories and different currencies.&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;When an order was placed the price list was not specified on the order header but instead it was selected automatically on lines based on the sales channel, territory and the line of products the item belonged to.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This worked fine with one exception; the currency on the order header defaulted from the order type instead of the customer site. Prices were tailored to a specific market and specific currency and we could not simply create a multicurrency price list. Instead we have created a mandatory flexfield on the customer site and used the PL/SQL defaulting rules to dynamically default it on the order.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;In the defaulting order screen you can select PL/SQL as the source type and specify the Package and Function name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/Si3rA4IJk-I/AAAAAAAAABk/YJh3sJZbw2Y/s1600-h/defaulting+rule.JPG"&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/Si3rA4IJk-I/AAAAAAAAABk/YJh3sJZbw2Y/s400/defaulting+rule.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5345186733057741794" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 197px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The above shows the seeded values where the currency is taken from the Set of Books.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Note that there is no way to pass a specific order number or ID, the values will be taken from the current ONT_HEADER_DEF_HDLR.g_record which is automatically populated by the application for any order.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Here is the code I used to default currency from Attribute11 of site use flexfield:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;FUNCTION Get_DEFAULT_CURRENCY&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;( p_database_object_name IN VARCHAR2&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;,p_attribute_code IN VARCHAR2)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RETURN VARCHAR2 IS&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;l_invoice_to_org_id NUMBER := APPS.ONT_HEADER_DEF_HDLR.g_record.invoice_to_org_id;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;l_currency VARCHAR2(4);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;l_debug_level CONSTANT NUMBER := apps.oe_debug_pub.g_debug_level;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;IF l_debug_level &gt; 0 THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;oe_debug_pub.add('ENTER Get_sales_channel');&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;oe_debug_pub.add('Sold To Org ID :'||l_invoice_to_org_id );&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;END IF;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;IF l_invoice_to_org_id is not null&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;AND l_invoice_to_org_id &lt;&gt; apps.fnd_api.g_miss_num&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;--Here is the actual code&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;select attribute11&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;into l_currency&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space: pre; "&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;from HZ_cust_SITE_USES_ALL situs&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;where situs.site_use_id=l_invoice_to_org_id;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RETURN l_currency;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;EXCEPTION&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;-- Return null if there is noinvoice to site&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;WHEN NO_DATA_FOUND THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RETURN NULL';&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;-- Return null if there is no customer&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;ELSE&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RETURN NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;END IF;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;EXCEPTION&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;WHEN OTHERS THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;IF l_debug_level &gt; 0 THEN&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;apps.oe_debug_pub.add('Error in Get_Currency') ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;apps.oe_debug_pub.add('Error :'||substr(sqlerrm,1,200)) ;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;END IF;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;RETURN NULL;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;END Get_DEFAULT_CURRENCY;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-2697379159294831087?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/2697379159294831087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/om-defaulting-rules-part-2_09.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2697379159294831087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2697379159294831087'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/om-defaulting-rules-part-2_09.html' title='OM Defaulting rules Part 2'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_URNIWGqb_4g/Si3rA4IJk-I/AAAAAAAAABk/YJh3sJZbw2Y/s72-c/defaulting+rule.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-5535697058635389497</id><published>2009-06-08T21:24:00.000-07:00</published><updated>2009-06-08T21:41:20.608-07:00</updated><title type='text'>OM Defaulting rules Part 1</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/Si3mz6B6SOI/AAAAAAAAABc/sSRU7A_S6-o/s1600-h/ordered+date.JPG"&gt;&lt;/a&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;Recently I came across a very annoying issue. Every time we changed the bill-to or ship-to address on the order header the 'Date Ordered' field would re-default to SYSDATE, messing up all the sales reporting. &lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;A short research on metalink revealed note 748269.1 which recommends updating package OE_Dependencies_Extn and changing some seeded dependencies. To make a long story short we did that ending up with a 3 weeks long P1 issue that did not seem related in any way.. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;There is, however, a trivially simple way of fixing this problem using the OM defaulting rules:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;(N) OM -&gt; Setup -&gt; Rules -&gt; Defaulting&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Query OM header, scroll down to Ordered Date and change the seeded defaulting rule to&lt;/span&gt;:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;img src="http://1.bp.blogspot.com/_URNIWGqb_4g/Si3mz6B6SOI/AAAAAAAAABc/sSRU7A_S6-o/s400/ordered+date.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5345182112183634146" style="float: left; margin-top: 0px; margin-right: 10px; margin-bottom: 10px; margin-left: 0px; cursor: pointer; width: 400px; height: 270px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This will make the date default to itself first and to &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;sysdate&lt;/span&gt; only if it was NULL in the first place.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#0000EE;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-5535697058635389497?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/5535697058635389497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/om-defaulting-rules.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5535697058635389497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/5535697058635389497'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/om-defaulting-rules.html' title='OM Defaulting rules Part 1'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_URNIWGqb_4g/Si3mz6B6SOI/AAAAAAAAABc/sSRU7A_S6-o/s72-c/ordered+date.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-2725561428700347348</id><published>2009-06-03T20:31:00.000-07:00</published><updated>2009-06-03T21:11:55.775-07:00</updated><title type='text'>Choosing the right instance</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SidIC24j1TI/AAAAAAAAABU/4tVz0dqtzJE/s1600-h/green+apps.JPG"&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Working in  a multi instance environment with the main PROD instance accompanied by TEST DEV and others can be tricky. While in my previoust post I covered on how to tell the difference if one is looking for it, it is too easy to confuse them and create a test record on the Production instance, or enter a valid customer order into Test, especially if both are opened at the same time. &lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The best way to avoid it is to change the application color and apperance for each instance. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;FORMS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Most of the time, when DBAs make a clone they set the value of the&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;Site Name &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;profile by putting the name of the instance there. This changes the name of the application displayed in the bar on top of the window:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238);   "&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SidGMe-hXrI/AAAAAAAAABE/SQxvvucso2k/s400/Site+Name+test.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5343316663186054834" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 376px; height: 225px; " /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This is very useful but often can be overlooked.  A good way to make the difference apparent is changing the colors of forms which can be done with the &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Java Color Scheme&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;profile.  As long as every instance has a different color, the risk of confusing them is minimized&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Another, a bit more radical approach is to remove the oralce graphical interface and display pure Java forms by changing the &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Java Look and Feel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;profile. This will make your 11i or R12 applications look vary much  like the old 11.0.3 version.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238);  "&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SidHcwlDG5I/AAAAAAAAABM/_KSk9aV7n3Y/s400/java+loook+and+feel.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5343318042300586898" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 317px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;OA Framework&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;The Java profile options will not change the way your Oracle Framework pages look like. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;To change them you need to se the &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Oracle Applications Look and Feel&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;profile. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;Here is an example of how the pages look after the profile change&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia; "&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SidIC24j1TI/AAAAAAAAABU/4tVz0dqtzJE/s1600-h/green+apps.JPG"&gt;&lt;img src="http://4.bp.blogspot.com/_URNIWGqb_4g/SidIC24j1TI/AAAAAAAAABU/4tVz0dqtzJE/s400/green+apps.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5343318696828065074" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 133px; " /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;If you want to go further than that, you can use the 'Customizing Look and Feel Administrator' responsibility to design your own graphical theme.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;There is also a http://oracleskins.com/ company that designs customized skins.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: arial;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-2725561428700347348?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/2725561428700347348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/choosing-right-instance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2725561428700347348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/2725561428700347348'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/choosing-right-instance.html' title='Choosing the right instance'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_URNIWGqb_4g/SidGMe-hXrI/AAAAAAAAABE/SQxvvucso2k/s72-c/Site+Name+test.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7204324636212178469.post-558357982782111788</id><published>2009-06-02T22:10:00.000-07:00</published><updated>2009-06-02T23:16:44.147-07:00</updated><title type='text'>How to find which instance I am using?</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SiYSYWOfqhI/AAAAAAAAAA8/74SXEHLyQDo/s1600-h/login.jpg"&gt;&lt;/a&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Forms&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;When in Oracle Applications forms the simplest way to identify whether we are on the right instance is  go to:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;Help -&gt; Diagnostics -&gt; Examine&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; from the application toolbar menu and find the field:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span"  style="font-size:medium;"&gt;TWO_TASK&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; in the&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153); "&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt; $ENVIRONMENT$&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; block.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; This will display the database identifier as on the picture below.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_URNIWGqb_4g/SiYIrawWSuI/AAAAAAAAAAM/MepKBElZwII/s1600-h/sid.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 189px;" src="http://4.bp.blogspot.com/_URNIWGqb_4g/SiYIrawWSuI/AAAAAAAAAAM/MepKBElZwII/s320/sid.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5342967549931178722" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Database&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In TOAD or plain SQL level the database can be found by running&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 153);"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;select name from&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; v$database&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;There is only one row in that table and it can give you some addtional info, like when the instance was refreshed from production.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;OA Framework&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;In Oracle Framework &lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;enable the '&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  ;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;FND:Diagnostics' &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  ;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;profile for your user and re-log into the application. In the lower left corner &lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;of the page you will see a link to &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  line-height: 12px; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;About Page&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  line-height: normal; "&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt; same as on the picture &lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;below&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:13px;"&gt;&lt;img src="http://2.bp.blogspot.com/_URNIWGqb_4g/SiYM3ZCcyXI/AAAAAAAAAAc/No3C41eDIMM/s320/about+this+page.JPG" style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 106px; height: 84px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5342972153675172210" /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This will take you to pages containing detailed information about your installation.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Switch to the '&lt;/span&gt;&lt;span class="Apple-style-span" style=" line-height: 12px; "&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;Page Context'&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" line-height: 12px; font-family:Tahoma;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;&lt;span class="Apple-style-span" style="font-family: georgia;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style=" line-height: normal; font-family:Georgia;"&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;tab and it will not only identify your database but also provide all the information needed to log in via TOAD or SQL,  other than the user name and password.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://3.bp.blogspot.com/_URNIWGqb_4g/SiYQrg9M-eI/AAAAAAAAAA0/e7UkEGexaiM/s400/framework.JPG" border="0" alt="" id="BLOGGER_PHOTO_ID_5342976347688729058" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 76px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:small;"&gt;This info can be either used to create TNSNAMES entry or used directly to connect to the database. In SQL*PLUS the syntax would be:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-size:48px;"&gt;&lt;span class="Apple-style-span"  style=" ;font-size:16px;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_URNIWGqb_4g/SiYSYWOfqhI/AAAAAAAAAA8/74SXEHLyQDo/s1600-h/login.jpg"&gt;&lt;img src="http://1.bp.blogspot.com/_URNIWGqb_4g/SiYSYWOfqhI/AAAAAAAAAA8/74SXEHLyQDo/s400/login.jpg" border="0" alt="" id="BLOGGER_PHOTO_ID_5342978217414208018" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 370px; height: 250px; " /&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The same syntax can be used in other tools like i.e. Workflow&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7204324636212178469-558357982782111788?l=piotrbelter.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://piotrbelter.blogspot.com/feeds/558357982782111788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-find-which-instance-i-am-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/558357982782111788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7204324636212178469/posts/default/558357982782111788'/><link rel='alternate' type='text/html' href='http://piotrbelter.blogspot.com/2009/06/how-to-find-which-instance-i-am-using.html' title='How to find which instance I am using?'/><author><name>Piotr Belter</name><uri>http://www.blogger.com/profile/17650689470625530607</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='30' src='http://3.bp.blogspot.com/_URNIWGqb_4g/SlVto03Y6_I/AAAAAAAAAFo/Jq7yEjAxRVA/S220/picture.JPG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_URNIWGqb_4g/SiYIrawWSuI/AAAAAAAAAAM/MepKBElZwII/s72-c/sid.JPG' height='72' width='72'/><thr:total>0</thr:total></entry></feed>
