cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ejbs for accessing Function Module.

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

I want to call ABAP function module using ejb(Since I want to expose them as web service on different server). I know how to do that using Models, but dont know how to go ahead using ejbs.

Could you please guide me on this?

Regards,

Abhijeet.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Create an enterprise application (EA) project.

Create an EJB module project.

Add the EJB module to the EA project.

In the EJB module create a session bean.

For each (ABAP) function call create a method on the bean with a similar signature (same import/export parameters).

In the implementation of the bean method you can add coding required for doing backend call (JCO stuff; this is the only part that requires coding, all other actions described here can be done using wizards/templates).

Generate a webservice for each method. (Wizard)

Deploy the EA project (ear file) to WAS. Your webservices should be available.

Good luck!

Roelof

PS You can do it even neater by creating an andditional Java project for the implementation of the backend calls. Then create an interface for the backend calls and make the ejb beans methods implement this interface.

abhijeet_mukkawar
Active Contributor
0 Kudos

Hi,

Could you tell me how to do the back end call coding or any threads reference.

And cant we do it using SAP Connectivity option?

Regards,

Abhijeet.

Former Member
0 Kudos

Hi,

In another thread with a similar question I found these references:

/people/kathirvel.balakrishnan2/blog/2005/07/26/remote-enable-your-rfchosttoip-to-return-host-ip-to-jco

And this code example:

		HashMap result = new HashMap();
		Object ret = new Object();
 
		JCO.Client mConnection = null;
 
		mConnection = getConnection();
 
		JCO.Repository mRepository;
		mRepository = new JCO.Repository("R3", mConnection);
 
		JCO.Function function =
			createFunction("Z_ISA_GET_ORDER_ITEM_INFO", mRepository);
 
		function.getImportParameterList().setValue(orderNum, "ORDER");
 
		if (function != null) {
			mConnection.execute(function);
 
			JCO.Table codes = function.getTableParameterList().getTable("INFO");
			for (int i = 0; i < codes.getNumRows(); i++) {
				codes.setRow(i);
				int tmp = new Integer(codes.getString("POSNN")).intValue();
				String tmpStr = new String(Integer.toString(tmp));
				ret = result.put(tmpStr, codes.getString("VBELN"));
			}
 
		} else {
			System.out.print("Fxn call failed for Z_ISA_GET_ORDER_ITEM_INFO");
		}
 
		JCO.releaseClient(mConnection);

Good luck,

Roelof

Answers (0)