a.menon
30th April 2014, 09:48
Dear All,

I have an AFS session which automates the Warehouse Receipt Process. The session calls The Receipts session - whinhf3520m000 and creates a new receipt. Then links the expected order lines to the receipt. I noticed that the stpapi.find which runs on whinh3820m000 and finds the record to be linked , fails in some cases.



stpapi.put.field("whinh3520m000", "whinh210.rcno", receipt.number) |AM.14042014.sn
stpapi.browse.set("whinh3520m000", error.mess)
if not isspace(error.mess) then
message(error.mess)
endif
stpapi.handle.subproc("whinh3520m000","whinh3820m000","add") |AM.14042014.en

whinhf3820m000.put.Order_Origin(whgei210.oorg)
whinhf3820m000.put.Order(whgei210.orno)
whinhf3820m000.put.Position_Number(whgei210.pono)
whinhf3820m000.put.Sequence_Number(ord.seq)
ret = whinhf3820m000.find(error.mess)




The FIND returns 2- another record found- in some cases. Whereas it works fine in others. The session does not have a view field , as such I don't understand as to why the script fails.

The session had been working fine for a long time now. But suddenly started to have this issue.

Kindly provide your insights. I have attached the AFS log files for 2 runs of the session as well.

Thanks in advance.

Anjana

bhushanchanda
30th April 2014, 14:15
Hi,

Were there any recent solution installations related to Warehouse Receipts? May be any changes to functionality. Verify if everything is same as it was earlier.

Also, try using stpapi.change.view() if the session has view fields instead of stpapi.find()

