sachinbaan
31st July 2014, 12:08
Hi,

I am writing AFS on tcmcs0536m000 - Tax Codes By Country, to approve range of tax together

During approve operation if any of the tax throws any message(error, info) I want it in error report, but in AFS I am not getting that message in my "error.message" variable.

please help.


function extern approve.tax.code()
{
brp = brp.open("rltmcs0536m0001", "D", 0)

select tcmcs036.ccty, tcmcs036.cvat
from tcmcs036
where tcmcs036._index1 inrange {:tax.country, :tax.code.from} and {:tax.country, :tax.code.to}
and tcmcs036.stpv.l = :tax.state
and tcmcs036.appr = tcyesno.no
selectdo
stpapi.put.field("tcmcs0536m000", "tcmcs036.ccty", tcmcs036.ccty)
ret = stpapi.change.view("tcmcs0536m000", error.message)
if ret = 1 then
stpapi.put.field("tcmcs0536m000", "tcmcs036.ccty", tcmcs036.ccty)
stpapi.put.field("tcmcs0536m000", "tcmcs036.cvat", tcmcs036.cvat)

ret = stpapi.find("tcmcs0536m000", error.message)
if ret = 1 then
ret = stpapi.mark("tcmcs0536m000", error.message)
if ret = 1 then
stpapi.form.command("tcmcs0536m000", 5, "approve.tax.code", error.message)
stpapi.enum.answer("tcmcs0536m000", "tcmcs00003", tcyesno.yes)

select tcmcs036.ccty
from tcmcs036
where tcmcs036._index1 = {:tcmcs036.ccty, :tcmcs036.cvat}
and tcmcs036.stpv.l = :tax.state
and tcmcs036.appr = tcyesno.yes
as set with 1 rows
selectempty
error.message = "Tax Code not approved."
brp.ready(brp)
stpapi.end.session("tcmcs0536m000")
endselect
endif
else
stpapi.end.session("tcmcs0536m000")
endif
else
stpapi.end.session("tcmcs0536m000")
endif
selectempty
message("No Data Within Selection.")
endselect
brp.close(brp)
}

mark_h
31st July 2014, 15:00
Moved it to the correct forum.

You can try stpapi.get.mess.code on the session - assuming these are warnings, because a true error should be returned in error.message. I would try it right after the form command. It should get the last message from the session. It does not always work depending on how the session is coded.

I would also make this change in your code - just from glancing at it.:

stpapi.enum.answer("tcmcs0536m000", "tcmcs00003", tcyesno.yes)
stpapi.form.command("tcmcs0536m000", 5, "approve.tax.code", error.message)

You always want to have the question answered before it is asked. I assume the question would be asked once the form.command is executed.

benito
31st July 2014, 16:08
another option is to use this DLL,

long tcmcs.dll0036.approve.tax.code.with.commit( domain tcccty i.tax.country, domain tccvat i.tax.code )

Return: 0 The tax code is approved.
DALHOOKERROR Approving is not allowed, error is set.

then you can set any error reporting that you want.

sachinbaan
1st August 2014, 06:11
Thanx benito, mark_h