Skip to Content
Author's profile photo Alvaro Tejada Galindo

Tasting the mix of Flex, PHP and SAP

After reading Matthias Zeller excelent blog [Engaging User Interfaces with Adobe Flex | Engaging User Interfaces with Adobe Flex] I start my Flex learning process…So yes…I have studied Flex for the last 10 days or less…Anyway…I have come to learn and really love Flex…It’s simple, nice and productive.

I download this awesome Module Flex Module for Apache and IIS in order to test my Flex experiments on my Apache Server.[
| http://labs.adobe.com/wiki/index.php/Flex_Module_for_Apache_and_IIS]

As I usually do when I first learn a new Scripting Language, I have developed a SE16 Emulator by using Flex, PHP and SAP…I know that you might be asking yourselfs…”Did Blag said PHP? Why?”…It’s fair simple…I can’t use WebServices on my laptop’s MiniSAP 4.6D so I needed a way to connect to SAP and pass the information to Flex.

What we need to do? We must create a Login Class…

Login_Class.php

We need an Index php page too…

index.php<br />

<textarea cols=”90″ rows=”20″><?php

session_start();

include(“Login_Class.php”);

$_SESSION[“Server”] = $_POST[“myServer”];

$_SESSION[“Sysnum”] = $_POST[“mySysnum”];

$_SESSION[“Client”] = $_POST[“myClient”];

$_SESSION[“User”] = $_POST[“myUser”];

$_SESSION[“Pass”] = $_POST[“myPassword”];

$Login = new Login();

$Log_Me =  $Login->Log_In($_SESSION[“Server”],$_SESSION[“Sysnum”],

             $_SESSION[“Client”],$_SESSION[“User”],$_SESSION[“Pass”]);

$RFC_Me = $Login->RFC_Connection($Log_Me);

if(isset($RFC_Me))

{

     $Return = “<connections><connection>

                  <value>Connected</value>

                  </connection></connections>”;

     print($Return);

}

else

{

$_SESSION = array();

session_destroy();

$Login = new Login();

$Login->Login_Page();

}

?>

</textarea>

</p><p>Now, we can build our UI in Flex.

</p><p>index.mxml

browser.mxml<br />

<textarea cols=”90″ rows=”20″><?xml version=”1.0″ encoding=”utf-8″?>

<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml” xmlns=”*”

layout=”horizontal”>

<mx:HTTPService id=”userRequest”

url=”http://localhost/SinglePath_Stuff/PHP_FLEX_SAP/SE16/SE16.php

useProxy=”false” method=”POST”>

     <mx:request xmlns=””>

          <myTable>{myTable.text}</myTable>

     </mx:request>

</mx:HTTPService>

<mx:Form>

<mx:Panel x=”10″ y=”10″ title=”SE16 Emulator”

width=”775″ height=”400″ layout=”absolute”>

     <mx:Label x=”60″ y=”10″ text=”Table” />

     <mx:TextInput x=”110″ y=”10″ id=”myTable” text=””/>

     <mx:Button x=”280″ y=”10″ id=”ShowData” label=”Show Data”

     click=”userRequest.send()”/>

          

     <mx:DataGrid id=”dgData” x=”20″ y=”40″ height=”300″ width=”710″

     dataProvider=”{userRequest.lastResult.tables.table}”>

          <mx:columns>

               <mx:DataGridColumn headerText=”{userRequest.lastResult.connections.     

               connection.value}” dataField=”data”/>

          </mx:columns>

     </mx:DataGrid>     

</mx:Panel>

</mx:Form>

</mx:Application>

</textarea>

</p><p>In order for this to work, we need to create our last php page…

</p><p>SE16.phpP.S you can download the source code from my public box Blag’s Box .

 

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Dushyant Shetty
      Dushyant Shetty
      Nice, my curiosity on Scripting and Flex continues to increase !
      Quite an impressive motivator for us "Don't know where to start" types...

      Regards,

      Dushyant

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Hi Dushyant:

      I'm glad to see that my humble blog have made you curious about Scripting -:) Hope to see some project from you soon -;)

      Greetings,

      Blag.

      Author's profile photo Former Member
      Former Member
      Well Done.
      I like the new possibilities that Flex offers and I want to test and experiment with flex myself.
      How can I get a test version, 'cause I acctually dont know where to start. Do I need to use the Java Stack of SAP or can I do it with the ABAP Stack?
      Author's profile photo Former Member
      Former Member
      Erik,

      An SAP ABAP stack will work fine, as long as you can create a web service.  Once you create your webservice in ABAP, you can then consume it from flex. 
      Download Flex Builder here:
      http://www.adobe.com/products/flex/flexbuilder/

      Watch Abesh' video blog (just use ABAP web service instead of xMII):
      https://weblogs.sdn.sap.com/pub/wlg/7193

      Hope this helps.  Cheers,
      ewH

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Hi Erik:

      ABAP Stack should do fine -:) You can also download the source code of my blog here http://public.box.net/Blag

      Greetings,

      Blag.

      Author's profile photo Matthias Zeller
      Matthias Zeller
      Hello Alvaro,
      I am impressed. All this in just a couple of days. Good work. Exciting to see all the various Flex projects going on in the SAP eco-system.

      Cheers,

      Matthias

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Thanks a lot Matthias -:) I came to learn and love Flex in a short time...Of course...I'm just beginning...There's a lot to learn an a lot of Flex, PHP and SAP integrations to do -;)

      Greetings,

      Blag.

      Author's profile photo Durairaj Athavan Raja
      Durairaj Athavan Raja
      Excellent Blag.

      Raja

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Thanks a lot Raja -:D

      Greetings,

      Blag.

      Author's profile photo Former Member
      Former Member
      Hi Blag,

      Nice one. Just thinking maybe you can try use states in Flex. Create a state for login and after login, create another state and show the datagrid. I dont know what the returned result are. Maybe you can use datafield in the each data column to map your returned data. I will download your source code and play around it.

      Just one question, I am using MacBook, so dont know if I can try to get a trial version of SAP to do the test.

      Michael

      Author's profile photo Alvaro Tejada Galindo
      Alvaro Tejada Galindo
      Blog Post Author
      Michael:

      When I wrote this blog I was beginning my Flex learning, so I didn't knew about states -:( Now I use them in all my AIR developments -;)

      I don't own a Mac but a lot of friends does...There's a forum about that here on SCN...
      https://forums.sdn.sap.com/forum.jspa?forumID=224&start=0

      Greetings,
      Blag.