VishalMistry
8th August 2017, 13:38
Hello Everyone,

this is related to Baan IV

I have a multi-occurance maintenance (tiitm9109m003) session for new custom table (tiitm909). The table has only three fields but no text field.

I want to maintain text of another table tiitm001.txtu (it's a custom text field).
I have added the text field of tiitm001.txtu through Text Field option in Specific menu. Now clicking on text button, the text manager opens, but when I save and exit text manager, the text is not saved in the tiitm001.txtu. The value of tiitm001.txtu still remains 0 (zero).

Has anybody faced similar issue ? I would appreciate any help in this regard.

Vishal

mark_h
8th August 2017, 15:35
The one time I did something like this was to use qkey to change a baan standard session. So on program tppss9161m00b I maintain text tppss990.txtn. So like you I added it to the maintain texts. Then when you create text it returns to the after.rewrite of maintable.io - at that point I go update the tppss990 table with the text number. Simple little select update statement to update the text number and a few other fields.

VishalMistry
8th August 2017, 15:56
Hello Mark,

Thanks for update. But in my case, the session where I need to invoke the text manager is new developed one. And the table it maintains the data does not contain any text field. It goes like below:

table structure of tiitm909:
Item tcitem
tcru tcmcs.str3
tdef tcmcs.str3

The text field to be maintained is tiitm001.txtu[/B]. But it has to be maintained through tiitm9109m003 and not through tiitm0101m000.

The session to maintain data in table tiitm909 is tiitm9109m003 (multi-occurrence). In session tiitm9109m003, I am able to add text field tiitm001.txtu through specific menu. On clicking text icon, It successfully invokes the text manager, but on saving, it does not store the text number in tiitm001.txtu.

So, in above case, I do not think I would be required to use QKey as the session script of tiitm9109m003 is available with source code, the only problem is adding text to tiitm001.txtu through session tiitm9109m003.

I am still searching Baanboard to find a thread with similar scenario.

Thank you again,
Vishal

mark_h
8th August 2017, 18:39
Sorry was not clear on what I meant. What I am saying is that if you put something in the main.table.io after.rewrite section to go do a select/update on tiitm001.txt then it might solve your issue. In my case I was updating a standard baan session to maintain a text field on a completely different table. Basically same thing you are doing.

VishalMistry
8th August 2017, 19:26
Hi Mark,

I think there is some misunderstanding. I want to update the text from other session which is based on a table (tiitm909) which is not having any text field. One simple way is to add text field in tiitm909 and then follow the steps you have suggested. But, I do not want to add any text field in tiitm909.

Regards,
Vishal

mark_h
8th August 2017, 20:33
That is what I am saying - add text field tiitm001.txtu to your session on the text fields which I think you aready did. Then go into your session script - in the main.table.io section after.rewrite - put in a message statement message(tiitm001.txtu). Compile your session - run it and create text for an item. When you exit the text it should give you the text number. If that works then just add code to go update the tiitm001 table for that item using that that text number for the item you just added text to. Some where alone the way you are going to have to update tiitm001 with the text number.
example:

main.table.io:
after.rewrite:
select tiitm001.txtu
from tiitm001 for update
where tiitm001.item = :your-item probably tiitm909.item
selectdo
tiitm001.txtu = tiitm001.txtu
endselect

VishalMistry
9th August 2017, 14:40
Hello Mark,

Unfortunately, the text number returned is zero. I am able to achieve updating text number through below code, but the issue is the text editor opens twice. I mean when first time it opens the text editor, I just enter the text and close it, but it opens one more time.

text.num = text.edit("tiitm001.txtu", "2", "tiitm001.txtu", tiitm001.seak, "", tiitm001.item, "text", "", 3)

select tiitm001.item, tiitm001.txtu
from tiitm001 for update
where tiitm001._index1 = {:tiitm909.item}
selectdo
tiitm001.txtu = text.num
db.update(ttiitm001, db.retry)
commit.transaction()
endselect

I suspect it is because I have added the text field tiitm001.txtu in Text Fields in specific menu. Any clue how to close the text editor process ?

Thank you for your help.

Vishal

VishalMistry
9th August 2017, 15:55
Hello Mark,

Finally I was able to do it. Below is the code that worked for me:

select tiitm001.item,tiitm001.seak, tiitm001.txtu
from tiitm001
where tiitm001._index1 = {:tiitm909.item}
selectdo
endselect

on case attr.textfield$
case "tiitm001.txtu":
text.num = text.edit("tiitm001.txtu", "2", "tiitm001.txtu", tiitm001.seak, "", tiitm001.item, "text", "", 3)

select tiitm001.item, tiitm001.txtu
from tiitm001 for update
where tiitm001._index1 = {:tiitm909.item}
selectdo
tiitm001.txtu = text.num
db.update(ttiitm001, db.retry)
commit.transaction()
endselect

endcase
|Below line is important as it will suppress opening up the text manager again
attr.textfield$ = ""
choice.again()

mark_h
9th August 2017, 18:08
Thanks for posting the solution. Might help others in the future. I totally forgot the first part from my session where I look up the text number on the table. I do that in the main.table.io after read section and I set the text attributes in the text.manager before choice event.