on ‎2012 Oct 22 3:58 PM
Hello!
Is there any way or you may modify the CardCode a Business Partner from the SDK,
so far I only update fields as cardCode, CardType, etc, but when I update the CardCode throws me the error -2035, which as I saw in the documentation is that "Data Source - Duplicate Keys" the cardCode is duplicated.
Here is the code (this in php):
<?php
try {
if(!$sap->Connected)
$sap->Connect();
if($sap->Connected) {
$oBO = $sap->GetBusinessObject(2);
if ($oBO->GetByKey('CL-7777776') == true) {
$oBo->CardCode='CL-7777777';
$VALOR = $oBo->Add();
if($VALOR != 0)
echo 'ERROR : ' . $ERR. '<br>';
}
$sap->Disconnect();
}
else {
echo 'No Conectado';
}
}
catch (Exception $e) {
echo 'ERROR: <br />' . $e . '<br />';
echo $sap->GetLastErrorDescription() . '<br />';
}
?>
Request clarification before answering.
Hi,
I guess you are trying to add new bp
$oBo->CardCode='CL-7777777';
$VALOR = $oBo->Add();
if seems that card code is already exists. If you want to update any existing transaction / master files, you need to use GetByKey function to get existing record and then fire update method.
Hope this will clear your confusion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jhonatan,
Until you have created any document for that Business Partner, you can change BP Code.
If you have any document created with that Business Partner you can not update the BP Code.
--
Amrut Sabnis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jhonatan,
As Pedro suspects, you cannot change the CardCode anymore once transactions are connected to this CardCode.
Unfortunately there is no single method to check for this. You will have to perform checks against several transaction tables, depending on the CardType ('C' = Customer, 'S' = supplier/vendor, 'L'= lead)
'C':
ORDR
ORDN
ODLN
ODPI
OINV
ORIN
'S':
OPOR
OPDN
ORPD
ODPO
OPCH
ORPC
'L'
None, as this type of card has no transactions per definition
Aside from these checks, the CardCode is the unique key in the OCRD table, and your code just tries to update the CardCode, without checking if that CardCode does not already exist. It is no wonder that you are getting a duplicate key error.
You have to build in a procedure to check for the next available code.
Regards,
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jhonatan,
I think you can only change the code if you have no transaction for that BP.
Good luck.
Best regards,
Pedro Magueija
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 17 | |
| 15 | |
| 14 | |
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.