Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
Do we need additional Products without changing existing ones?
Innovate existing Products
100%
Need more Products
0%
Depend on the Industries
0%
Other, Pl comment
0%
Total votes: 1

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #16  
Old 26th March 2009, 22:01
mark_h's Avatar
mark_h mark_h is offline
Guru
 
Join Date: Sep 2001
Location: Kentucky, USA
Posts: 7,617
mark_h will become famous soon enough
Baan: Baan 4C4 A&D1 - DB: Oracle - OS: Sun Solaris
The text.read writes text to a file. If you have the text in a file then the the text.write is all you need. Just put your text field(tipcs021.txta)that you want to write, your text group that the text goes into and your filename to read from. That should take care of it.

In my case I am reading text already in a baan table, writing it to a file then reading in back into a different table. Sounds like you do not need all these steps.
__________________
Mark

GO Cards!
My latest mantra - make sure you have latest stpapi patches and the latest session object. If on LN then please explore the option of using DAL2 functionality.

Shared Solutions for Baan systems provided free by Baan Board.
Play the Google game and help Baanboard get better rankings. Do your part. Click here to find how.
Reply With Quote
  #17  
Old 27th March 2009, 14:01
tnzabo's Avatar
tnzabo tnzabo is offline
Senior Member
 
Join Date: Jul 2002
Location: Butler
Posts: 189
tnzabo is on a distinguished road
Baan: BaaN IV C4 - DB: SQL Server 2005 - OS: Windows 2003 SP2
I started going that way as well since I wasn't trying to read text that was already in Baan. However, another issue is the text I want isn't the only thing in my file. It's a simple flat text file that will have fixed length fields. The text will be on the end of the record and I'm allowing it to be a field 256 long. I'm reading that text into a field can I then write it to a temp file that can be written into the baan text of the tipcs021 table?
Reply With Quote
  #18  
Old 27th March 2009, 15:11
tnzabo's Avatar
tnzabo tnzabo is offline
Senior Member
 
Join Date: Jul 2002
Location: Butler
Posts: 189
tnzabo is on a distinguished road
Baan: BaaN IV C4 - DB: SQL Server 2005 - OS: Windows 2003 SP2
I GOT IT!!! Thanks for your help!! Now if I can just get it to align properly without the user having to modify it...
Reply With Quote
  #19  
Old 8th September 2021, 06:31
GeekGirlAkshara's Avatar
GeekGirlAkshara GeekGirlAkshara is offline
Junior Member
 
Join Date: Jul 2020
Location: India
Posts: 29
GeekGirlAkshara is on a distinguished road
Baan: 10.4 / 10.7 (Infor LN) - DB: MySQL, Oracle - OS: Windows
Quote:
Originally Posted by mark_h View Post
Something like this:
Code:
function process.inquiry.text()
{
	domain	tcmcs.str15	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.str15 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.str15 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()
	on case zoom.prog
		case "tdpur4101m000":
			db.eq(ttdpur040,db.delayed.lock)
			break
		case "tdpur1101m000":
			db.eq(ttdpur001,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
	endcase
	commit.transaction()
	file.chmod(temp.file1,S_IRWXU)
	ret.code = seq.unlink(temp.file1)
}
I was here to find the functionality to write the text into tttxt tables using proper way, and this code has helped me a lot! Thanks Mark for posting your code.
I have made necessary changes as per my need though.. Posting it here in case anybody (or me ) needs to use it in future.

Code:

declaration:
        string text(1000)
	long fp.in,ret
	string	temp.file1(500)
	string	kw1(17),kw2(17),kw3(17),kw4(17),tgrp(8),eopt(15)
	long	write.return, ret.code

functions:
function extern copy.text()
{
		select *
		from ziint102
		where ziint102.id = :ziint102.id
		selectdo
			text = text & ziint102.rem     |the text (string) i want to insert in tttxt table.
		endselect
		
		db.retry.point()
		select *                                           |the table where i want to store the textid/text
		from ziint100 for update
		where ziint100.id = :ziint102.id
		and ziint100.ticketid = :ziint102.ticketid
		selectdo
			text = strip$(shiftl$(text))	
			kw1 = trim$(ziint102.id)
			kw2 = trim$(ziint102.ticketid)
			kw3 = trim$(ziint100.account)
			
			if ziint100.textid > 0 then
				append.text("ziint100.textid")
			else
				create.text("ziint100.textid")
			endif
			
			db.update(tziint100,db.retry)         
			commit.transaction()
		endselect	
}

function create.text(domain tcmcs.str15 text.field)
{
|This function will create new textID	
        temp.file1 = creat.tmp.file$(bse.tmp.dir$())  |file created
	temp.file1 = strip$(temp.file1)
	
	fp.in = seq.open(temp.file1,"w+")        |created file is opened in write mode
	
		seq.puts(text, fp.in)                       |put the desired data in the opened file
		text = ""
	
	ret = seq.close(fp.in)                             |closed the file
	
	write.return = text.write(text.field, "2", kw1, kw2, kw3, kw4, "", "", temp.file1)  |new text is created and content of file is stored into the text

	file.chmod(temp.file1,S_IRWXU)          |set the access permissions for file
	ret.code = seq.unlink(temp.file1)
}

function append.text(domain tcmcs.str15 text.field)
{
|This function will append the new text int existing text/textID.
	temp.file1 = creat.tmp.file$(bse.tmp.dir$())    |file created
	temp.file1 = strip$(temp.file1)
	
	write.return = text.read(text.field, "2", kw1, kw2, kw3, kw4, tgrp, eopt, temp.file1, 0)  |Reads existing text in the passed field and stores it into specified file(temp.file1).
		
	fp.in = seq.open(temp.file1,"a+")                 |created file is opened in append mode
	
		seq.puts(text, fp.in)                               |put the desired data in the opened file
		text = ""
	
	ret = seq.close(fp.in)                                      |closed the file
	
	write.return = text.rewrite(text.field, "2", kw1, kw2, kw3, kw4, tgrp, "", temp.file1)       |rewrite the field with the new contents of file which is now - old + new
	ret.code = seq.unlink(temp.file1)
}
Hope this helps someone
__________________
Always ready to learn new things!
Reply With Quote
Sponsored Links
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming Question mr_suleyman Tools Development 37 11th November 2016 08:14
No read authorization for text group text aihbikers Tools Development 2 31st October 2003 15:26
printing different languages on one layout olabas Tools Development 8 21st May 2002 14:27


All times are GMT +2. The time now is 14:34.


©2001-2021 - Baanboard.com - Baanforums.com