Shipping Inquiry Details Page @ OAF
1. Create a New Workspace and Project
Right click Workspaces and click create new OAworkspace and name it as ShippingSearch. Automatically a new OA Project is also created. Name the project as ShippingInqDetails and package as Shipping.oracle.apps.fnd.ShippingInqDetails
2. Create a New Application Module (AM)
Right Click on SearchDemo > New > ADF Business Components > Application Module
Name -- SippingAM
Package -- Shipping.oracle.apps.fnd.ShippingInqDetails
3. Enable Passivation for the Root UI Application Module (AM)
Right Click on SearchAM > Edit SearchAM > Custom Properties >
Name – RETENTION_LEVEL
Value – MANAGE_STATE
Click add > Apply > OK
4. Bulid a qurey to get data regarding Shipping Inquire Details
SELECT distinct ool.ordered_item,wdd.tracking_number, ooh.cust_po_number,ooh.order_number,rct.trx_number,wdd.LAST_UPDATE_DATE,hcsua.location
,wdt.name,hcsua.attribute1,loc.POSTAL_CODE,sum(ool.SHIPPED_QUANTITY),nvl(wdd.attribute2,wdd.container_name),sum(rctl.quantity_ordered*rctl.unit_selling_price)
FROM oe_order_headers_all ooh
,oe_order_lines_all ool
,wsh_delivery_details wdd
,wsh_deliverable_trips_v wdt
,wsh_new_deliveries wnd
,wsh_delivery_assignments wda
,ra_customer_trx_all rct
,ra_customer_trx_lines_all rctl,
hz_locations loc,
hz_party_sites party_site,
hz_cust_acct_sites_all acct_site,
hz_cust_site_uses_all hcsua
WHERE ooh.header_Id=ool.header_id
AND wdd.source_header_id=ooh.header_id
AND wdd.delivery_detail_Id=wdT.delivery_detail_id
and wdd.delivery_detail_Id=wdA.delivery_detail_id
AND wda.delivery_id=wnd.delivery_id
and wdd.source_line_id=ool.line_id
AND rctl.interface_line_attribute1=to_char(ooh.order_number)
AND rctl.interface_line_attribute6=to_char(ool.line_id)
AND rctl.interface_line_attribute3=to_char(wnd.delivery_id)
AND rctl.customer_trx_id=rct.customer_trx_id
and acct_site.party_site_id = party_site.party_site_id
AND loc.location_id = party_site.location_id
and acct_site.cust_acct_site_id = hcsua.cust_acct_site_id
and ool.ship_to_org_id=hcsua.site_use_id
group by ool.ordered_item,wdd.tracking_number, ooh.cust_po_number,ooh.order_number,rct.trx_number,wdd.LAST_UPDATE_DATE,hcsua.location,wdt.name,hcsua.attribute1
,loc.POSTAL_CODE,nvl(wdd.attribute2,wdd.container_name)
order by rct.trx_number desc
6. Create a New View Object (VO)
Right click on SearchDemo > New > ADF Business Components > View Object
Name -- ShippingVO
Package -- Shipping.oracle.apps.fnd.ShippingInqDetails
In Step3 in Attributes Window select columns and shuttle them to selected list
Add Qurey in VO
In Java page Select Generate Java file for View Object Class: ShippingVOImpl and Generate Java File for View Row Class: ShippingVORowImpl
7. Add Your View Object to Root UI Application Module
Select Right click on SearchAM > Edit SearchAM > Data Model >
Select ShippingVO and shuttle to Data Model list
8. Create a New Page
Right click on Project> New > Web Tier > OA Components > Page
Name -- ShippingInqPG
Package -- Shipping.oracle.apps.fnd.ShippingInqDetails
9. Select the ShippingInqPG and go to the strcuture pane where a default region has been created
10. Select region1 and set the following properties:
ID -- PageLayoutRN
Region Style -- PageLayout
AM Definition -- Shipping.oracle.apps.fnd.ShippingInqDetails
Window Title -- Shipping Inq Page Window
Title -- Shipping Inq Details
Auto Footer -- True
11. Add a Query Bean to Your Page
Right click on PageLayoutRN > New > Region
Select new region region1 and set following properties
ID – QueryRN
Region Style – query
Construction Mode – resultBasedSearch
Include Simple Panel – True
Include Views Panel – True
Include Advanced Panel – True
12. Add a Result Data Table to your QueryRN
Select QueryRN right click > New > Region using Wizard
In BC4J Objects page, Select your ShippingAM and then select your ShippingVO1
Note – DO NOT select Use this as Application Module Definition for this region checkbox
In Region Properties page, set Region ID value to ResultsTable and Region Style to table
In view Attributes page, select attributes from Available View Attributes list and shuttle them to
Selected View Atributes list:
All Columns
In Region Items Page, you can set ID, Style and Attributes Set. Currently we are going to set only Style as messageStyledText
13. Set and verify Your Results Table Region Properties
ID – ResultsTable
Region Style – table
AM – Please Donot put any AM
Rendered – True
Records Displayed – 10
Width – 100%
User Personalization – True
14. Set or Verify Column1 Item Properties
Search Allowed -- True
Sort Allowed – ascending
Initial Sort Seqence – first
Selective Search Criteria – True
User Personalization – True
15. Set or Verify Column2 Item Properties
Search Allowed – True
Sort Allowed -- ascending
Selective Search Criteria – True
User Personalization – True
Repeate For all Columns
16. Add Button under the Qurey Region
Promt-- Export
Attributeset-- ImportExport
17. Write the Following Code on CO (Create new CO Shipping CO)
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
{
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Export")!=null)
{
//array of Vo attr names which need not be written in csv file
String ss[]={"Location","OrderNumber"};//Here RecordNumber and BatchId are the attributes of VO that you donot want in your output file
downloadCsvFile(pageContext, "shippingVO1",null, "MAX",ss); //XxescTcInterfaceStageEOVO1 is the VO instance Name
}
}
public void downloadCsvFile(OAPageContext pageContext,String shippingVO1,String file_name_without_ext,String max_size,String[] hidden_attrib_list)
{
OAViewObject v = (OAViewObject) pageContext.getRootApplicationModule().findViewObject("shippingVO1");
if (v == null)
{
throw new OAException("Could not find View object instance " + "shippingVO1"
+ " in root AM.");
}
if (v.getFetchedRowCount() == 0)
{
throw new OAException("There is no data to export.");
}
String file_name = "Export";
if (!((file_name_without_ext == null) || ("".equals(file_name_without_ext))))
{
file_name = file_name_without_ext;
}
HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();
response.setContentType("application/text");
response.setHeader("Content-Disposition","attachment; filename=" + file_name + ".csv");
ServletOutputStream pw = null;
try
{
pw = response.getOutputStream();
int j = 0;
int k = 0;
boolean bb = true;
System.out.println("inside try block");
if ((max_size == null) || ("".equals(max_size)))
{
k = Integer.parseInt(pageContext.getProfile("VO_MAX_FETCH_SIZE"));
bb = false;
}
else if ("MAX".equals(max_size))
{
bb = true;
}
else
{
k = Integer.parseInt(max_size);
bb = false;
}
//Making header
AttributeDef[] a = v.getAttributeDefs();
StringBuffer cc = new StringBuffer();
ArrayList exist_list = new ArrayList();
for (int l = 0; l < a.length; l++)
{
boolean zx = true;
if (hidden_attrib_list != null)
{
for (int z = 0; z < hidden_attrib_list.length; z++)
{
if (a[l].getName().equals(hidden_attrib_list[z]))
{
zx = false;
exist_list.add(String.valueOf(a[l].getIndex()));
}
}
}
if (zx)
{
cc.append("\"" + a[l].getName() + "\"");
cc.append(",");
}
}
String header_row = cc.toString() ;//+ "\n";
pw.println(header_row);
for (OAViewRowImpl row = (OAViewRowImpl) v.first(); row != null;row = (OAViewRowImpl) v.next())
{
j++;
StringBuffer b = new StringBuffer();
for (int i = 0; i < v.getAttributeCount(); i++)
{
boolean cv = true;
for (int u = 0; u < exist_list.size(); u++)
{
if (String.valueOf(i).equals(exist_list.get(u).toString()))
{
cv = false;
}
}
if (cv)
{
Object o = row.getAttribute(i);
if (!(o == null))
{
if (o.getClass().equals(Class.forName("oracle.jbo.domain.Date")))
{
//formatting of date
oracle.jbo.domain.Date dt = (oracle.jbo.domain.Date) o;
java.sql.Date ts = (java.sql.Date) dt.dateValue();
java.text.SimpleDateFormat displayDateFormat =
new java.text.SimpleDateFormat("dd-MMM-yyyy");
String convertedDateString = displayDateFormat.format(ts);
b.append("\"" + convertedDateString + "\"");
}
else
{
b.append("\"" + o.toString() + "\"");
}
}
else
{
b.append("\"\"");
}
b.append(",");
}
}
String final_row = b.toString() ;//+ "\n";
pw.println(final_row);
if (!bb)
{
if (j == k)
{
break;
}
}
}
}
catch (Exception e)
{
// TODO
e.printStackTrace();
throw new OAException("Unexpected Exception occured.Exception Details :" +
e.toString());
}
finally
{
pageContext.setDocumentRendered(false);
try
{
pw.flush();
pw.close();
}
catch(IOException e)
{
e.printStackTrace();
throw new OAException("Unexpected Exception occured.Exception Details :" +
e.toString());
}
}
}
18.Run the Page
(a).Enter any Value in Search
(b).Cust_po_number
(c). Click on Export Button
(d). Save the File
END
No comments:
Post a Comment