srinivas
28th December 2001, 13:52
HI,
I am trying to make a receipt using STPAPI call.
The message I am getting is Purchase Order not allowed.
Pls. go through the script and suggest where I am going wrong
Thanks and Regards,
Srinivas
declaration:
table ttccom950 | API test for Employee Sal Table
table ttdpur045
#pragma used dll ottstpapihand |Baan API handler
domain tcbool all.ok
long file.fp
long err.fp
long rec.read
long rec.writ
long rec.rej
long ret.code
string field(50)
string err.line(132),error.msg(132),err.subproc(132)
string data.line(2048)
string err(50)
string dat(12) | Store current date and time in format MMDDYYHHMMSS
string reno(50)
string dino(50)
string orno(50)
string pono(50)
string diqu(50)
string rrdt(50)
string dqua(50)
domain tcdate work.date
|*** choices *******************************************************************
choice.cont.process:
on.choice:
main.processing()
after.choice:
execute(end.program)
functions:
function main.processing()
{
rec.read = 0
rec.writ = 0
rec.rej = 0
file.fp = 0
err.fp = 0
|error.report.header()
file.fp = seq.open("e:\apiupload\receipts.txt" ,"r")
if file.fp < 1 then
err = "Input File e:\apiupload\receipts.txt could not be opened"
Message("Input File e:\apiupload\receipts.txt could not be opened Reason %d",file.fp)
|write.err.record()
return
endif
ret.code = seq.gets(data.line, 2048, file.fp)
while seq.eof(file.fp) = 0
rec.read = rec.read + 1
all.ok = true
read.record()
run.main.sess()
ret.code = seq.gets(data.line, 2048, file.fp)
endwhile
ret.code = seq.close(file.fp)
|error.report.totals()
|ret.code = seq.close(err.fp)
}
function read.record()
{
|*** This function extracts the individual fields from the current record in
|*** the input ASCII file.
reno = extract.field()
dino = extract.field()
orno = extract.field()
pono = extract.field()
diqu = extract.field()
rrdt = extract.field()
dqua = extract.field()
work.date = INPUTSTR.TO.DATE(rrdt,"%D002,2")
}
function string extract.field()
{
|*** This function searches for the 'pipe' delimiter and extracts the next
|*** field in the current record in the input ASCII file
string extracted.field(50)
long pointer
long flag
string character(1)
pointer = 0
flag = FALSE
while flag = FALSE
pointer = pointer + 1
character = data.line(pointer; 1)
if data.line(pointer;1) = "|" or data.line(pointer;1) = "" then
flag = TRUE
endif
endwhile
extracted.field = data.line(1;pointer - 1)
data.line = data.line(pointer+1; 2048)
return(extracted.field)
}
function run.main.sess()
{
stpapi.put.field("tdpur4120m000", "tccom950.reno", reno)
stpapi.put.field("tdpur4120m000", "form.dino", dino)
stpapi.handle.subproc( "tdpur4120m000", "tdpur4224s000", "add")
stpapi.put.field("tdpur4224s000", "form.orno", orno)
stpapi.continue.process("tdpur4224s000", error.msg)
stpapi.change.view("tdpur4120m000")
stpapi.put.field("tdpur4120m000", "tccom950.orno", orno)
stpapi.put.field("tdpur4120m000", "tccom950.pono", pono)
stpapi.put.field("tdpur4120m000", "tccom950.diqu", diqu)
stpapi.put.field("tdpur4120m000", "tccom950.date", str$(work.date))
stpapi.put.field("tdpur4120m000", "tccom950.dqua", dqua)
stpapi.insert("tdpur4120m000", 1, err)
Message(err)
stpapi.end.session("tdpur4120m000")
}
I am trying to make a receipt using STPAPI call.
The message I am getting is Purchase Order not allowed.
Pls. go through the script and suggest where I am going wrong
Thanks and Regards,
Srinivas
declaration:
table ttccom950 | API test for Employee Sal Table
table ttdpur045
#pragma used dll ottstpapihand |Baan API handler
domain tcbool all.ok
long file.fp
long err.fp
long rec.read
long rec.writ
long rec.rej
long ret.code
string field(50)
string err.line(132),error.msg(132),err.subproc(132)
string data.line(2048)
string err(50)
string dat(12) | Store current date and time in format MMDDYYHHMMSS
string reno(50)
string dino(50)
string orno(50)
string pono(50)
string diqu(50)
string rrdt(50)
string dqua(50)
domain tcdate work.date
|*** choices *******************************************************************
choice.cont.process:
on.choice:
main.processing()
after.choice:
execute(end.program)
functions:
function main.processing()
{
rec.read = 0
rec.writ = 0
rec.rej = 0
file.fp = 0
err.fp = 0
|error.report.header()
file.fp = seq.open("e:\apiupload\receipts.txt" ,"r")
if file.fp < 1 then
err = "Input File e:\apiupload\receipts.txt could not be opened"
Message("Input File e:\apiupload\receipts.txt could not be opened Reason %d",file.fp)
|write.err.record()
return
endif
ret.code = seq.gets(data.line, 2048, file.fp)
while seq.eof(file.fp) = 0
rec.read = rec.read + 1
all.ok = true
read.record()
run.main.sess()
ret.code = seq.gets(data.line, 2048, file.fp)
endwhile
ret.code = seq.close(file.fp)
|error.report.totals()
|ret.code = seq.close(err.fp)
}
function read.record()
{
|*** This function extracts the individual fields from the current record in
|*** the input ASCII file.
reno = extract.field()
dino = extract.field()
orno = extract.field()
pono = extract.field()
diqu = extract.field()
rrdt = extract.field()
dqua = extract.field()
work.date = INPUTSTR.TO.DATE(rrdt,"%D002,2")
}
function string extract.field()
{
|*** This function searches for the 'pipe' delimiter and extracts the next
|*** field in the current record in the input ASCII file
string extracted.field(50)
long pointer
long flag
string character(1)
pointer = 0
flag = FALSE
while flag = FALSE
pointer = pointer + 1
character = data.line(pointer; 1)
if data.line(pointer;1) = "|" or data.line(pointer;1) = "" then
flag = TRUE
endif
endwhile
extracted.field = data.line(1;pointer - 1)
data.line = data.line(pointer+1; 2048)
return(extracted.field)
}
function run.main.sess()
{
stpapi.put.field("tdpur4120m000", "tccom950.reno", reno)
stpapi.put.field("tdpur4120m000", "form.dino", dino)
stpapi.handle.subproc( "tdpur4120m000", "tdpur4224s000", "add")
stpapi.put.field("tdpur4224s000", "form.orno", orno)
stpapi.continue.process("tdpur4224s000", error.msg)
stpapi.change.view("tdpur4120m000")
stpapi.put.field("tdpur4120m000", "tccom950.orno", orno)
stpapi.put.field("tdpur4120m000", "tccom950.pono", pono)
stpapi.put.field("tdpur4120m000", "tccom950.diqu", diqu)
stpapi.put.field("tdpur4120m000", "tccom950.date", str$(work.date))
stpapi.put.field("tdpur4120m000", "tccom950.dqua", dqua)
stpapi.insert("tdpur4120m000", 1, err)
Message(err)
stpapi.end.session("tdpur4120m000")
}