cancel
Showing results for 
Search instead for 
Did you mean: 
Subscribe

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 />';

}

?>

0 Likes
View Entire Topic
Johan_Hakkesteegt
Active Contributor
0 Likes

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