on 07-17-2006 11:36 AM
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';
?>
<?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.?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please try this-->
<?php
$vCmp=new COM("SAPbobsCOM.company") or die ("No connection");
$vCmp->DbServerType=6;
$vCmp->Server = "SQL_SERVER_NAME"; \\Server
$vCmp->CompanyDB = "SQL_DB_NAME"; \\SBODemoIN
$vCmp->LicenseServer = "LICENSE_SERVER_WITH_PORT"; \\ Server:30000
$vCmp->UserName = "(B1_company_ussername"; \\ manager
$vCmp->Password = "B1_company_password"; \\ 1234
$vCmp->DbUserName = "sa";
$vCmp->DbPassword = "sql_server_password"; \\ 1234
$lRetCode = $vCmp->Connect;
echo $vCmp->CompanyName;
?>
--Note-- Don't forget to replace credentials with your actual one.
Regards,
ARYA
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Working PHP script :
<?php
$vCmp=new COM("SAPbobsCOM.company") or die ("No connection");
$vCmp->server = "(local)";
$vCmp->CompanyDB = "sbodemo_dutch";
$vCmp->username = "manager";
$vCmp->password = "manager";
$lRetCode = $vCmp->Connect;
$vItem = $vCmp->GetBusinessObject(305);
$rs = $vItem->getitemprice("sw2","a1000",70,"17-07-2006");
echo $rs[0]->value;
echo $rs[1]->value;
?>
305 = BoBridge
SW2 = cardcode
A1000 = itemcode
70 = amount
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
6 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.