countnikon
10th April 2006, 22:04
I'm writing a program in BaaN that imports a pipe delimeted text document and creates a sales order. However, when I try to add footer text to the sales order, it doesn't appear. Any help would be appreciated.


function create.tdsls040()
{
table ttdsls994
table ttdsls040

select *
from tdsls994
selectdo
tdsls040.orno = get.tdsls040.orno(tdsls994.serp)
tdsls040.cuno = tdsls994.cuno
tdsls040.cper = ""
tdsls040.comp = 100
tdsls040.cpay = get.tdsls040.cpay(tdsls994.cuno)
tdsls040.cotp = "OPS"
tdsls040.odat = tdsls994.odat
tdsls040.odis = 0
tdsls040.ccur = "USD"
tdsls040.fcrt = tcfcrt.fixed
tdsls040.rats = 1
tdsls045.rats = 1
tdsls040.ratf = 1
tdsls040.ccor = ""
tdsls040.cdel = tdsls994.cdel
tdsls040.crep = 0
tdsls040.cfcg = get.tdsls040.cfcg(tdsls994.cuno)
tdsls040.cvyn = tcyesno.yes
tdsls040.ccrs = str$("")
tdsls040.cfrw = tdsls994.cfrw
tdsls040.cpls = str$("")
tdsls040.pldd = str$("")
tdsls040.pcpr = str$("")
tdsls040.pctx = str$("")
tdsls040.ccty = str$("USA")
tdsls040.clan = str$(" EN")
tdsls040.cdec = tdsls994.cdec
tdsls040.crte = str$("")
tdsls040.ddat = tdsls994.ddat
tdsls040.futo = tcfuto.no
tdsls040.cbrn = str$("")
tdsls040.creg = tdsls994.creg
tdsls040.refa = tdsls994.refa
tdsls040.refb = str$("")
tdsls040.bkyn = tcyesno.no
tdsls040.cblc = 0
tdsls040.prno = 0
tdsls040.scom = tcyesno.no
tdsls040.prdt = tdsls994.ddat
tdsls040.ctrj = str$("")
tdsls040.eono = tdsls994.eono
|tdsls040.txta = str$("")
tdsls040.agen = tcyesno.no
tdsls040.txtb=text.write("tdsls040.txtb", "2", "Sales", "Footer Text", str$(tdsls040.orno), tdsls994.refa, "wintext","txt", "/baan/parts/footertxt-"&tdsls994.refa&".txt")
db.insert(ttdsls040,db.skip.dupl)
commit.transaction()
create.tdsls041(tdsls040.orno, tdsls040.refa)
endselect
}

The Output file that I write in a previous function does create the text file.

countnikon
11th April 2006, 00:01
I have done a little research and now my code has changed as follows:

function create.tdsls040()
{
table ttdsls994
table ttdsls040
long temp.long
long orno

select *
from tdsls994
selectdo
tdsls040.orno = get.tdsls040.orno(tdsls994.serp)
orno = get.tdsls040.orno(tdsls994.serp)
tdsls040.cuno = tdsls994.cuno
tdsls040.cper = ""
tdsls040.comp = 100
tdsls040.cpay = get.tdsls040.cpay(tdsls994.cuno)
tdsls040.cotp = "OPS"
tdsls040.odat = tdsls994.odat
tdsls040.odis = 0
tdsls040.ccur = "USD"
tdsls040.fcrt = tcfcrt.fixed
tdsls040.rats = 1
tdsls045.rats = 1
tdsls040.ratf = 1
tdsls040.ccor = ""
tdsls040.cdel = tdsls994.cdel
tdsls040.crep = 0
tdsls040.cfcg = get.tdsls040.cfcg(tdsls994.cuno)
tdsls040.cvyn = tcyesno.yes
tdsls040.ccrs = str$("")
tdsls040.cfrw = tdsls994.cfrw
tdsls040.cpls = str$("")
tdsls040.pldd = str$("")
tdsls040.pcpr = str$("")
tdsls040.pctx = str$("")
tdsls040.ccty = str$("USA")
tdsls040.clan = str$(" EN")
tdsls040.cdec = tdsls994.cdec
tdsls040.crte = str$("")
tdsls040.ddat = tdsls994.ddat
tdsls040.futo = tcfuto.no
tdsls040.cbrn = str$("")
tdsls040.creg = tdsls994.creg
tdsls040.refa = tdsls994.refa
tdsls040.refb = str$("")
tdsls040.bkyn = tcyesno.no
tdsls040.cblc = 0
tdsls040.prno = 0
tdsls040.scom = tcyesno.no
tdsls040.prdt = tdsls994.ddat
tdsls040.ctrj = str$("")
tdsls040.eono = tdsls994.eono
|tdsls040.txta = str$("")
tdsls040.agen = tcyesno.no
db.insert(ttdsls040,db.skip.dupl)
commit.transaction()

select *
from tdsls040 for update
where tdsls040.orno = orno
selectdo
temp.long=text.write("tdsls040.txtb", "2", "Sales", "Footer Text", str$(tdsls040.orno), tdsls994.refa, "wintext","txt", "/baan/parts/footertxt-"&tdsls994.refa&".txt")
db.update(ttdsls040)
endselect
commit.transaction()
create.tdsls041(tdsls040.orno, tdsls040.refa)
endselect
}

Now I am getting the following error:
Fatal error : Error 112 (No current record) on tdsls040100 in db_update
Fatal error : Can not continue in tdsls9294m00o (unknown)

mark_h
11th April 2006, 00:14
Just curious - the only thing I see different between one of ours is the edit_opt. We have "text" - not sure I understand what this should be. Are you positive about the file name and group name?

This probably should be in the tools form.

vahdani
11th April 2006, 00:16
Hi,

The return value of text.write() is the number of lines written(!) and not the text number!!
A second error maybe there as well because file name may not be correctly put together!

try something like this:


string file.name$(256)
long file.id
long lines
....
file.name$ = "/baan/parts/footertxt-" & strip$(tdsls994.refa) & ".txt"
file.id = seq.open(file.name$, "r")
if file.id > 0 then
|File can be opened!
seq.close(file.id)
lines = text.write("tdsls040.txtb", "2",
"Sales", "Footer Text",
str$(tdsls040.orno), tdsls994.refa,
"wintext","txt", file.name$)
endif


now you could use debug mode to check if file.name$ is really ok!

mark_h
11th April 2006, 00:19
This is from one we use to insert routing text:

function add_new_operation()
{
tirou102.mitm = find.rout.item
tirou102.opro = " 1"
tirou102.opno = current.operation
tirou102.seqn = 1
tirou102.tano = 4055
tirou102.cwoc = find.rout.wrkctr
tirou102.mcno = ""
tirou102.sutm = 12
tirou102.rutm = 12
tirou102.mnoc = 1
tirou102.mcoc = 0
tirou102.olap = 0
tirou102.exin = find.rout.wrkctr
tirou102.bfls = tcyesno.no
tirou102.qpnt = 0
tirou102.nnts = 0
tirou102.desn = ""
tirou102.copo = tcyesno.yes
tirou102.txta = 0
tmpfield = "Operation "&str$(current.operation)
write.return = text.write("tirou102.txta","2","Operation Text",
find.rout.item,tmpfield,"",
"routing","text",temp.file)
|need to add new text field for operation 10
db.insert(ttirou102,db.retry)
commit.transaction()
}


Is it a type in your new query - should "orno" be ":orno".

countnikon
17th April 2006, 19:43
Everybody who responded,

Thanks a bunch. I got it to work with ya'lls help.