Jordi.Tolra
10th October 2012, 15:06
Hola a tohom,

I'm working with an AFS to Maintain Period status (tfgld0107m000).

I simply find the record to modify and fill in the 4 fields to update and I execute the update.

My problem is that one of the fields has to be changed before the orders (it has an after.input check).

Is there a way in the AFS session to force the order in which the fields are updated?

The code is the following:

fiscal.period = tfgld.ptyp.financial
tax.period = tfgld.ptyp.vat
status.open = tfgld.sper.open
status.closed = tfgld.sper.closed

mess.update = ""
ok = 0
ok.find = 0

cdll0107.put.fiscal_year(year.f)
cdll0107.put.period_number(prno.f)
cdll0107.put.period_type(fiscal.period)

ok.find = cdll0107.find()

if ok.find then
ok = 0
cdll0107.put.Status_of_GLD(status.open) |# 1
cdll0107.put.Status_of_CMG_Module(status.open) |# 2
cdll0107.put.Status_of_ACR_Module(status.open) |# 3
cdll0107.put.Status_of_ACP(status.open) |# 4

ok = cdll0107.update(1, mess.update)
endif


In principle the order of the field input should be the one in the program, but it seems that it is not the case when the Update is done.

Does anybody know how to force this order?

thanks & regards

Jordi

mark_h
13th October 2012, 21:38
I don't think there is a way to force the order. But maybe you can do the update after each field or only on those that you need to update at one time. Not sure if this will work, but worth a try.


if ok.find then
ok = 0
cdll0107.put.Status_of_GLD(status.open) |# 1
ok = cdll0107.update(1, mess.update)

Jordi.Tolra
15th October 2012, 13:20
Thanks Mark,

I already tried what you propose but next problem appears: session tfgld0107m000 requieres that the 4 statuses are the same, so it doesn't allow to do the first update if the other 3 fields don't have the same status.

it is like going round and round in circles....

Jordi

mark_h
15th October 2012, 16:08
Have you tried use false instead of true with the stpapi.update after the first field? That might activiate the after.input.check without actually doing the update. You could also set all 4 fields and do the update with false as the second parameter to see what happens followed by another update with true or even stpapi.save. I know there was one session where I did a stpapi.update("session",false, error) followed immediately with a stpapi.save("session",error) and this solved my problem.

I do not have access to source code so I somethimes just play around till I get them to work. If you have source code you can try different versions of the commands at different places to see what happens. At the same time you might be able to force the after.input.check even using if api.mode statement.

Jordi.Tolra
15th October 2012, 17:18
Many thanks Mark!

It solved the problem. I was also thinking in play with stapi.update(false) and stapi.save, but you gave me the clue.

Thanks & Regards

Jordi