Showing posts with label Oracle Forms. Show all posts
Showing posts with label Oracle Forms. Show all posts

Monday, January 5, 2015

Forms: Implementing sub-functions

Oracle apps sub functions Overview:
There are two types of functions: form functions, and non-form functions. For clarity, we refer to a form function as a form, and a non-form function as a sub function, even though both are just instances of functions in the database.
Oracle Applications aggregates several related business functions into a single form. But all users should not have access to every business function in a form; Oracle Applications provides the ability to identify pieces of applications logic as subfunctions. When part of an application’s functionality is identified as a sub functions, it can be secured (i.e., included or excluded from a responsibility).

Sub function (Non-Form Function):
A non-form function (sub function) is a securable subset of a form’s functionality. Sub functions are frequently associated with buttons or other graphical elements on forms. For example, when a sub function is created for a button in a form and if the created sub function is added to the particular responsibility, then only the corresponding button will be enabled in that responsibility, otherwise (if the created sub function is not added to responsibility) the button is disabled, even if the main function is added to that responsibility, and the user will not be able to access the button.
The user can access the main function but not the sub function, if the sub function is not added to the responsibility, which means we can provide security to the part of the form functionality, using the function security mechanism through the sub function.
Diagrammatic illustration of the sub functions

Steps to implement a Sub function in a form:
1: Open Template.fmb using Oracle form builder, save it with another name(XX_SUB_FUNC.fmb) and give the module name as “XX_SUB_FUNC”.
2: Delete the following:
“BLOCKNAME” from Canvas and Data Block
“DETAILBLOCK” from Data Block
“BLOCKNAME” from Window.
3: Create window (XX_SUB_WIN), apply subclass information as “WINDOW” and give the title.
4: Give this window name in PRE-FORM trigger (Form Level) and also in APP_CUSTOM body from Program_Unit (in place of window name).
Give this window name in PRE-FORM trigger (Form Level) As Shown below

Give this window name in APP_CUSTOM (PACKAGE BODY) as below
5: Create New Canvas
6: Now create a new Data block (EMP) using Wizard or Manual, apply subclass information to the block as “BLOCK” and also apply subclass information to the items as “TEXT_ITEM”.
Click on Finish…………..until finish
7: Give the Subclass information for Block (EMP) As BLOCK
8: Create a Button(EXIT) in Canvas and write your required functionality code in when button pressed trigger.
9: Give the Subclass information for ITEM (EMPNO) as TEXT_ITEM
10: Finally move your form from our Local Machine to CUSTOM_TOP using WINSCP or any of your local tools.
11: Compile the Form using “f60gen”
In the UNIX environment, type the following command:
f60gen XX_SUB_FUNC.fmb apps/apps
12: Connect to Oracle Applications:
1. Create a Form (Navigation: Application Developer->Application-> Form)
Here give the following details and save the details.
Form =>XX_SUB_FUNC (.fmx )
Application => xxmz Custom(Custom TOP Application)
User Form Name=>Give any name
2. Create a function (Navigation: Application->function)
Here give the following details:
Description Tab:
Function name: Any Name (XX_SUB_FUNC_FUNC)
User Function Name: Any Name (XX_SUB_FUNC_FUNC)
Properties Tab:
Type: Form
Maintenance Mode Support: None
Context Dependence: Responsibility
Form Tab:

Attach User Form Name:XX_SUB_FUNC

Create Sub Function (XX_SUB_FUNC_FUNC1) below the main function
(Navigation: Application Developer=>Application=>Function)
Give the User Function Name: XX_SUB_FUNC_FUNC: EXIT (User function name: button name)


Properties Tab:

Type: Sub function
Maintenance Mode Support: None
Context Dependence: Responsibility
13: Once again Switch to Form builder open the user form and go to Form Level Trigger
“WHEN_NEW_FORM_INSTANCE” and incorporate the function
14: Write the Function ( Function name=>fnd_function.test) As
Script:
if fnd_function.test(‘XX_SUB_FUNC_FUNC1′)then
set_item_property(‘emp.exit’,ENABLED<PROPERTY_TRUE):
else
set_item_property(‘emp.exit’,ENABLED,PROPERTY_FALSE);
END IF;
15: Save it and move the form to custom top using WINSCP like tools and compile the form again
16: Switch to Oracle application:
Switch to Menu
(Navigation: Application Developer=>Application=>Menu)
Attach Main function to the Custom TOP menu
User function name: XX_SUB_FUNC_FUNC
Switch to Custom Application Responsibility (XXMZ CUSTOM)
Execute the Function (Click on the Function name)
(Function name=>sub functions)
The button will be disabled (because the sub function is added for the button and sub function is not added to the custom menu)
Switch to Application Developer Responsibility
Attach Sub function to the Custom TOP menu without giving prompt.
User sub function name: XX_SUB_FUNC_FUNC: EXIT
Again Switch Custom Application Responsibility(XXMZ CUSTOM)
Click on Function name (sub functions)
The button will be enabled (because the sub function is added to the button and also to the custom menu)

