You are on page 1of 11

desc xla_tb_ap_report_pvt.

before_report
desc xla_tb_ap_report_pvt.populate_trial_balance_gt
cursor
select
from
where
and
and
and
and
and

c1 is
nvl(cr_days,0)
comm_cust_creditor
comp_code = :blk_display.jc_comp_code
sys_code
= :blk_title.fa_sys
subsys_code = :blk_title.fa_subsys
rec_typ
= '1'
ccr_code
= :blk_display.jc_cust_code
loc_code
= (select br_fa_loc
from mghe_brch
where br_comp_code = :blk_control.comp_code
and br_sys_code = :blk_control.sys_code
and br_brch_code = nvl(:blk_display.jc_srvcont_brch,
:blk_control.brch_code));
execute mo_global.set_policy_context('S',181)
fnd_global.apps_initialize (p_user_id, p_resp_id, p_resp_appl_id);
AP_APXVDMVD_MENU
Suppliers
OA.jsp?page=/oracle/apps/pos/supplier/webui/SuppSummPG&OAHP=POS_HT_SP_HP&OASF=PO
S_HT_SP_B_SUPP&OAPB=AP_PAY_PRODUCT_BRAND
Set env variable in -> My Computer Properties -> Advanced -> Environment Variabl
es -> User Variables -> New ->
JDEV_USER_HOME as C:\oaf\jdevhome\jdev
Copy the VIS.dbc file
from /u100/oracle/VIS/inst/apps/VIS_test/appl/fnd/12.0.0/secure
to C:\oaf\jdevhome\jdev\dbc_files\secure
Update User Profile with the following responsibility
----------------------------------------------------Framework ToolBox Tutorial
Framework ToolBox Menu Lab (1)
Framework ToolBox Tutorial Labs
Framework ToolBox Tutorial Labs (New)
Application Short Name : ICX
Responsibility KEY :FWK_TBX_TUTORIAL
Model -- AM (EO, VO)
View -- Page, regions,tables, text, lovs,radio, check boxes
controller: class and actions class
ap_terms
aptermsEO
aptermsVO
apstermsAM

-----

Table
EO
VO
AM

select * from
suppliers, supplier_sites

where --search , create, insert, update, delete


JWS
JPR

- model (AM, EO, VO, EA), View links, VAM)

Indepndently test the AM..


JPR
- view (PG,RN,tbl..)
Configure jdev ->
Database ->
Identify tables ->
Develop eo, vo and am ->
and then develop the page, region, table..
place the am on the view
add controller class if required
make
build
deploy
clean the cache or restart the server
register the page in oracle apps
run the page
MODEL (Table) -> EO -> VO -> AM
AM - Application Module
VO - View Objects
EO - Entity Objects
TBL - Tables
SRW - Standard Report Writer
BN - Beana
PG - Page
RN - Region
CO - Controller
UI - User Interface
CSS - Cascading Style Sheets
OAF - Oracle Application Framework
ADF - Application Development Framework
XML - Extensive Markup Language
MDS - Meta Data Service
FSG - Financial Statement Generator
ICX - Self Service Module
MVC - Model View Controller
BC4J - Business Components for Java
AOL/J - Application Object Library for Java
UIX - User Interface XML
JWS - Java Web Service
EAO - Entity Association Objects
EAM - Entity Association Module
VAM - Validation Application Module
IDE - Integrated Development Environment
TDF - Template Definition File
OIE - Oracle Internet Expenses
JPX - Java Personalization Export
SPEL - Simplest Possible Expression Language
JWS Page -> Model (AM, EO, VO, EA, Views, Links, VAM) -> View (PG, RN, TBL) -> C
ontroller (Triggers, Functions)

