Joy Conner
27th June 2006, 22:09
I am having trouble passing parameters to print an invoice and the problem is not obvious. I think that I am getting the printed variable but not the invn.f, invn.t, ttyp.f and ttyp.t. Can anyone tell me what I am doing wrong?

function print.sales.invoices(domain tfgld.ttyp ttyp.in,
domain tcinvn invn.in)
{
domain tcmcs.str25 error

error = ""
stpapi.clear("tdsls4404m000")
stpapi.put.field("tdsls4404m000", "printed", str$(etol(printed)))
if printed = tcyesno.yes then
stpapi.put.field("tdsls4404m000", "invn.f", str$(invn.in))
stpapi.put.field("tdsls4404m000", "invn.t", str$(invn.in))
stpapi.put.field("tdsls4404m000", "ttyp.f", ttyp.in)
stpapi.put.field("tdsls4404m000", "ttyp.t", ttyp.in)
else
stpapi.put.field("tdsls4404m000", "selection", str$(etol(selection)))
stpapi.put.field("tdsls4404m000", "inv.date", str$(inv.date))
stpapi.put.field("tdsls4404m000", "cuno.f", cuno.f)
stpapi.put.field("tdsls4404m000", "cuno.t", cuno.t)
stpapi.put.field("tdsls4404m000", "orno.f", str$(orno.f))
stpapi.put.field("tdsls4404m000", "orno.t", str$(orno.t))
stpapi.put.field("tdsls4404m000", "cotp.f", cotp.f)
stpapi.put.field("tdsls4404m000", "cotp.t", cotp.t)
stpapi.put.field("tdsls4404m000", "definite", str$(etol(definite)))
stpapi.put.field("tdsls4404m000", "direct.process", str$(etol(direct.process)))
stpapi.put.field("tdsls4404m000", "totals", str$(etol(totals)))
stpapi.put.field("tdsls4404m000", "prnt.options", str$(etol(prnt.options)))
stpapi.put.field("tdsls4404m000", "prnt.sellpr", str$(etol(prnt.sellpr)))
stpapi.put.field("tdsls4404m000", "recal.tax", str$(etol(recal.tax)))
stpapi.put.field("tdsls4404m000", "disp.slash", "/")
endif
stpapi.put.field("tdsls4404m000", "comp.f", str$(comp.f))
stpapi.put.field("tdsls4404m000", "comp.t", str$(comp.t))
stpapi.put.field("tdsls4404m000", "amount.f", str$(amount.f))
stpapi.put.field("tdsls4404m000", "amount.t", str$(amount.t))
stpapi.set.report("tdsls4404m000", "rtdsls440401000", "ACCTLOGO", error )
stpapi.continue.process("tdsls4404m000", error)
if not isspace(error) then
message("Error when setting report: %s", error)
endif
stpapi.print.report("tdsls4404m000", error)
stpapi.end.session("tdsls4404m000")
}

mark_h
28th June 2006, 01:33
I think this:

stpapi.put.field("tdsls4404m000", "ttyp.t", ttyp.in)

should be this

stpapi.put.field("tdsls4404m000", "ttyp.t", str$(ttyp.in))

I am basing this guess on the fact that ttyp's are usually an enumerated domain, but I really do not know in this case. That could make it seem like you are not getting both variables - only takes one to cause problems.

Joy Conner
28th June 2006, 15:21
I have verified data type of ttyp.f and ttyp.t is a 3 character string field.:confused:

Will you elaborate on what you mean about "only takes one to cause problems". This is my first attempt using api commands.

mark_h
28th June 2006, 16:54
On a print session like this one wrong field can cause the report not to work or cause unexepected reporting results. What exactly is happening? Are you getting more than you expected on the report or is it just not running. Do you have session code for tdsls4404m000 where you can check to see what makes it to the form?

I also notice that you have both a continue and print.report. In reality I have never used the stpapi.print.report. The stpapi.continue should be sufficient. Since we do not use this session my guess is only a stpapi.continue is needed.

vinceco252
28th June 2006, 20:41
Joy,

I am not seeing where you are passing a value for printed. I only see the transaction type and invoice number as function arguments. Where is the value for printed coming from?

Vince

Joy Conner
29th June 2006, 16:55
Here is what I have done thus far:
1. Developed wrapper session using api commands to execute tdsls4404m000. And having read Mark's responses, all parameters are sent using the stpapi.put.field function
2. I have tail -f running on the afs.log so I can see what there is to see.
3. I use QKEY and have a script on tdsls4404m000, so I have script compiled in debug mode with a break set at before.choice section of choice.cont.process.
When I execute the wrapper session, I can see the appropriate values being passed through the afs.log. Following all the stpapi.put.field lines, I execute the stpapi.set.report and the stpapi.continue.process and I hit the break point set in tdsls4404 script.

Now I want to test the values in parameters. In this example, I am reprinting 2 invoices. I am expecting a value of "SSS" in ttyp.f and ttyp.t but instead I find ttyp.f = "" and ttyp.t = "ZZZ". Also, I am expecting a value of 126158 in invn.f and a value of 126159 in invn.t. Instead, invn.f = 0 and invn.t = 999999.

I can see the appropriate values in the afs.log but I CANNOT see the appropriate values in tdsls4404 script.

What am I missing? :confused: My wrapper code is in attachment.

mark_h
29th June 2006, 17:19
Found this thread (http://www.baanboard.com/baanboard/showthread.php?t=9636&highlight=tdsls4404m000) which does mention a solution for the session. There is also a recommendation to delete user defaults for the session. The solution mentioned may handle the problem with form 1 and form 2. At least on my system when you say "yes" to printed it jumps to form 2 for the fields being put.

Joy Conner
29th June 2006, 17:42
For the record, user defaults have been deleted.

I was missing "stpapi.print.report" command. According to white papers from baan, this command sends input fields to the session. This command follows stpapi.set.report() and preceeds stpapi.continue.process(). Now I can test parameter values and I am getting the expected results.:)

mark_h
29th June 2006, 17:53
Hmmm - I have never used stpapi.print.report in all my function servers. One of the reasons I recommended pulling it. My apologies. I noticed on the link I posted that it said use stpapi.print.report, but I just ignored it.

Glad you solved it!