Problem while calling RFC in java
hi,
I writed a java program calling a batch input RFC. The RFC return an internal table which storing the system messages of the batch input process. My problem is:
When i debug the java program,the RFC excecuted and return the correct internal table to me.
But when i executed it not in debug mode, there is no batch input messages return to me.
My code is:
package com.hongta.com.z_delivery_bdc;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.ParameterList;
@author Administrator
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
public class ConnectRFC extends Object {
JCO.Client mConnection;
JCO.Repository mRepository;
String filePath;
String BDCLOG;
JCO.Function function;
public void Connect1() {
filePath =
"C:
Documents and Settings
Administrator.3939200975DB4C5
desktop
cigaXY2008-12-15.xml";
function = null;
try {
// Change the logon information to your own system/user
mConnection = JCO.createClient("610", // SAP client
"xxxxxx", // userid
"xxxxxx", // password
null, // language
"10.96.0.53", // application server host name
"01"); // system number
// mConnection.setAbapDebug(true);
mConnection.connect();
mRepository = new JCO.Repository("ARBsoft", mConnection);
} catch (Exception ex) {
ex.printStackTrace();
System.out.println("jco connect failed");
mConnection.disconnect();
System.exit(1);
//JCO.Table codes = null;
try {
function = this.createFunction("Z_BAPI_CONTRACT_BDC");
if (function == null) {
System.out.println(
"Z_BAPI_contract_bdc" + " not found in SAP.");
if ( mConnection != null && mConnection.isAlive()) {
mConnection.disconnect();
System.exit(1);
//function.getImportParameterList().setValue(filePath, "FILEPATH");
//function.getImportParameterList().setValue(BDCLOG, "BDCLOG");
mConnection.execute(function);
catch (Exception ex) {
//System.out.println(ex.toString());
ex.printStackTrace();
System.out.println("execute failed");
mConnection.disconnect();
System.exit(1);
JCO.Table codes = null;
codes =
function.getTableParameterList().getTable("MESSAGE");
try {
codes.firstRow();
for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
System.out.println(codes.getString("CON")" "codes.getString("MESG"));
catch(Exception ex1){
ex1.printStackTrace();
System.out.println("codes");
if ( mConnection != null && mConnection.isAlive()) {
mConnection.disconnect();
System.out.println("chenggong");
public JCO.Function createFunction(String name) throws Exception {
try {
IFunctionTemplate ft =
mRepository.getFunctionTemplate(name.toUpperCase());
if (ft == null){
return null;
return ft.getFunction();
} catch (Exception ex) {
throw new Exception("Problem retrieving JCO.Function object.");
public static void main(String[] args) {
ConnectRFC app = new ConnectRFC();
app.Connect1();
Regards,
taowenbo.
hi,
i had resolved my problem in other way.I don't upload my data using ws_upload now,but upload with table.
here is my code.Maybe helpful to somebody:
JCO.Table C_XYORDERTable;
JCO.Table C_XYORDPR_FINALTable;
public void getXyordprFinalElement(Element e) {
try {
for (Iterator i = e.getChildren().iterator(); i.hasNext();) {
Element child = (Element) i.next();
if (child.getName().equals("ORDER_ID"))
C_XYORDPR_FINALTable.setValue(child.getText(), "ORDER_ID");
else if (child.getName().equals("ID"))
C_XYORDPR_FINALTable.setValue(child.getText(), "ID");
else if (child.getName().equals("PRODUCT_ID"))
C_XYORDPR_FINALTable.setValue(
child.getText(),
"PRODUCT_ID");
else if (child.getName().equals("MATNR"))
C_XYORDPR_FINALTable.setValue(child.getText(), "MATNR");
else if (child.getName().equals("QUANTITY"))
C_XYORDPR_FINALTable.setValue(child.getText(), "QUANTITY");
C_XYORDPR_FINALTable.nextRow();
} catch (Exception ex) {
ex.printStackTrace();
Similar Messages
-
Problem while calling RFC function module in java
Hi all
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM GWHOST=<system.ab.ydydy.yyyd.com>, GWSERV=sapgw00, ASHOST=<system.ab.ydydy.yyyd.com>, SYSNR=00
LOCATION CPIC (TCP/IP) on local host
ERROR hostname '<system.ab.ydydy.yyyd.com>' unknown
TIME Mon Jun 06 14:50:25 2005
RELEASE 640
COMPONENT NI (network interface)
VERSION 37
RC -2
MODULE ninti.c
LINE 332
DETAIL NiPGetHostByName2: hostname '<system.ab.ydydy.yyyd.com>' not found
SYSTEM CALL gethostbyname_r
COUNTER 1
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1098)
at com.sap.mw.jco.JCO$Client.connect(JCO.java:2983)
at MyProject.Bapi2.<init>(Bapi2.java:43)
at MyProject.Bapi2.main(Bapi2.java:231)
Pl help me
pradeepHi
This is my code....
Created on Jun 2, 2005
To change the template for this generated file go to
Window>Preferences>Java>Code Generation>Code and Comments
package MyProject;
@author pradeep
To change the template for this generated type comment go to
Window>Preferences>Java>Code Generation>Code and Comments
import com.sap.mw.jco.*;
public class Bapi2 extends Object {
JCO.Client mConnection;
JCO.Repository mRepository;
public Bapi2() {
try {
// Change the logon information to your own system/user
mConnection =
JCO.createClient("122", // SAP client
"<pradeep>", // userid
"*****", // password
"EN", // language
"<abc11.aa.abc23.company.com>", // application server host name
"<00>");//system no
mConnection.connect();
mRepository = new JCO.Repository("HLL", mConnection);
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
JCO.Function function = null;
JCO.Table codes = null;
try {
function = this.createFunction("BAPI_COMPANYCODE_GETLIST");
if (function == null) {
System.out.println("BAPI_COMPANYCODE_GETLIST" +
" not found in SAP.");
System.exit(1);
mConnection.execute(function);
JCO.Structure returnStructure =
function.getExportParameterList().getStructure("RETURN");
if (! (returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S")) ) {
System.out.println(returnStructure.getString("MESSAGE"));
System.exit(1);
codes =
function.getTableParameterList().getTable("COMPANYCODE_LIST");
codes.setRow(2);
codes.deleteRow();
codes.deleteRow(5);
codes.appendRow();
codes.setValue("XXXX", "COMP_CODE");
codes.setValue("Does not exist", "COMP_NAME");
codes.appendRows(2);
codes.setValue("YYYY", "COMP_CODE");
codes.setValue("Does not exist either", "COMP_NAME");
codes.nextRow();
codes.setValue("ZZZZ", "COMP_CODE");
codes.setValue("Nor does this", "COMP_NAME");
for (int i = 0; i < codes.getNumRows(); i++) {
codes.setRow(i);
System.out.println(codes.getString("COMP_CODE") + '\t' +
codes.getString("COMP_NAME"));
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
try {
codes.firstRow();
for (int i = 0; i < codes.getNumRows(); i++, codes.nextRow()) {
function = this.createFunction("BAPI_COMPANYCODE_GETDETAIL");
if (function == null) {
System.out.println("BAPI_COMPANYCODE_GETDETAIL" +
" not found in SAP.");
System.exit(1);
function.getImportParameterList().
setValue(codes.getString("COMP_CODE"), "COMPANYCODEID");
mConnection.execute(function);
JCO.Structure returnStructure =
function.getExportParameterList().getStructure("RETURN");
if (! (returnStructure.getString("TYPE").equals("") ||
returnStructure.getString("TYPE").equals("S") ||
returnStructure.getString("TYPE").equals("W")) ) {
System.out.println(returnStructure.getString("MESSAGE"));
JCO.Structure detail =
function.getExportParameterList().
getStructure("COMPANYCODE_DETAIL");
System.out.println(detail.getString("COMP_CODE") + '\t' +
detail.getString("COUNTRY") + '\t' +
detail.getString("CITY"));
catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
mConnection.disconnect();
public JCO.Function createFunction(String name) throws Exception {
try {
IFunctionTemplate ft =
mRepository.getFunctionTemplate(name.toUpperCase());
if (ft == null)
return null;
return ft.getFunction();
catch (Exception ex) {
throw new Exception("Problem retrieving JCO.Function object.");
public static void main (String args[]) {
Bapi2 app = new Bapi2();
This is the error i'm getting...
com.sap.mw.jco.JCO$Exception: (102) RFC_ERROR_COMMUNICATION: Connect to SAP gateway failed
Connect_PM GWHOST=<abc11.aa.abc23.company.com>, GWSERV=sapgw00, ASHOST=<abc11.aa.abc23.company.com>, SYSNR=00
LOCATION CPIC (TCP/IP) on local host
ERROR hostname '<abc11.aa.abc23.company.com>' unknown
TIME Mon Jun 06 17:15:12 2005
RELEASE 640
COMPONENT NI (network interface)
VERSION 37
RC -2
MODULE ninti.c
LINE 332
DETAIL NiPGetHostByName2: hostname
'<abc11.aa.abc23.company.com>' not
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.nativeConnect(Native Method)
at com.sap.mw.jco.rfc.MiddlewareRFC$Client.connect(MiddlewareRFC.java:1098)
at com.sap.mw.jco.JCO$Client.connect(JCO.java:2983)
at MyProject.Bapi2.<init>(Bapi2.java:45)
at MyProject.Bapi2.main(Bapi2.java:233)
Thx
PRadeep -
Problem while calling servlet from java bean
I am trying to call a servlet from java bean in cep.
My java bean:
package com.bea.wlevs.example.algotrading;
import com.bea.wlevs.ede.api.StreamSink;
import com.bea.wlevs.example.algotrading.event.MarketEvent;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
public class MarketEventBean implements StreamSink {
String s=null;
public void onInsertEvent(Object event) {
if (event instanceof MarketEvent) {
MarketEvent marketEvent = (MarketEvent) event;
try {
JAXBContext cxt = JAXBContext.newInstance(MarketEvent.class);
Unmarshaller unmarsh = cxt.createUnmarshaller();
StringReader strReader = new StringReader(marketEvent.getString_1());
MarketEvent obj = (MarketEvent) unmarsh.unmarshal(strReader);
s=obj.getSymbol();
System.out.println("data: " + s);
} catch(Exception e) {
e.printStackTrace();
try {
System.out.println("test1");
URL url = new URL("http://172.18.21.94:7001/AppServletrecv-Model-context-root/ReceiveServlet");
URLConnection conn = url.openConnection();
System.out.println("test2");
conn.setDoOutput(true);
System.out.println("test3");
BufferedWriter out =
new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
out.write("symbol="+s);
System.out.println("test4");
out.flush();
System.out.println("test5");
out.close();
System.out.println("test6");
BufferedReader in =
new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
System.out.println("test7");
String response;
while ( (response = in.readLine()) != null ) {
System.out.println( response );
in.close();
catch ( MalformedURLException ex ) {
// a real program would need to handle this exception
catch ( IOException ex ) {
// a real program would need to handle this exception
My servlet code:
package model;
import javax.servlet.http.HttpServlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ReceiveServlet extends HttpServlet {
private final static String _SYMBOL = "symbol";
public void doPost(HttpServletRequest request, HttpServletResponse response) {
* Get the value of form parameter
// private final static String USERNAME = "username";
String symbol = request.getParameter( _SYMBOL );
* Set the content type(MIME Type) of the response.
response.setContentType("text/html");
* Write the HTML to the response
try {
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title> A very simple servlet example</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello " + symbol +"</h1>");
out.println("</body>");
out.println("</html>");
out.close();
} catch (IOException e) {
Web.xml:
<?xml version = '1.0' encoding = 'windows-1252'?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
<servlet>
<servlet-name>ReceiveServlet</servlet-name>
<servlet-class>model.ReceiveServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ReceiveServlet</servlet-name>
<url-pattern>/ReceiveServlet</url-pattern>
</servlet-mapping>
</web-app>
My servlet is running in weblogic server.
But when I am running this program in weblogic server side there is no log.
Edited by: 856272 on Jun 23, 2011 6:43 AMI would run both sides in a debugger and see what code is getting invoked
-
Error while calling RFC when using BSP Web Interface
Hi,
we have a problem with the Authorization when we use an Web Interface for BSP. We have assigned all roles to the user which were mentioned in the SAP standard documentation:
R_AREA
R_METHOD
R_PACKAGE
R_PARAM
R_PLEVEL
R_PM_NAME
R_PROFILE
R_STS_PT
R_STS_SUP
R_WEBITF
S_RS_ADMWB
S_RS_AUTH
S_RS_COMP
S_RS_COMP1
S_RS_DAS
S_RS_ICUBE
but we still get the error message: "Error while calling RFC".
When using a user with SAP_ALL, it works.
What can we do?
Thx for your time.
JoergActually that's surprising - because BSP (Business Server Pages) and RFC (Remote Function Call) are not related; they use totally different transport protocols (http vs. RFC). Even if an BSP application is calling a function module remotely (acting as RFC client) no authorizations for S_RFC are required - in the calling system (but in the called system, i.e. the RFC server).
Since assigning SAP_ALL seems to "cure" the problem, it seems to be an authorization issue, indeed. In that case it makes sense to use the authorization trace (ST01 - notice: that's specific to one single ABAP application server; you might have to activate the trace on multiple instances) to find out which authorizations are checked / demanded. -
Sample Java code and detail to call RFC from Java clas developed in Eclipse
Hi All,
I am new to Java. I have downloaded Eclipse IDE and planning to use for developing Java application to send data to SAP by calling RFC JCO Interface.
I need a sample java code/tutorial step by step to create Java class for simple example to call RFC from Java.
I have downloaded SAPJCO3 from service market place.
Kindly help me to send steps involved to configure for JCO with my Eclipse with JCO.
Thanks in advance.
SharmaHi Sharma,
Please have a look at [Example: Using Generated Proxies to Call Function Modules |http://help.sap.com/saphelp_nw04/helpdata/en/b6/55e3952a902447847066a0df27b0d6/content.htm]
JCo Exceptions : http://help.sap.com/saphelp_nw70ehp1/helpdata/en/f6/daea401675752ae10000000a155106/content.htm
Hope it will helps
Regards
Arun -
Problem while Calling a CGI pgm From Java with code sample
Hey guys,
I am calling a CGI program from java servlet, while calling cgi program I am passing encoded(Base64) content via post process,
My problem is the encoded data is not posted as expected, the encoded data is corrupting. But when I send encoded data in a text file, cgi program is perfectly decoding and working fine.
Here I am doing Base64 encoding as per requirement, I cannot avoid this encoding.
My doubt is about OutputStreamWriter constructor argument , In OutputStream Constructor I am passing one argument is OutputStream object and another argument is encoding type. I tried with ASCII, US-ASCII & UTF-8 .
My code is as follows, please help me to resolve this issue.
URL url = new URL("CGI server path");
URLConnection urlConnection = url.openConnection();
urlConnection.setDoOutput(true);
OutputStream os = urlConnection.getOutputStream();
BufferedOutputStream buffer = new BufferedOutputStream(os);
OutputStreamWriter writer = new
OutputStreamWriter(buffer, "US-ASCII");
writer.write(encodedPDF-Content);
writer.write("\r\n");
writer.flush();
writer.close();
here encodedPDF-Content is String and it's size is 9565 bytesWhenever you read something in java into string (with Reader implementation) it expects source to contain text in encoding you specified. It then decodes it and makes 16 bit unicode string from it. Whenever you store string using Writers it does reverse operation with specified encoding (may be different than this which you used to read source) and stores text as a sequence of bytes made of 16 bit unicode string. So, passing text back and forth between programs with the help of files or I/O you can make mistake at both reading and writing encoding. Check for it.
Now, when C programm or other application reads file it may take another assumptions about encoding or may even completly ignore it and read source as a binary file. Then, if you have a source text as a file and have to pass it to other application never do it using Reader/Writer. User raw InputStream/OutputStream instead what will preserve all information unchanged.
here encodedPDF-Content is String and it's size is 9565 byteHow id you get this info? String.length() gets you how many chars is in it, it will be half the number of bytes. If you see your input file beeing 9565 bytes long, see my above statements. -
RFC call having problem while calling from webdynpro
Hi ,
I am facing a strange problem .In my webdynpro i have a RFC function module . the structure is like this.
Loop.
<GET current system>.
TRY.
call <RFC FUNCTION MODULE> DESTInation <own system> .
ENDTRY.
ENDLoop
With in the Function module we have created a BDC seesion.
Here the loop is running for 10 times .for the first time it is the rfc call is perfect and a session is created in sm35.
For the second loop run the system is going to hang.and when i checked sm35 the next day 1 session is created (for the second loop)
Like this the session are created in different days .And the session created times are like00:00:04,00:00:08 etc.
I have checked if any hold time is there for the session but there is noting like this .
And i digged more and checked in SM50 there the call is running in background and it is connected some other system though i have given the target system as own system.
please advice me about this and how to find the root cause for this.
thanksThanks for your reponse .
Here the problem is it has already been developed now the Bug is the function call is still running and the sessions created as
below
17.06.2010 00:00:30 SAPMSSY1
17.06.2010 00:00:28 SAPMSSY1
16.06.2010 00:00:36 SAPMSSY1
15.06.2010 01:21:46 SAPMSSY1
15.06.2010 00:59:33 SAPMSSY1
15.06.2010 00:01:06 SAPMSSY1
Now teh problem is why the sessions are not created at the same time i executed it.ie,on 11:06:2010.
so,please let me know why is call is taking that much long time .(it is very rare for RFC call for such a long time ). -
Error while calling RFC adapter(FILE-XI-RFC scenario)
Hi,
I am trying for FILE-XI-RFC scenario. I am getting the following error. I have checked in message monitoring. The error is coming while calling the RFC adapter. Can any body tell what problem is this?
Regards,
Dhana
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
- <!-- Call Adapter
-->
- <SAP:Error xmlns:SAP="http://sap.com/xi/XI/Message/30" xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" SOAP:mustUnderstand="">
<SAP:Category>XIServer</SAP:Category>
<SAP:Code area="INTERNAL">AE_DETAILS_GET_ERROR</SAP:Code>
<SAP:P1>af.f23.sofd00001530a</SAP:P1>
<SAP:P2 />
<SAP:P3 />
<SAP:P4 />
<SAP:AdditionalText>2: Unable to find URL for Adapter Engine af.u7a.us4296</SAP:AdditionalText>
<SAP:ApplicationFaultMessage namespace="" />
<SAP:Stack>Error while reading access data (URL, user, password) for the Adapter Engine af.f23.sofd00001530a</SAP:Stack>
<SAP:Retry>M</SAP:Retry>
</SAP:Error>Hi,
I did SLD check.
The status says 'Summary: Connection to SLD works correctly'.
But it fails while checking the access to XI profile.
Here is the status
Summary: Connection to SLD works correctly
Now checking access to the XI Profile
Properties of RFC destination LCRSAPRFC
RFC host:
%%RFCSERVER%%
program id: LCRSAPRFC_DZ1
gateway host:
gateway service:
Testing the RFC connection to the SLD java client...
RFC ping returned exception with message:
/ CPIC-CALL: 'ThSAPOCMINIT' : cmRc=2 thRc=679#Transaction program not registere -
Date format while calling RFC??
Hi all,
Do we need to format date in WDJ while calling a RFC function module??
I am trying to populate with the code.
import java.sql.Date;
Date payDate;
payDate = wdContext.currentContextElement().getSelectedPayDate();
incInput1.setPay_Date(payDate);
and i am getting the following error
java.lang.arrayindexoutofboundsexceptio.
at com.sap.mw.jco.JCO$MetaData.getType(JCO.java10179)
at com.sap.aii.proxy.framework.core.jcobasetypedata.selelementvalue(jcobasetypedata.java :731)
i got this error when i added a new date paramter to my FM and reimported the model pls. gimme ur suggestions.
Thanks,
Srini..Hi Ganga,
I did every thing you said already, but still some thiing is going wrong.. and i am not facing any nullpointer exception it has a date value..
the following is the error trace.
[code]java.lang.ArrayIndexOutOfBoundsException
at com.sap.mw.jco.JCO$MetaData.getType(JCO.java:10179)
at com.sap.aii.proxy.framework.core.JcoBaseTypeData.setElementValue(JcoBaseTypeData.java:731)
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setAttributeValueAsDate(DynamicRFCModelClass.java:578)
at com.peabodyenergy.compensationcommunication.Zhr_Get_Incentive_Data_Input.setPay_Date(Zhr_Get_Incentive_Data_Input.java:237)
at com.sap.xss.hr.ecm.review.VEcmReviewView.printIncentiveLetter(VEcmReviewView.java:305)[/code] -
Hi all WebDynpro Gurus
I am using EP7.
I am developing an WD application for KM functionality in which I need to call RFC from backend. I followed the "<b>Creating WD application accessing ABAP function</b>" example.
But when I executed the application I got following exception.
<i><b>Root Cause</b>
The initial exception that caused the request to fail, was:
com.sap.lcr.api.cimclient.CIMClientException: java.net.MalformedURLException: URL must have a host part
<b>Correction Hints</b>
Accessing the System Landsape Directory (SLD) failed. Depending on the concrete reason (see root cause) check the following:
is the SLD Supplier in the J2EE engine configured correctly? See the SLD documentation for more details about the SLD and about how to configure it.
are all JCO destinations maintained correctly? Use the preinstalled Web Dynpro Content Admin application to check/edit the destination. Use the Ping and Test functions of the Content Admin to verify that each destination is properly configured.</i>
I checked JcO connections in the webdynpro content admin. There the status is unknown and create tabs are disabled.
I checked the SLD connections in content admin , the entries are as below:
<b>Host name : blank
Port: -1
User: blank
Url: http://.-1/sld</b>
Where could i configure these SLD settings and what should be the new entries ?
I dont have permission to view WebDynpro console.
Please help me out.Vinod,
Claim: "Hello, World" application with WD and RFC is the "Hello, World" application with most complex configuration.
Prove:
1. You need to run http://host:port/sld and import CIM context
2. You need to add technical WebAS ABAP systems to SLD (same URL)
3. You need to run Visual Administrator and setup SLD connection parameters (host, port, user, password)
4. You need to (re)deploy your WD application
5. You need to run web-based WebDynpro Content Administrator and configure JCO connections.
Fortunately, [1]-[4] is necessary only ones per server, [5] is necessary per every application.
Valery Silaev
SaM Solutions
http://www.sam-solutions.net
P.S. After I'd started working with XI I understood that procedure described above is not complex at all -
Call RFC from java (j2ee) / call to j2ee from R/3
hello
i´ve browsed the forum for some time to find how to:
1.) call ejb from r/3 system via rfc
2.) call rfc enabled function modules on r/3 from within an j2ee enviroment
but i didn´t quite get it, because i was a bit confused about all the mentionend techniques
what i found out about
1.) use ejb (session bean) and jndi; configure RFC-Engine Service (we use sap webas)
2.) use jco / jca
(or all rfc enables rfm´s are available as web service, but didn´t find anything about this)
so my question:
are these the preferred techniques to connect j2ee (webAS) <-> r/3; if not are there any others, maybe easier methods?
and last but not least: are there any good online tutorials for this topic?
thanks in advance
franzJust as a short partial reply.
The generic Java --> RFC method is JCO (it will work on older versions as well), you can think of it as a JDBC driver where R/3 is the database, it behaves very similar in many ways.
EJB development on SAP WAS is really not any different from EJB development on any other J2EE server. The deploy tool is superb. very easy to use and the JNDI registry, etc. are standard stuff...
ABAP to EJB calls, haven't looked at this in over a year now, but back then we did a Proof Of Concept based on information at http://help.sap.com and it did work indeed. The only thing was back then that you needed to do a few tweaks to get it to work properly.
As mentioned above, look at the JCO examples and then you can ask more specific questions once you get stuck.
Good Luck!
Cheers,
Kalle -
Hi
How can I to use java procedure and call RFC for to access tables of SAP ?
Thank YouRFC? That term in the IT environment usually means "+Request For Comments+" and refers to Internet protocol and usage standards.
Do you perhaps means RPC (Remote Process/Procedure Calls)? Or something else?
Also, SAP is a company. Not a product. SAP has a product called R3. This runs inside a database.
Connecting from Java to a database typically requires nothing more than a JDBC driver. So why can't you use a JDBC driver and need to call the database (and access tables) using another method? -
Problem when call rfc using function control
i try to call rfc using functin control but error "wdtfuncs error '800a03eb' Fail to call Remote Function Module" be popuped.
my code like that:
Set objSAPFunction = Server.CreateObject("SAP.Functions")
Set objSAPFunction.Connection = objSAPConn.NewConnection
IsLogOnSAP = False
If objSAPFunction.Connection.Logon(1, True) Then
IsLogOnSAP = True
'Upload Cancel Invoice
Set objFunc = objSAPFunction.Add("ZRFC_SD_BILLINGDOC_GET1")
Set objISGR1 = objFunc.exports("DOCUMENT")
Set objISGR2 = objFunc.exports("COMPANYCODE")
Set objISGR3 = objFunc.exports("YEAR")
set objOSGR1 = objFunc.imports("NETVALUE")
set objOSGR2 = objFunc.imports("CURRENCY")
set objOSGR3 = objFunc.imports("DATE")
set objOSGR4 = objFunc.imports("CUSTOMERCODE")
set objOSGR5 = objFunc.imports("CUSTOMERNAME")
objISGR1.value = cstr(doc)
objISGR2.value = cstr(companycode)
objISGR3.value = cstr(year)
bResult = objFunc.Call <<<<< Error
GetDataFromSAP = Array(cstr(objOSGR1),cstr(objOSGR2),cstr(InvDateFormat(objOSGR3)),cstr(objOSGR4),cstr(objOSGR5))
If IsLogOnSAP Then
objSAPFunction.Connection.Logoff
End If
End If
These code can run on the A machine, but do not run on the B machine. And both two machines have been installed SAP FrontEnd.
which problem about it?To change all definition of parameters of the function from type to like may be solution.
-
Calling RFCs in Java WebDynpro
Hello Experts,
I'm new to WebDynpro. I'm a novice at best and have just learned the basics. I'll probably be asking a lot of questions about this soon. Here is one problem I recently encountered:
I managed to call RFCs from R/3 using a user input and then another one by using one field retrieved from the first called RFC. Now i have to call a BAPI recursively from the data I got from the 2nd RFC that I called.
Here is the code so far:
public void executeBapi_Network_Getdetail_Input( )
//@@begin executeBapi_Network_Getdetail_Input()
//$$begin Service Controller(246259973)
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try
BigDecimal plannedCost = new BigDecimal(0);
for (int i=0; i<wdContext.nodeZps_Fm_Get_Network_Num_Input().nodeNetworks().nodeEx_Networks().size(); i++) {
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Network(false);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Network_Activity(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Relation(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Activity_Element(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Activity_Milestone(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Component(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setNumber(
wdContext.nodeZps_Fm_Get_Network_Num_Input().nodeNetworks().nodeEx_Networks().getEx_NetworksElementAt(i).getAufnr());
wdContext.currentBapi_Network_Getdetail_InputElement().modelObject().execute();
wdContext.nodeNetworkDetails().invalidate();
plannedCost.add(wdContext.nodeBapi_Network_Getdetail_Input().nodeNetworkDetails().nodeE_Network().getE_NetworkElementAt(i).getPlanned_Cost());
sorry if this is totally wrong. I'm totally a newbie here.
Hoping for your kind and helpful responses.
Cheers,
AlfonsoHi Alfonso,
Can you please try this code:
IWDMessageManager manager = wdComponentAPI.getMessageManager();
try
BigDecimal plannedCost = new BigDecimal(0);
// Initializing a IWDNode to make code more readable and clean
IWDNode nodeEx_Networks = wdContext.nodeZps_Fm_Get_Network_Num_Input().nodeNetworks().nodeEx_Networks();
// I have initialized the int variable because you should never calculate the size() in for loop.
// It is major performance hit.
int size = nodeEx_Networks.size();
for (int i=0; i<size; i++) {
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Network(false);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Network_Activity(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Relation(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Activity_Element(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Activity_Milestone(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setI_Without_Component(true);
wdContext.currentBapi_Network_Getdetail_InputElement().setNumber(nodeEx_Networks.getEx_NetworksElementAt(i).getAufnr());
wdContext.currentBapi_Network_Getdetail_InputElement().modelObject().execute();
// WHY IS THIS INVALIDATE DONE.. WHICH IS THIS NODE???
wdContext.nodeNetworkDetails().invalidate();
IWDNode nodeE_Network = wdContext.nodeBapi_Network_Getdetail_Input().nodeNetworkDetails().nodeE_Network();
int sizeNetwork_Getdetail = nodeE_Network.size();
for (int i = 0; i < sizeNetwork_Getdetail; i++) {
plannedCost.add(nodeE_Network.getE_NetworkElementAt(i).getPlanned_Cost());
// Now you can check the plannedCost by printing it using the manager you have initialized above.
I hope this solves your issue. If you have any further issue please revert back.
Thanks and Regards
Pravesh -
Hi people,
I have developed a function module in R/3 system and wants to access it in BW system. While checking syntax, it do not give any error. But when I try to execute the function module in BW, I get short dump saying please check the name of the Function Module in SE37.
The call of RFC is like :
CALL FUNCTION 'ZFM_POUSR' DESTINATION dest
IMPORTING
table = itab
EXCEPTIONS
system_failure = 1
communication_failure = 2
cx_sy_dyn_call_illegal_type = 3
OTHERS = 4.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Please suggest solution.
Thanks in Advance.
NitinHi,
http://help.sap.com/saphelp_nw04/helpdata/en/13/90a594a1ab0841bbb731bdec1a7fd7/content.htm - check this link for handling exception when calling RFCs
call the function like below
data: list like UINFO occurs 0 with header line .
CALL FUNCTION 'TH_USER_LIST' destination <dest>
TABLES
list = list
exceptions
communication_failure = 1
system_failure = 2 .
if sy-subrc ne 0 .
handle error here
endif .
<b>Reward points</b>
Regards
Maybe you are looking for
-
On my iTouch, I have 3 exercise bike workouts. All 3 play perfectly on my computer and my iTouch. However, only 2 of them play all the way through on Apple TV. The third one starts to play, and then every few minutes stops and starts buffering for
-
Dialer not connecting to campaign manager
Hello, I have the dialer not connecting to campaign manager and showing the following: 10:00:50 Trace: Attempting EMT connection to computer [172.16.200.82/172.16.200.82], port [40032] 10:00:51 Trace: Unable to establish an EMT connection: 10
-
Why is Photoshop CS4 so slow?
Hi, I know there's probably a lot of talk on this - there is doing google searches. I recently upgraded to CS4. All other programs are great (ID, DW, etc.) but Photoshop... I'm ready to go back to Photoshop CS3. When I turn the guides on and off it l
-
Automator-creating actions for printing
I would like to create an automator action for printing in preview. When printing, I have several print profiles set up based on black and white, color, etc. I also send those profiles to different trays when I print to my multifunction printer. For
-
Photoshop 7 and camera raw....help
I've been trying for months to get camera raw running in photoshop 7 but to no avail. Help please.