SAP Knowledge Base Article - Public

3280435 - MDF Object Association Error when try to Upsert two child for same start date

Symptom

You are facing below error when you try to upsert the MDF object with associate value or Child value.

error message:-  Save batch with same externalCode failed! Same records exist in Batch!


Environment

  • SAP SuccessFactors HXM Suite
    • Integrations
      • Integration Center

Reproducing the Issue

1. You are using below query to perform the upsert with post operation in postman.

Query:-

https://apisalesdemo4.successfactors.com/odata/v2/cust_FinanceDepartment?$format=JSON&$expand=cust_costcenter


Payload:-

{
    "externalCode": "0030",
                "effectiveStartDate": "/Date(1495746637000)/",
                "externalName_defaultValue": "0030",
                "mdfSystemStatus": "A",
                
                "cust_costcenter": {

                            "externalCode": "24001-500",
                            "startDate": "/Date(-2208988800000)/",
                            "status": "A",
                            
         

                            "externalCode": "36152-100",
                            "startDate": "/Date(-2208988800000)/",
                            "status": "A",
                            
                }
                
                
}


2. Getting error response

{
    "error": {
        "code": "COE_GENERAL_BAD_REQUEST",
        "message": {
            "lang": "en-US",
            "value": "Save batch with same externalCode failed! Same records exist in Batch!"
        }
    }
}


Cause

This is expected behavior as both records are considered as same, there are two problems with above query

1. In the query upsert operation is not in use.

2. All the child or associate field are added in one expand entity. It should be added with metadata.

To resolve the issue, use the payload showing the resolution.


Resolution

Query:https://apisalesdemo4.successfactors.com/odata/v2/upsert

Payload:-

{
    "__metadata": {
"uri": "cust_FinanceDepartment"
},
    "externalCode": "0030",
                "effectiveStartDate": "/Date(1495746637000)/",
                "externalName_defaultValue": "0030",
                "mdfSystemStatus": "A",
                
                "cust_costcenter":[
                    {
                        
                            "__metadata": {
                                "uri": "https://apisalesdemo4.successfactors.com/odata/v2/FOCostCenter(externalCode='24001-500',startDate=datetime'1900-01-01T00:00:00')"
                            },
                            "externalCode": "24001-500",
                            "startDate": "/Date(-2208988800000)/",
                            "status": "A"
                        

                    },

                    {
                        
                            "__metadata": {
                                "uri": "https://apisalesdemo4.successfactors.com/odata/v2/FOCostCenter(externalCode='36152-100',startDate=datetime'1900-01-01T00:00:00')"
                            },
                            "externalCode": "36152-100",
                            "startDate": "/Date(-2208988800000)/",
                            "status": "A"
                        

                    }
                ]

}


Response:-
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">
    <entry>
        <content type="application/xml">
            <m:properties>
                <d:key m:null="true"></d:key>
                <d:status>OK</d:status>
                <d:editStatus>UPSERTED</d:editStatus>
                <d:message m:null="true"></d:message>
                <d:index m:type="Edm.Int32">0</d:index>
                <d:httpCode m:type="Edm.Int32">200</d:httpCode>
                <d:inlineResults m:type="Bag(SFOData.UpsertResult)"></d:inlineResults>
            </m:properties>
        </content>
    </entry>
</feed>

Keywords

MDF, upsert, Payload, response, Save batch with same externalCode failed! Same records exist in Batch!, Same date , KBA , LOD-SF-INT-ODATA , OData API Framework , Problem

Product

SAP SuccessFactors HXM Core all versions ; SAP SuccessFactors HXM Suite 2211