I have a requirement on my hands to update sales order and sales order lines via x++ code.
That's nice. Do you need something from us? If so, you'll have to explain your problem...
I have a custom table linked to a custom data entity. So I need some x++ snippet to update sales orders header and sales lines...
If you're unable to say what the code should do, you're not in a position to start coding. First think about what you're trying to achieve from the functional point of view. If you don't know, go back to your functional consultant or whoever is responsible for these things on your project.
When you know what you want to achieve, think about how. What should happen in the application at what time, what should be atomic operations, which objects are involved, which pieces of logic don't exist yet and so on.
Only when you know what needs to be changed in the application, start writing code (if any is needed in the first place). Cover what you can and when you get stuck, come here and explain your problem. At the point, you'll be able to explain it.
I know these operations are atomic and that's why I'm not thinking of just doing a select for update statement, there could be more to it.
I need to update sales order headers and sales line from a web API which will, of course, hit the data entity endpoint for sales order and sales line.
I've been having a hard time achieving this, that's why I'm thinking of coming up with a custom table and data entity and then add the fields needed for the update operation to work as columns on the table and the on the insert() method, carry out the update operation and wipe the custom table clean when the update operation completes.