Corporate Name -> Header -> Search Bean -> Table Bean
Application Workspace -> Projects -> Application Node
eo - oracle.apps.icx.nagaraj.schema.server
am & vo - oracle.apps.icx.nagaraj.server
pg & controller - oracle.apps.icx.nagaraj.webui
poplist & lov - oracle.apps.icx.nagaraj.poplist.server
oracle.apps.icx.nagaraj.lov.server
sysadmin/sysadmin - functional administrator
This should be set for default AM Module - oracle.apps.fnd.framework.server.OAAp
plicationModule
Image - Image Style (Image), Image URI (image name), Additional Test (If any)
Page -> Page Layout -> Query -> Table
Free Flow Text -> Page Layout -> FlowLayout -> StaticStyledText, CSS Class (OraI
nstructionText),
Message Appl Short Name (DEMXX), Message Name (ORDLINES_PAGE_GENERAL)

/u100/oracle/VIS/apps/apps_st/comn/java/classes
OA.jsp?page=/oracle/apps/icx/nagaraj/zmSupplierPGSuppSearchZMPG
/oracle/apps/icx/nagaraj
/u100/oracle/VIS/apps/apps_st/comn/java/classes/oracle/apps/icx/nagaraj
OA.jsp?page=/oracle/apps/icx/nagaraj/webui/nagpage1
/u100/oracle/VIS/apps/apps_st/comn/java/classes/oracle/apps/icx/nagaraj/webui/zm
SupplierPG
OA.jsp?page=/oracle/apps/ap/invoice/request/webui/MatchedInvoicePG&akRegionAppli
cationId=200&OASF=AP_ISP_INV_DET_PO
FWK_TBX_TUTORIAL
Framework ToolBox Tutorial
OA.jsp?page=/oracle/apps/icx/nagaraj/webui/nagpage1
java oracle.jrad.tools.xml.importer.XMLImporter nagpage1.xml -rootdir /u100/orac
le/VIS/apps/apps_st/comn/java/classes -username apps -password apps -dbconnecti
on test.galadari.ae:1521:VIS
Instructor Deploy
Suppliers Search Page -- zafar
ZM_SUB_MENU

OA.jsp?page=/oracle/apps/icx/zafar/webui/zmSupplierPG
OA.jsp?page=/oracle/apps/icx/zafar/webui/zmSupplierPG
OA.jsp?page=/oracle/apps/icx/nagaraj/webui/nagpage1
NAG_SUP_PAGE
AP_SUP_PAGE
FWK_TBX_TUTORIAL
OrderEntryWS
OrderEntryPj
OrderEntryAM
- Form Name
OrderEO
Name
OrderSearchVO
Name

- (Workspace)
- nagaraj.oracle.apps.demxx.orderentry (Project)
- nagaraj.oracle.apps.demxx.orderentry.server (Application Module)
- nagaraj.oracle.apps.demxx.schema.server (Entity Object) - Block
- nagaraj.oracle.apps.demxx.orderentry.server (View Object) - View

Link VO - AM
OrderSearchPG - nagaraj.oracle.apps.demxx.orderentry.webui (Page) - Browser Page
PageLayoutRN - Region Style (PageLayout) - Create a Region in the Browser Page
ProductBranding -> ProdBrand - Image URI (Image.gif) -- To Add Corporate
Brand Image in the Region
pageStatus -> PageStatusRN - flowlayout - To display a message in the re
gion
Item -> PageHelp - staticStyledText, CSS Class (OraInstructionTe
xt)
QueryRN -> query - Construction Mode (resultsBasedSearch)
Region Using Wizard - ResultsTable - table
SimpleSearchPanel ->
Shortcuts to Remember while coding in java
-----------------------------------------Ctrl + Enter - Code Template
Ctrl + Shift + Enter - Complete Statement
Ctrl + Alt + Space - Smart Complete
Ctrl + Alt + V - Create Variables For You
SELECT hou.name operating_unit, hou.organization_id org_id, gsob.name ledger, pb
g.name business_group
FROM hr_operating_units hou, gl_sets_of_books gsob, per_business_groups pbg
where hou.set_of_books_id = gsob.set_of_books_id
and hou.business_group_id = pbg.business_group_id
and mo_global.check_access(hou.organization_id) = 'Y'
select
from
where
and

