cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Update CardCode SDK - DI API

Former Member
0 Likes
845

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

}

?>

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Likes

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.

Former Member
0 Likes

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

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

pedro_magueija
Active Contributor
0 Likes

Hi Jhonatan,

I think you can only change the code if you have no transaction for that BP.

Good luck.

Best regards,

Pedro Magueija