Skip to Content

Business One PHP access

Hi,

I'm trying to access SBO with PHP

Connecting to the company object is working fine

But the next step (getbusinessobject) is not working

Does anybody have tips ?

This is the current code :

<?php

echo "SBO PHP TEST<br>";

$vCmp=new COM("SAPbobsCOM.company") or die ("No connection");

$vCmp->server = "(local)";

$vCmp->CompanyDB = "sbodemo_dutch";

$vCmp->username = "manager";

$vCmp->password = "manager";

//$vCmp->language = "ln_English";

//$vCmp->UseTrusted = True;

$lRetCode = $vCmp->Connect;

echo $vCmp->CompanyName;

echo '<br>';

$vItem = $vCmp->GetBusinessObject(oItems);

$RetVal = $vItem->GetByKey("A1010");

echo '$vItem->Itemname';

echo '<br><br>Ready';

?>

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Jul 17, 2006 at 11:41 AM

    Hmm.. ok

    Try instead of this line: $vItem = $vCmp->GetBusinessObject(oItems);

    This:

    $vItem = $vCmp->GetBusinessObject("oItems");

    or this:

    $vItem = $vCmp->GetBusinessObject(4);

    or this:

    $vItem = $vCmp->GetBusinessObject("4");

    Don't really know how PHP respond to the DI-API.. Never seen anyone do DI-work using PHP before..

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 17, 2006 at 10:59 AM

    Are you sure you have a valid connection ($IRetCode == 0)..

    Possible problem if you dont have a connection

    - Seems you are missing $vCmp->LicenseServer = "servername:30000";

    - Are you sure you PHP-user have Usetrusted (Win Auth) access? use properties dbUsername and dbPassword instead

    The DI Server should be a much better approach when working with PHP (Actually I didn't even know that PHP could work with COM objects)... The DI Server uses a web-service architecture...

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 29, 2009 at 11:58 AM

    Hi,

    Thanks a lot for this post.

    For me the following is running

    $oItem=$vCmp->GetBusinessObject(4);

    $RetBool=$oItem->GetByKey("A1010");

    echo "<br>". $RetBoll;

    echo "<br>". $oItem->ItemName;

    This return:

    1

    Nom de l'article

    For recordset

    $oRS=$vCmp->GetBusinessObject(300);

    $oRS->DoQuery("Select Top 10 itemcode,itemName from oitm")

    $oRS->MoveFirst

    while ($oRS->EOF!=1){

    echo "<BR>".$oRS->Fields->Item(0)->value." ".$oRS->Fields->Item(1)->value;

    $oRS->MoveNext;

    }

    To add an order

    $oOrder=$vCmp->GetBusinessObject(17);

    $oOrder->CardCode="C01";

    $oOrder->DocDueDate="06/04/2009";

    $oOrder->Lines->Itemcode="A1010";

    $oOrder->Quantity=100;

    $RetCode=$oOrder->Add;

    $Nk="";

    if ($RetCode==0) {

    $vCmp->GetNewObjectCode($Nk);

    echo "<BR>" ."Doc Entry ".$vCmp->GetNewObjectCode($Nk);

    }

    Christophe

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 19, 2011 at 12:56 PM

    <?php

    echo "SBO PHP TEST<br>";

    $vCmp=new COM("PERPETUA.company") or die ("No connection");

    $vCmp->server = "(localhost)";

    $vCmp->CompanyDB = "SYSTEM";

    $vCmp->LicenseServer = "localhost:30000";

    $vCmp->username = "manager";

    $vCmp->password = "manager";

    $vCmp->DbServerType(PERPETUA.BoDataServerTypes.dst_MSSQL2008);

    $lRetCode = $vCmp->Connect;

    echo $vCmp->CompanyName;

    echo '<br>';

    $vItem = $vCmp->GetBusinessObject(oItems);

    $RetVal = $vItem->GetByKey("A1010");

    echo '$vItem->Itemname';

    echo '<br><br>Ready';

    ?>

    didnot work?

    1.How to connect the Sap b1 database.

    2. How to entries are pushed into PHP to SAP b1 database?

    Any idea.?

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Gaurav,

      Did you ever try to connect SAP with PHP?

      I tried to do that but I'm getting result as -8037 those are the connection codes I used

      <?php

      $mycomp = new COM("SAPbobsCOM.Company") or die("Cannot start SBO");

      $mycomp->DBServerType =6;

      $mycomp->Server="192.168.0.103";

      $mycomp->LicenseServer = "192.168.0.103:30000";

      $mycomp->DbUserName = "sa";

      $mycomp->DbPassword = "****";

      $mycomp->UserName = "manager";

      $mycomp->Password = "****";

      $mycomp->CompanyDB = "SBODEMOUS";

      echo $mycomp->Connect();

      ?>

      I'm using SQL server 2008 and Xampp for PHP file,

      If it's possible please help me to check in above codes.