Professional Documents
Culture Documents
03 SAP Resource Adapter SOL
03 SAP Resource Adapter SOL
03 SAP Resource Adapter SOL
1. Development Objectives
Creating a J2EE Project and using the Common Client Interface API to make a
remote function call. The J2EE Project will contain an EAR application and a
WAR application. The Web Application will have a Servlet which will make use
of the Common Client Interface API Classes to get a list of Company Codes from
SAP R/3 function module BAPI_COMPANYCODE_GETLIST.
2. Result
As a result of the exercise you will be able to display a list of Company Codes and
Company Names.
3-1. Prerequisites
3-1 You have installed the SAP Resource Adapter file on the Web Application
Server.
3-2 You have launched the Netweaver Developer Studio.
3-3 You have selected the J2EE perspective.
SAPJRAExample
The EAR Project which
contains the web project.
SAPJRAExampleWeb
The WAR Project which
contains the Servlet which uses the
CCI API.
TestServlet
The Servlet used for the
remote function call.
}
catch (Exception ex){
out.println("Can't look up SAPJRAFactory.");
out.println(ex);
}
4-4 Get a Connection
// Step 3. Get Connection
try
{
connection = connectionfactory.getConnection();
// Print the System details.
out.println("Connection to "+
connection.getMetaData().getEISProductName()+
", "+ connection.getMetaData().getEISProductVersion() +
" with user \""+connection.getMetaData().getUserName() +
"\" created <br/><br/>");
}
catch (Exception ex){
out.println("Can't create Connection .");
}
4-5 Get a Record Factory and an Interaction
// Step 4. Create a record factory
RecordFactory recordfactory =
connectionfactory.getRecordFactory();
MappedRecord output=(MappedRecord)interaction.execute
(null,input);
ResultSet list = (ResultSet) output.get("COMPANYCODE_LIST");
4-7 Display the List in Tabular Format
while( list.next())
out.println("<tr><td>" + list.getObject(1).toString()
+"</td><td>"+list.getObject(2).toString()+
"</td></tr>");
out.println ( "</table>");
out.println ( "</table>");
4-8 Release the Connection
// Step 8. Release interaction
interaction.close();