Oracle Configurator Implementation Guide Release 12.1 for Part Number E14322-03 | ![]() Contents | ![]() Previous | ![]() Next |
This appendix covers the following topics:
This chapter contains code examples that support other chapters of this document. These examples are more complete and longer than the examples provided in the rest of this document, which are often fragments. See the cited background sections for details.
The following table lists the code examples provided in this chapter.
Purpose of Example | Example |
---|---|
Pricing and ATP Callback Procedures | Example of Multiple-item Callback Pricing Procedure Example of Callback ATP Procedure |
Implementing a Return URL Servlet | Example Return URL Servlet (Checkout.java) |
You should consult these other documents for details on the tasks described in this section:
For information on how to write and compile Configurator Extensions, and on how to incorporate them into your configuration model, see the Oracle Configurator Extensions and Interface Object Developer’s Guide.
For information on how to install Configurator Extensions, see the Oracle Configurator Installation Guide.
For an explanation of building a configuration model and updating configurations, see the Oracle Configurator Developer User’s Guide.
This appendix contains minimal examples of PL/SQL procedures you might write to use the OC callback interface for pricing and ATP procedures.
See the following sections for background:
Example of Multiple-item Callback Pricing Procedure
PROCEDURE price_multiple_items (p_configurator_session_key IN VARCHAR2,
p_price_type IN VARCHAR2,
p_total_price OUT NUMBER) AS
BEGIN
update cz_pricing_structures set list_price = 3.0*seq_nbr,
selling_price = 2.0*seq_nbr,
where configurator_session_key =
p_configurator_session_key;
-- calculation using pricing table for storage
select sum(selling_price) into p_total_price from cz_pricing_structures
where configurator_session_key = p_configurator_session_key;
-- hard-coded price amount
-- p_total_price := 343.00;
END price_multiple_items;
Example of Callback ATP Procedure
PROCEDURE call_atp (p_config_session_key IN VARCHAR2,
p_warehouse_id IN NUMBER,
p_ship_to_org_id IN NUMBER,
p_customer_id IN NUMBER,
p_customer_site_id IN NUMBER,
p_requested_date IN DATE,
p_ship_to_group_date OUT DATE) IS
BEGIN update cz_atp_requests set ship_to_date = sysdate-10
where configurator_session_key
= p_config_session_key;
p_ship_to_group_date := sysdate;
END call_atp;
The first step in implementing a return URL is to register an alias name for the return URL servlet. For details, see the Oracle Configurator Installation Guide.
The section Example Return URL Servlet (Checkout.java) shows the complete source code for Checkout.java, which you can use as a template for constructing your own return URL servlet.
The Java servlet shown here obtains the value of the valid_configuration element from the configuration outputs element of the termination message and displays it in the place of the Oracle Configurator window after the end user has closed the window and saved the configuration session.
See the following sections for background:
The parts of the code that you should customize to work with a configuration output element other than valid_configuration are typographically emphasized.
Note the use of top.location in the example which causes the servlet output to replace the contents of the runtime Oracle Configurator window.
Note that this example places Checkout.java in a package myorg.myservlets, which requires the addition of path information to the following line:
out.println("top.location = \"/myorg/myservlets/Checkout?ValidConfig=" + validConfig + "\"");
For more information, see the Oracle Configurator Installation Guide section on registering a return URL servlet.
Example Return URL Servlet (Checkout.java)
package myorg.myservlets;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import oracle.apps.cz.common.XmlUtil;
import oracle.xml.parser.v2.XMLDocument;
import org.xml.sax.SAXException;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Checkout extends HttpServlet {
// Responds to the UiServlet request containing the <terminate> XML message
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String terminateString = request.getParameter("XMLmsg");
XMLDocument terminateDoc;
try {
terminateDoc = XmlUtil.parseXmlString(terminateString);
} catch (SAXException se) {
throw new ServletException(se.getMessage());
}
String validConfig = getValidConfig(terminateDoc);
System.err.println("configuration valid?: " + validConfig);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<script language=\"javascript\">");
out.println("top.location = \"/myorg/myservlets/Checkout?ValidConfig=" + validConfig + "\"");
out.println("</script>");
out.println("</html>");
}
// Responds to the secondary request for the page to replace the content frame
// containing the ValidConfig
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String validConfig = request.getParameter("ValidConfig");
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Checked Out with Valid Configuration</title></head>");
out.println("<body>");
out.println("Configuration Valid?: " + validConfig);
out.println("</body>");
out.println("</html>");
}
String getValidConfig(XMLDocument doc) {
return getTagValue(doc, "valid_configuration", null); // get element from termination msg
}
String getTagValue(XMLDocument doc, String tagName, String defaultValue) { Node n = doc.getDocumentElement();
if (n != null) {
NodeList nl = n.getChildNodes();
if (nl != null) {
for (int i = 0; i < nl.getLength(); i++) {
Node cn = nl.item(i);
if (cn.getNodeName().equals(tagName)) {
NodeList cnl = cn.getChildNodes();
if (cnl != null) {
return cnl.item(0).getNodeValue();
}
}
}
}
}
return defaultValue;
}
}
Copyright © 1999, 2010, Oracle and/or its affiliates. All rights reserved.