28 August 2013

OAF Page to Upload Files into Server from local Machine

OAF Page to Upload Files into Server from local Machine

File > New > General > Workspace Configured for Oracle Applications
File Name – PrajkumarFileUploadDemo

Automatically a new OA Project will also be created

Project Name -- FileUploadDemo
Default Package -- xxcmn.oracle.apps.fnd.fileuploaddemo

2. Create a New Application Module (AM)
Right Click on FileUploadDemo > New > ADF Business Components > Application Module
Name -- FileUploadAM
Package -- xxcmn.oracle.apps.fnd.fileuploaddemo.server
Check Application Module Class: FileUploadAMImpl Generate JavaFile(s)

3. Create a New Page
Right click on FileUploadDemo > New > Web Tier > OA Components > Page
Name -- FileUploadPG
Package --  xxcmn.oracle.apps.fnd.fileuploaddemo.webui

4. Select the FileUploadPG and go to the strcuture pane where a default region has been created

5. Select region1 and set the following properties --

Attribute
Property
ID
PageLayoutRN
AM Definition
xxcmn.oracle.apps.fnd.fileuploaddemo.server.FileUploadAM
Window Title
Uploading File into Server from Local Machine Demo Window
Title
Uploading File into Server from Local Machine Demo


6. Create messageComponentLayout Region Under Page Layout Region
Right click PageLayoutRN > New > Region

Attribute
Property
ID
MainRN
Item Style
messageComponentLayout


7. Create a New Item messageFileUpload Bean under MainRN
Right click on MainRN > New > messageFileUpload
Set Following Properties for New Item --

Attribute
Property
ID
MessageFileUpload
Item Style
messageFileUpload


8. Create a New Item Submit Button Bean under MainRN
Right click on MainRN > New > messageLayout
Set Following Properties for messageLayout --

Attribute
Property
ID
ButtonLayout


Right Click on ButtonLayout > New > Item

Attribute
Property
ID
Submit
Item Style
submitButton
Attribute Set
/oracle/apps/fnd/attributesets/Buttons/Go


9. Create Controller for page FileUploadPG
Right Click on PageLayoutRN > Set New Controller
Package Name: prajkumar.oracle.apps.fnd.fileuploaddemo.webui
Class Name: FileUploadCO

Write Following Code in FileUploadCO processFormRequest
import oracle.cabo.ui.data.DataObject;
import java.io.FileOutputStream;
import java.io.InputStream;
import oracle.jbo.domain.BlobDomain;
import java.io.File;
import oracle.apps.fnd.framework.OAException;

public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{ super.processFormRequest(pageContext, webBean);

if(pageContext.getParameter("Submit")!=null)
{
upLoadFile(pageContext,webBean);
}
}


CODE #1 -- If Page has not deployed at instance, testing at Local Machine, use following Code
public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
{ String filePath = "D:\\temp";
System.out.println("Default File Path---->"+filePath);

String fileUrl = null;
try
{
DataObject fileUploadData = pageContext.getNamedDataObject("MessageFileUpload");

//FileUploading is my MessageFileUpload Bean Id
if(fileUploadData!=null)
{
String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");

String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
System.out.println("User File Name---->"+uFileName);

FileOutputStream output = null;
InputStream input = null;

BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
System.out.println("uploadedByteStream---->"+uploadedByteStream);

File file = new File("D:\\temp", uFileName);
System.out.println("File output---->"+file);

output = new FileOutputStream(file);
System.out.println("output----->"+output);
input = uploadedByteStream.getInputStream();

System.out.println("input---->"+input);
byte abyte0[] = new byte[0x19000];
int i;

while((i = input.read(abyte0)) > 0)
output.write(abyte0, 0, i);

output.close();
input.close();
}
}
catch(Exception ex)
{
throw new OAException(ex.getMessage(), OAException.ERROR);
}
}


