Hi Dinesh,
You can test it yourself to see if checking status=Delivered is enough or not.
For example, create a sales order with two lines. One with Qty =1 and one with Qty=2.
Confirm the order, then deliver the item with 1 Qty and and change the item2 qty to 1 in the delivery dialog.
You'll notice that the sales order status is still open order.
Click post packing slip again, to deliver the remaining qty of 1 for the 2nd item and click ok, you'll notice that the status became now delivered. which will mean that what you did is correct. You could also debug to see if it brought orders you are not interested in.
So maybe checking SalesTable.SalesStaus = delivered is better than SalesLine to make sure the whole order is delivered(based on your requirement)
We can't tell what your code does, but for example to enhance performance, you can amend few lines
In the select statement for markupTrans
Select firstOnly MarkupCode from markupTrans.....
And the first select statement where you join salesTable
while select.....
join ISFLOC, SalesStatus From salesTable where....
Thanks,
Layan Jweihan
Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future