Baanboard.com

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

Retirement Notice

Baanboard is shutting down on 31-dec-2023. See: http://www.baanboard.com/baanboard/showthread.php?t=76043


User login

Frontpage Sponsor

Main

Poll
What do you expect from your SI Implementation partner for the success of ERP implementation.
Bring best practices - Not to offer more CR's Leveraging standard functions
20%
Need more honesty to work with the Users until their processes are fully mapped & Users are trained
40%
Focus on process automation/ integrations/ Real time data/ BI analytics
13%
Stick to basics
27%
Total votes: 15

Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 4th May 2023, 17:59
Keitaro84's Avatar
Keitaro84 Keitaro84 is offline
Junior Member
 
Join Date: Nov 2022
Posts: 25
Keitaro84 is on a distinguished road
Baan: LN 10.7 - DB: Oracle - OS: Windows
I've implemented this code, but I don't know if it's the best solution.

Code:
function long change.xml.file.declaration(domain tcmcs.str256m i.file.path) {	
	
	domain tcmcs.str256m o.file.path
	long	i.fp, o.fp, ret
	string	buffer(1024)
	string temp.uuid(22)
	string final.uuid(36)
	boolean is.first

	is.first = true
	temp.uuid = uuid.generate$()
	final.uuid = uuid.format$(temp.uuid)
	
	o.file.path = bse.dir$() & path.dir.separator() & "purchases" & path.dir.separator() & "tmp" & path.dir.separator() & final.uuid & ".xml"
	
	i.fp = seq.open(i.file.path, "r+")
	o.fp = seq.open(o.file.path, "w+")
	
	if (i.fp >= 1 and o.fp >= 0) then
	
		while not seq.gets(buffer, 1024, i.fp, GETS_ALL_CHARS)
			
			if(is.first) then
			
				string	new.buffer(1024)
			
				new.buffer = str.replace$(buffer,
						"<?xml version=" & chr$(34) & "1.0" & chr$(34) & "?>",
						"<?xml version=" & chr$(34) & "1.0" & chr$(34) & " encoding=" & chr$(34) & "UTF-8" & chr$(34) & "?>")
				is.first = false
				
				new.buffer = trim$(new.buffer)
				
				ret = seq.write(new.buffer, len(new.buffer), o.fp)
			
			else
			
				ret = seq.write(buffer, 1024, o.fp)
			
			endif		
			
		endwhile
		
		seq.close(i.fp)
		seq.close(o.fp)
		
		ret = file.cp(o.file.path, i.file.path)
		
		ret = file.rm(o.file.path)
		
	else
	
		if i.fp > 0 then
		
			seq.close(i.fp)
			
		else
		
			seq.close(o.fp)
		
		endif
			
	
	endif

	return(ret)
}
Reply With Quote
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
Undocumented Functions & Variables george7a Tools Development 82 28th September 2021 17:12
Generic solution for writing XML files from Baan en@frrom Tools Development 1 11th April 2011 11:53
Problem with multiple XML documents.... BaaNovva Open World, Portal & Decision Manager 0 11th February 2008 13:12
XML READING ERROR (baan IV) mr_suleyman Tools Development 5 2nd February 2007 16:08
XML Declaration TFojan Miscellaneous 1 11th August 2004 17:48


All times are GMT +2. The time now is 01:12.


©2001-2023 - Baanboard.com - Baanforums.com