The above diagram describes a high-level flow of the complete requirement. We have already have discussed a high-level view of the requirement, now let’s discuss this in more detail. Data can choose to come through JSON or XML as we are using Rest API here. Oh! I know your next question, why rest API? The answer is the modern standards. Since Rest is lightweight, faster, easy, and flexible, we will be choosing this API over any other.
Let’s assume both parties agree for the transfer of data using JSON, but the condition may consist of both insertable and updatable data. Are you confused about what I mean by that? See, invoices can be altogether new or can be an old one with some modification. It is vital that we also capture changes to the invoices. Consider a scenario, an end customer had bought 5 elevators for this business apartment but due to a damaged piece wants to return one and further decided to adjust in 4 elevators itself, thereby canceling 1 elevator. In this case, an invoice must be modified to reflect the billing for 4 elevators, and such change should appear in Salesforce too. Hence, the JSON file may consist of both new invoices, where we will use insert operation and modification in invoices where we will use update operation. I think the diagram above would be easily understandable to you, how data flow from SAP through JSON to Salesforce and Salesforce processes it to the database. Now here, this diagram defines two kinds of databases, one for success records and another for failed records. It is necessary to have two kinds of databases to handle exception occurring during processing and send back error records to SAP for correction. An exception can be of many types, sometimes your relationships are not correct, or your email fields consists of junk, or your phone number has some alphabets in it, or you forgot to capture the name of the person on the invoice! Jokes apart, but using the error database, proper exception management can be done, and the response for success or error can be sent back to SAP. “Response JSON,” an arrow going from Salesforce to SAP in the diagram, defines such a response.
As you have a bit more idea about the requirement now, Can you tell me one thing? How can you relate a record between SAP and Salesforce? I mean to say if I want to search for a record in SAP and the same record in Salesforce, how can I do that? If you know it, hats off! If you scratching your head, the next section is for you! Let’s start reading it.