cancel
Showing results for 
Search instead for 
Did you mean: 

steps to connect sap by using Sap Jco

Former Member
0 Kudos

Hi All,

I am basically sap consultant.

Now I have to work on java. Here i have to use rfc from sap in my java program.

I need the following help.

1) how to install the sap jco . step by step process , so that i can use rfc from sap . I just downloadded sap Jco from market place.

2) any sample program that uses sap rfc with jco connection.

So that i can build my own java program using sap jco.

Regards,

Kishan

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos
Former Member
0 Kudos

its done .. thanks for evry boady...

Thanks ....

Former Member
0 Kudos

Hi,

Here is the sample code. Any questions are welcome

	
        static JCO.Client mConnection;
	static JCO.Repository mRepository;

	public static JCO.Function createJCOFunction(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 String CallRFC() throws Exception
	{
		String ret = "";
		String[] SAPInterfaces;
		try
		{
			mConnection = JCO.createClient("100", "username", "password", "language", "serverip", "system");
			mConnection.connect();
			mRepository = new JCO.Repository("SU", mConnection);
		}
		catch (Exception ex) 
		{
			ex.printStackTrace();
			System.exit(1);
		}
		JCO.Function function = null;
		JCO.Table it_wbs_element = null;
		JCO.Table et_wbs_el_amounts = null;
		JCO.ParameterList importParam = null;
		try 
		{
			function = createJCOFunction("ZPYO_GETACTBUDGET");
			if (function == null) 
			{
				System.out.println("ZPYO_GETACTBUDGET not found in SAP.");
				System.exit(1);
			}

			importParam = function.getImportParameterList();
			importParam.setValue(Currency, "I_WAERS");

			it_wbs_element = function.getImportParameterList().getTable("IT_WBS_ELEMENT");
			it_wbs_element.appendRow();
			it_wbs_element.setValue(SUProjectCode, 0);
			
			mConnection.execute(function);
			mConnection.disconnect();
			et_wbs_el_amounts = function.getExportParameterList().getTable("ET_WBS_EL_AMOUNTS");
			
			for (int i = 0; i < et_wbs_el_amounts.getNumRows(); i++, et_wbs_el_amounts.nextRow()){
	 			
			}
		}
		catch (Exception e) 
		{
			ret = e.getLocalizedMessage();
			throw e;
		}
		return ret;
	}

Former Member
0 Kudos

Hi,

These links might help you.

[Sun Java|http://developers.sun.com/docs/javacaps/designing/dotdappadptr.ggije.html]

[JCo|http://www.thespot4sap.com/Articles/SAP_Netweaver_Java_Connector.asp]

Thanks,

Venkat