tomzak
21st August 2009, 11:04
Hi @all

I want to write an automatic session to insert records into the general ledger. I can create the batch-status (tfgld100) and the main transaction (tfgld101). But when I try to insert a voucher into tfgld102 i allways get the message "command disabled". My code looks like that:


retVal = stpapi.browse.view("tfgld1101m000", "last.view", error.msg)
if (retVal = 1) then
retVal = stpapi.mark("tfgld1101m000", error.msg)
if (retVal = 1) then
stpapi.put.field("tfgld1114s000", "tfgld102.ttyp", "CAB")
retVal = stpapi.change.view("tfgld1114s000", error.msg)
retVal = stpapi.browse.view("tfgld1103s000", "last.view", error.msg)
stpapi.handle.subproc("tfgld1101m000", "tfgld1103s000", "add")
stpapi.continue.process("tfgld1101m000", error.msg)
retVal = stpapi.change.view("tfgld1103s000", error.msg)
endif
endif

stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("CAB"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(201))
.
.
retVal = stpapi.insert("tfgld1103s000", 1, error.msg)
if (retVal = 0) then
rc = stpapi.recover("tfgld1103s000", w.err.msg)
endif
return (retVal)



At the "stpapi.continue.process" the error.message is "command disabled". I searched the forum for this problem, but didn't found any solution for this. We are using BaanERP (B50Ccstnd)

Kind regards
Thomas

mark_h
21st August 2009, 15:29
Not sure I understand what you are doing in the code. You do a browse view on tfgld1101m000 - not sure this will always work, sometimes you have to do a find to make the record the current record. Next out of no where you put a field to tfgld1114s000 - why? I do not see anything that activated or controlled tfgld1114s000. Then you do a change view on it - again not sure why. Then you do a change view on 1103s000 - again not sure what you are trying accomplish. Next I see where you do the add process on tfgld1103s000, then a continue on tfgld1101m000 - that makes sense. No promise this will work for you, but this is all I do to launch one session out of tfgld1101m000

stpapi.put.field("tfgld1101m000","tfgld101.year",str$(tfudi210.year))
stpapi.put.field("tfgld1101m000","tfgld101.btno",str$(batch.number))
stpapi.put.field("tfgld1101m000","tfgld101.ttyp","JSB")
rc = stpapi.find("tfgld1101m000",errmsg)
if rc = 1 then
stpapi.handle.subproc("tfgld1101m000","tfgld1115s000","add")
stpapi.continue.process("tfgld1101m000",errmsg)


I think in your case you might be able to replace tfgld1115s000 with tfgld1103s000. Not sure since I am not familiar with your system, patches.

stpapi.put.field("tfgld1103s000", "tfgld102.ttyp", str$("CAB"))
stpapi.put.field("tfgld1103s000", "tfgld102.docn", str$(201))
.
.
retVal = stpapi.insert("tfgld1103s000", 1, error.msg)
if (retVal = 0) then
rc = stpapi.recover("tfgld1103s000", w.err.msg)
endif
return (retVal)
[/code]

tomzak
24th August 2009, 09:24
Hi mark_h

this was my first try to put the data into the session. But this didn't work, so I searched the board and found this thread (http://www.baanboard.com/baanboard/showthread.php?t=19039&highlight=afs+tfgld1103s000). The session tfgld1114s000 refers to table tfgld102.

In the GUI (tfgld1103s000) there are 3 forms. Form.1 is the header and Form.2 are for the vouchers. This form is disabled until all fields of the header are written. But I didn't find in the sourcecode where the form.2 is disable btw. enabled.

Have anyone on idea?

Thomas