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

access java code

Former Member
0 Likes
852

please suggest me a fn_module that will help to connect sap to java and back

6 REPLIES 6
Read only

Former Member
0 Likes
736

refer the below thread

Regards

Vivek

<b>Reward points for all the useful answers</b>

Read only

Former Member
0 Likes
736

hi Sarath,

you can connect sap to java and vice versa using SAP JCO. SAP Java Connector (SAP JCo) is a middleware component that enables the development of SAP-compatible components and applications in Java. SAP JCo supports communication with the SAP Server in both directions: inbound calls (Java calls ABAP) and outbound calls (ABAP calls Java).

SAP JCo can be implemented with Desktop applications and with Web server applications.

SAP JCo is used as an integrated component in the following applications:

1. SAP Business Connector, for communication with external Java applications

2. SAP Web Application Server, for connecting the integrated J2EE server with the ABAP environment.

SAP JCo can also be implemented as a standalone component, for example to establish communication with the SAP system for individual online (web) applications.

If you want more details on SAP JCO, give me your email ID so that i can send some good documents.

Regards,

Richa

Read only

Former Member
0 Likes
736

Hi,

you need to Configure the system first, then you can create a RFC function module ..

see the below SAP URL for information

http://help.sap.com/saphelp_nw2004s/helpdata/en/34/7c40cf1e6849e2899f55ac396f994b/content.htm

mark all the helpful answers

Regards

Sudheer

Read only

Former Member
0 Likes
736

Hi Sarath,

Guess ur scenario is something to do with execution of a function module at the r/3 as backend.U hvae a java servlet program which connects to the sap.For connecting to SAP u wud have to expose ur function module as an RFC/BAPI in the attribute tab.For connecting java application to SAP u ll require a java connector.Is this wht is needed?

Reward valuable answers.

Regards,

Shrita.

Read only

0 Likes
736

i want to know ,is there any fn_module available that will help to connect java from sap

Read only

0 Likes
736

hi Sarath,

You cannot connect SAP and java without the use of SAP JCO. If you have installed the JCO files then onlyl you can do it. You can call a RFC FM or any BAPI from your java program.

Here is hte sample code.

import com.sap.mw.jco.*;

public class Bapi1 extends Object{

  JCO.Client mConnection;
  JCO.Repository mRepository;

  public Bapi1(){
	try{
	   mConnection = JCO.createClient("100","NTWDEV","******",
						  null,"10.111.11.111","00" );
	   mConnection.connect();
	   mRepository = new JCO.Repository("MyRepos", 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.lastRow();
	  codes.deleteRow();
	  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();
	  for( int i = 0; i < codes.getNumRows();i++){
		codes.setRow(i);
		System.out.println(codes.getString("COMP_CODE") + "   " +
						   codes.getString("COMP_NAME"));
	  }
	}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("Probelm retrieving JCO.Fucntion object");

	}
  }
  public static void main(String agrs[]){
	  Bapi1 app = new Bapi1();
  }
}

Regards,

Richa.