hou.business_group_id business_group_id, pbg.name business_group_name


hr_operating_units hou, per_business_groups pbg
pbg.business_group_id = hou.business_group_id
mo_global.check_access(hou.organization_id) = 'Y'

MO_GLOBAL.init('PA');
select distinct gl.ledger_id set_of_books_id, gl.name
from gl_ledgers gl,

select distinct gsob.set_of_books_id, gsob.name


from hr_operating_units hou, per_business_groups pbg, mtl_parameters mp, gl_se
ts_of_books gsob
where hou.name between nvl(:query_find.qry_from_organization_name, hou.name)
and nvl(:query_find.qry_to_organization_name, hou.name)
and pbg.business_group_id = hou.business_group_id
and pbg.name = nvl(:query_find.qry_business_group_name, pbg.name)
and mp.organization_id = hou.organization_id
and gsob.set_of_books_id = hou.set_of_books_id
and mo_global.check_access(hou.organization_id) = 'Y'
order by gsob.set_of_books_id
-- M multiple, S single
mo_global.init ('M');
DECLARE
l_default_org_id number;
l_default_ou_name varchar2(240);
l_ou_count number;
BEGIN
mo_utils.get_default_ou(l_default_org_id, l_default_ou_name, l_ou_count);
dbms_output.put_line ('1' || ' ' || l_default_org_id);
dbms_output.put_line ('2' || ' ' || l_default_ou_name);
dbms_output.put_line ('3' || ' ' || l_ou_count);
end;
/
lov should have this command mo_global.check_access(hr.organization_id) = 'Y'