CODE #2 -- If Page has been Deployed at Instance, Use Following Code
public void upLoadFile(OAPageContext pageContext,OAWebBean webBean)
{ String filePath = "/Unix Path/";
System.out.println("Default File Path---->"+filePath);

String fileUrl = null;
try
{
DataObject fileUploadData = pageContext.getNamedDataObject("MessageFileUpload");

//FileUploading is my MessageFileUpload Bean Id
if(fileUploadData!=null)
{
String uFileName = (String)fileUploadData.selectValue(null, "UPLOAD_FILE_NAME");
String contentType = (String) fileUploadData.selectValue(null, "UPLOAD_FILE_MIME_TYPE");
System.out.println("User File Name---->"+uFileName);

FileOutputStream output = null;
InputStream input = null;

BlobDomain uploadedByteStream = (BlobDomain)fileUploadData.selectValue(null, uFileName);
System.out.println("uploadedByteStream---->"+uploadedByteStream);

File file = new File(
"/Unix Path/", uFileName);
System.out.println("File output---->"+file);

output = new FileOutputStream(file);
System.out.println("output----->"+output);
input = uploadedByteStream.getInputStream();

System.out.println("input---->"+input);
byte abyte0[] = new byte[0x19000];
int i;

while((i = input.read(abyte0)) > 0)
output.write(abyte0, 0, i);

output.close();
input.close();
}
}
catch(Exception ex)
{
throw new OAException(ex.getMessage(), OAException.ERROR);
}
}


10. Congratulation you have successfully finished. Run Your page and Test Your Work










 Page has not been deployed and Used CODE #1

Before Upload the File



After Upload the File




Courtesy : https://blogs.oracle.com/prajkumar/entry/oaf_page_to_upload_files


18 July 2013

How to Generate Sample XML Data for Standard PO Report for use with XML Publisher



1. Give Core Apps user (who needs to be a Buyer) access to run the 'PO Output for Communications' concurrent request

2. Once you have your PO, do not approve it_ - leave it as incomplete

3. Go to run a new Request > PO Output for Communication

4. Enter PO Number, and set: Print Selection = New, PO Number = Incomplete PO you just created, Test=Debug

5. Submit request

6. On completion, request will error

7. View log of errored job

8. Do Tools > Copy Document to open Log in browser

9. Scroll down until you find the tag. Start copying from there (including that tag).

10. Stop copying at the


