关于从基于Multi-Org的视图中查询数据的问题(轉)

来源:互联网 发布:php打开服务器本地程序 编辑:程序博客网 时间:2024/05/29 18:31

记得之前一次面视考官问过这样一个问题,在Report中如何获得基于Multi-Org的视图中的数据?
答:begin
      fnd_global.APPS_Initialize( user_id=>3070,resp_id=>50650,resp_appl_id =>20003);
    end;
考官:可以实现,但不是Oracle推荐的方法

答:在定义Cocurrent Program时定义参数P_ORG_ID,设定初始值为fnd_profile.value(‘ORG_ID’), 在报表的BeforeReport Trigger中加入下面的代码:
fnd_client_info.set_org_context(to_char(x_org_id));
考官:可以实现,但不是Oracle推荐的方法,正确的方法应当是使用用户出口函数

问:是不是像测试报表性能时那样,
在BeforeReport Trigger加入:SRW.USER_EXIT('FND SRWINIT');
在AfterReport Trigger加入:SRW.USER_EXIT('FND SRWEXIT');
报表中还要添加一个Number类型的用户参数P_CONC_REQUEST_ID
考官:正是。
注:测试报表性能时还要将Cocurrent Program定义中的Enable Trace打勾

随后总结了下,要查询得到基于Muti-Org的视图中的数据,一般有以下几种方法:
1.
begin
dbms_application_info.set_client_info(:org_id);-
end;

2.
Declare
x_org_id number;
begin
Fnd_profile.GET('ORG_ID',x_org_id);
fnd_client_info.set_org_context(x_org_id);
end;

3.
begin
fnd_client_info.setup.client_info(application_id    => 1,
                    responsibility_id   => 2,
                    user_id in number  => 3,
                    security_group_id  => 4);
end;

4.
begin
      fnd_global.APPS_Initialize( user_id=>3070,resp_id=>50650,resp_appl_id =>20003);
end;

其原理都是直接或间接的获取OU的ORG_ID后设置环境环境变量,我一般用2,4最多
重点参考Package  fnd_global,Fnd_profile,可以得到获取许多其他profile或者环境变量的方法,比如:
fnd_profile.value('GL_SET_OF_BKS_ID') from dual
fnd_profile.value('SO_ORGANIZATION_ID') from dual;
fnd_profile.value('ORG_ID');
fnd_profile.value('MFG_ORGANIZATION_ID')
FND_PROFILE.VALUE('USER_ID');
FND_PROFILE.VALUE('login_ID');
FND_PROFILE.VALUE('USERNAME');
FND_PROFILE.VALUE('CONCURRENT_REQUEST_ID');
FND_PROFILE.VALUE('RESP_APPL_ID');
FND_PROFILE.VALUE('APPL_SHRT_NAME');
我的理解是对应于Form. $PROFILE$块的字段:

以下是User Guide中对这些变量的说明
USERNAME     Your user’s current Oracle Application Object Library username.
USER_ID        Your user’s current Oracle Application Object Library user ID.
RESP_ID       Your user’s current responsibility ID.
APPL_SHRT_NAME   The short name of the application connected to your user’s current responsibility.
RESP_APPL_ID     The application ID of the application connected to your user’s current responsibility.
FORM_NAME        The name of the current form. Not available for concurrent programs.
FORM_ID          The form ID of the current form. Not available for concurrent programs.
FORM_APPL_NAME   The name of the application for which the current form is registered. Not available for concurren programs.
FORM_APPL_ID    The application ID of the application for which the current form is registered. Not available for concurrent programs.
LOGON_DATE      Your user’s logon date for the current session.
LAST_LOGON_DATEYour user’s logon date for the previous session.
LOGIN_ID        Your user’s Sign–On Audit login ID in Oracle Application Object Library.
CONC_REQUEST_ID  Instance of your running current program. You can only use this profile option in a concurrent            program. You use this profile option to fill the REQUEST_ID Who column.
CONC_PROGRAM_ID  The program ID associated with a running current program. You can only use this profile option in a       concurrent program. You use this profile option to fill the PROGRAM_ID Who column.
CONC_PROGRAM_APPLICATION_ID   The application ID associated with a running current program. You can only use this profile   option in a concurrent program. You use this profile option to fill the PROGRAM_APPLICATION_ID Who column.
CONC_LOGIN_ID    The login ID associated with a running concurrent program. You can only use this profile option in a       concurrent program. You can use this profile option to fill the LAST_UPDATE_LOGIN Who column.
CONC_PRINT_OUTPUTThe value Yes or No that you enter in the Print Output field when you register a concurrentprogram. You can use the routine afpoput() fromyour concurrent programs to change the value ofthis profile option for a particular instance of yourrunning concurrent program. This profile optiondetermines whether the concurrent managers printthe concurrent program’s output to the printer.
CONC_PRINT_STYLE  The print style of your concurrent program’soutput that you enter in the Print Style field whenyou register a concurrent program. You can usethe routine afpoput() from your concurrentprograms to change the value of this profile option

另外还要说明的是开发中经常需要获取的mfg_org_id,即库存组织Id
可以用fnd_profile.value('MFG_ORGANIZATION_ID')来获得,但是未必能得到,因为打开某些模块的Form时系统并不会给给变量赋值,直到执行Change Oranization,选择一个库存组织后才能取到。
Form中通常采用的办法是在PRE-FORM或WHEN-NEW-FORM-INSANCE  trigger中使用:fnd_org.choose_org ;并添加4个用户参数chart_of_account_id(number), org_name(char), org_code(char), org_id(number).

下表是一些和OU,库存组织相关的表和视图
表或视图说明
HR_OPERATING_UNITS
OU信息
ORG_ORGANIZATION _DEFINITIONS
库存组织信息
OE_SYS_PARAMETERS_V
库存主组织,PARAMETER_CODE = MASTER_ORGANIZATION_ID

原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 个体户怎么办对公账户 公章法人章丢失怎么办 广州买房没有社保怎么办 辞职后计生关系怎么办 广州换工作社保怎么办 学校更名了盖章怎么办 工商注册资金没有交怎么办 住公司宿舍怎么办居住证 住在公司宿舍怎么办居住证 滴滴没有的车型怎么办 假的租房合同怎么办 代注册公司被骗怎么办 公司跨区迁址怎么办 公司搬走注册地怎么办 注册公司没有房产证怎么办 公司不运营了怎么办 公司注销了账户怎么办 租户不变更地址怎么办 营业执照忘审了怎么办 工商营业执照年检过期怎么办 个体营业执照没有年报怎么办? 个体工商户一年没有申报怎么办 个体工商户逾期未申报怎么办 个体户没报税过怎么办 农业银行证书过期了怎么办 ca证书丢了怎么办 ca证书被锁怎么办 上个月忘记清卡怎么办 财务人员进入税务黑名单怎么办 社保本丢了怎么办 贷款车辆登记证书怎么办 发票薄丢了怎么办? 汽车发票丢了怎么办 税票弄丢了怎么办 交强险正本丢了怎么办 个体营业执照正本丢失怎么办 简易注销后税务怎么办 拒绝了日历邀请怎么办 老人走丢了怎么办 老人走丢找不到怎么办 没人给介绍对象怎么办