rduncan10
6th June 2013, 21:23
I am writing an AFS session for Maintain Receipt (tdpur4120m000).

Everything is working fine thanks to help from other posts on this site, but I am having one problem.

Sometimes the source data (a text file sent by another application) only has receipts for a few lines on a PO. I need to deliver zero and backorder the remaining lines so that they can immediately be available for another receipt.

I tried to use the following code to do this. My idea was to backorder all lines first, then use stpapi.find to find the lines in the source data and receive them:

loop = stpapi.browse.set("tdpur4120m000", "first.set", err)
while loop
stpapi.get.field("tdpur4120m000", "tdpur045.pono", value)
stpapi.put.field("tdpur4120m000", "tdpur045.date", str$(date.num()))
stpapi.put.field("tdpur4120m000", "tdpur045.diqu", str$(0))
stpapi.put.field("tdpur4120m000", "tdpur045.dqua", str$(0))
stpapi.update("tdpur4120m000", 1, err)
loop = stpapi.browse.set("tdpur4120m000", "next.set", err)
endwhile

The code does loop through all lines. The stpapi.get.field does return the value of every line number. But the stpapi.update stops working after 12-15 lines. There is no error: the lines just don't get updated.

The updates stop about half way down the second page, that is just after I would have to hit page down if I were receiving this manually. I'm not sure if that has something to do with it.

Any help is appreciated.

mark_h
6th June 2013, 23:33
Can I ask why you have to put them in back order? All I do is create one receipt for every line in the PO. The next time a part comes in the AFS code finds the original receipt and does a receipt against it. So this receipt is always ready to go for the next part - even if it is months later(and it is sometimes).

Now having said that something to try in the code - after the browse.set try a stpapi.mark record. If that does not work then can you put a find right have the browse.set? I know I have one session where I have to do that - just can't find it right now. Let me check some more.

mark_h
6th June 2013, 23:54
What happens is the next set does not make the record the current record in the buffer, by doing a find it makes it the current record.

Found it:



rc = stpapi.browse.set( "ticpr9152m00b", "next.set" )
| Do this because the next set is not making the record available
| for update
if rc = 1 then
stpapi.get.field( "ticpr9152m00b", "ticpr952.cpcp", cpc )
stpapi.get.field( "ticpr9152m00b", "ticpr952.ptyp", ptyp )
stpapi.put.field("ticpr9152m00b", "ticpr952.item", adj.item)
stpapi.put.field("ticpr9152m00b", "ticpr952.cprj", adj.proj)
stpapi.put.field("ticpr9152m00b", "ticpr952.mbcs", str$(adj.mbcs))
stpapi.put.field( "ticpr9152m00b", "ticpr952.ptyp", ptyp )
stpapi.put.field( "ticpr9152m00b", "ticpr952.cpcp", cpc )
rc1 = stpapi.find( "ticpr9152m00b" )
endif

rduncan10
7th June 2013, 00:03
Thanks for the tips. I will try them.

We mostly backorder out of habit, but there are a few reasons we want to continue to do this.

We may be using a combination of AFS and manual receiving. For a manual user it is generally faster to create a new receipt than to find an old one.

We are also working on automating the AP matching process, and you can use the supplier's packing slip number as a way to match AP to a receipt. Our suppliers usually have one invoice per packing slip.

mark_h
7th June 2013, 01:03
That makes sense. All of our production part receipts are done via the automated session - but they still have the manual option. They only use manual for non-production part receipts. I think we trained our users out of doing it manual since the automated session required so much less work(and thought) on their part. :)

PS - I found 3 other places where the next.set did not work. Two were deletes - in those cases I just used first.set every time until all the records were deleted. In the other case I did a browse with next.set and then a stpapi.mark right after it to get it to work.