What I am trying to do; Loop through ALL sales order lines and store certain fields to a user defined table. My problem is; When an invoice is being shipped the lines on the previous order are duplicated. This is due to the MoveNext() command returning a 0 and the message "This Order is currently being shilled. The Invoice number is 0000001." The order number is still pointing at the prior order number Here is the code; ' Loop through the Sales Order Header & Detail file and dump its contents into a User Defined Table Set oSOhead = oSession.AsObject(oSession.GetObject("SO_SalesOrder_bus")) Set oSOlines = oSOhead.AsObject(oSOhead.Lines) retVal = oSOhead.MoveFirst() Do While oSOhead.EOF 1 retVal = oSOlines.MoveFirst() Do While oSOlines.EOF 1 OrderNo = "" ItemCode = "" Whse = "" QtyOrd = 0 retVal = oSOlines.GetValue("SalesOrderNo$", OrderNo) retVal = oSOlines.GetValue("ItemCode$", ItemCode) retVal = oSOlines.GetValue("WarehouseCode$", Whse) retVal = oSOlines.GetValue("QuantityOrdered", QtyOrd) 'store values to User Defined Table retVal = oSOlines.MoveNext() Loop retVal = oSOhead.MoveNext() msgbox oSOhead.LastErrorMsg 'This returns the message "being invoiced when it tries to go to the Order. 'Using Msgbox I was able to determine that since it doesn't go into the order properly, it loops though the same order twice. 'I have tried assigning the OrderNo variable from the Header, 'but then the lines are still looping through the prior order but now with the correct order number Loop Is there a way to virtually press the OK button like you would if you went into the Sales Order being shipped manually? thanks for any assistance.
↧