Rendering Data from a Non-SAP Data Source
To demonstrate access to a non-SAP system, I use the open source MySQL database as the external data source. However, the programming constructs from this example are valid for all JDBC-compliant databases. As with an SAP data source, you must maintain the connection parameters for third-party systems and remote databases in the portal landscape XML files.
Instead of managing a special data model and using HTMLB to output on a JSP page, this example employs the Portal Data Viewer (PDV) service of the SAP API. The PDV also provides an implementation of HTMLB, but it can render tabular data directly in the EP without JSP programming.
While you can access non-SAP systems with SAP Logon Tickets, another method to enable remote authentication from the EP is via user mapping. In this process, the portal administrator can correlate (or map) a portal user to the ID and password for a remote system. A custom table in the EP's LDAP directory server stores the mapped credentials. At runtime, the Dispatcher class can access this table via the SAP Portal Component API and retrieve the logon credentials. In the following code snippet, KEY is the destination system (here, the MySQL database) that is registered in the portal landscape:
bConn = new backend(KEY);
un = bConn.getUser();
pw = bConn.getPassword();
Once the Dispatcher class determines the mapped user name (un) and password (pw) for the portal user, you can access the database and query it via the standard connection of the DriverManager:
Connection con =
Statement std = con.createStatement();
ResultSet res = std.executeQuery("select * from my_table");
Finally, you set the result from the query (here, res) as the data source for the PDV service, which automatically renders the output in the EP:
ISource pdvSource = portalDV.createSource(request, res);
Figure 4 depicts the PDV output of the MySQL database iView. In addition to its automated rendering mechanism, the PDV service supplies a number of standard features, including column sorting, tabulation, and user personalization.
|Figure 4: The Database iView via the Portal Data Viewer |
SAP for Web-enabled, Enterprise Java AppsWho Knew?
The two examples in this article provide the simplest of introductions to portal component development for the SAP EP, but they are enough to get you started with SAP's Portal Component API and the available development tools. While SAP may not be the first name you consider when it comes to Web-enabled, enterprise applications in Java, you might be surprised what you can learn.