2009 May 03 7:56 PM
Hi,
I have a big problem, hope some experts can help me.
I want to write some external program using JCo to call some BAPIs.
But some BAPIs can be called but some other can't, and I really don't know what happened.
I write two programs using JCo to call two BAPIs.
But one can work and another can't.
The first program try to call BAPI_COMPANYCODE_GETDETAIL, and I import Company_code 1000. Then it return the IDES_AG correctly.
But the second program try to call BAPI_COMPANY_GETDETAIL, and I import Company_id 1000 again. But it doesn't return anything.
I really can't figure out the reason, the differents between these two programs is the Fm and the parameters only. And these two BAPIs are builded in the R/3. I've tested in R/3 and both of them are work correctly.
But why only one can work when I called them by external program using JCo?
Where could be wrong?
The reason I want to ask this question is that not only BAPI_COMPANY_GETDETAIL can't be called by external program using JCo in my system, but also all ZBAPIs write by myself can't be call.
I really hope some experts can give me some advise about what points should I check.
Thanks.
2009 May 04 3:18 AM
Hi,
there is no difference between BAPIs in term of calling them from JCo. Are you sure that you have correct types for your second BAPI? For example BAPI_COMPANYCODE_GETDETAIL returns company code with type CHAR4 and BAPI_COMPANY_GETDETAIL returns company with type CHAR6. Do you get any messages in return table?
Cheers
2009 May 03 8:51 PM
hi,
BAPI_COMPANYCODE_GETDETAIL and BAPI_COMPANY_GETDETAIL
are completly different: compare them in se37 transaction....
regards,darek
2009 May 04 3:18 AM
Hi,
there is no difference between BAPIs in term of calling them from JCo. Are you sure that you have correct types for your second BAPI? For example BAPI_COMPANYCODE_GETDETAIL returns company code with type CHAR4 and BAPI_COMPANY_GETDETAIL returns company with type CHAR6. Do you get any messages in return table?
Cheers
2009 May 04 6:59 AM
Hi,
Thanks for your response.
I've checked the TYPE of returned parameters, but I think "maybe" these can be assigned to a String in Jco?
If it can't,how should I get the returned parameters correctly?
The source codes of these two programs are show below.
I tried to assign 1000 as the input parameter for both program1 and program2.
But only program1 can return IDES AG correctly, program2 returned nothing.
Do I miss any part?
Hope experts can give me some advises.
Thanks a lot.
repository = JCO.createRepository("MYRepository", SID);
// Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_COMPANYCODE_GETDETAIL");
// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);
JCO.Client client = JCO.getClient(SID); // Get a client from the pool
JCO.ParameterList input = function.getImportParameterList(); // Fill in input parameters
input.setValue(id, "COMPANYCODEID" );
client.execute(function); // Call the remote system
JCO.Structure ret = function.getExportParameterList().getStructure("COMPANYCODE_DETAIL");
System.out.println(ret.getString("COMP_NAME"));
repository = JCO.createRepository("MYRepository", SID);
// Get a function template from the repository
IFunctionTemplate ftemplate = repository.getFunctionTemplate("BAPI_COMPANY_GETDETAIL");
// Create a function from the template
JCO.Function function = new JCO.Function(ftemplate);
JCO.Client client = JCO.getClient(SID); // Get a client from the pool
JCO.ParameterList input = function.getImportParameterList(); // Fill in input parameters
input.setValue(id, "COMPANYID" );
client.execute(function); // Call the remote system
JCO.Structure ret = function.getExportParameterList().getStructure("COMPANY_DETAIL");
System.out.println(ret.getString("NAME1"));
2009 May 04 7:18 AM
Hi,
Try giving the input as '001000' instead of '1000'.
As the Input parameter ("COMPANYID") for second BAPI is of 6 char length, may be it's not considering the leading spaces.
thanks\
Mahesh
2009 May 04 7:22 AM
Hi,
I agree with this comment. You need to add zeros. Actually it's stated in BAPI documentation.
The system does not convert the input parameter COMPANYID, meaning that
leading blank characters within this parameter are not cleared.
Cheers
2009 May 04 9:26 AM
Hi Mahesh and Cheers,
Thanks a lot, I fixed my problem.
Thank you very much for the advices.