Wednesday, December 10, 2014

Forms: NAME_IN and COPY in Forms

Name_In function : 

You can reference items indirectly with the NAME_IN and COPY built-in subprograms. The NAME_IN function returns the contents of an indicated variable or item. Use the NAME_IN function to get the value of an item without referring to the item directly. 

The following two statements retruning the content of an indicated variable ('global.'||name_in('system.cursor_block')||'_active'

1)IF name_in('global.'||name_in('system.cursor_block')||'_active') = 'Y' THEN
property();

2)name_in('global.privelege') NOT IN ('A','D') then 
error menu 

Copy Procedure : The COPY procedure assigns an indicated value to an indicated variable or item. Unlike standard PL/SQL assignment, however, using the COPY procedure allows you to indirectly reference the item whose value is being set: 

3)copy('I',name_in('system.cursor_block')||'.active_status');



COPY can be used with the NAME_IN function to assign a value to an item whose name is stored in a reference variable or item: 

/* put value 'KING' in item whose name is stored in ref_item */ 
Copy('KING',Name_In('control.ref_item')); 

More in Name_In and copy 

Why Use Indirect Reference Referencing items indirectly allows you to write more generic, reusable code. By using variables in place of actual item names, you can write a subprogram that can operate on any item whose name has been assigned to the indicated variable. 
Also, using indirect reference is mandatory when you refer to the value of a form bind variable (item, parameter, global variable) in PL/SQL that you write in a library or a menu module. Because libraries, menus, and forms are separate application modules, you cannot refer directly to the value of a form item in a menu-item command or library procedure.

Wednesday, November 19, 2014

Forms: Finding Data Source of Control Blocks






FND: Submitting Oracle Reports/XMLP Reports using Forms Personalisation

Submit a concurrent request from menu item AND EXECUTE PROCEDURE
  • IF THE REPORT TYPE IS ORACLE REPORTS
1-create procedure to submit it when I called it
CREATE OR REPLACE procedure APPS.CALL_XXCSD_VEH_CHKIN(XX_INCIDENT_NUMBER IN VARCHAR2,XX_INCIDENT_NUMBER2 IN VARCHAR2,RELEASE IN VARCHAR2) AS
v_request_id VARCHAR2(100) ;
BEGIN
-- First set the environment of the user submitting the request by submitting
-- fnd_global.apps_initialize().
-- The procedure requires three parameters
-- Fnd_Global.apps_initialize(userId,responsibilityId,applicationId)
-- replace the following code with correct value as get from sql above

Fnd_Global.apps_initialize(1134,50019,512);
v_request_id := FND_REQUEST.SUBMIT_REQUEST (
'PO', -- Application short name
'XX_CUSTOM_PURCHASE_ORDER', -- Program short name
'', -- description (Not require)
'', -- start_time (start immediately)
FALSE,-- sub_request (default FALSE)
-- Next is the parameters list of ARACCPB
XX_INCIDENT_NUMBER,
XX_INCIDENT_NUMBER2,
release
);
dbms_output.put_line('Request submitted. ID = ' || v_request_id);
commit ;
exception
when others then
dbms_output.put_line('Request set submission failed - unknown error: ' || sqlerrm);
END;
2-create menu item and call the proc from it
-After selecting execute_procedure
-the argument:
='DECLARE
BEGIN
CALL_XXCSD_VEH_CHKIN('''||${item.INCIDENT_TRACKING.INCIDENT_ID.VALUE}||'''
);
END'

Note:
To get value from item from the canvas using personalization will be like this :
('''||${item.block_name.item_name.VALUE}||''')


  • IF THE REPORT TYPE IS XML PUBLISHER (ADD LAYOUT TO IT)
CREATE OR REPLACE procedure APPS.CALL_XXCSD_VEH_CHKIN(XX_INCIDENT_NUMBER IN VARCHAR2) AS
v_request_id VARCHAR2(100) ;
xml_layout boolean;
BEGIN
Fnd_Global.apps_initialize(1134,50019,512);
xml_layout := FND_REQUEST.ADD_LAYOUT('CSD','XXCSD_VEH_CHKIN_T','en','US','PDF');
v_request_id := FND_REQUEST.SUBMIT_REQUEST (

'CSD', -- Application short name
'XXCSD_VEH_CHKIN', -- Program short name
'', -- description (Not require)
'', -- start_time (start immediately)
FALSE,-- sub_request (default FALSE)
-- Next is the parameters list of ARACCPB
'402'
);
dbms_output.put_line('Request submitted. ID = ' || v_request_id);
commit ;
exception
when others then
dbms_output.put_line('Request set submission failed - unknown error: ' || sqlerrm);
END;


******************end**********************

Forms: Hidden methods to Query in Forms

#  between 1 and 90000
# is null
# >=90000
# in (10001,1)

# like 'AB%'