<html>
<head>
   <title>Unit of measure</title>
</head>
<body>
<script type="text/javascript">
function sendValue(s){
var selvalue = s;
window.opener.document.form1.txt_erfme.value = selvalue;
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>Unit of measure</h1><br>
  <strong><em>Search
by:</em></strong>
  <form name="form1" method="get" action="">
  <table width="401" border="0" cellspacing="1" cellpadding="1">
    <tr>
      <th bgcolor="#CCCCCC">int.measurement unit:</th>
      <td><input name="txt_msehi" type="text" id="txt_msehi" value="<?php echo strtoupper($_GET['txt_msehi']); ?>" size="3" maxlength="3"></td>
    </tr>
    <tr>
      <th bgcolor="#CCCCCC">Unit text :</th>
      <td><input name="txt_msehl" type="text" id="txt_msehl" value="<?php echo strtoupper($_GET['txt_msehl']); ?>" size="30" maxlength="30"></td>
    </tr>
    <tr>
      <th width="176">&nbsp;</th>
      <td width="218"><label for="txt_max"></label>
        <label for="txt_maktx">
          <input type="submit" name="button" id="button" value="Search">
    </label></td>
    </tr>
  </table>
</form>
  <?php
  if($_GET['txt_msehi'] != '' || $_GET['txt_msehl'] != '' )
  		{
		
    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_UOM_CIS");
    if ($fce == false ) {
       $sap->PrintStatus();
       exit;
    }
	
	
	  	$fce->GR_MSEHI->row["SIGN"] = "I";
		$fce->GR_MSEHI->row["OPTION"] = "CP";
		$fce->GR_MSEHI->row["LOW"] = "*".strtoupper($_GET['txt_msehi'])."*";
		$fce->GR_MSEHI->row["HIGH"] = " ";
		$fce->GR_MSEHI->Append($fce->GR_MSEHI->row);
		
		$fce->GR_MSEHL->row["SIGN"] = "I";
		$fce->GR_MSEHL->row["OPTION"] = "CP";
		$fce->GR_MSEHL->row["LOW"] = "*".strtoupper($_GET['txt_msehl'])."*";
		$fce->GR_MSEHL->row["HIGH"] = " ";
		$fce->GR_MSEHL->Append($fce->GR_MSEHL->row); 
  		
	
	/*if($_GET['txt_max'] != '' )
  		{
			$fce->GV_MAX_ROWS=$_GET['txt_max'];
		}*/
    $fce->Call();
	
    if ($fce->GetStatus() == SAPRFC_OK) {
		
		
        //Tables
        echo "<table border=1 bordercolor='#000000' cellpadding='0' cellspacing='0'><tr  bgcolor='#CCCCCC'><th>Unit</th><th>Measurement unit text</th></tr>";
        $fce->GI_HEADER_T006->Reset();
		//Display Tables
        while ( $fce->GI_HEADER_T006->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_T006->row["MSEHI"]."'); >".$fce->GI_HEADER_T006->row["MSEHI"]."</a></td>"
	   ."<td><a href=# onClick=sendValue('".$fce->GI_HEADER_T006->row["MSEHI"]."'); >".$fce->GI_HEADER_T006->row["MSEHL"]."</a></td></tr>";
		}
        echo "</table>";							
    } else
        $fce->PrintStatus();
	$sap->Close();
		}
		else
		{
			
			echo '<center><font color="#FF0000"><b>Please input your search keyword</b></font></center>';
			
		}
  ?>

</body>
</html>
