<html>
<head>
   <title>Movement type</title>
</head>
<body>
<script type="text/javascript">
function sendValue(s,a){
var selvalue = s;
var selvalue2 = a;
window.opener.document.form1.txt_bwartwa.value = selvalue;
window.opener.document.form1.txt_bwartwa2.value = selvalue2;
window.close();
}
</script>
<style type="text/css">
a:link {
	color: #000;
}
a:visited {
	color: #000;
}
a:hover {
	color: #000;
}
a:active {
	color: #000;
}
</style>
<style type="text/css">
body,td,th {
	font-family: Verdana, Geneva, sans-serif;
	font-size: 12px;
}
</style>
<h1>Movement type</h1><br>
<?php
  include_once("sap.php");
  include_once("lib.php");

    $sap = new SAPConnection();
    $sap->Connect(connection_string());
    if ($sap->GetStatus() == SAPRFC_OK ) $sap->Open ();
    if ($sap->GetStatus() != SAPRFC_OK ) {
       $sap->PrintStatus();
       exit;
    }

    $fce = &$sap->NewFunction ("YFM_MVT_CIS");
    if ($fce == false ) {
       $sap->PrintStatus();
       exit;
    }
	
    $fce->Call();
	
    if ($fce->GetStatus() == SAPRFC_OK) {
		
		
        //Tables
        echo "<table border=1 bordercolor='#000000' cellpadding='0' cellspacing='0'>
		<tr  bgcolor='#CCCCCC'>
		<th>MvT</th>
		<th>S</th>
		<th>Text</th>
		</tr>";
        $fce->GI_HEADER_T157H->Reset();
		//Display Tables
        while ( $fce->GI_HEADER_T157H->Next() ){
			if($bg==0)
           {
           echo"<tr style=background-color:#eeeeee;>";
           $bg++;
           }
          else
			{
			echo"<tr style=background-color:#;>";
			$bg--;
			}
       echo '<td><a href="#" onClick="sendValue('.'\''.$fce->GI_HEADER_T157H->row["BWART"].'\''.','.'\''.$fce->GI_HEADER_T157H->row["HTEXT"].'\''.');" >'.$fce->GI_HEADER_T157H->row["BWART"].'</a></td>
	  <td><a href="#" onClick="sendValue('.'\''.$fce->GI_HEADER_T157H->row["BWART"].'\''.','.'\''.$fce->GI_HEADER_T157H->row["HTEXT"].'\''.');" >'.$fce->GI_HEADER_T157H->row["SOBKZ"].'</a></td>
	  <td><a href="#" onClick="sendValue('.'\''.$fce->GI_HEADER_T157H->row["BWART"].'\''.','.'\''.$fce->GI_HEADER_T157H->row["HTEXT"].'\''.');" >'.$fce->GI_HEADER_T157H->row["HTEXT"].'</a></td></tr>';
		}
        echo "</table>";							
    }
	 else
	 {
     $fce->PrintStatus();
	$sap->Close();
		}
		
  ?>

</body>
</html>
