<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Flex application using LCDS to access Java Data in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174964#M1372332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the layout, the "code" markup is not working....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 28 Nov 2009 14:39:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-11-28T14:39:20Z</dc:date>
    <item>
      <title>Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174959#M1372327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm currentrly working on a Flex application that connects to the SAP system to retrieve some data.&lt;/P&gt;&lt;P&gt;This connection is made through the JCo (to be able to use RFC), and thus I'm using LCDS to map the Java results to the Flex application. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I made a Flex/Java project in Eclipse.&lt;/P&gt;&lt;P&gt;I'm properly using the JCo in my Java class (I do retrieve the data I want from SAP). &lt;/P&gt;&lt;P&gt;In &lt;EM&gt;ConnexionManager.java&lt;/EM&gt;, I have a &lt;EM&gt;public static JCoTable all()&lt;/EM&gt; function that returns a table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are my different sources:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Flex_JCo_Test.mxml&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#FFFFFF"&amp;gt;
	
	&amp;lt;mx:RemoteObject id="srv" destination="cnxMngr"/&amp;gt;
	
	&amp;lt;mx:DataGrid dataProvider="{srv.results}" width="100%" height="100%"/&amp;gt; 

	&amp;lt;mx:Button label="Get Data" click="srv.all()"/&amp;gt;	
		
&amp;lt;/mx:Application&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;remoting-config.xml&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;service id="remoting-service" 
    class="flex.messaging.services.RemotingService"&amp;gt;

    &amp;lt;adapters&amp;gt;
        &amp;lt;adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/&amp;gt;
    &amp;lt;/adapters&amp;gt;

    &amp;lt;default-channels&amp;gt;
        &amp;lt;channel ref="my-amf"/&amp;gt;
    &amp;lt;/default-channels&amp;gt;
    
    &amp;lt;destination id="cnxMngr"&amp;gt;
        &amp;lt;properties&amp;gt;
            &amp;lt;source&amp;gt;connexionJCo.ConnexionManager&amp;lt;/source&amp;gt;
            &amp;lt;scope&amp;gt;application&amp;lt;/scope&amp;gt;
        &amp;lt;/properties&amp;gt;
        &amp;lt;adapter ref="java-object"/&amp;gt;
    &amp;lt;/destination&amp;gt;

&amp;lt;/service&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And this is the error I'm getting:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost/WebContent/messagebroker/amf'"]
	at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:220]
	at mx.rpc::Responder/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\Responder.as:53]
	at mx.rpc::AsyncRequest/fault()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:103]
	at mx.messaging::ChannelSet/faultPendingSends()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:1482]
	at mx.messaging::ChannelSet/channelFaultHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\ChannelSet.as:975]
	at flash.events::EventDispatcher/dispatchEventFunction()
	at flash.events::EventDispatcher/dispatchEvent()
	at mx.messaging::Channel/connectFailed()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\Channel.as:997]
	at mx.messaging.channels::PollingChannel/connectFailed()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\PollingChannel.as:354]
	at mx.messaging.channels::AMFChannel/statusHandler()[C:\autobuild\3.2.0\frameworks\projects\rpc\src\mx\messaging\channels\AMFChannel.as:390]
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm using the lcds.war provided with the lcds. And I kept the default settings for the channels.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really don't have a clue on what I'm doing wrong.&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Cristina CHEN MA on Sep 22, 2009 4:35 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Sep 2009 14:35:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174959#M1372327</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-22T14:35:10Z</dc:date>
    </item>
    <item>
      <title>Re: Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174960#M1372328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't know what's wrong, but the markups in my sources are not working. Sorry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Sep 2009 14:40:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174960#M1372328</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-09-22T14:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174961#M1372329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I solved my problem by starting from scratch.&lt;/P&gt;&lt;P&gt;I was using the tomcat provided by the LCDS when installing it. Thus, I had no control over the java runtime that was used by the server, which was different from the one I was using to compile my java project.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution was simply installing a LCDS without server. Having a standalone tomcat. And define in Eclipse and Tomcat the same java runtime.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;C.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Oct 2009 12:51:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174961#M1372329</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-10-14T12:51:00Z</dc:date>
    </item>
    <item>
      <title>Re: Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174962#M1372330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi crist,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Could please tell me how u connect SAP system from java class using eclipse.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Arun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Nov 2009 12:32:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174962#M1372330</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-28T12:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174963#M1372331</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Vgarun.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find some very helpfull "how to" about connecting to sap system via a Java Class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check this out:&lt;/P&gt;&lt;P&gt;[http://help.sap.com/saphelp_nw04/helpdata/en/35/42e13d82fcfb34e10000000a114084/frameset.htm]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And just to get you started, here you have part of my Java code.&lt;/P&gt;&lt;P&gt;You'll have to change the system data according to your system.&lt;/P&gt;&lt;P&gt;And the function getTableResult is an example of how call a function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;public class JcoTest{
	static String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
	static{
	    Properties connectProperties = new Properties();
	    //System data
	    connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER,  "/H/xxx.xxx.xxx.xxx/H/");
		connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "sap-ecc.xxxxxx.xxx");
		connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR,  "xx");
		//User data
		connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "xxx");
		connectProperties.setProperty(DestinationDataProvider.JCO_USER,   "xxxxxxxx");
		connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "xxxxxx");
		connectProperties.setProperty(DestinationDataProvider.JCO_LANG,   "en");
		//Pool data
		connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "3");
		connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT,    "10");
		//Create data file with all the properties
		createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties);
		
	}

	static void createDataFile(String name, String suffix, Properties properties){
	    File cfg = new File(name+"."+suffix);
		if(!cfg.exists()){
		    try{
		        FileOutputStream fos = new FileOutputStream(cfg, false);
		        properties.store(fos, "for tests only !");
		    fos.close();
			}catch (Exception e){
			    throw new RuntimeException("Unable to create the destination file " + cfg.getName(), e);
	        }
	    }
	}
	
	/*
	 * Establish connection
	 */
	public static void connectUsingPool() throws JCoException{
	    JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
	    destination.ping();
	}

	/*
	 * Get data
	 */
	public static JCoTable getTableResult() throws JCoException{
		// Connection
	    JCoDestination destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
	    
	    // Call function BAPI_FLIGHT_GETLIST
	    JCoFunction function = destination.getRepository().getFunction("BAPI_FLIGHT_GETLIST");
		if(function == null)
		    throw new RuntimeException("BAPI_FLIGHT_GETLIST not found in SAP.");
		// Get import parameters
		function.getImportParameterList().setValue("AIRLINE", "AA");
		try{
			// Execute function
		    function.execute(destination);
		}catch(AbapException e){
		    System.out.println(e.toString());
		    return null;
		}
		
		// Get table RETURN to check error messages
		JCoTable returnTable = function.getTableParameterList().getTable("RETURN");
		if (! (returnTable.getString("TYPE").equals("")||returnTable.getString("TYPE").equals("S")))
		   throw new RuntimeException(returnTable.getString("MESSAGE"));

		// Get result table FLIGHT_LIST
		JCoTable codes = function.getTableParameterList().getTable("FLIGHT_LIST");
		return codes;	

	}
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;C.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Nov 2009 14:38:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174963#M1372331</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-28T14:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: Flex application using LCDS to access Java Data</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174964#M1372332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the layout, the "code" markup is not working....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 28 Nov 2009 14:39:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/flex-application-using-lcds-to-access-java-data/m-p/6174964#M1372332</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-11-28T14:39:20Z</dc:date>
    </item>
  </channel>
</rss>