Check this thread (http://www.baanboard.com/baanboard/showthread.php?t=25687).

And, I guess you are the owner of this Thread (http://www.baanboard.com/baanboard/showthread.php?t=66077).

a.menon
30th April 2014, 16:03
Hi,

Were there any recent solution installations related to Warehouse Receipts? May be any changes to functionality. Verify if everything is same as it was earlier.

Also, try using stpapi.change.view() if the session has view fields instead of stpapi.find()

Check this thread.

And, I guess you are the owner of this Thread.

__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!

Thank you for your reply. The session does not have a view field as such change.view may not be applicable I believe.

mark_h
30th April 2014, 16:55
Moved this thread the the correct AFS forum.

I am not familiar with the session, but the thread Bhushan linked in shows 5 fields for the find and you only show 4. So if the find has 5 fields even if you do not use a field like oset - you should still possible put it. I just do not know if you have to have that field.

stpapi.put.field("whinh3820m000","whinh210.oorg","80")
stpapi.put.field("whinh3820m000","whinh210.orno","100000135")
stpapi.put.field("whinh3820m000","whinh210.oset","1")
stpapi.put.field("whinh3820m000","whinh210.pono","10")
stpapi.put.field("whinh3820m000","whinh210.seqn","1")


And on of the threads it links to shows 5 fields also, but they put receipt number again - so you might want to try that.

stpapi.handle.subproc("whinh3520m000","whinh3820m000","add")
stpapi.put.field("whinh3820m000", "receipt.number", recnum)
stpapi.put.field("whinh3820m000", "whinh210.oorg", "1")
stpapi.put.field("whinh3820m000", "whinh210.orno", "211000499")
stpapi.put.field("whinh3820m000", "whinh210.pono", "10")
stpapi.put.field("whinh3820m000", "whinh210.seqn", "0")
stpapi.form.command("whinh3820m000", 5, "exec.user.1",error)


Basically when you hit the find button manually what ever fields show up in it are what you should put in the session to execute the find.

bhushanchanda
30th April 2014, 17:04
Good catch Mark :)

a.menon
1st May 2014, 08:18
Moved this thread the the correct AFS forum.

I am not familiar with the session, but the thread Bhushan linked in shows 5 fields for the find and you only show 4. So if the find has 5 fields even if you do not use a field like oset - you should still possible put it. I just do not know if you have to have that field.

stpapi.put.field("whinh3820m000","whinh210.oorg","80")
stpapi.put.field("whinh3820m000","whinh210.orno","100000135")
stpapi.put.field("whinh3820m000","whinh210.oset","1")
stpapi.put.field("whinh3820m000","whinh210.pono","10")
stpapi.put.field("whinh3820m000","whinh210.seqn","1")


And on of the threads it links to shows 5 fields also, but they put receipt number again - so you might want to try that.

stpapi.handle.subproc("whinh3520m000","whinh3820m000","add")
stpapi.put.field("whinh3820m000", "receipt.number", recnum)
stpapi.put.field("whinh3820m000", "whinh210.oorg", "1")
stpapi.put.field("whinh3820m000", "whinh210.orno", "211000499")
stpapi.put.field("whinh3820m000", "whinh210.pono", "10")
stpapi.put.field("whinh3820m000", "whinh210.seqn", "0")
stpapi.form.command("whinh3820m000", 5, "exec.user.1",error)


Basically when you hit the find button manually what ever fields show up in it are what you should put in the session to execute the find.

Thank you mark for the great find.
When I open the session and do a find the set no is not included in the find fields. I checked the indices on the session and the table. The table has an index with the set no , but the session does not seem to use it.
I have attached screenshots of the same.

Problem is I am not able to reproduce the issue on my test environment and as such I am not able to do a trial and error. Hope you understand the pickle am in!! :(

a.menon
1st May 2014, 09:17
The following Thread (http://www.baanboard.com/baanboard/showthread.php?t=60200) shows a case in which a FIND was done twice. Any chance this could be the solution here. Mine is not a session with view field.

If someone has tried a similar solution and worked please do reply. Thanks.

bhushanchanda
1st May 2014, 14:49
Hi,

You can definitely give it a try. I am not familiar with your session so can't try anything.

AFS requires a lot of trial and errors and even after you think you are done, you can get some unusual problems either due to some new scenarios introduced or may be any system changes. You just need to be a bit patient and you will do it.

mark_h
1st May 2014, 15:58
Well it tells me something is different between production and development. Session, libraries, porting set or something. I am just not sure how to determine which it is.

And yes - I can't remember which case it was that I had to do a find twice to make sure I got the correct record. I have also had to do change view and a find to make sure I got the correct record. Sometimes you just have to play with it like Bhushan mentioned.

a.menon
8th May 2014, 12:27
Hello Gurus,

I tried the solution with 2 finds as given below.

|whinhf3520m000.handle.sub.process("whinh3820m000", "add") |AM.14042014.so
|stpapi.put.field("whinh3820m000", "whinh210.rcno", receipt.number) |AM.14042014.eo

stpapi.put.field("whinh3520m000", "whinh210.rcno", receipt.number) |AM.14042014.sn
stpapi.browse.set("whinh3520m000", error.mess)
if not isspace(error.mess) then
message(error.mess)
endif
stpapi.handle.subproc("whinh3520m000","whinh3820m000","add") |AM.14042014.en

|ret = whinhf3820m000.find(error.mess) |AM.04052014.n


whinhf3820m000.put.Order_Origin(whgei210.oorg)
whinhf3820m000.put.Order(whgei210.orno)
whinhf3820m000.put.Position_Number(whgei210.pono)
whinhf3820m000.put.Sequence_Number(ord.seq)
ret = whinhf3820m000.find(error.mess)


if ret<>1 then |AM.06052014.en
whinhf3820m000.put.Order_Origin(whgei210.oorg)
whinhf3820m000.put.Order(whgei210.orno)
whinhf3820m000.put.Position_Number(whgei210.pono)
whinhf3820m000.put.Sequence_Number(ord.seq)
ret = whinhf3820m000.find(error.mess)
endif



The test environment all worked fine , the first find returns 2 then the next find returns 1. But on Live , only on certain cases , both finds return 2 .

The test and live only differ by the package combination . Rest all is the same in both . As such I don't see why any difference should be there.

Does anyone have any other suggestions ? Will change.view work in this situation? But the session does not have a view field.

Thank you.

mark_h
8th May 2014, 15:07
Never hurts to try change view. My thing is if it works in test and not production - there is a difference somewhere between the two systems. I just do not know how to identify where.