Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Using Java Connector Calling RFC.....But it's not returning correct result

Former Member
0 Likes
579

Hi Friends,

In the code ....

I am calling Remote Function module ZRFC_PO_VEND_VALID using java connector and passing PO_Number and Vendor Number as input parameters and after execution it returns (E_POVALID =1 [PO_NUMBER exists for Vendor number] otherwise E_POVALID = 0 )

when i am executing the below code ....in both cases it is returning Zero value.

I tested the function module in se37 its working....

may i know the reason for this....

import com.sap.mw.jco.*;

/**

*/

public class TutorialBapi1 extends Object {

JCO.Client mConnection;

JCO.Repository mRepository;

public TutorialBapi1() {

try {

// Change the logon information to your own system/user

mConnection =

JCO.createClient("100", // SAP client

"abap", // userid

"abap", // password

"en", // language

"sapdev1", // application server host name

"00"); // system number

mConnection.connect();

mRepository = new JCO.Repository("ARAsoft", mConnection);

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

JCO.Function function = null;

JCO.Table codes = null;

try {

function = this.createFunction("ZRFC_PO_VEND_VALID");

if (function == null) {

System.out.println("ZRFC_PO_VEND_VALID" +

" not found in SAP.");

System.exit(1);

}

//mConnection.execute(function);

//*************

JCO.Field vendID = function.getImportParameterList().getField("I_EBELN");

JCO.Field poID = function.getImportParameterList().getField("I_LIFNR");

vendID.setValue("20081");

poID.setValue("4500000017");

try {

mConnection.execute(function);

}

catch (Exception ex) {

ex.printStackTrace();

System.exit(1);

}

JCO.Field povalid =

function.getExportParameterList().getField("E_POVALID");

//if (povalid.getValue() == null ){

// System.out.println("Error Message");

//}

//**************

System.out.println(povalid.getValue());

//if (povalid == null ){

//System.out.println(povalid.getValue("E_POVALID"));

//System.out.println("Error Message");

//System.exit(1);

//}

}

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[]) {

TutorialBapi1 app = new TutorialBapi1();

}

}

with warm regards,

Madhu.

2 REPLIES 2
Read only

Former Member
0 Likes
468

Try padding the vendor number with leading zeroes(Total length 10).

<b>vendID.setValue("0000020081");</b>

Regards,

Ravi

Read only

0 Likes
468

Hi Ravi ,

I tried as per your sugggestion..still getting the same problem.

Regards,

Madhu!!