raikar_raviraj
3rd January 2012, 17:25
Hi,

I am trying to upload a text in a table through a program. The text gets uploaded perfectly fine, but when i try to display it with normal Baan Text Editor i am not able to see the last line of text, but when i open the same text in Text editor which is defined as external editor (notepad), i am able to see the last line of Text.

The code which is written is as under.

function update.text.number()
|* Function to update text number
{
domain tcmcs.long temp.ret |Return Value
string temp.kw1(17) |Keyword 1
string temp.kw2(17) |Keyword 2
string temp.kw3(17) |Keyword 3
string temp.kw4(17) |Keyword 4
string temp.tgrp(8) |Text Group
string temp.editopt(15) |Edit Option
string temp.date(80) |Date
temp.lang = ""
temp.txtn = ""
get.language()

txtpath = "/home/" & logname$ & "/temp.txt"
file.rm(txtpath)
text.fp = seq.open(txtpath, "w")
if text.fp >= 1 then
temp.txtn = strip$(shiftl$(file.fields(1,5)))
temp.date = sprintf$("%D(Date: %02d/%02m/%04Y)", date.num())
temp.txtn = temp.date &" " & temp.txtn
db.retry.point()
select tppdm600.txtc.c
from tppdm600 for update
where tppdm600._index1 = {:temp.cprj}
selectdo
if tppdm600.txtc.c = 0 then
seq.write(strip$(shiftl$(temp.txtn)), 2048, text.fp)
seq.close(text.fp)
text.ret = text.write("tppdm600.txtc.c", temp.lang, "", "", "", "", "text", "standard", txtpath)
db.update(ttppdm600,db.retry)
temp.ret = commit.transaction()
if temp.ret = 0 then
stpapi.put.field("tpppc9202m000", "cprj.f", temp.cprj)
stpapi.put.field("tpppc9202m000", "cprj.t", temp.cprj)
| stpapi.set.report("tpppc9202m000", "rtpppc920201000", "D",err.mess)
stpapi.continue.process("tpppc9202m000", pp.error)
if shiftl$(shiftr$(pp.error)) <> "" then
pp.cprj = temp.cprj
brp.ready(pp.brp)
endif
stpapi.end.session("tpppc9202m000")
endif
else
text.ret = text.read("tppdm600.txtc.c", temp.lang, temp.kw1, temp.kw2, temp.kw3,
temp.kw4, temp.tgrp, temp.editopt, txtpath,1)
seq.close(text.fp)
if text.ret <> -1 then
text.fp = seq.open(txtpath, "a")
seq.puts("",text.fp)
seq.write(strip$(shiftl$(temp.txtn)), 2048, text.fp)
seq.close(text.fp)
text.ret = text.rewrite("tppdm600.txtc.c", temp.lang, "", "", "", "", "text", "standard", txtpath)
db.update(ttppdm600,db.retry)
temp.ret = commit.transaction()
if temp.ret = 0 then
stpapi.put.field("tpppc9202m000", "cprj.f", temp.cprj)
stpapi.put.field("tpppc9202m000", "cprj.t", temp.cprj)
| stpapi.set.report("tpppc9202m000","rtpppc920201000", "D",err.mess)
stpapi.continue.process("tpppc9202m000", pp.error)
if shiftl$(shiftr$(pp.error)) <> "" then
pp.cprj = temp.cprj
brp.ready(pp.brp)
endif
stpapi.end.session("tpppc9202m000")
endif
endif
endif
selectempty
endselect
endif
}

Please help resolving this issue.

mark_h
4th January 2012, 01:57
The first thing that jumped out to me is why are you using seq.write? Did you mean seq.puts? I would try that first. Looks like the seq.write starts at the current location and writes 2048 bytes.

raikar_raviraj
16th January 2012, 07:14
Thanks Mark. That helps.