on 12-31-2008 7:47 AM
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,
calling a bapi from java application u can try this
http://help.sap.com/saphelp_46c/helpdata/en/76/4a42f4f16d11d1ad15080009b0fb56/content.htm
let me know u need any further info
bvr
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi, bvr
thanks for your help.
The example "Calling BAPIs from Java" you provided need the package com.ibm.sap.bapi.;com.ibm.sap.bapi.generated.;
I do not know where to get these.
Also please give me some help why my program running correctly only when debug if possible.
thanks and regards,
taowenbo
hi tao,
check this link
check this thread
http://www.apentia-forum.de/viewtopic.php?t=1962
add those... if u still in same case
check with pdf how to create a bapi and how to access the bapi from java application programming
http://www.sapdevelopment.co.uk/java/jco/bapi_jco.pdf
let me know u need any further info
bvr
Edited by: bvr on Jan 1, 2009 5:34 AM
Edited by: bvr on Jan 4, 2009 5:29 AM
some help to me .thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.