Upload
sampetruda
View
1.246
Download
1
Tags:
Embed Size (px)
Citation preview
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
PeopleTools Advanced Tips and TechniquesJim MarionSenior Applications Technology Consultant, ADS
© 2008 Oracle Corporation – Proprietary and Confidential
The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Program Agenda Example
• Communities and resources• PeopleTools – the extensible foundation• Extend the app server• Extend the web server• Extend Integration Broker• Extend the user interface
– IScripts– Ajax
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Communities and Resources
© 2008 Oracle Corporation – Proprietary and Confidential
mix.oracle.com
• Groups– PeopleTools– PeopleSoft– Enterprise Portal– Application specific groups
• Mingle with peers• Solicit votes for ideas• See what other customers are asking, doing, and
want to do• Post your own tips and techniques• Answer your peers questions
© 2008 Oracle Corporation – Proprietary and Confidential
Blogs
• http://jjmpsj.blogspot.com/• http://blog.greysparling.com/• IT Toolbox groups ERP > PeopleSoft• http://blogs.ittoolbox.com/peoplesoft/rob• http://xtrahot.chili-mango.net/• http://peoplesofttipster.com/• http://campus-codemonkeys.blogspot.com/• http://blogs.oracle.com/peopletools/
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
PeopleTools Foundation
© 2008 Oracle Corporation – Proprietary and Confidential
The Extensible FoundationThe “Tech Stack”
• Relational database– Programmable
• Functions, procedures, triggers• App Server
– Java VM– Native libraries
• J2EE web server– JSP/JSF– Servlets– EJB
• Web Browser
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Extend the App Server
© 2008 Oracle Corporation – Proprietary and Confidential
Extend the PeopleCode Language
• Operating system native libraries– dll’s– so’s
• Java VM– Standard Java API– Custom Java classes
© 2008 Oracle Corporation – Proprietary and Confidential
Extend the PeopleCode LanguageWhy?
• Some things are easier to do in Java– Java regular expressions versus PeopleCode String
manipulation• Take advantage of existing libraries
– Apache POI for reading binary Microsoft Excel files (integration)
© 2008 Oracle Corporation – Proprietary and Confidential
Extend PeopleCode LanguageUsing the Java API
Function ResolveMetaHTML(&html as string) returns stringLocal JavaObject &pattern;Local JavaObject &matcher;Local String &node_url;
REM ** Resolve %NodePortalURL(NODENAME) tags;&pattern = GetJavaClass("java.util.regex.Pattern")
.compile("(?i)%NodePortalURL\((\w+)\)");
&matcher = &pattern.matcher(CreateJavaObject("java.lang.String", &html));
While &matcher.find() SQLExec("SELECT URI_TEXT FROM PSNODEURITEXT WHERE MSGNODENAME
= :1 AND URI_TYPE = 'PL'", &matcher.group(1), &node_url);&html = Substitute(&html, &matcher.group(), &node_url);
End-While;End-Function;
© 2008 Oracle Corporation – Proprietary and Confidential
Extend PeopleCode LanguageCustom Java Classes
REM ** Generate MD5 checksum;
Function test_md5() Returns stringLocal JavaObject &jMD5;
&jMD5 = GetJavaClass("com.oracle.ads.peoplesoft.MD5");&sig = &jMD5.encodeString("String to encode");
End-Function;
© 2008 Oracle Corporation – Proprietary and Confidential
Access PeopleSoft from Java
• Within a PeopleSoft session (app or process scheduler server) – PeopleCode objects
• Record, SQL, Field, File, XMLDoc, etc– PeopleCode functions
• Func.SQLExec, Func.SendMail, etc– PeopleCode system variables
• Sysvar.UserId(), Sysvar.Roles() – TIP: Add peoplecode.jar to your Java IDE’s classpath
© 2008 Oracle Corporation – Proprietary and Confidential
Java Integration Scenario
• Vendor e-mails invoice in Microsoft Excel format• You need to create a voucher from that invoice• Solution
– Use Apache POI (http://poi.apache.org/) and PeopleCode objects/functions to copy spreadsheet to staging table (Java)
– Use a component interface based on VCHR_EXPRESS to create vouchers (PeopleCode)
© 2008 Oracle Corporation – Proprietary and Confidential
Java Integration ScenarioJava Component
public
}
static void processSpreadsheet(int processInstance) {//POI variable initilization, etc...// 20 insert bind valuesObject[] parms = new Object[20];parms[0] = row.getCell(0).getStringCellValue();// column 2 contains an integerParms[1] = new
Integer(row.getCell(1).getNumericCellValue().intValue());...
// use Meta-SQL to simplify retrieving SQL from// stored SQL objectFunc.SQLExec("%SQL(MYSQLOBJECT)", parms);
...
© 2008 Oracle Corporation – Proprietary and Confidential
Advantages of usingPeopleCode Data Objects from Java
• Avoid JDBC configuration, data access, authentication, etc
• Simplicity of SQLExec• Simplicity of SQL objects/cursors• Meta-SQL expansion• Avoid updating PS database directly
© 2008 Oracle Corporation – Proprietary and Confidential
Access PeopleSoft from JavaAditional References
• Enterprise PeopleTools 8.49 PeopleBook: PeopleCode API Reference > Java Class
• http://tinyurl.com/2vzv9w (links to my blog)
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Extend the Web Server
© 2008 Oracle Corporation – Proprietary and Confidential
Extensible Options
• Standard J2EE web server options– Servlet filters– JSP– JSF– Custom Servlets– CGI
© 2008 Oracle Corporation – Proprietary and Confidential
Standard Request Response Cycle...… and then ServletFilters
Web Server App Server
Request
Response
Request
ResponseClient/Browser
Web Server
ServletFilter Servlet
Request
Response
Modify Request
Modify Response
© 2008 Oracle Corporation – Proprietary and Confidential
ServletFilters
• Allow you to modify the HTTP request or response• Examples
– Authentication– Injection
• Monkeygrease– Add additional HTML/JavaScript/CSS to pages
– Compression– URLRewriting– Encryption– Encoding– Request/Response header modification
© 2008 Oracle Corporation – Proprietary and Confidential
Monkeygrease ExamplesServletFilter
• Highlight the active field– http://jjmpsj.blogspot.com/2006/09/where-am-i.html
• Keyboard navigation– http://tinyurl.com/yrwsap (links to Grey Sparling blog)
• Override CSS without customizing PeopleSoft stylesheets
© 2008 Oracle Corporation – Proprietary and Confidential
Authentication ExamplesServletFilter
• Use jCIFS to pass Windows authentication token to web server using NTLM– http://tinyurl.com/yuk8bl (links to my blog)
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Extend Integration Broker
© 2008 Oracle Corporation – Proprietary and Confidential
Integration Broker SDKCustom Connectors
• Create connectors to send Integration Broker messages to targets not covered by delivered connectors– Databases via JDBC (JDBCTargetConnector) – Other TCP/IP based protocols– Anywhere, in any electronic way
• JavaTargetConnector• ScriptTargetConnector
© 2008 Oracle Corporation – Proprietary and Confidential
Vendor Batch Integration Scenario
• Open cursor on vendor table• For each row, select row from target
– If exist, compare values• If changed, update
– If not exist, insert• How often do you run this?
– Too often for the system to handle (resource intensive) – Not often enough for the user
© 2008 Oracle Corporation – Proprietary and Confidential
JavaTargetConnectorPrototype
packageimport
public// respond to "pings"public
}// send the messagepublic
}// provide connector setup ipublic
}}
com.peoplesoft.pt.integrationgateway.targetconnector;...;
class JavaTargetConnector implements TargetConnector {
IBResponse ping(IBRequest request) throws ... {...
IBResponse send(IBRequest request) throws ... {// look up Java class handler from config and use reflection// to call registered Java class
nfo for gateway and node setupConnectorDataCollection introspectConnector() {
...
© 2008 Oracle Corporation – Proprietary and Confidential
Custom Connector Advantages
• Real time integration• Reuse PeopleSoft delivered integration points• Changes are published at save time, you don’t need
complex logic to find them.
© 2008 Oracle Corporation – Proprietary and Confidential
Custom ConnectorsCustom Connectors Documentation and Examples
• SDK location: web server’s /PSIGW/SDK directory• Java IDE configuration tips
– See /PSIGW/SDK/docs/SDK/ReadMe.txt• Contains tips on configuring your classpath
– Most important, add /PSIGW/WEB-INF/classes to your classpath
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
IScripts – The Swiss Army Knife
© 2008 Oracle Corporation – Proprietary and Confidential
What is an IScript?
• A function that can be called from a URL• http:…/EMPLOYEE/EMPL/s/WEBLIB_ADS_FB.ISCRIPT1.FieldFormula.IScript_GetFriends
• Takes no parameters and does not return a value
• Contained in a record named WEBLIB_XXXXXXXX
• Provides access to %Request and %Response
Function IScript_GetFriends() ...
End-Function;
© 2008 Oracle Corporation – Proprietary and Confidential
What can they Do?
• Custom user interfaces– Not bound to Page/Component paradigm
• Ajax/Flex/Applet request/response handlers– Serve JSON, XML, or HTML in response to Ajax requests
• Excellent for testing PeopleCode snippets• Just about anything… but choose wisely (see
disadvantages)
© 2008 Oracle Corporation – Proprietary and Confidential
IScript Examples
• Bookmarklets– Turn on session tracing– Switch the language– Switch users– Get component CREF name– Lookup component search record
• Data source for a Flex grid• Data source for an extjs Ajax grid (http://extjs.com/)
© 2008 Oracle Corporation – Proprietary and Confidential
Get Component Search RecordIScript Example
• IScript to query database• JavaScript Bookmarklet to gather parameters
© 2008 Oracle Corporation – Proprietary and Confidential
The IScript(Declare function and variables)
Function IScript_GetSearchRecname() Local string &menu = %Request.GetParameter("m");Local string &component = %Request.GetParameter("c");Local string &market = %Request.GetParameter("mk");Local string &recname;Local string &barname;Local boolean &override = True;
REM continued on next slide;
© 2008 Oracle Corporation – Proprietary and Confidential
The IScript(Continued – Query the Database)
REM continued from previous slide;
REM ** select search record name override from menu defn;SQLExec("SELECT SEARCHRECNAME, BARNAME FROM PSMENUITEM WHERE
:2 AND MARKET = :3", &menu, &recname, &barname);
If (None(&recname)) Then&override = False;REM ** select search record name from component;SQLExec("SELECT SEARCHRECNAME FROM PSPNLGRPDEFN WHERE
&component, &market, &recname);End-If;
REM continued on next slide;
MENUNAME = :1 AND PNLGRPNAME = &component, &market,
PNLGRPNAME = :1 AND MARKET = :2",
© 2008 Oracle Corporation – Proprietary and Confidential
The IScript(Continued – Write the response)
REM continued from previous slide;
%Response.SetHeader("Content-Type", "text/plain");%Response.Write("The search record is " | &recname);If (&override) Then
%Response.Write(" and is overridden on menu " | &menu | " in
End-If;%Response.Write(".");
;
bar " | &barname);
End-Function
© 2008 Oracle Corporation – Proprietary and Confidential
The Bookmarklet
javascript:(function(){var v1 = frames['Targe
// parse the menu, component, marketvar v2 = v1.match(
// parse the url componentsvar v3 = v1.match(
// open the new results windowwindow.open(v3[1] + v3[2] + 'ps
's/WEBLIB_ADS_UTIL.ISCRI' + v2[1] + '&c=' + v2[2] +
})();
tContent'].strCurrUrl;
/\/c\/([\w_]+?)\.([\w_]+?)\.([\w_]+?)\b/);
/^(https?:\/\/)(.+?\/).+?\/(.+?\/)(.+?\/)(.+?\/)/);
c/' + v3[3] + v3[4] + v3[5] + PT1.FieldFormula.IScript_GetSearchRecname?m=
'&mk=' + v2[3], 'results','width=400,height=100');
© 2008 Oracle Corporation – Proprietary and Confidential
The BookmarkletCompressed
javascript:(function(){vv2=v1.match(/\/c\/([\w_]+?)\.(v3=v1.match(/^(https?:ow.open(v3[1]+v3[2]+'pRIPT1.FieldFormula.ISc&mk='+v2[3],'results', 'wid
ar v1=frames['TargetContent'].strCurrUrl;var [\w_]+?)\.([\w_]+?)\b/);var
\/\/)(.+?\/).+?\/(.+?\/)(.+?\/)(.+?\/)/);windsc/'+v3[3]+v3[4]+v3[5]+'s/WEBLIB_ADS_UTIL.ISCript_GetSearchRecname?m='+v2[1]+'&c='+v2[2]+'
th=400,height=100');})()
© 2008 Oracle Corporation – Proprietary and Confidential
Advantages of IScripts
• Unstructured Request/Response handling– PeopleCode version of JSP/ASP– Very few rules
• Full PeopleCode/Database access• Leverage PeopleSoft security model• Great for non-UI development
© 2008 Oracle Corporation – Proprietary and Confidential
Disadvantages of IScripts
• No META-DATA• No upgrade• No component processor
– Event processing• More difficult to develop and maintain
© 2008 Oracle Corporation – Proprietary and Confidential
<Insert Picture Here>
Ajax
© 2008 Oracle Corporation – Proprietary and Confidential
Keep the User Logged InAjax Replacement for Timeout Warning
• Relevant JavaScript variables
• Clear the existing timeout and timeout warning
• Ajax request to reset timeout at warning timeout interval
• Set timeout interval low (5 min) and warning interval low (4 min)
timeOutURLwarningTimeoutMillisecondstimeoutWarningID
window.clearTimeout(timeoutWarningID);window.clearTimeout(timeoutID);
// Ajax URL that will reset the timeout on the servertimeOutURL.replace(/expire$/, "resettimeout");
© 2008 Oracle Corporation – Proprietary and Confidential
Keep the User Logged InThe JavaScript Globals
/* clear old timeout after 30 seconds* macs don't set tim*/window.setTimeout('ads_s
var ads_timeoutIntervalId;var ads_resetUrl = null;
eout until 1000 ms
etupTimeout()', 30000);
© 2008 Oracle Corporation – Proprietary and Confidential
Keep the User Logged InThe Setup Function
function ads_setupTimeout() {/* some pages don't haif(typeof(timeOutURL)
}}
ve timeouts defined */ != "undefined") {
if(timeOutURL.length > 0) {ads_resetUrl = timeOutURL.replace(/expire$/, "resettimeout");if(totalTimeoutMilliseconds != null) {window.clearTimeout(timeoutWarningID);window.clearTimeout(timeoutID);ads_timeoutIntervalId =
window.setInterval('ads_resetTimeout()',warningTimeoutMilliseconds);
}}
© 2008 Oracle Corporation – Proprietary and Confidential
Keep the User Logged InInjection Methods
• Modify the header HTML object– PeopleTools Header: PORTAL_UNI_HEADER_NNS
(potential upgrade issue) – Enterprise Portal Header:
• PAPPBR_HTMLHDR4_TOOLS• Custom HTML object
• Monkeygrease (http://monkeygrease.org) – Servlet filter that allows you to inject HTML into the
PeopleSoft response
© 2008 Oracle Corporation – Proprietary and Confidential
Pagelet Ajax ExampleFacebook (Social Networking)
• Putting it all together– Java API, Ajax UI, IScripts
© 2008 Oracle Corporation – Proprietary and Confidential
References
• Bookmarklets– http://www.subsimple.com/bookmarklets/default.asp
• Excellent tutorial, rules, and builder– http://www.bookmarklets.com/
• Ajax– http://jquery.org– http://monkeygrease.org
• Blogs with PeopleTools Tips– http://jjmpsj.blogspot.com (My blog) – http://blog.greysparling.com/– http://blogs.oracle.com/peopletools/
© 2008 Oracle Corporation – Proprietary and Confidential
© 2008 Oracle Corporation – Proprietary and Confidential
The preceding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions.The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
© 2008 Oracle Corporation – Proprietary and Confidential
© 2008 Oracle Corporation – Proprietary and Confidential