ORACLE ERP維護與開發中常用到的變數

longwansheng發表於2006-10-23

You will need to make sure that the line
SRW.USER_EXIT('FND SRWINIT');
occurs above this line (in the Before Report Trigger or in one of the parameter form triggers) to set up the correct environment.

用此方式調整正確的當前噝協h境,特別是在multi_org環境下(在報表前,報表後均要執行因有可能在噝羞^程中變數被人為改變)

[@more@]

有一些view用到org環境引數的,一般要如下設定後,才能select到記錄:

begin

dbms_application_info.set_client_info(:org_id);--如1,2,3之類的

end;

可用'FND_PROFILE.GET' function 檢視以下一些引數

取得set of book id

Select fnd_profile.value('GL_SET_OF_BKS_ID') from dual

取得master_id

select fnd_profile.value('SO_ORGANIZATION_ID') from dual;

取得當前org_id

select to_number(fnd_profile.value('ORG_ID')) from dual;

org_id = :$PROFILES$.ORG_ID;也可用此來取得,在定義報表引數時來定義

fnd_profile.value('MFG_ORGANIZATION_ID') 與上的區別

取得當前user_id

select TO_NUMBER(FND_PROFILE.VALUE('USER_ID')) from dual;

FND_GLOBAL.USER_ID 用此方式在report中有可能不好用,report中建議用上一種方式
FND_WHO.PROFILE('USERID') 又一種方式

取得當前login_id

select TO_NUMBER(FND_PROFILE.VALUE('login_ID')) from dual;

取得當前username

Declare
username varchar2(30);
begin
username := FND_PROFILE.VALUE('USERNAME');
end;

另獲取username 也可以用FND_Global.User_Name

fnd_global package可以取得一些關於當前login in使用者的資訊

取得當前request_id

select FND_PROFILE.VALUE('CONCURRENT_REQUEST_ID') from dual;

FND_REQUEST.SUBMIT_REQUEST 另一種方式

請看fnd_concurrent_requests functions

關於印表機及錯誤資訊

Resolved the problem by getting a more specific error message to appear in the log file.

used v_message: =fnd_message.get; SRW.MESSAGE('994',v_message);

This problem turned out to be the users printer profile not matching the printer assigned to the concurrent program being called.

Used nvl(userPrinter,'MOSGIEL') which didn't work as expected as

userPrinter( =FND_PROFILE.VALUE('PRINTER') ) is never null,

as if the user value is blank it defaults to the Site level profile value.

如何在當前form中應用username

1) Create a user Parameter : p_user_name 

2) In Form-Level PRE-FORM trigger add this code
:PARAMETER.P_USER_NAME := FND_PROFILE.VALUE('USERNAME');

3) On the field in which u want to display the value
open the Item Properties of the field
populate the "Defalult" property with ":PARAMETER.P_USER_NAME"

指定當前org_id

execute dbms_application_info.set_client_info(&org_id);
FND_CLIENT_INFO.SET_ORG_CONTEXT(to_char(x_org_id));
fnd_cleint_info.setup_client_info
取得當前application_id
select FND_PROFILE.VALUE('RESP_APPL_ID') from dual
如取得不到可用fnd_form  fnd_application 來取得
取得當前 responsibility.applicationshort name
FND_PROFILE.VALUE('APPL_SHRT_NAME')
可能會不支援,此為user guid 的一個錯誤

使用者所擁有的 Responsibilty

select * from FND_USER_RESP_GROUPS;

取得當前responsibility名稱

fnd_profile.value('RESP_NAME')

fnd_profile.value('RESP_ID')

如何在視窗標題處顯示位置名稱

The following solution works:

The solution involves customization to an Oracle Application form and library.

The form name is “fndscsgn.fmb” and the library name is “custom.pll”.
The form “fndscsgn.fmb” is located in apps ncaau1.0formsus and “fndscsgn.fmx” is located

in appsncafnd7.5formsus directories.The library “custom.pll” and “custom.plx”

are located in appsncaau1.0resource directory.

I)Customization to fndscsgn.fmb:
1)Save a copy of the original form “fndscsgn.fmb” and “fndscsgn.fmx”.
2)Open the form “fndscsgn.fmb” using Oracle forms designer.
3)Edit the program unit “START_RESP” as follows:
Original code:

-- Set window title
FND_MESSAGE.SET_NAME('FND','NAVIGATOR');
FND_MESSAGE.GET(navigator_name);
set_window_property('NAVIGATOR', TITLE, navigator_name || ' - '||
FND_PROFILE.VALUE('RESP_NAME'));

New code:

declare
lv_app_title varchar2(100);
lv_site_name varchar2(100);
begin
-- Set window title
FND_MESSAGE.SET_NAME('FND','NAVIGATOR');
FND_MESSAGE.GET(navigator_name);

IF fnd_profile.defined('SITENAME') = TRUE THEN
fnd_profile.get('SITENAME',lv_site_name);
lv_app_title := '';
END IF;
set_window_property('NAVIGATOR', TITLE, navigator_name || ' - '||
FND_PROFILE.VALUE('RESP_NAME')||' '||lv_app_title);
set_window_proper('ROOT_WINDOW',TITLE,'Toolbar'||' '||lv_app_title);
end;

4)Compile the form and save it.
5)Generate the form executable “fndscsgn.fmx”.
6)Copy the new form “fndscsgn.fmb” to appsncaau1.0formsus and “fndscsgn.fmx” to appsncafnd7.5formsus
directories.

II)Customization to custom.pll:
1)Save a copy of the original library “custom.pll” and “custom.plx”.
2)Open the library “custom.pll” using Oracle forms designer.



