Options

Locking issues in webservice function

livingdolllivingdoll Member Posts: 45
edited 2012-06-12 in NAV Three Tier
Hi,

I have to create a webservice that can be used to insert sales orders. The function called in NAV must create a sales header and one sales line. Since multiple users can be using this service (I presume with the same sql-user login) I'm foreseeing table locks/dead locks issues. I can't afford to get errors in the webservice because of locking.

In short, this is the flow that I need in the published codeunit:

1. Data is received via XMLport and stored in a separate table in NAV.
2. From this table, I'm inserting a Sales Header:
- SalesHeader.init;
- fill some fields in SalesHeader;
- SalesHeader.Insert(true);
- Modify some fields in SalesHeader to overrule the values that were put in by the Insert(True)
- SalesHeader.modify;

3. Inserting a Sales Line for that header:
- SalesLine.FINDLAST to find last line number used and increment it with 10000
- SalesLine.init;
- fill some fields in SalesLine
- SalesLine.Insert(true);
- Modify some fields in SalesLine to overrule the values that were put in by the Insert(True)
- Depending on some values in SalesLine, modify shortcut dim 1 & 2 in SalesHeader
- SalesHeader.modify (if shortcut dim 1 & 2 were modified)
- SalesLine.modify(true);

Since I think i'm using one insert followed by a modify on both sales header and sales line tables, I want to know where to put locktables - and what parameters I have to use (locktable(true,false)) ? If I put in SalesHeader.locktable and SalesLine.locktable at the start of the function (before step 2), is the lock then removed on the first Insert statement? Do I have to lock it again to be able to modify it?

Since I'm only inserting, what is the best strategy?

I hope someone can shine a light on this!

Best regards,
Greys
Sign In or Register to comment.