arthur_info
11th March 2010, 16:32
Hello,

Is there some method using AFS that we can manipulate the creation of Texts in a session? Like the attached screen?

Thanks all...

mark_h
12th March 2010, 00:42
I usually just use the text funtions to read from a file. So if I wanted text to just say "testing" for some function I would have a session that would write to a file then write to the record involved. More details might generate more suggestions.

What I did for purchasing was create a session that lets them create text. They give the text some description. Then they have the option in same session to add this text to purchase orders, RFQ's, etc. See below for a piece of the code.


function process.purchase.text()
{
domain tcmcs.str16 text.field

if hdft = tdudi.hdft.head then
text.field = "tdpur040.txta"
else
text.field = "tdpur040.txtb"
endif

select tdpur040.*
from tdpur040
where tdpur040._index1 = {:orno}
as set with 1 rows
selectdo
endselect
if (text.field = "tdpur040.txta" and tdpur040.txta>0) or (text.field = "tdpur040.txtb" and tdpur040.txtb>0) then
append.text(text.field)
else
create.text(text.field)
endif
}
function process.inquiry.text()
{
domain tcmcs.str16 text.field

if hdft = tdudi.hdft.head then
text.field = "tdpur001.txta"
else
text.field = "tdpur001.txtb"
endif

select tdpur001.*
from tdpur001
where tdpur001._index1 = {:orno}
as set with 1 rows
selectdo
endselect
if (text.field = "tdpur001.txta" and tdpur001.txta>0) or (text.field = "tdpur001.txtb" and tdpur001.txtb>0) then
append.text(text.field)
else
create.text(text.field)
endif
}

function append.text(domain tcmcs.str16 some.field)
{
string temp.file1(500), temp.file2(500), cmd(1024)
string kw1(17),kw2(17),kw3(17),kw4(17),tgrp(8),eopt(15)
long write.return, ret.code

temp.file1 = creat.tmp.file$(bse.tmp.dir$())
temp.file1 = strip$(temp.file1)
write.return = text.read("tdudi010.txtn", "2", kw1, kw2, kw3, kw4, tgrp, eopt, temp.file1, 0)

temp.file2 = creat.tmp.file$(bse.tmp.dir$())
temp.file2 = strip$(temp.file2)
write.return = text.read(some.field, "2", kw1, kw2, kw3, kw4, tgrp, eopt, temp.file2, 0)

cmd = sprintf$("cat %s>>%s", temp.file1 , temp.file2)
ret.code = shell(cmd, SHELL_NO_OUTPUT)

write.return = text.rewrite(some.field, "2", kw1, kw2, kw3, kw4, tgrp, "", temp.file2)
commit.transaction()
ret.code = seq.unlink(temp.file1)
ret.code = seq.unlink(temp.file2)
}
function create.text(domain tcmcs.str16 some.field)
{
string temp.file1(500)
string kw1(17),kw2(17),kw3(17),kw4(17),tgrp(8),eopt(15)
long write.return, ret.code

temp.file1 = creat.tmp.file$(bse.tmp.dir$())
temp.file1 = strip$(temp.file1)
write.return = text.read("tdudi010.txtn", "2", kw1, kw2, kw3, kw4, tgrp, eopt, temp.file1, 0)
db.retry.point()
|select tdpur040.*
|from tdpur040 for update
|where tdpur040._index1 = {:orno}
|selectdo
on case zoom.prog
case "tdpur4101m000":
db.eq(ttdpur040,db.delayed.lock)
break
case "tdpur1101m000":
db.eq(ttdpur001,db.delayed.lock)
break
case "tdexi0109m000":
db.eq(ttdexi001,db.delayed.lock)
break
endcase
write.return = text.write(some.field, "2", kw1, kw2, kw3, kw4, "purchase", "", temp.file1)
on case zoom.prog
case "tdpur4101m000":
db.update(ttdpur040,db.retry)
break
case "tdpur1101m000":
db.update(ttdpur001,db.retry)
break
case "tdexi0109m000":
db.update(ttdexi001,db.retry)
break
endcase
commit.transaction()
|endselect
file.chmod(temp.file1,S_IRWXU)
ret.code = seq.unlink(temp.file1)
}

manish_patel
12th March 2010, 12:25
Text management is not supported by the AFS. You have to use text.* functions to handle text.

http://www.baanboard.com/baanboard/showthread.php?t=55508&highlight=text+AFS

arthur_info
12th March 2010, 13:16
Well, I was trying to put manually the relation between the tables (see printscreen attached)... But Baan doesn't understand this and when I go to the form (tdcotd201m000) and click on "T", Baan asks if I want to create a new text, even though I've already placed the value internally. I'm doing this because I'm using AFS with .Net, then I don't know how to use the text.write by this feature, since I can only use AFS commands or insert directly into the database.

Does anyone have any suggestions for doing this operation manually in other way?

Thanks a lot...

mark_h
12th March 2010, 15:16
How was the text created in tttxt010? Is the correct record also in tttxt001 and tttxt002? I am thinking this should work. The 001 table contains the text group and window type and the 002 table contains key word info. I think those are the only tables I involved.

I am not sure how to access the text functions out side of baan.

arthur_info
12th March 2010, 16:43
Oh Mark! You're right ... Lacked the tables tttxt001 and tttxt002. Now is working.

Thanks a lot!

Arthur