mitchell
21st June 2013, 22:28
I have a customized session which reads a few tables and creates a “txt” file. I now want the contents of this “txt” file to be added as my text for an ECO.
I use the text.write command to create the text field within tiedm310. This part works ... the text within tiedm310 looks good.
The issue is the original txt file. The format for this txt file has been changed. It starts off with a nice format and ends up all on one line. Any ideas why?
functions:
function read.main.table()
{
name = getenv$("LOGNAME")
name = strip$(name)
|* Open Export Files
|* Create file with ECO data
exportfile = "\baan\tmp\public\ECO Data\ECO-" & str$(eco.orno) & name & ".txt"
exportfile = strip$(exportfile)
fp2 = seq.open(exportfile, "w")
if fp2 < 1 then
message("File " & exportfile & " does not exist")
else
select tiedm310.*
from tiedm310
where tiedm310._index1 = {:eco.orno}
selectdo
write.header.record()
get.Eitems.by.eco()
endselect
seq.close(fp2)
create.text.from.file.created()
endif
}
function create.text.from.file.created()
{
db.retry.point()
select tiedm310.txta
from tiedm310 for update
where tiedm310._index1 = {:eco.orno}
selectdo
if tiedm310.txta = 0 then
kw1 = "tiedm310.txta"
kw2 = ""
kw3 = ""
kw4 = ""
tgroup = "eng"
edit_opt = "eng"
endif
ret = text.write("tiedm310.txta","2", kw1, kw2, kw3, kw4, tgroup, edit_opt, exportfile)
message("Number of lines written to text - %s", ret)
db.update(ttiedm310, db.retry)
endselect
commit.transaction()
}
function get.Eitems.by.eco()
{
select tiedm322.*, tiedm010.dsca
from tiedm322, tiedm010
where tiedm322._index1 = {:tiedm310.orno}
and tiedm322.eitm refers to tiedm010
selectdo
select tiedm100.dsca
from tiedm100
where tiedm100._index1 = {:tiedm322.eitm,:tiedm322.revi}
selectdo
rev.desc = tiedm100.dsca
selectempty
rev.desc = ""
endselect
write.detail.record()
endselect
}
function write.header.record()
{
write.rec.string = ""
write.rec.string = "ECO#" & str$(tiedm310.orno) & " " &
sprintf$("%D(Date: %d/%h/%04Y)",tiedm310.ecdt) & " " &
"NAME: " & name &
chr$(13) & chr$(10)
rec = seq.write(write.rec.string, len(write.rec.string), fp2)
}
function write.detail.record()
{
write.rec.string = ""
write.rec.string = str$(tiedm322.pono) & " " &
tiedm322.eitm & " " &
tiedm010.dsca & " " &
tiedm322.orev & " " &
tiedm322.revi & " " &
rev.desc &
chr$(13) & chr$(10)
write.rec.string = strip$(shiftl$(write.rec.string))
rec = seq.write(write.rec.string, len(write.rec.string), fp2)
}
I use the text.write command to create the text field within tiedm310. This part works ... the text within tiedm310 looks good.
The issue is the original txt file. The format for this txt file has been changed. It starts off with a nice format and ends up all on one line. Any ideas why?
functions:
function read.main.table()
{
name = getenv$("LOGNAME")
name = strip$(name)
|* Open Export Files
|* Create file with ECO data
exportfile = "\baan\tmp\public\ECO Data\ECO-" & str$(eco.orno) & name & ".txt"
exportfile = strip$(exportfile)
fp2 = seq.open(exportfile, "w")
if fp2 < 1 then
message("File " & exportfile & " does not exist")
else
select tiedm310.*
from tiedm310
where tiedm310._index1 = {:eco.orno}
selectdo
write.header.record()
get.Eitems.by.eco()
endselect
seq.close(fp2)
create.text.from.file.created()
endif
}
function create.text.from.file.created()
{
db.retry.point()
select tiedm310.txta
from tiedm310 for update
where tiedm310._index1 = {:eco.orno}
selectdo
if tiedm310.txta = 0 then
kw1 = "tiedm310.txta"
kw2 = ""
kw3 = ""
kw4 = ""
tgroup = "eng"
edit_opt = "eng"
endif
ret = text.write("tiedm310.txta","2", kw1, kw2, kw3, kw4, tgroup, edit_opt, exportfile)
message("Number of lines written to text - %s", ret)
db.update(ttiedm310, db.retry)
endselect
commit.transaction()
}
function get.Eitems.by.eco()
{
select tiedm322.*, tiedm010.dsca
from tiedm322, tiedm010
where tiedm322._index1 = {:tiedm310.orno}
and tiedm322.eitm refers to tiedm010
selectdo
select tiedm100.dsca
from tiedm100
where tiedm100._index1 = {:tiedm322.eitm,:tiedm322.revi}
selectdo
rev.desc = tiedm100.dsca
selectempty
rev.desc = ""
endselect
write.detail.record()
endselect
}
function write.header.record()
{
write.rec.string = ""
write.rec.string = "ECO#" & str$(tiedm310.orno) & " " &
sprintf$("%D(Date: %d/%h/%04Y)",tiedm310.ecdt) & " " &
"NAME: " & name &
chr$(13) & chr$(10)
rec = seq.write(write.rec.string, len(write.rec.string), fp2)
}
function write.detail.record()
{
write.rec.string = ""
write.rec.string = str$(tiedm322.pono) & " " &
tiedm322.eitm & " " &
tiedm010.dsca & " " &
tiedm322.orev & " " &
tiedm322.revi & " " &
rev.desc &
chr$(13) & chr$(10)
write.rec.string = strip$(shiftl$(write.rec.string))
rec = seq.write(write.rec.string, len(write.rec.string), fp2)
}