Ankita Patel
24th October 2013, 10:36
Hi all,

I have written AFS on session timps3501m000.
timps3501m000 session stores last found value as the default values.
I'm trying to find data from session timps3501m000, find returns 1 but when I'm trying to retrieve the value it gives me default values.

please help me out ..

mark_h
24th October 2013, 15:56
Post your code? That session might need you to do a change.view followed by a find.

Ankita Patel
25th October 2013, 09:21
Hi mark,

here is the code

stpapi.clear("timps3501m000")
stpapi.put.field( "timps3501m000", "plan.site","500" )
stpapi.put.field( "timps3501m000", "timps300.plnc","MPE")
stpapi.put.field( "timps3501m000", "timps300.plvl","4")
stpapi.put.field( "timps3501m000", "timps300.plni","8002297" )
retval = stpapi.find("timps3501m000")

find returns 1 but when I'm trying to get the value of plnc,plvl and plni it gives me the default values that is stored in session

bhushanchanda
25th October 2013, 12:22
Hi,

Have you tried combining change.view() & browse.set() or change.view() & find()?

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

There can be many reasons, I am on LN, so don't have this session in my Env.

Also, as Mark said, you might try using stpapi.change.view() before using stpapi.find() or you can do a change.view() and then browse.set().

Also, check the indexes on the table if you are missing something.

These links can help you:-

1 (http://www.baanboard.com/baanboard/showthread.php?t=53201)
2 (http://www.baanboard.com/baanboard/showthread.php?t=54269)
3 (http://www.baanboard.com/baanboard/showthread.php?p=144564)

mark_h
25th October 2013, 16:28
I think bhushan has most of the basics covered. I ran the session on my system. I really do not have any permissions in it. From just running my session the plan site was on form 1. To get it set it looks like you enter hit and then hit the exit button. From the looks of it the default is the current company. So do you even need to enter it?

If you do the way I would play with writing the session - I would first put the plan site and then use stpapi.application.option to exist the choice.user.2 option. Which is what it looks like to me. Then I would try the find. On my system the find includes the plan code, plan level, item, period date. So I would only put those fields - well at least the first two fields, followed by the find.

If the above did not work I would then do the same thing for the site code, but I would then do a change view, followed by a find. See if that works - if not then more playing around with the various commands. Since we do not have source code I can use qkey to just give me an idea of what the session does.

The whole key to AFS is to try to mimic what you would do manually. I usually document a simple little flow chart of what I hit and what the session does. In this case it looks like (if I used the session) I would just start the session, hit find to get the right plan level. So I would not mess with the site unless I had to. No promises any of this works and sometimes you just have to play with the commands and the sessions to get them to work.