Jump to content
NunoDinis

[Resolvido] Problema na procura com array

Recommended Posts

NunoDinis

Bom dia,

Estou a buscar dados a um software que provêm em arrays. Consigo listar os valores de cada array, e até aqui tudo ótimo..

Quando pesquiso, por exemplo "TC" (todos os artigos começados por TC), ele lista muito bem, mas quando pretendo pesquisar um artigo especifico, por exemplo :TC0114, ele retorna-me a array correto (faço o print_r), no entanto retorna-me todos os valores que a tabela do software tem em branco e não mete em nenhuma linha os valores da pesquisa que efetuei e que o array retorna bem (TC0114).

Ex: Pesquisa -> TC

Retorna - linha 1 -TC0114

linha 2 - TC0450

linha 3 -TC0529

Pesquisa -> TC0114

Retorna - linha 1 - em branco

linha 2 -em branco

linha 3 -em branco

(retorna o numero de linhas, de artigos começados por TC, mas retorna o array direito.

stdClass Object
(
[OutGestArquivo] => stdClass Object
 (
	 [item] => stdClass Object
		 (
			 [Mandt] => 200
			 [Artigo] => TC0450
			 [Descricao] => W 0395
			 [GrpMerc] => 5015
			 [GrpMercDes1] => TECIDO - GRP COR TP
			 [GrpMercDes2] => TECIDO - GRP COR TINTO PEÇA
		 )
 )
[PStatus] => 0
)

Dá para entender ?

Obrigado.

Edited by apocsantos
geshi

Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro.

ndsotware.org

Share this post


Link to post
Share on other sites
NunoDinis

É esta função.

(É grande porque a tabela tem mesmo muitos campos, se for mais fácil para compreenderes diz que corto os campos quase todos).

<?php

function func1(){
global $SOAP_AUTH;
$artigo=$_POST['artigo'];
$WSDL = "http://srvsapdev01.riopele.pt:8000/sap/bc/srt/wsdl/bndg_DED5E1E44CF572F1B50D001CC4448430/wsdl11/allinone/standard/document?sap-client=200%22;
$result ="";
#Create Client Object, download and parse WSDL
$client = new SoapClient($WSDL,$SOAP_AUTH);
$x[]  = array('Mandt' => "200",
    'Artigo' => $_POST['artigo'],
    'Descricao' => "",
    'GrpMerc' => "",
    'GrpMercDes1' => "",
    'GrpMercDes2' => "",
    'Peso' => "",
    'Peso1' => "",
    'HierCode' => "",
    'HierN1Code' => "",
    'HierN1Des' => "",
    'HierN2Code' => "",
    'HierN2Des' => "",
    'HierN3Code' => "",
    'HierN3Des' => "",
    'HierN4Code' => "",
    'HierN4Des' => "",
    'Composicao' => "",
    'CompCo' => "",
    'Tela' => "",
    'CompPl' => "",
    'CompPa' => "",
    'CompEa' => "",
    'CompVi' => "",
    'CompCu' => "",
    'CompRay' => "",
    'CompWo' => "",
    'CompLi' => "",
    'CompWa' => "",
    'CompSe' => "",
    'CompPc' => "",
    'CompMo' => "",
    'CompLy' => "",
    'CompCa' => "",
    'CompInox' => "",
    'CompPva' => "",
    'CompAc' => "",
    'CompWm' => "",
    'CompTe' => "",
    'CompRa' => "",
    'CompJu' => "",
    'CompBamboo' => "",
    'TipoTecido' => "",
    'PontoBase' => "",
    'DesenhoTecido' => "",
    'TipoElastic' => "",
    'Obs' => "",
    'UrlImage' => "",            
    'Inactivo' => "",
    'DataCri' => "",
    'HoraCri' => "",
    'UsrCri' => "",
    'DataAlt' => "",
    'HoraAlt' => "",
    'UsrAlt' => "",
    'CompCo1' => "",
    'CompPl1' => "",
    'CompPa1' => "",
    'CompEa1' => "",
    'CompVi1' => "",
    'CompCu1' => "",
    'CompRay1' => "",
    'CompWo1' => "",
    'CompLi1' => "",
    'CompWa1' => "",
    'CompSe1' => "",
    'CompPc1' => "",
    'CompMo1' => "",
    'CompLy1' => "",
    'CompCa1' => "",
    'CompInox1' => "",
    'CompPva1' => "",
    'CompAc1' => "",
    'CompWm1' => "",
    'CompTe1' => "",
    'CompRa1' => "",
    'CompJu1' => "",
    'CompBamboo1' => "");
#Setup input parameters (SAP Likes to Capitalise the parameter names)
$params = array('OutGestArquivo' => $x,
     'PAccao' => "C",
     'PMatnr' => "M",
     'PObs' => "obs",
     'PUrlImg' => "nnn",
     'PUser' => "matos",
     'PStatus' => ""
     );

#Call Operation (Function). Catch and display any errors
try
 {
$result = $client->ZrrWsComunicaArquivo($params);

 /*echo count($params,COUNT_RECURSIVE);
 foreach($params as $v)
 {
  echo 'Valores ' .$v;
 }*/
  foreach ($result->OutGestArquivo->item as $row) {
   $Matriz = array(array($row->Descricao,$row->Artigo,$row->Obs));
 ?>
<html>
<table style="width: 50%" cellspacing="1" class="style1">
<tr>
   <td><?PHP echo $Matriz[0][0]; ?></td>
   <td class="style2"><?PHP echo $Matriz[0][1]; ?></td>
</tr>
</table>
</html>
<?PHP
}
   $Mandt=$arr[0];
   $Artigo=$arr[1];
   $Descricao=$arr[2];
   $GrpMerc=$arr[3];
   $GrpMercDes1=$arr[4];
   $GrpMercDes2=$arr[5];
   $Peso=$arr[6];
   $Peso1=$arr[7];
   $HierCode=$arr[8];
   $HierN1Code=$arr[9];
   $HierN1Des=$arr[10];
   $HierN2Code=$arr[11];
   $HierN2Des=$arr[12];
   $HierN3Code=$arr[13];
   $HierN3Des=$arr[14];
   $HierN4Code=$arr[15];
   $HierN4Des=$arr[16];
   $Composicao=$arr[17];
   $CompCo=$arr[18];
   $Tela=$arr[19];
   $CompPl=$arr[20];
   $CompPa=$arr[21];
   $CompEa=$arr[22];
   $CompVi=$arr[23];
   $CompCu=$arr[24];
   $CompRay=$arr[25];
   $CompWo=$arr[26];
   $CompLi=$arr[27];
   $CompWa=$arr[28];
   $CompSe=$arr[29];
   $CompPc=$arr[30];
   $CompMo=$arr[31];
   $CompLy=$arr[32];
   $CompCa=$arr[33];
   $CompInox=$arr[34];
   $CompPva=$arr[35];
   $CompAc=$arr[36];
   $CompWm=$arr[37];
   $CompTe=$arr[38];
   $CompRa=$arr[39];
   $CompJu=$arr[40];
   $CompBamboo=$arr[41];
   $TipoTecido=$arr[42];
   $PontoBase=$arr[43];
   $DesenhoTecido=$arr[44];
   $TipoElastic=$arr[45];
   $Obs=$arr[46];
   $UrlImage=$arr[47];      
   $Inactivo=$arr[48];
   $DataCri=$arr[49];
   $HoraCri=$arr[50];
   $UsrCri=$arr[51];
   $DataAlt=$arr[52];
   $HoraAlt=$arr[53];
   $UsrAlt=$arr[54];
   $CompCo1=$arr[55];
   $CompPl1=$arr[56];
   $CompPa1=$arr[57];
   $CompEa1=$arr[48];
   $CompVi1=$arr[59];
   $CompCu1=$arr[60];
   $CompRay1=$arr[61];
   $CompWo1=$arr[62];
   $CompLi1=$arr[63];
   $CompWa1=$arr[64];
   $CompSe1=$arr[65];
   $CompPc1=$arr[66];
   $CompMo1=$arr[67];
   $CompLy1=$arr[68];
   $CompCa1=$arr[69];
   $CompInox1=$arr[70];
   $CompPva1=$arr[71];
   $CompAc1=$arr[72];
   $CompWm1=$arr[73];
   $CompTe1=$arr[74];
   $CompRa1=$arr[75];
   $CompJu1=$arr[76];
   $CompBamboo1=$arr[77];

echo("<pre>");
       print_r($result);
echo("</pre>");

 }
catch (SoapFault $exception)
 {
    print "***Caught Exception***\n";
    print_r($exception);
    print "***END Exception***\n";
    die();
 }
    return $result;
}
func1();

?>

Edited by brunoais
batota para no inicio tb aparecer com cores.

Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro.

ndsotware.org

Share this post


Link to post
Share on other sites
NunoDinis

Com o valor a TC :

Array
(
[0] => Array
 (
	 [0] => 100%CO
	 [1] => TC3826
	 [2] =>
 )
)

TC3826 é o último valor da tabela.

Com

TC0114:

Array
(
[0] => Array
 (
	 [0] =>
	 [1] =>
	 [2] =>
 )
)
Edited by NunoDinis

Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro.

ndsotware.org

Share this post


Link to post
Share on other sites
HappyHippyHippo

tens a certeza que quando fazes com "TC0114" o print_r do $result vem com os dados correctos ?


IRC : sim, é algo que ainda existe >> #p@p

Share this post


Link to post
Share on other sites
NunoDinis

Sim, retorna-me todo o array.

stdClass Object
(
   [OutGestArquivo] => stdClass Object
    (
	    [item] => stdClass Object
		    (
			    [Mandt] => 200
			    [Artigo] => TC0114
			    [Descricao] => E 215G72373
			    [GrpMerc] => 5015
			    [GrpMercDes1] => TECIDO - GRP COR TP
			    [GrpMercDes2] => TECIDO - GRP COR TINTO PEÇA
			    [Peso] => 225
			    [Peso1] =>
			    [HierCode] => 100120013005400561
			    [HierN1Code] => 1001
			    [HierN1Des] => 100% ALGODÃO
			    [HierN2Code] => 2001
			    [HierN2Des] => LISO
			    [HierN3Code] => 3005
			    [HierN3Des] => ALGODOES PESADOS
			    [HierN4Code] => 400561
			    [HierN4Des] => LIMA
			    [Composicao] => 100% CO
			    [CompCo] => 100,00 %
			    [Tela] => TL0053
			    [CompPl] =>
			    [CompPa] =>
			    [CompEa] =>
			    [CompVi] =>
			    [CompCu] =>
			    [CompRay] =>
			    [CompWo] =>
			    [CompLi] =>
			    [CompWa] =>
			    [CompSe] =>
			    [CompPc] =>
			    [CompMo] =>
			    [CompLy] =>
			    [CompCa] =>
			    [CompInox] =>
			    [CompPva] =>
			    [CompAc] =>
			    [CompWm] =>
			    [CompTe] =>
			    [CompRa] =>
			    [CompJu] =>
			    [CompBamboo] =>
			    [TipoTecido] => CETINS
			    [PontoBase] => CETIM 5
			    [DesenhoTecido] => LISOS
			    [TipoElastic] => SEM ELASTICIDADE
			    [Obs] =>
			    [urlImage] => http://srvsapportal.riopele.pt:50000/irj/go/km/docs/documents/Arquivo/TC0114.jpg
			    [inactivo] => N
			    [DataCri] => 2010-03-24
			    [HoraCri] => 15:10:40
			    [usrCri] => MATOS
			    [DataAlt] => 2010-11-19
			    [HoraAlt] => 17:02:54
			    [usrAlt] => MATOS
			    [CompCo1] =>
			    [CompPl1] =>
			    [CompPa1] =>
			    [CompEa1] =>
			    [CompVi1] =>
			    [CompCu1] =>
			    [CompRay1] =>
			    [CompWo1] =>
			    [CompLi1] =>
			    [CompWa1] =>
			    [CompSe1] =>
			    [CompPc1] =>
			    [CompMo1] =>
			    [CompLy1] =>
			    [CompCa1] =>
			    [CompInox1] =>
			    [CompPva1] =>
			    [CompAc1] =>
			    [CompWm1] =>
			    [CompTe1] =>
			    [CompRa1] =>
			    [CompJu1] =>
			    [CompBamboo1] =>
		    )
    )
   [PStatus] => 0
)


Estranha forma de vida que tem a capacidade de transformar comandos em mensagens de erro.

ndsotware.org

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.