monica1
26th May 2005, 10:25
I'm making a session to call another one with AFS. This session is 3rd type session and in the choice cont.process it call to another session. In the before choice of cont.process there is and ask.enum() and if the answer is no if execute a choice.again().
I write this code:
stpapi.put.field("cacmgca022m15", "cacmg022.fecha", str$(cacmg022.fecha))
stpapi.put.field("cacmgca022m15", "cacmg022.ttyp", cacmg022.ttyp)
stpapi.put.field("cacmgca022m15", "cacmg022.doc", str$(cacmg022.doc))
stpapi.put.field("cacmgca022m15", "resto", "0.00")
ret = stpapi.find("cacmgca022m15", mensaje)
if ret = 1 then
stpapi.handle.subproc("cacmgca022m15", "cacmgca024m00", "modify")
stpapi.enum.answer("cacmgca022m15", "caseguro", tcyesno.yes)
stpapi.form.command("cacmgca022m15", 5, "exec.cont.process", mensaje)
stpapi.put.field("cacmgca024m00", "cacmg024.banco", cacmg022.ttyp)
stpapi.put.field("cacmgca024m00", "cacmg024.docu", str$(cacmg022.docn))
stpapi.put.field("cacmgca024m00", "cacmg024.fecha", str$(fecha.lote))
stpapi.put.field("cacmgca024m00", "cacmg024.fecha.v", str$(cacmg100.fval))
stpapi.form.command("cacmgca024m00", 5, "exec.user.1", mensaje)
stpapi.end.session("cacmgca024m00")
endif
stpapi.end.session("cacmgca022m15")
The answer of ask.enum() is alwais no and the session doen´t work.
Where is my problem?
Thank you in advance,
mark_h
26th May 2005, 14:31
The problem could be that baan sets the answer to the question as "no" in the session script. I have seen hard coded default answers to questions. If that is the case then the stpapi.enum.answer does not work. One work around is to modify the session source to remove the question if in api.mode is true. Or if you do not own source you can look at one of the extend source options like RMCis, Qkey, ~Vamsi soultion.
monica1
26th May 2005, 18:10
In the program the line with the ask.enum is this:
choice.cont.process:
on.choice:
if ask.enum("caseguro", tcyesno.no) = tcyesno.yes then
if resto <> 0 then
message("Error. El preasiento no está cuadrado.\nEl traspaso no se ha realizado.")
else
traspaso.divisa = false
tratar.traspaso()
endif
endif
mark_h
26th May 2005, 18:48
From just glancing at some of the questions that I know that work with stpapi.enum.answer, they look like this.
choice.cont.process:
on.choice:
if ask.enum("caseguro", empty) = tcyesno.yes then
if resto <> 0 then
message("Error. El preasiento no está cuadrado.\nEl traspaso no se ha realizado.")
else
traspaso.divisa = false
tratar.traspaso()
endif
endif
Not sure if that makes a difference. Looking at your code it should work. It maybe that you might need an update of stpapi DLL's. Seems to me somebody had a post in this forum about stpapi.enum.answer not working and a patch resolved it. I will look around.
mark_h
26th May 2005, 18:55
Gahhhh! Just realized this was in your code:
stpapi.enum.answer("cacmgca022m15", "caseguro", tcyesno.yes)
It should be:
stpapi.enum.answer("cacmgca022m15", "caseguro", str$(tcyesno.yes))
The stpapi.enum should contain a str$ variable also.
monica1
26th May 2005, 19:04
No, when I compile the source I get this error messages:
Error: Argument 3 for function 'stpapi.enum.answer' has ilegal type.
Error: Ilegal type combination: 'string should be: enum[bitset'
The change ask.enum("caseguro", empty) does`'t work.
mark_h
26th May 2005, 19:39
My apologies. That is what happens when I try to do two things at once - we just installed a service pack and I am having problems in production. Your format is correct. I could not find the post on stpapi.enum.answer.
So changing ask.enum("caseguro",empty) did not work either. Something you can try since you have source - is this:
choice.cont.process:
on.choice:
if ask.enum("caseguro", tcyesno.no) = tcyesno.yes or api.mode then
if resto <> 0 then
message("Error. El preasiento no está cuadrado.\nEl traspaso no se ha realizado.")
else
traspaso.divisa = false
tratar.traspaso()
endif
endif
But this would only work if you always were to say yes to the question.
monica1
26th May 2005, 19:52
Thank you very much. With this change it works. But a bit question: if the ask.enum has NO like default you can not send TRUE with stpapi.enum.answer?
NPRao
26th May 2005, 20:53
Yes you can. Here is a sample code-
stpapi.put.field(session.code, "btle.s", str$(btle.s))
stpapi.put.field(session.code, "btle.t", str$(btle.t))
e = stpapi.enum.answer(session.code, "daxch025102", daxch.yesno.yes)
stpapi.form.command(session.code, 5, "exec.cont.process", err.mess)
err.code = stpapi.get.mess.code(session.code, err.mess)
if not isspace(err.mess) and not
pos(tolower$(err.mess), "process completed") then
mess("zmadms0053", 1, err.mess) |* %1$s
endif
Also refer to the latest AFS manual -
Set answers to questions in session
SYNTAX
void stpapi.enum.answer(string session, string question, bset answer)
ARGUMENTS
session Name of the session this command is executed on. question Baan ERP
question code. This question code must be valid within the session, that is, the
session must ask this question when the user interface is used. answer The enum
or set answer to be supplied as answer to the question. This must be expressed
as the enum value as opposed to the numeric equivalent for example, tcyesno.yes
i.s.o. 1.
DESCRIPTION
This sets the answers to questions that occur while the session is executing.
RETURN VALUES
None.
EXAMPLE
stpapi.put.field("dtfsa1101s000", "dtfsa101.seno", str$(i.seno))
stpapi.put.field("dtfsa1101s000", "dtfsa101.name", new.name)
stpapi.enum.answer("dtfsa1101s000", "dtfsa1101a", tcyesno.yes)
ret = stpapi.insert("dtfsa1101s000", true, error.msg)
Explanation:
The session prompts the user whether to continue if a record is already present
with the same name. The default answer in the session is No, but you must continue.
USAGE NOTES
Functions in dll created by creatdll:
Function extern long <fs-name>.define.enum.answer(string question, bset answer)
This function must only be used for questions for which the default answer in
the session must be overruled.
If the same question is used more than once in the same session, you can
define only one answer.