3)Edit the “custom.style” function to include the following code:

if (upper(event_name) = 'WHEN-NEW-FORM-INSTANCE') then
return custom.after;
else
return custom.standard;
end if;

4)Edit the “custom.event” procedure to include the following code:
declare
lv_app_title VARCHAR2(100);
lv_win_title VARCHAR2(100);
lv_item_id item;
lv_canvas_name VARCHAR2(50);
lv_event_window VARCHAR2(50);
lv_site_name VARCHAR2(100);
begin
IF (upper(event_name) = 'WHEN-NEW-FORM-INSTANCE') THEN
lv_item_id := find_item(name_in('system.cursor_item'));
IF not id_null(lv_item_id) THEN
lv_canvas_name := get_item_property(lv_item_id,item_canvas);
IF lv_canvas_name IS NOT NULL THEN
lv_event_window :=
get_view_property(lv_canvas_name,window_name);
IF lv_event_window != 'ROOT_WINDOW' THEN
lv_win_title :=
get_window_property(lv_event_window,TITLE);
END IF;
END IF;
END IF;
IF fnd_profile.defined('SITENAME') = TRUE THEN
fnd_profile.get('SITENAME',lv_site_name);
lv_app_title := '';
set_window_property (lv_event_window,TITLE,lv_win_title||' '||lv_app_title);
set_window_property('ROOT_WINDOW',TITLE,'Toolbar'||' '||lv_app_title);
END IF;
END IF;
end;
5)Compile the library and save it.
6)Generate the library executable “custom.plx” using Oracle forms generate.
7)Copy the new library “custom.pll” and executable “custom.plx” to appsncaau1.0resource directory.



The risk exists when Oracle patches this form.So if you loose the change then you have to

reimplement this after applying the patch.

How to Display instance Site Name on window title in Oracle Apps 10.7NCA

An excellent solution...but created problems in some of the forms. So modified the logic slightly

in the CUSTOM.EVENT procedure as folows...
(This displays the sitename in the Main window only.)

declare
lv_app_title varchar2(100);
lv_site_name varchar2(100);
Begin
IF (upper(event_name) = 'WHEN-NEW-FORM-INSTANCE') THEN
IF fnd_profile.defined('SITENAME') = TRUE THEN
fnd_profile.get('SITENAME',lv_site_name);
lv_app_title := '';
set_window_property (FORMS_MDI_WINDOW,TITLE,'Oracle Applications'||' '||lv_app_title);
END IF;
END IF;
End;

如何用只讀方式開啟特定responsibility的同一個form

In Oracle Applications, the System Administrator can grant/revoke
responsibilities to him/herself. In many organizations, it is imperative that not any one individual have such sweeping,

all-inclusive power. A simple and effective way to address this solution is to use the CUSTOM library.

The code below works against the Application Object Library user security definition screen.

It checks to see if the user has queried up his/her own record, and if
so, disables the entire responsibilities block.

PROCEDURE event(event_name VARCHAR2) IS
form_name VARCHAR2(30) := name_in('system.current_form');
block_name VARCHAR2(30) := name_in('system.current_block');
new_state number;
BEGIN
IF form_name = 'FNDSCAUS' THEN
IF event_name = 'WHEN-NEW-BLOCK-INSTANCE' THEN
IF block_name = 'USER_RESP' THEN
IF (fnd_profile.value('USERNAME') = name_in('USER.user_name')) THEN
new_state := property_false;
ELSE
new_state := property_true;
END IF;
set_block_property(block_name, insert_allowed, new_state);
set_block_property(block_name, update_allowed, new_state);
END IF;
END IF;
END IF;
END event;

儲存當前環境做完作業後再恢復以前環境

old_profile := fnd_profile.value('conc_single_thread');
fnd_profile.put('conc_signle_thread','Y');
request_id := fnd_request.submit_requests(.......)
fnd_profile.put('conc_signle_thread',old_profile);

在建立function時可用Query_Only="YES". 來達到此form只可查詢的目的

但前提為在程式中必須有此引數可用

關於appl_initaliza

There is a procedure, APPS.FND_GLOBAL.APPS_INITIALIZE that will perform exactly what you are looking to accomplish. The following is the declaration:

--
-- APPS_INITIALIZE - Setup PL/SQL security context
--
-- This procedure may be called to initialize the global security
-- context for a database session. This should only be done when
-- the session is established outside of a normal forms or
-- concurrent program connection.
--
-- IN
-- FND User ID
-- FND Responsibility ID (two part key, resp_id / resp_appl_id)
--
procedure APPS_INITIALIZE(user_id in number,
resp_id in number,
resp_appl_id in number);

Do note that this is only for database sessions that are not "normal" application sessions and should not be used in those contexts.

取得當前報表是何人產生的Select user_name from fnd_user where
user_id = (select requested_by from fnd_concurrent_requests where
reuqest_id=###)

以下為user guid 中取得

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 concurrent

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_DATE Your 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_OUTPUT The value Yes or No that you enter in the Print

Output field when you register a concurrent

program. You can use the routine afpoput() from

your concurrent programs to change the value of

this profile option for a particular instance of your

running concurrent program. This profile option

determines whether the concurrent managers print

the concurrent program’s output to the printer.

CONC_PRINT_STYLE The print style of your concurrent program’s

output that you enter in the Print Style field when

you register a concurrent program. You can use

the routine afpoput() from your concurrent

programs to change the value of this profile option

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/92289/viewspace-873201/,如需轉載,請註明出處,否則將追究法律責任。

相關文章