Skip to Content

Did you know what WML is? Simple…WML stands for Wireless Markup Language and it’s used to make Mobile applications development.

Some weeks ago, I needed to do a simple game using JavaME, so of course I tought about making some JavaME and SAP integration using the SAPJCo connector…Sadly…Some library errors keep showing…Anyway…Because of my “failure” I decide to revive one of my older projects…Use PHP and WML along with SAP to make an SE16 emulation…It tooks me a few hours to make this…

index.php

Login_Class.php

Class Login{var $Login, $rfc;function Log_In($Server,$Sysnum,$Client,$User,$Pass){$this->Login = array (“ASHOST”=>$Server,                      “SYSNR”=>$Sysnum,                      “CLIENT”=>$Client,                      “USER”=>$User,                      “PASSWD”=>$Pass,                      “CODEPAGE”=>”1404”);return $this->Login;}function RFC_Connection($Login){$this->rfc = saprfc_open($Login);   IF ( !$this->rfc )   {       ECHO “The connection fails with the following error:”.saprfc_error();       EXIT;   }   else   {       return $this->rfc;   }}}?>

process.php<br />

<textarea cols=”70″ readonly=”readonly” rows=”10″><?php

session_start();

header(“Content-type: text/vnd.wap.wml”);

header(“Cache-Control: no-cache, must-revalidate”);

header(“Pragma: no-cache”);

echo (“<?xml version=’1.0′?>”);

?>

<?php

require_once(“Login_Class.php”);

?>

<?php

if(!isset($_SESSION[“Server”]))

{

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

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

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

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

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

}

$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);

?>

<!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD WML 1.1//EN” “http://www.wapforum.org/DTD/wml_1.1.xml“>

<wml>

<card id=”choose” title=”SE16″ ordered=”false”>

<p>

Table:<input name=”Table” size=”20″/><br/>

</p>

<do type=”accept” label=”OK” optional=”false”>

<go href=”Show_Table.php” method=”post”>

<postfield name=”Table” value=”$Table”/>

</go>

</do>

</card>

</wml>

</textarea>

</p><p>Show_Table.php

session_start();require_once(“SE16.php”);require_once(“Login_CLass.php”);if(isset($_POST[“Table”])){$Table = $_POST[“Table”];$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);$SE16 = new SE16();$SE16->Show_Table($Table,$RFC_Me);}?>

SE16.php<br />

<textarea cols=”70″ readonly=”readonly” rows=”10″><?php

header(“Content-type: text/vnd.wap.wml”);

header(“Cache-Control: no-cache, must-revalidate”);

header(“Pragma: no-cache”);

echo (“<?xml version=’1.0′?>”);

?>

<!DOCTYPE wml PUBLIC “-//WAPFORUM//DTD WML 1.1//EN” “http://www.wapforum.org/DTD/wml_1.1.xml“>

<?php

Class SE16

{

var $fce;

function Show_Table($Table,$RFC_Me)

{

   $this->fce = saprfc_function_discover($RFC_Me, “RFC_READ_TABLE”);

   IF (! $this->fce )

   {

       ECHO “The function module had failed.”;

       EXIT;

   }

   $Table = STRTOUPPER($Table);

   saprfc_import ($this->fce,”QUERY_TABLE”,$Table);

   saprfc_import ($this->fce,”DELIMITER”,”/”);

   saprfc_table_init ($this->fce,”OPTIONS”);

   saprfc_table_init ($this->fce,”FIELDS”);

   saprfc_table_init ($this->fce,”DATA”);

   $rfc_rc = “”;

   $rfc_rc = saprfc_call_and_receive ($this->fce);

   if ($rfc_rc != SAPRFC_OK)

   {

       if ($rfc == SAPRFC_EXCEPTION )

           echo (“Exception raised: “.saprfc_exception($this->fce));

       else

           echo (“Call error: “.saprfc_error($this->fce));

       exit;

   }

   $data_row = saprfc_table_rows ($this->fce,”DATA”);

   $field_row = saprfc_table_rows ($this->fce,”FIELDS”);

   ECHO “<wml>”;

   ECHO “<card id=’SE16′ title=” ordered=’false’>”;

   ECHO “<p>”;

   ECHO “<table columns=’$field_row’ title=’$Table’>”;

   ECHO “<tr>”;

   for($i=1; $i<=$field_row ; $i++)

   {

   $FIELDS = saprfc_table_read ($this->fce,”FIELDS”,$i);   

   ECHO “<td><b>”;

   ECHO $FIELDS[‘FIELDNAME’];

   ECHO “</b></td>”;

   }

   ECHO “</tr>”;

   for($i=1; $i<=$data_row ; $i++)

   {

   ECHO “<tr>”;

   $DATA = saprfc_table_read ($this->fce,”DATA”,$i);

   $TEST = SPLIT(“/”,$DATA[‘WA’]);

     for($j=0; $j<$field_row; $j++)

     {

     ECHO “<td>”;

     ECHO $TEST[$j];

     ECHO “</td>”;

     }

   ECHO “</tr>”;

   }  

   ECHO “</table>”;

   ECHO “</p>”;

   ECHO “</card>”;

   ECHO “</wml>”;

}

}

?>

</textarea>

</p><p>

Now, we can see some pictures…</p><p>!https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Login.png|height=400|alt=image|width=190|src=https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Login.png|border=0!</p><p>!https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Table.png|height=400|alt=image|width=188|src=https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Table.png|border=0!</p><p>!https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Show.png|height=400|alt=image|width=190|src=https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Show.png|border=0!</p><p>We can even use Opera Browser, to take a better look of the output table…</p><p>!https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Show_Opera.png|height=234|alt=image|width=400|src=https://weblogs.sdn.sap.com/weblogs/images/48024/SE16_WAP_Show_Opera.png|border=0!</body>

To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

Leave a Reply