howtodo
26th June 2005, 10:37
Hi,
I am trying the following script to automate manual purchase invoices.
|*********************************************************|*********************************************************|* Main table tfgld102 Non-finalized Transactions, Form Type 4
|*********************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand
#pragma nowarnings
#define ERR shiftl$(shiftr$(error)) <> ""
#include <bic_tt>
|****************************** DECLARATION SECTION ***************************
table ttfgld100
table ttfgld101
table ttfgld102
double trans.amnt
long ret, opno,ret1,ret2
string error(256),sess(13),sub.sess1(13),sub.sess2(13),seqn(4),docn(10),lino(10),
str.btno(11),err.str(50),suno(6),suno1(6),ccur(3),isup(30),refa(30),docd(10)
domain tcbool afs.success,first.record,valid.data
long amnt, line, doc, rp, reof, wp,dbcr
string leac(12),refr(30),file.name(50), buff(1024), err.file(50),ttyp(3)
double line.amnt, inv.amnt
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
choice.cont.process:
on.choice:
create.mpi()
functions:
function create.mpi()
{
handle.batches()
manual.purchase.invoice.header()
stpapi.end.session("tfgld1101m000", error)
}
function handle.batches()
{
clean.mess()
afs.success = false
str.btno = ""
stpapi.put.field("tfgld1101m000", "tedt.f", str$(date.num()))
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(2005))
stpapi.put.field("tfgld1101m000", "bref.f", "PI9 test")
stpapi.change.view("tfgld1101m000", error)
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", "PI9")
ret = stpapi.insert("tfgld1101m000", true, error)
if ERR then
message("Cannot Create Batch :- ",shiftl$(error))
stpapi.recover("tfgld1101m000", error)
stpapi.end.session("tfgld1101m000", error)
else
stpapi.get.field("tfgld1101m000","tfgld101.btno",str.btno)
afs.success = true
endif
if afs.success then
stpapi.put.field("tfgld1101m000", "tfgld101.year", "2005")
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str.btno)
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", "PI9")
ret = stpapi.find("tfgld1101m000", error)
if ret = 1 then
ret = stpapi.mark("tfgld1101m000", error)
afs.success = true
else
message(" 1 %s",error)
afs.success = false
endif
message("Batch Created %s",str.btno)
endif
}
function manual.purchase.invoice.header()
{
clean.mess()
stpapi.handle.subproc("tfgld1101m000","tfacp1110s000", "add")
stpapi.handle.subproc("tfacp1110s000", "tfacp1120s000", "kill")
stpapi.continue.process("tfgld1101m000", error)
if ERR then
message("Error message is %s",error)
stpapi.end.session("tfgld1101m000", error)
else
stpapi.put.field("tfacp1110s000", "tfacp200.suno", " A123")
stpapi.put.field("tfacp1110s000", "tfacp200.ccur", "AED")
stpapi.put.field("tfacp1110s000", "screen.amnt", "8550.00")
stpapi.put.field("tfacp1110s000", "tfacp200.isup", "100012")
stpapi.get.field("tfacp1110s000","tfacp200.invn",suno1)
ret1=stpapi.insert("tfacp1110s000", 1, error)
|stpapi.save("tfacp1110s000",error)
if not ret1 then
message(" insert error @ tfacp1110s000 %s %s",error,suno1)
stpapi.recover("tfacp1110s000",error)
stpapi.end.session("tfacp1110s000", error)
else
stpapi.handle.subproc("tfacp1110s000", "tfacp1120s000", "add")
stpapi.continue.process("tfacp1110s000", error)
stpapi.put.field("tfacp1120s000", "tfgld102.leac", "11085")
stpapi.put.field("tfacp1120s000", "amount", "8550.00")
ret2=stpapi.insert("tfacp1120s000", true, error)
if not ret2 then
message(" insert error @ tfacp1120s000 %s ",error)
stpapi.recover("tfacp1120s000",error)
stpapi.end.session("tfacp1120s000", error)
else
stpapi.end.session("tfacp1120s000")
endif
stpapi.end.session("tfacp1110s000", error)
endif
endif
}
But ,i am getting erro "Invoice already available in open items!",any ideas!
Thanks
I am trying the following script to automate manual purchase invoices.
|*********************************************************|*********************************************************|* Main table tfgld102 Non-finalized Transactions, Form Type 4
|*********************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand
#pragma nowarnings
#define ERR shiftl$(shiftr$(error)) <> ""
#include <bic_tt>
|****************************** DECLARATION SECTION ***************************
table ttfgld100
table ttfgld101
table ttfgld102
double trans.amnt
long ret, opno,ret1,ret2
string error(256),sess(13),sub.sess1(13),sub.sess2(13),seqn(4),docn(10),lino(10),
str.btno(11),err.str(50),suno(6),suno1(6),ccur(3),isup(30),refa(30),docd(10)
domain tcbool afs.success,first.record,valid.data
long amnt, line, doc, rp, reof, wp,dbcr
string leac(12),refr(30),file.name(50), buff(1024), err.file(50),ttyp(3)
double line.amnt, inv.amnt
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
choice.cont.process:
on.choice:
create.mpi()
functions:
function create.mpi()
{
handle.batches()
manual.purchase.invoice.header()
stpapi.end.session("tfgld1101m000", error)
}
function handle.batches()
{
clean.mess()
afs.success = false
str.btno = ""
stpapi.put.field("tfgld1101m000", "tedt.f", str$(date.num()))
stpapi.put.field("tfgld1101m000", "tfgld101.year", str$(2005))
stpapi.put.field("tfgld1101m000", "bref.f", "PI9 test")
stpapi.change.view("tfgld1101m000", error)
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", "PI9")
ret = stpapi.insert("tfgld1101m000", true, error)
if ERR then
message("Cannot Create Batch :- ",shiftl$(error))
stpapi.recover("tfgld1101m000", error)
stpapi.end.session("tfgld1101m000", error)
else
stpapi.get.field("tfgld1101m000","tfgld101.btno",str.btno)
afs.success = true
endif
if afs.success then
stpapi.put.field("tfgld1101m000", "tfgld101.year", "2005")
stpapi.put.field("tfgld1101m000", "tfgld101.btno", str.btno)
stpapi.put.field("tfgld1101m000", "tfgld101.ttyp", "PI9")
ret = stpapi.find("tfgld1101m000", error)
if ret = 1 then
ret = stpapi.mark("tfgld1101m000", error)
afs.success = true
else
message(" 1 %s",error)
afs.success = false
endif
message("Batch Created %s",str.btno)
endif
}
function manual.purchase.invoice.header()
{
clean.mess()
stpapi.handle.subproc("tfgld1101m000","tfacp1110s000", "add")
stpapi.handle.subproc("tfacp1110s000", "tfacp1120s000", "kill")
stpapi.continue.process("tfgld1101m000", error)
if ERR then
message("Error message is %s",error)
stpapi.end.session("tfgld1101m000", error)
else
stpapi.put.field("tfacp1110s000", "tfacp200.suno", " A123")
stpapi.put.field("tfacp1110s000", "tfacp200.ccur", "AED")
stpapi.put.field("tfacp1110s000", "screen.amnt", "8550.00")
stpapi.put.field("tfacp1110s000", "tfacp200.isup", "100012")
stpapi.get.field("tfacp1110s000","tfacp200.invn",suno1)
ret1=stpapi.insert("tfacp1110s000", 1, error)
|stpapi.save("tfacp1110s000",error)
if not ret1 then
message(" insert error @ tfacp1110s000 %s %s",error,suno1)
stpapi.recover("tfacp1110s000",error)
stpapi.end.session("tfacp1110s000", error)
else
stpapi.handle.subproc("tfacp1110s000", "tfacp1120s000", "add")
stpapi.continue.process("tfacp1110s000", error)
stpapi.put.field("tfacp1120s000", "tfgld102.leac", "11085")
stpapi.put.field("tfacp1120s000", "amount", "8550.00")
ret2=stpapi.insert("tfacp1120s000", true, error)
if not ret2 then
message(" insert error @ tfacp1120s000 %s ",error)
stpapi.recover("tfacp1120s000",error)
stpapi.end.session("tfacp1120s000", error)
else
stpapi.end.session("tfacp1120s000")
endif
stpapi.end.session("tfacp1110s000", error)
endif
endif
}
But ,i am getting erro "Invoice already available in open items!",any ideas!
Thanks