MO_GLOBAL.ORG_SECURITY
R12 Multi Org Design For Custom Tables.
Steps:
1. Create a Table in Custom Schema for multi org data.
Ex: CREATE TABLE XX_TABLE_ALL
(
num NUMBER,
name VARCHAR2 (100),
org_id NUMBER
);
Insert some data with different org_id s
2. Give the Grants to Apps Schema for above created table
GRANT ALL ON XX.XX_TABLE_ALL TO APPS
3. Connect to APPS Schema
Create a synonym named XX_TABLE_ALL in APPS schema, referring to XX.XX_TABLE_ALL
.
CREATE OR REPLACE SYNONYM APPS.XX_TABLE_ALL FOR PO.XX_TABLE_ALL;
Create another synonym named XX_TABLE in APPS, referring to XX.XX_TABLE_ALL.
CREATE OR REPLACE SYNONYM APPS.XX_TABLE FOR PO.XX_TABLE_ALL;
4. Now we can apply Row Level security to XX_TABLE, using function MO_GLOBAL.ORG
_SECURITY.
Oracle RLS will dynamically append WHERE CLAUSE similar to below
SELECT * FROM XX_TABLE WHERE EXISTS (SELECT 1 FROM mo_glob_org_access_tmp oa WHE

RE oa.organization_id = org_id)
For Applying RLS we can add policy for XX_TABLE synonym by using DBMS_RLS.ADD_PO
LICY API.
Example for add Policy with ADD_POLICY API
BEGIN
dbms_rls.add_policy ('apps', -- Schema Name
'TAB1', -- synonym name
'ORG_SEC',-- use policy_name 'ORG_SEC' standard policy
'apps', --function_schem
'MO_GLOBAL.ORG_SECURITY',--Standard MO VPD policy fun
'SELECT, INSERT, UPDATE, DELETE', -- statement_type
TRUE, -- update_check
TRUE -- Policy enable
);
END;
After creating policy for the synonym we can get data only for which org_id init
ialized in the back end by using MO_GLOBAL.SET_POLICY_CONTEXT('S', Org_id );
Example for Testing:
Run the query
SELECT * FROM XX_TABLE
(The query returns no data)
Initialize the org_id
BEGIN
MO_GLOBAL.SET_POLICY_CONTEXT('S',12);
END;
Single OU Access
org_id = sys_context( multi_org2', current_org_id )
Only data for the current operating unit is accessible. The value of sys_context
( multi_org2', current_org_id )
would have to be set to the current operating unit as described
below.
Multiple OU Access
EXISTS (SELECT 1
FROM mo_glob_org_access_tmp oa
WHERE oa.organization_id = org_id)
The user will be able to access data for any org_id which has been populated int
o mo_glob_org_access_tmp. When a session is initialized in the applications, val
ues will be populated into mo_glob_org_access_tmp for each of the operating unit
s the user has access to based on their MO: Security Profile setting.
Multi-Org Session Context
The database utility DBMS_SESSION.SET_CONTEXT(, , ) is used to initialize and se
t the Multi-Org context information for a user s session. The utility SYS_CONTEXT(
, ) is used to retrieve this data. The key context items are:
Namespace Namespace Value
multi_org access_mode S=Single, M=Multiple, A=All, X=None
multi_org2 current_org_id Operating unit org id, only applicable if access mode
is Single
For example: The following example shows how you could set the access mode or de
termine the current setting:
dbms_session.set_context( multi_org ,'access_mode ,'S );

myvar := sys_context( multi_org ,'access_mode );


dbms_output.put_line( Access Mode: ||myvar);
However, it is generally preferable to use the following wrapper functions from
MO_GLOBAL which will call the appropriate utilities to maintain the various elem
ents of the multi-org context:
Procedure: SET_POLICY_CONTEXT(p_access_mode varchar2, p_org_id number)
This procedure will set the access mode, and when applicable the current operati
ng unit context.
Procedure: SET_ORG_ACCESS(p_org_id_char varchar2, p_sp_id_char varchar2, p_appl_
short_name varchar2)
This procedure determines if the application specified has multi-org access cont
rol enabled, by querying FND_MO_PRODUCT_INIT for the application short name. If
this is enabled, and a security profile is specified (p_sp_id_char), then all or
gs the user has access to will be populated in MO_GLOB_ORG_ACCESS_TMP. If there
are more than one such org, the access method will be set to Multiple . Otherwise i
f no security profile id is specified, it will use the value of p_org_id to set
the current operating unit value and set the access mode to Single .
Procedure: INIT(p_appl_short_name varchar2)
The procedure used by the applications when starting a new session. Based on the
profile options MO: Operating Unit (ORG_ID) and MO: Security Profile (XLA_MO_SECURI
TY_PROFILE_LEVEL), this procedure calls set_org_access to establish the multi-or
g context for the session. To call this from withing SQL, the profile option con
text should have been initialized for the session.
Function: GET_CURRENT_ORG_ID
Returns the current operating unit setting. This should be null if the access mo
de is not S
Function: GET_ACCESS_MODE
Returns the current access mode value.
For Example:
1) When logging into a SQL session to set the org context as it would be for a p
articular user in a particular responsibility:
a) If you know the security_profile_id for that responsibility and user, you cou
ld call:
execute mo_global.set_org_access(null, , PA );
Security profiles are stored in PER_SECURITY_PROFILES, and the final parameter i
s the application short name of the application associated with the responsibili
ty you would be using.
b) If you do not know the security profile or operating unit profile option sett
ings for your user, responsibility and application, you could use code similar t
o the following to get this information:
declare
l_user_id fnd_user.user_id%type;
l_resp_id fnd_responsibility.responsibility_id%type;
l_appl_id fnd_application.application_id%type;
l_appl_short_name fnd_application_vl.application_short_name%type;
l_ou_value fnd_profile_option_values.profile_option_value%type;

