rduncan10
7th April 2014, 21:56
I have an AFS session for receiving (tdpur4120m000) that is working well, but I'm having an issue with backorders.

With some lines, I want the system calculate the backorder. With other lines, I want to enter a specific backorder. The problem is that as soon as I enter a backorder, that value of tdpur045.bqua stays in memory and it is copied to the subsequent lines.

I might end up with this:

Line 10; Order Qty: 10; Del. Qty: 5 < System enters 5 in Backorder
Line 20; Order Qty: 8; Del. Qty: 4 < System enters 4 in Backorder
Line 30; Order Qty: 10; Del. Qty: 5; Backorder Qty: 0
Line 40; Order Qty: 3; Del. Qty 1; Backorder Qty: 0 < System picked up 0 from Line 40.

In Lines 10 and 20, I don't send a backorder to AFS, and it calculates the correct backorder. In Line 30, I send a backorder of 0 (to cancel the line). In Line 40, I want it to go back to calculating the backorder, but instead it picks up 0, the amount from the previous line.

How do I clear that value from memory and get AFS to go back to calculating the backorder?

My code looks like this (somewhat simplified). I have the values to receive in a table called tdcus021. If the backorder quantity is -1, AFS should calculate the backorder.
loop = stpapi.browse.set("tdpur4120m000", "first.set", err)
while loop
| You need to use this get, put and find combo to make each line of the
| receipt current, so you can edit it. Just using next.set by itself
| doesn't do that.
stpapi.get.field("tdpur4120m000", "tdpur045.orno", f.orno)
stpapi.get.field("tdpur4120m000", "tdpur045.pono", f.pono)
stpapi.put.field("tdpur4120m000", "tdpur045.reno", str$(reno))
stpapi.put.field("tdpur4120m000", "tdpur045.orno", f.orno)
stpapi.put.field("tdpur4120m000", "tdpur045.pono", f.pono)
pono = lval(f.pono)
rc1 = stpapi.find("tdpur4120m000")
| Line is now current, start entering data
stpapi.put.field("tdpur4120m000", "tdpur045.date", str$(date.num()))
| form.quan contains the order quantity. need this for backorder stpapi.put.field("tdpur4120m000", "tdpur045.diqu", str$(tdcus021.dqua))
stpapi.put.field("tdpur4120m000", "tdpur045.dqua", str$(tdcus021.dqua))
|if tdcus021.bqua <> -1 then
stpapi.put.field("tdpur4120m000", "tdpur045.bqua", str$(tdcus021.bqua))
endif

| Upsdate and go to next line
stpapi.update("tdpur4120m000", 1, err)
loop = stpapi.browse.set("tdpur4120m000", "next.set", err)
endwhile

mark_h
8th April 2014, 00:42
You can always try opening and closing the session after each line - or at least when you put the back order qty. A lot of overhead if you are doing hundreds of orders. This is all that jumps into my mind right now.