tag (just before starts...


11. Copy the selection


12. Paste the selection into a new text document, but put this in the first line:


13. At the end of the text you pasted in (last bit should say .


14. Manually type at the end of the text you pasted in.


15. Save as an XML file.


How to Generate Sample XML Data for Standard PO Report for use with XML Publisher [ID 364177.1] Ability to Edit po_standard_xslfo.xsl Using XML Publisher Desktop [ID 356596.1] Can POXPPO and POXPOPDF be Set to Call the Same Custom XML Data Source? [ID 562957.1]


Oracle Notes :



305307.1


364177.1

14 June 2013

Adding a Special Menu



a menuitem;



Begin

a := FIND_MENU_ITEM ('SPECIAL.SPECIAL15');

if (event_name = 'WHEN-NEW-BLOCK-INSTANCE') then

if (form_name = 'OEXOEORD' AND block_name = 'LINE') then

app_special2.instantiate ('SPECIAL15', 'Query Form');

SET_MENU_ITEM_PROPERTY (a, displayed, property_true);

SET_MENU_ITEM_PROPERTY (a, enabled, property_true);

end if;

end if;



if (event_name = 'SPECIAL15') then

if (form_name = 'INVIDITM') then

fnd_function.EXECUTE (function_name => 'INV_INVMATWB',

open_flag => 'Y',

session_flag => 'Y' );

end if;

end if;

12 June 2013

Orace Application Adding User and Adding Responsibility



User following PL/SQL to achieve the same,




DECLARE
l_user_id NUMBER;
l_resp_id NUMBER;
l_app_id NUMBER;
BEGIN
FND_USER_PKG.CreateUser (x_user_name => 'DEVUSER',
x_owner => NULL,
x_unencrypted_password => 'WELCOME123',
x_email_address => 'devuser@domain.com');

SELECT user_id
INTO l_user_id
FROM fnd_user
WHERE user_name = 'DEVUSER';

SELECT responsibility_id, application_id
INTO l_resp_id, l_app_id
FROM fnd_responsibility
WHERE responsibility_key = 'SYSTEM_ADMINISTRATOR';

FND_USER_RESP_GROUPS_API.
insert_assignment (user_id => l_user_id,
responsibility_id => l_resp_id,
responsibility_application_id => l_app_id,
security_group_id => NULL,
start_date => SYSDATE,
end_date => NULL,
description => NULL);

COMMIT;
EXCEPTION
WHEN OTHERS THEN
raise_application_error ( -20001, 'An error was encountered - ' || SQLCODE || ' -ERROR- ' || SQLERRM);
END;

28 May 2013

Transferring the Business Events and Subscriptions

In the source environment, where the event and its subscriptions are define, download the data as follows:

- Download business event definition
java oracle.apps.fnd.wf.WFXLoad -d apps SERVER:PORT:SID thin US filename.wfx EVENTS


example

java oracle.apps.fnd.wf.WFXLoad -d apps apps myserver.oracle.com:8068:PROD thin US DelayFlag.wfx EVENTS oracle.apps.fnd.wf.myevent.created

- Download business event subscriptions

java oracle.apps.fnd.wf.WFXLoad -d apps SERVER:PORT:SID thin US filenam.wfx SUBSCRIPTIONS oracle.apps.fnd.wf.myevent.created


adjava oracle.apps.fnd.wf.WFXLoad -d apps $APPS_PWD $MACHINE_NAME:$PORT_NUMBER:$TWO_TASK thin US adkfjdslf.wfx SUBSCRIPTIONS xxirc.oracle.apps.fnd.signon.failure


In the target instance, where you do not have access to events studio:


- Upload business event definition

java oracle.apps.fnd.wf.WFXLoad -u apps SERVER:PORT:SID thin US filename.wfx

- Upload business event subscriptions

java oracle.apps.fnd.wf.WFXLoad -u apps SERVER:PORT:SID thin US filename.wfx

11 April 2013

Need DBC Files in Oracle apps



http://SERVERNAME:8002/OA_HTML/jsp/fnd/aoljtest.jsp

Enter following information.

Oracle APPS User Name and Password, Host Name, SID

Click on "Enter AOL/J Setup Test" in the AOL/J Diagnostic Tests page

Click on "Locate DBC File"

Typically it is at $INST_TOP/appl/fnd/12.0.0/secure/.dbc in application server.

Pre R12

$FND_TOP/secure/.dbc file.




14 March 2013

How to set org context in Oracle apps R12 and 11i

How to set org context in Oracle apps R12 and 11i

Set org context in R12
The SQL command to set the ORG_ID prior to running a script is:
SQL> exec mo_global.init('AR');
exec mo_global.set_policy_context('S','&org_id');
Enter the org_id when prompted.

The procedure - mo_global.set_policy_context has two parameters
p_access_mode & p_org_id

p_access_mode
Description
S
In case you want your current session to work against SingleORG_ID
M
In case you want your current session to work against multiple ORG_IDs

          p_org_id: Only applicable if p_access_mode is passed value of "S"


If using Toad
Begin
mo_global.set_policy_context(‘S’, &org_id);
End;

Set org context in 11i:
The SQL command to set the ORG_ID prior to running a script is:
SQL> execute dbms_application_info.set_client_info(&org_id);
Enter the org_id when prompted.


If using Toad

Begin
fnd_client_info.set_org_context(&org_id);
End;


Multiple Organizations Partitioned Objects

Tables that contain Multiple Organizations data can be identified by the suffix "_ALL" in the table name. These tables include a column called ORG_ID, which partitions Multiple Organizations data by organization.

Every Multiple Organizations table has a corresponding view that partitions the table's data by operating unit. Multiple Organizations views partition data by including a DECODE on the internal variable CLIENT_INFO. This variable is set by the security system to the operating unit designated for the responsibility. It operates is a similar way to the LANGUAGE variable, which returns the language of the current session.

Note: If accessing data from a Multiple Organizations partitioned object when CLIENT.INFO has not been set (for example, from SQL*Plus), you must use the _ALL table, not the view.

SO_HEADERS_ALL, with its corresponding view SO_HEADERS, is an example of a Multiple Organizations partitioned object.