tmannais
6th April 2018, 10:41
Hi,
I am trying to make it click "Confirm" form command in session "whinh4130m000".
The part that is having an issue is here:
stpapi.put.field(session.code, "whinh430.shpm", i.tdcrm412.shpm)
if stpapi.find(session.code, error.msg) = 1 then
if stpapi.mark(session.code, error.msg) = 1 then
stpapi.set.report(session.code, "rdtfsa140111000", "ASCIF", error.msg)
if isspace(error.msg) then
stpapi.form.command(session.code, 5, "confirm.shipment", error.msg)
else
error.msg = "Cannot set report: " & error.msg
endif
else
error.msg = "Cannot mark record: " & error.msg
endif
else
error.msg = "Record not found: " & error.msg
endif
To be precise, the problem is on this line:
stpapi.form.command(session.code, 5, "confirm.shipment", error.msg)
It just does not return error message even when there is actually an error message from clicking the form command on a specific record manually.
Ajesh
7th April 2018, 05:53
Try dal.get.error.message
tmannais
9th April 2018, 04:52
I tried it.
stpapi.form.command(session.code, 5, "confirm.shipment", error.msg)
dal.get.error.message(error.msg)
show.dal.messages(MSG.ALL)
I also tried this.
stpapi.form.command(session.code, 5, "confirm.shipment", error.msg)
stpapi.get.mess.code(session.code, error.msg)
message(error.msg)
Still, the functions give me no errors at all.
tmannais
9th April 2018, 08:01
I think I got some more clues about this.
The error message that shows when I manually click the form command has a title code "tcstl0002" with the only clickable button is "OK".
So, I searched the messages in the system. Found nothing related to it.
Then I searched the questions in the system. Found the exact code in there -- "tcstl0002".
It is a warning-type question, with domain tcstl.message in Language-Independent Data section.
However, I tried answering the question but still it gives no errors.
stpapi.enum.answer(session.code, "tcstl0002", tcstl.message.ok)
Actually, I want to capture the message from that since the confirm process is done with no problem. I just want to capture and then display the error whenever it occurs.
mark_h
9th April 2018, 20:14
I have always use stpapi.get.mess.code to retrieve messages. Check both the return value(which is a string with the code) and the message value. See if anything is in either value. The help reads like the below - but I think I have only ever gone back for just the last message. If it is working it may be working without generating that warning. Seems to me I had that once and I just coded to check what I needed before running the AFS code.
From AFS document I have:
This retrieves the messages generated by the indicated session as a result of an stpapi.* function call. The messages are returned in the opposite order as generated in the session. Messages generated by the AFS or 4GL-Engine are also returned.
tmannais
10th April 2018, 05:08
I tried this as you suggested.
mess.code = stpapi.get.mess.code(session.code, error.msg)
message(mess.code)
message(error.msg)
stpapi.form.command(session.code, 5, "confirm.shipment", error.msg)
mess.code = stpapi.get.mess.code(session.code, error.msg)
message(mess.code)
message(error.msg)
But all of the messages are empty.
mark_h
10th April 2018, 14:52
Without source code I am not sure what else you could do to try to trap the message. That is assuming the api actually hits the warning message. If you know what causes the message you could check those things first. I have done that a few times just to prevent warnings or error messages.
Ajesh
10th April 2018, 16:48
What if you tried commenting
stpapi.set.report(session.code, "rdtfsa140111000", "ASCIF", error.msg)
?
I have a funny feeling, this is causing problem...
tmannais
11th April 2018, 04:22
@Ajesh
I tried commenting that command but the problem still persists.
@mark_H
I will try what you suggested and I will update in here soon.
tmannais
20th August 2018, 09:08
Checking the conditions that will cause the form command to return errors will work because then we can detect the cause of it and decide not to execute the form command. However, I use AFS because I do not know how the form command works including its conditions, which are a lot. So I still try to find a way to capture the error from executing the form command using AFS. If anyone has any more clues, please help.