l_sp_value fnd_profile_option_values.profile_option_value%type;
begin
select user_id into l_user_id
from fnd_user
where user_name = upper( &user_name );
select responsibility_id into l_resp_id
from fnd_responsibility_vl
where responsibility_name = ( &resp_name );
select application_id, application_short_name into l_appl_id, l_appl_short_name
from fnd_application_vl
where application_short_name = upper( &appl_short_name );
l_ou_value := fnd_profile.value_specific(
ORG_ID ,l_user_id, l_resp_id, l_appl_id);
l_sp_value := fnd_profile.value_specific(
XLA_MO_SECURITY_PROFILE_LEVEL , l_user_id, l_resp_id, l_appl_id);
dbms_output.put_line( MO: Operating Unit: ||l_ou_value);
dbms_output.put_line( MO: Security Profile: ||l_sp_value);
if l_sp_value is null and l_ou_value is null then
dbms_output.put_line( No operating unit or security profile information
found );
else
mo_global.set_org_access(l_ou_value, l_sp_value, l_appl_short_name);
end if;
exception when others then
dbms_output.put_line( Error:
end;
/

||sqlerrm);

2) To set the operating unit context to a single operating unit, you could simpl
y use:
execute mo_global.set_policy_context( S ,);
Backwards Compatibility
When running queries on multi-org objects in SQL, you can still use the old CLIE
NT_INFO settings to gather data and run queries against multi-org objects if the
profile option:
MO: Set Client_Info for Debugging (FND_MO_INIT_CI_DEBUG) is set to

Yes .

When this profile option is set to Yes and the global access mode setting is null
(as it would be in a SQL*Plus or other client session unless specifically set),
the VPD function MO_GLOBAL.ORG_SECURITY will return the following as the additio
nal where clause condition for the object:
org_id = substrb(userenv( CLIENT_INFO ),1,10)
What is MO_GLOBAL.INIT
Purpose of mo_global.init :It will check if new Multi Org Security Profile is set, to decide if new Securit
y Profile method will be used.

If the new MO security profile is set, then mo_global.init inserts one record, f
or each Organization in Org Hierarchy, in table mo_glob_org_access_tmp
What is the purpose of MO_GLOBAL.ORG_SECURITY?
The purpose of Row-Level-Security is to hide certain data[based on some conditio
ns]. RLS does so by appending a where clause to the secured object.
1. MO_GLOBAL.ORG_SECURITY is a function that returns a predicate for the WHERE C
LAUSE
2. The where clause will be appended to Table/Synonym/View for which Multi Org R
ow Level security is enabled
What is the purpose of MO_GLOBAL.SET_POLICY_CONTEXT ?
This procedure has two parameters
p_access_mode
Pass a value "S" in case you want your current session to work against Single OR
G_ID
Pass a value of "M" in case you want your current session to work against multip
le ORG_ID's
p_org_id
Only applicable if p_access_mode is passed value of "S"
R12 -> mo_global.set_policy_context('S',&org_id);
Why will I as a Apps Techie ever use MO_GLOBAL.SET_POLICY_CONTEXT ?
Lets say you wish to call an API to create invoices in ORG_ID 101. In case the A
PI does not have a parameter for Org_id, you can do the below
a. exec MO_GLOBAL.SET_POLICY_CONTEXT('S',101)
b. Call the Invoice API, which will internally read the ORG_ID from MO Current C
ontext.
From SQL*Plus, I wish to simulate login to a specific responsibility. How do I d
o this?
a. Call FND_GLOBAL.INITIALIZE
This will set your responsibility id, user_id etc
b. call MO_GLOBAL.INIT
This will read the MO pro
http://support.rysigo.com/entries/20514742-r12-oracle-applications-multiple-orga
nizations-access-control-for-custom-code-oracle-note-id-420787http://oracledelivery.wordpress.com/2009/08/07/oracle-apps-multiorg-access-contr
ol-for-custom-code/
In R.12, you have to initialize the user and use the mo_global package.
begin
fnd_global.apps_initialize (p_user_id, p_resp_id, p_resp_appl_id);
mo_global.init (p_appl_short_name);
end;

