tmannais
6th August 2019, 05:46
I tried putting a string into a field using this command along with other fields.
. . .
dal.set.field("tsclm100.txta", "Test Text")
. . .
The other fields are correctly saved except this text field.
Any suggestion?
andreas.toepper
6th August 2019, 08:13
Text fields do store a numeric value. It's the number of the text stored in the text tables. Therefore, you will have to create the text itself before storing the text number in the table.
See text.to buf(..) and text.write(..) in the programmers reference guide. When I create a new text in LN I usually store the text in a text file on the server and then text.write(..) is used to create a new text in the database (this will create a new text number). The next step is to store the text number in the text field and perform an update on the table.
tmannais
6th August 2019, 10:12
I tried this following code.
string temp.file1(500), text(300)
string kw1(17),kw2(17),kw3(17),kw4(17)
long write.return, input.file, seq
select tsclm100.txta
from tsclm100 for update
where tsclm100.ccll = :ticket.number
as set with 1 rows
selectdo
message(ticket.number)
temp.file1 = creat.tmp.file$(bse.tmp.dir$())
temp.file1 = strip$(temp.file1)
input.file = seq.open(temp.file1,"w")
seq = seq.puts("Test Text", input.file)
seq = seq.close(input.file)
write.return = text.write("tsclm100.txta", "2", kw1, kw2, kw3, kw4, "text", "", temp.file1)
db.update(ttsclm100, db.retry)
seq = seq.unlink(temp.file1)
commit.transaction()
message(write.return)
endselect
where ticket.number is the Call Number.
This code does create a new text and put the text id into the database. However, when I access the detail session (tsclm1100m000) the text displays in the comment input field rather than in the comment history field, and once the session is closed the text disappears. The data in the table tsclm100 becomes blank and no comment history is added.
What I am trying to do is just to add a comment to the Ticket.
What did I do wrong?
andreas.toepper
6th August 2019, 11:57
Try creating the new text in a dumy field.
extern domain tctxtn new.xta
(..)
write.return = text.write("new.txta", "2", kw1, kw2, kw3, kw4, "text", "", temp.file1)
tsclm100.txta = new.txta
db.update(..)
(..)
I've checked my old source. I did something like this:
dal.new.object("tsbsc110")
(..)
err = text.write("tscfg200.txta", language$, "Cluster-Installation", tscfg200.desc, "", "", "text", "text", text.file)
(..)
dal.set.field("tscfg200.txta", tscfg200.txta)
ret = dal.save.object("tsbsc110")
tmannais
6th August 2019, 13:53
Still does not work.
The text is created with a new id and stored in the table, but if I start the session and then close it, the text data just disappears.
In the session, the text will not display in the Comment History too, which is where it should be displayed.
andreas.toepper
6th August 2019, 16:16
There may be some hidden logic in the session copying the new text into the history fields.
We’re not using TS but we do have sources.
In the script tsclm1100 in choice.text.manager/after,choice a function is calls (update.history.texts())
This function simply calls a DLL function:
db.retry.point()
tsclm.dll1025.update.history()
commit.transaction()
The DLL functions needs to have tsclm100 set. Hope this helps.
tmannais
7th August 2019, 05:55
There may be some hidden logic in the session copying the new text into the history fields.
We’re not using TS but we do have sources.
In the script tsclm1100 in choice.text.manager/after,choice a function is calls (update.history.texts())
This function simply calls a DLL function:
db.retry.point()
tsclm.dll1025.update.history()
commit.transaction()
The DLL functions needs to have tsclm100 set. Hope this helps.
I tried it several times with DAL but it just does not work as expected.
So, I decided to update its related tables that I could find, which are Call Transaction Logging (tsclm180) and Call History (tsclm810).
I can now add the comment using these steps:
1. Get the ticket number (Create one or get one)
2. Prepare the text (Create a new text and get its text id)
3. Update tsclm180 and tsclm810 with the necessary fields
Here is the actual code for step 2-3.
function add.comment(domain tcorno ticket.number)
{
string temp.file1(500), text(300), kw1(17),kw2(17),kw3(17),kw4(17)
long write.return, input.file, seq
temp.file1 = creat.tmp.file$(bse.tmp.dir$())
temp.file1 = strip$(temp.file1)
input.file = seq.open(temp.file1,"w")
seq = seq.puts("Test Text", input.file)
seq = seq.close(input.file)
write.return = text.write("tsclm100.txta", "2", kw1, kw2, kw3, kw4, "text", "", temp.file1)
seq = seq.unlink(temp.file1)
if tsclm100.txta > 0 then
domain tsmdm.serd sequence.number
domain tcmcs.s200m error.msg
error.msg = ""
select tsclm180.seqn:sequence.number
from tsclm180
where tsclm180.ccll = :ticket.number
order by tsclm180.seqn ASC
as set with 1 rows
selectdo
if dal.new.object("tsclm180") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
dal.set.field("tsclm180.ccll", ticket.number)
dal.set.field("tsclm180.seqn", sequence.number - 1)
dal.set.field("tsclm180.trtc", utc.num())
dal.set.field("tsclm180.user", "baan")
dal.set.field("tsclm180.cfld", tsclm.cfld.txtf)
dal.set.field("tsclm180.nval", "")
dal.set.field("tsclm180.txtf", tsclm100.txta)
if dal.save.object("tsclm180") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
commit.transaction()
message(ticket.number)
endselect
select tsclm810.txta, tsclm810.txtk
from tsclm810 for update
where tsclm810.ccll = :ticket.number
selectdo
dal.change.object("tsclm810")
dal.set.field("tsclm810.txta", tsclm100.txta)
dal.set.field("tsclm810.txtk", tsclm100.txta)
if dal.save.object("tsclm810") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
commit.transaction()
message(tsclm100.txta)
endselect
endif
}
The problem is solved now. Thank you for helping.
Moreover, I suggest that a mod edit this title a little bit so that it describes this topic in a more specific way because this is not about general DAL text field update. It is more like a solution for Call/Ticket process.
Ajesh
7th August 2019, 16:10
Strangely i couldnt see any db.retry.point in your code..
tmannais
8th August 2019, 04:52
Strangely i couldnt see any db.retry.point in your code..
Yes, because there isn't one.
Where do you suggest I put it?
Ajesh
8th August 2019, 11:26
Yes, because there isn't one.
Where do you suggest I put it?
Beginning of the Transaction.
function add.comment(domain tcorno ticket.number)
{
string temp.file1(500), text(300), kw1(17),kw2(17),kw3(17),kw4(17)
long write.return, input.file, seq
db.retry.point()
temp.file1 = creat.tmp.file$(bse.tmp.dir$())
temp.file1 = strip$(temp.file1)
input.file = seq.open(temp.file1,"w")
seq = seq.puts("Test Text", input.file)
seq = seq.close(input.file)
write.return = text.write("tsclm100.txta", "2", kw1, kw2, kw3, kw4, "text", "", temp.file1)
seq = seq.unlink(temp.file1)
if tsclm100.txta > 0 then
domain tsmdm.serd sequence.number
domain tcmcs.s200m error.msg
error.msg = ""
select tsclm180.seqn:sequence.number
from tsclm180
where tsclm180.ccll = :ticket.number
order by tsclm180.seqn ASC
as set with 1 rows
selectdo
if dal.new.object("tsclm180") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
dal.set.field("tsclm180.ccll", ticket.number)
dal.set.field("tsclm180.seqn", sequence.number - 1)
dal.set.field("tsclm180.trtc", utc.num())
dal.set.field("tsclm180.user", "baan")
dal.set.field("tsclm180.cfld", tsclm.cfld.txtf)
dal.set.field("tsclm180.nval", "")
dal.set.field("tsclm180.txtf", tsclm100.txta)
if dal.save.object("tsclm180") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
commit.transaction()
message(ticket.number)
endselect
select tsclm810.txta, tsclm810.txtk
from tsclm810 for update
where tsclm810.ccll = :ticket.number
selectdo
dal.change.object("tsclm810")
dal.set.field("tsclm810.txta", tsclm100.txta)
dal.set.field("tsclm810.txtk", tsclm100.txta)
if dal.save.object("tsclm810") <> 0 then
dal.get.error.message(error.msg)
message(error.msg)
endif
commit.transaction()
message(tsclm100.txta)
endselect
endif
}
Marek_C
12th September 2019, 11:01
There is nice Infor's function to get text number from string.
function description: tcbod.dll0038.get.text.number.for.string
Expl: The purpose of this function is adds a text to the text manager with the specified text in the specified language.
Pre: db.retry.point is set.
Post: Call 'commit.transaction()/abort.transaction()'.
i.string - String to save as text.
i.table.field.text - Table (text) field for text defaults.
For example: tdsls040.txta
i.lanugage - Language or system language
For example: "2"
If empty, the system language (language$) is taken.
Output: o.text.number - The created text number
Return: 0 if OK
DALHOOKERROR if error
tcbod.dll0038.get.text.number.for.string(
i.string,
i.table.field.text,
i.language,
o.text.number) |* ref