vineetu1
11th November 2005, 09:02
I am in process of automating Sales order creation to printing of invoices.
I have written the following code for executing session tdsls4404m000 "Print Sales Invoice" which when executed with the option "Final Invoices = Yes" generates an invoice no.
I have tried using both the functions i.e. stpapi.continue.process() and stpapi.print.report with stpapi.set.report().
When I use stpapi.continue.process() I get the message no data within selection. When I use stpapi.set.report() it does not give any message but the invoice not is not getting generated.
declaration:
#pragma used dll ottstpapihand
table ttdsls045 | Sales Deliveries
extern domain tcorno sales.order.no |
extern domain tcdate inv.date |
string error.message(100)
string invoice.date(10)
string sales.order.number(6)
string company.number(3)
choice.cont.process:
on.choice:
process.print.sales.order()
functions:
function process.print.sales.order()
{
select tdsls045.*
from tdsls045
where tdsls045._index1 = {:sales.order.no}
and tdsls045.ssls = 6
as set with 1 rows
selectdo
print.sales.invoices()
selectempty
message("No records present")
endselect
}
function print.sales.invoices()
{
initalize.vars()
error.message = ""
invoice.date = str$(num.to.date$(date.num(),3))
| message("%s",invoice.date)
sales.order.number = str$(sales.order.no)
company.number = str$(get.compnr())
stpapi.put.field("tdsls4404m000", "printed", "No")
stpapi.put.field("tdsls4404m000", "inv.date", invoice.date)
stpapi.put.field("tdsls4404m000", "selection", "No")
stpapi.put.field("tdsls4404m000", "comp.f", company.number)
stpapi.put.field("tdsls4404m000", "comp.t", company.number)
stpapi.put.field("tdsls4404m000", "cuno.f", "")
stpapi.put.field("tdsls4404m000", "cuno.t", "ZZZZZZ")
stpapi.put.field("tdsls4404m000", "orno.f", sales.order.number)
stpapi.put.field("tdsls4404m000", "orno.t", sales.order.number)
stpapi.put.field("tdsls4404m000", "cotp.f", "")
stpapi.put.field("tdsls4404m000", "cotp.t", "ZZZ")
stpapi.put.field("tdsls4404m000", "amount.f", "-99999999")
stpapi.put.field("tdsls4404m000", "amount.t", "999999999")
stpapi.put.field("tdsls4404m000", "definite", "Yes")
stpapi.put.field("tdsls4404m000", "direct.process", "No")
stpapi.put.field("tdsls4404m000", "totals", "No")
stpapi.put.field("tdsls4404m000", "prnt.options", "No")
stpapi.put.field("tdsls4404m000", "prnt.sellpr", "No")
stpapi.set.report("tdsls4404m000", "rtdsls440401000","D",error.message)
if isspace(error.message) then
| stpapi.continue.process("tdsls4404m000", error.message)
stpapi.print.report("tdsls4404m000", error.message)
if error.message <> "" then
message(error.message)
else
message("Invoice printed succesfully for order no %d", sales.order.no)
endif
else
message("error.message")
endif
stpapi.end.session("tdsls4404m000")
}
I have written the following code for executing session tdsls4404m000 "Print Sales Invoice" which when executed with the option "Final Invoices = Yes" generates an invoice no.
I have tried using both the functions i.e. stpapi.continue.process() and stpapi.print.report with stpapi.set.report().
When I use stpapi.continue.process() I get the message no data within selection. When I use stpapi.set.report() it does not give any message but the invoice not is not getting generated.
declaration:
#pragma used dll ottstpapihand
table ttdsls045 | Sales Deliveries
extern domain tcorno sales.order.no |
extern domain tcdate inv.date |
string error.message(100)
string invoice.date(10)
string sales.order.number(6)
string company.number(3)
choice.cont.process:
on.choice:
process.print.sales.order()
functions:
function process.print.sales.order()
{
select tdsls045.*
from tdsls045
where tdsls045._index1 = {:sales.order.no}
and tdsls045.ssls = 6
as set with 1 rows
selectdo
print.sales.invoices()
selectempty
message("No records present")
endselect
}
function print.sales.invoices()
{
initalize.vars()
error.message = ""
invoice.date = str$(num.to.date$(date.num(),3))
| message("%s",invoice.date)
sales.order.number = str$(sales.order.no)
company.number = str$(get.compnr())
stpapi.put.field("tdsls4404m000", "printed", "No")
stpapi.put.field("tdsls4404m000", "inv.date", invoice.date)
stpapi.put.field("tdsls4404m000", "selection", "No")
stpapi.put.field("tdsls4404m000", "comp.f", company.number)
stpapi.put.field("tdsls4404m000", "comp.t", company.number)
stpapi.put.field("tdsls4404m000", "cuno.f", "")
stpapi.put.field("tdsls4404m000", "cuno.t", "ZZZZZZ")
stpapi.put.field("tdsls4404m000", "orno.f", sales.order.number)
stpapi.put.field("tdsls4404m000", "orno.t", sales.order.number)
stpapi.put.field("tdsls4404m000", "cotp.f", "")
stpapi.put.field("tdsls4404m000", "cotp.t", "ZZZ")
stpapi.put.field("tdsls4404m000", "amount.f", "-99999999")
stpapi.put.field("tdsls4404m000", "amount.t", "999999999")
stpapi.put.field("tdsls4404m000", "definite", "Yes")
stpapi.put.field("tdsls4404m000", "direct.process", "No")
stpapi.put.field("tdsls4404m000", "totals", "No")
stpapi.put.field("tdsls4404m000", "prnt.options", "No")
stpapi.put.field("tdsls4404m000", "prnt.sellpr", "No")
stpapi.set.report("tdsls4404m000", "rtdsls440401000","D",error.message)
if isspace(error.message) then
| stpapi.continue.process("tdsls4404m000", error.message)
stpapi.print.report("tdsls4404m000", error.message)
if error.message <> "" then
message(error.message)
else
message("Invoice printed succesfully for order no %d", sales.order.no)
endif
else
message("error.message")
endif
stpapi.end.session("tdsls4404m000")
}