MO_GLOBAL.SET_POLICY_CONTEXT / MO_GLOBAL.ORG_SECURITY
In this article i will try to give the answer of follwoing questions.

Question
1) What is the purpose MO_GLOBAL.ORG_SECURITY
Answer:
The purpose of Row-Level-Security is to hide certain data[based on some conditio
ns]. RLS does so by appending a where clause to the secured object.
1. MO_GLOBAL.ORG_SECURITY is a function that returns a predicate for the WHERE C
LAUSE
2. The where clause will be appended to Table/Synonym/View for which Multi Org R
ow Level security is enabled
Questions
2) What is the purpose of MO_GLOBAL.SET_POLICY_CONTEXT
3) Following queries return null / No Rows.
select * from po_headers_v
select * from po_lines_v
select * from po_headers_print
select * from po_lines_print
select * from po_requisition_headers
select * from po_requisition_lines
5) In SQL-Plus how can I work against specific organization. How is it possible
in R12
Answer:
MO_GLOBAL.SET_POLICY_CONTEXT has two parameters
1. p_access_mode
Pass a value S in case you want your current session to work against
Single ORG_ID
Pass a value of M in case you want your current session to work
against multiple ORG_ID s
2. p_org_id
Only applicable if p_access_mode is passed value of S
SQL>> exec MO_GLOBAL.SET_POLICY_CONTEXT( S ,82);
In the above case, ORG_ID 101 will be assigned as current org for your session.
Internally, following code in blue will be executed by Oracle when you set your
context to single Org, dbms_session.set_context( multi_org2 , current_org_id , 101);
If the current database session is initialised for Single Org[as in above step],
then Where clause appended to object by Row-Level-Security will be
WHERE org_id = sys_context( multi_org2 , current_org_id )
Question
6) How can I simulate login to a specific responsibility in SQL*Plus
Answer
a. Call FND_GLOBAL.INITIALIZE
This will set your responsibility id, user_id etc
b. call MO_GLOBAL.INIT
This will read the MO profile option values for your responsibility/user, and wi
ll initialize the Multi Org Access.
Question
6) How can I simulate login to a specific responsibility in SQL*Plus.
Answer
You have to add ORG_ID column in your table and assign package function MO_GLOBA
L.ORG_SECURITY to the object (table/view/synonym).
https://support.oracle.com/epmos/faces/ui/km/SearchDocDisplay.jspx?_afrLoop=6336
93561043144&type=DOCUMENT&id=420787.1&displayIndex=1&_afrWindowMode=0&_adf.ctrlstate=wj86wyj1v_61

http://mahraj1.blogspot.com/2012_05_01_archive.html
Oracle Support Document 356221.1 (A Practical Methodology on Porting Reports fro
m Windows to Unix with Different Fonts) can be found at: https://support.oracle.
com/epmos/faces/DocumentDisplay?id=356221.1
Oracle Support Document 1371452.1 (E1: PRINT: Printing Languages in EnterpriseOn
e Reports) can be found at: https://support.oracle.com/epmos/faces/DocumentDispl
ay?id=1371452.1
http://oracle.ittoolbox.com/groups/technical-functional/oracle-appserver-l/print
ing-report-in-arabic-and-english-from-oracle-application-server-2056811
http://onlineappsdba.com/index.php/2007/01/02/pasta-printing-with-oracle-applica
tions-11i/
http://www.orafaq.com/forum/t/162197/149761/
https://forums.oracle.com/forums/thread.jspa?threadID=2300800
http://www.strsoftware.com/blog/oracle-ebs-r12-1-3-submit-request-delivery-optio
ns-button-ipp-print-2-of-6/
http://kiranaireddy.blogspot.com/2009/07/emailing-output-as-attachment-using.htm
l
http://unix.ittoolbox.com/groups/technical-functional/ibm-aix-l/arabic-support-n
eeded-to-print-in-aix-52-1066041
mailx -s"`date` - MyReport" theUser@mydomain.com </path/to/report/MyReport.txt