abattoir
21st September 2015, 23:48
Hi, I am trying to close one order at a time using AFS code, but the program is ignoring the "Order Number" value passed to code and is closing for the entire range (0 - 999999) of Production Orders.
Below is the code snippet:
I am passing (tisfc001.pdno, tisfc001.mitm) value from another function, but still it is closing all the orders. I have checked in debug mode, that tisfc001.pdno and tisfc001.mitm are getting passed with correct values, but still it is closing the entire range of production orders.
function close.order()
{
error.msg = ""
stpapi.put.field( "ticst0201m000", "pdno.f", str$(tisfc001.pdno) )
stpapi.put.field( "ticst0201m000", "pdno.t", str$(tisfc001.pdno) )
stpapi.put.field( "ticst0201m000", "cprj.f", "" )
stpapi.put.field( "ticst0201m000", "cprj.t", "ZZZZZZ" )
stpapi.put.field( "ticst0201m000", "item.f", tisfc001.mitm )
stpapi.put.field( "ticst0201m000", "item.t", tisfc001.mitm )
stpapi.put.field( "ticst0201m000", "woar.f", "" )
stpapi.put.field( "ticst0201m000", "woar.t", "ZZZ" )
stpapi.put.field( "ticst0201m000", "cmdt.f", str$(date.f) )
stpapi.put.field( "ticst0201m000", "cmdt.t", str$(date.t) )
stpapi.put.field( "ticst0201m000", "rpt.only", str$(2) )
stpapi.put.field( "ticst0201m000", "cldt", str$(date.t) )
stpapi.get.field( "ticst0201m000", "pdno.f", f.value )
stpapi.get.field( "ticst0201m000", "pdno.t", t.value )
stpapi.set.report( "ticst0201m000", "rticst020101000", "NOTEPAD", error.msg )
stpapi.get.field( "ticst0201m000", "pdno.f", f.value )
stpapi.get.field( "ticst0201m000", "pdno.t", t.value )
if isspace(error.msg) then
stpapi.continue.process( "ticst0201m000", error.msg )
if NOT isspace(error.msg) then
error.msg = error.msg
else
counter = counter + 1
endif
stpapi.end.session( "ticst0201m000" )
else
stpapi.end.session( "ticst0201m000" )
endif
}
I cannot understand what can be the issue here. Thanks for the help in advance.
Regards,
Abattoir
pillai.ganesh
22nd September 2015, 08:11
Hi Abattoir,
I would suggest you to read the values of form fields item.f, item.t and "select.grouping" with stpapi.get.field() before the stpapi.continue.process() statement; as I see a possibility where value of "select.grouping" checkbox is yes as per user defaults due to which the other fields will be considered for full range. So you must delete the user defaults before running the AFS in this case.
You can alternatively use standard dll - ticst.dll0004.close.production.order.or.operation() to close the Production orders by passing parameters to the dll. As using dlls wherever possible in place of AFS will make you solution more standard.
Hope this helps.
Regards,
Ganesh
abattoir
22nd September 2015, 15:52
Hello Ganesh, Thanks for the reply. I am on BaanIV environment, so the DLL ticst.dll0004.close.production.order will not work for me. If you know the related DLL in Baan IV, i can use that.
2. I tried to read the form field inputs after continue statement in debug mode and I can still see that (pdno.f,pdno.t) are getting correct value assigned.
Below is the code change:
function close.order()
{
error.msg = ""
stpapi.put.field( "ticst0201m000", "pdno.f", str$(tisfc001.pdno) )
stpapi.put.field( "ticst0201m000", "pdno.t", str$(tisfc001.pdno) )
stpapi.put.field( "ticst0201m000", "cprj.f", "" )
stpapi.put.field( "ticst0201m000", "cprj.t", "ZZZZZZ" )
stpapi.put.field( "ticst0201m000", "item.f", tisfc001.mitm )
stpapi.put.field( "ticst0201m000", "item.t", tisfc001.mitm )
stpapi.put.field( "ticst0201m000", "woar.f", "" )
stpapi.put.field( "ticst0201m000", "woar.t", "ZZZ" )
stpapi.put.field( "ticst0201m000", "cmdt.f", str$(date.f) )
stpapi.put.field( "ticst0201m000", "cmdt.t", str$(date.t) )
stpapi.put.field( "ticst0201m000", "rpt.only", str$(2) )
stpapi.put.field( "ticst0201m000", "cldt", str$(date.t) )
stpapi.get.field( "ticst0201m000", "pdno.f", f.value )
stpapi.get.field( "ticst0201m000", "pdno.t", t.value )
f.value = ""
t.value = ""
stpapi.set.report( "ticst0201m000", "rticst020101000", "NOTEPAD", error.msg )
stpapi.get.field( "ticst0201m000", "pdno.f", f.value )
stpapi.get.field( "ticst0201m000", "pdno.t", t.value )
f.value = ""
t.value = ""
if isspace(error.msg) then
stpapi.get.field( "ticst0201m000", "pdno.f", f.value )
stpapi.get.field( "ticst0201m000", "pdno.t", t.value )
stpapi.continue.process( "ticst0201m000", error.msg )
if NOT isspace(error.msg) then
error.msg = error.msg
else
counter = counter + 1
endif
stpapi.end.session( "ticst0201m000" )
else
stpapi.end.session( "ticst0201m000" )
endif
}
Regards,
Ankur
mark_h
22nd September 2015, 17:16
Do you have baan source code? You can put the baan code in debug mode and see what happens to each of the input fields and various points of the program. Best way to figure out what is happening.
If you can't do the about - do you have any other fields on the form? My version of the session has a "pegged order" field. The session on our system could be different from yours. What might be occurring is when you execute continue there might be another field that resets or re-initializes some of the form fields. Not all baan sessions are friendly to AFS code.
abattoir
24th September 2015, 18:18
I dont have source code in Baan and I have tried everything I could to make it work, but it just wont work. Any other suggestions, that i can apply, which can help. It's a very simple session with equally simple AFS Code. I dont know what am i could be doing wrong??
Regards,
Abattoir
bhushanchanda
24th September 2015, 19:10
As Ganesh suggested,
Did you already cleared user defaults for that session? If not, you need to clear them. Also, what are the other form fields? Did you tried setting value for all the form fields?
Though for simpler sessions its easier, but you never know with AFS. You need to play around and tweak things to get it work.
mark_h
25th September 2015, 18:02
Bhushan is correct - even simple sessions might not work as intended when running in afs mode. What I think is happening, but do not know for a fact, is that an event like after.input, is not firing until the continue is executed. At that point the input fields get reset to something else. You might even what to try you stpapi.get after the stpapi.continue to see if the fields have been reset. That would confirm some event or something is changing the values or resetting them.
Now what I would do on my system is make the baan session a qkey session - put it in debug mode and step thru each event after the continue. Seeing what happens to each of the variables along the way. You can check ~vamsi's source code extension in the code and libraries forum - it will allow you to do the same type stuff. It will take some work getting it going, but at least then you could step thru the baan session. In order to get some sessions to work correctly I have had to make them qkey sessions to import variables. I have one heck of a time with some sessions and the spool.* variables with reports.
If you are feeling frisky here are some off the wall things you can try to get it to work -
(1) Run it once in report only mode, put the all the fields again - then set report only to no and run again. Do not end the session between the runs.
(2) You can try a stpapi.save or update before the continue, you can try with true and false as the option, do your stpapi.get and see if the variables are changed. Of course this depends on the session options that are set. You can always run ttstpcreatdll to see what is available on the session.
Those were the first two things that popped into my mind.