teddybear
4th August 2005, 08:30
I understand that uploading of text from Excel is not supported by API. Is there any other way that we can upload text into BaaN ?
Rita Kotecha
4th August 2005, 14:22
Have you tried ttaad4227m000 create table from sequential dump ?
mark_h
4th August 2005, 14:49
You can load text using exchange schemes. Or you can just write a program to read the text and write it.
Neal Matthews
4th August 2005, 17:45
I did write some code for an Exchange Script condition which pulls text out of a spreadsheet / ascii file and adds it as text against the item. If anybody is interested I'll post it.
Cheers
Neal Matthews
IT Support Analyst
ATY Automotive & Industrial Components (UK) Ltd.
prademaker
8th August 2005, 15:00
I came across the same limits of AFS. I wanted to add text to a specific salesorder line.
I solved my problem by writing two functions. The first finds the salesorder and eventually existing text, the second one creates/rewrites the text using the standard functions TEXT.WRITE and TEXT.REWRITE from bic_text.
Both are in a custom dll "zoslsdllvbbaan".
From a VB-application, the user selects the Order/line and the text. Hitting the button sends it right into Baan using OLE.
Here's my Baan code, i hope it's usefull to anyone:
function extern domain tcinvn zoslsdllvbbaan.find.text(
domain tcorno i.orno,
domain tcpono i.pono,
string i.text(4000) )
{
domain tcmcs.str1 current.clan
db.retry.point()
select tdsls041.txta, tdsls040.clan
from tdsls041 for update, tdsls040
where tdsls041._index1 = { :i.orno, :i.pono }
and tdsls041.orno refers to tdsls040
selectdo
selectempty
endselect
on case tdsls040.clan
case " N":
current.clan = "1"
break
case " NL":
current.clan = "1"
break
case " F":
current.clan = "4"
break
case " FR":
current.clan = "4"
break
case " E":
current.clan = "2"
break
case " D":
current.clan = "3"
break
default:
current.clan = "1"
endcase
write.item.text( tdsls041.txta, "tdsls041.txta", current.clan, i.text)
db.update(ttdsls041, db.retry)
commit.transaction()
return( tdsls041.txta )
}
function write.item.text( domain tcinvn text.number, domain tcmcs.str15 text.field,
domain tcmcs.str1 clan, string i.text(4000))
{
long l.ret
long l.layout.lfn
string l.layout(128)
string line(80)
long counter
if strip$(i.text) > "" then
l.layout = creat.tmp.file$(bse.tmp.dir$()) | Create a temporary ASCII file.
l.layout.lfn = seq.open(l.layout, "a") | Open ASCII file.
l.ret = seq.puts(i.text, l.layout.lfn) | Write string that must be added to text into ASCII file.
seq.close(l.layout.lfn) | Close ASCII file.
attr.textkw1$ = "Verkoop"
attr.textkw2$ = ""
attr.textkw3$ = str$(tdsls041.orno)
attr.textkw4$ = ""
attr.textgrp = "tsls"
attr.textopt$ = ""
attr.textlang$ = clan
| If text present, then rewrite, else write!
if text.number <> 0 then
l.ret = TEXT.REWRITE(
text.field,
attr.textlang$,
attr.textkw1$,
attr.textkw2$,
attr.textkw3$,
attr.textkw4$,
attr.textgrp,
attr.textopt$,
l.layout)
else
l.ret = TEXT.WRITE(
text.field,
attr.textlang$,
attr.textkw1$,
attr.textkw2$,
attr.textkw3$,
attr.textkw4$,
attr.textgrp,
attr.textopt$,
l.layout)
endif
seq.unlink(l.layout)
endif
}
bkkland
6th May 2011, 00:23
I did write some code for an Exchange Script condition which pulls text out of a spreadsheet / ascii file and adds it as text against the item. If anybody is interested I'll post it.
Cheers
Neal Matthews
IT Support Analyst
ATY Automotive & Industrial Components (UK) Ltd.
Hi Neal,
could you share the code? I want to uplaod test to item table using echange scheme but didn't work.
mpfaender
6th May 2011, 11:06
Hi bkkland,
when you want to insert text with exchange schemes you've to consider somethings. The structure of cvs file must be as following.
In this example we want appending text to table tccom110 (Sold To).
4711 the number of Sold To, 4712 is the second Sold To.
{\{...}\} entclose all text rows
txta defines the text field in table tccom110
the value 2 after txta defines the language of the text. it's import the language number must be on position 9!!!
4711
{\{txta 2
Sold to of 4711 text row 1
Sold to of 4711 text row 2
Sold to of 4711 text row 3
Sold to of 4711 text row 4
}\}
4712
{\{txta 2
Sold to of 4712 text row 1
Sold to of 4712 text row 2
Sold to of 4712 text row 3
Sold to of 4712 text row 4
}\}
When you have more then one fields to update table tccom110 the structure looks like this.
The second value after the Sold To number is the Sold To Status for example.
4711^1
{\{txta 2
Sold to of 4711 text row 1
Sold to of 4711 text row 2
Sold to of 4711 text row 3
Sold to of 4711 text row 4
}\}
best regards
michael
bkkland
6th May 2011, 18:44
Is the format the same for single line text?
I'm trying to upload the item text (tiitm001)
Now the condition syntax is OK, but the import data still has error, which I don't know what it is. :confused:
Do you include the path of the text file on the text.write(...)?
Thank you for oyur help!!!
Neal Matthews
12th May 2011, 13:52
Hello sorry for the delay it took me a while to dig this out from our old server. This basically was generating text for items already loaded onto our system from a spreadsheet which I saved as a csv file. The csv file is then read and a temp file generated for each item. Finally the text.rewrite function is called. Please test before using.
Good luck Neal
|****************************************************************
|*** Exchange script for purch text creation
|*** NAM 18/08/03
|****************************************************************
|**
|** Use low level file handling to pull in downloaded files
|**
|** Function then writes and appends to required tables
|**
|****************************************************************
long open.ptr,put.ptr,close.ptr,fd,rt,size,mode,read,nrbytes
long m_pos,offset,n,m_start,m_end
string m_bit(1),m_string(159),m_item(7),m_type(17)
string m_grade(28),m_dima(5),m_dimb(5),m_wall(6),m_length(8),m_tol(7),m_draw(27),m_other(47)
string cdir(80),fname(80)
cdir = "/triappiv/exchange/pur003/textfile/"
fd = dir.open(cdir)
fname = "text.txt"
open.ptr = seq.open(strip$(cdir) & strip$(fname),"rt")
|message(strip$(cdir) & strip$(fname))
n = 0
m_start = 0
m_pos = 0
repeat
offset = seq.seek(m_pos,0,open.ptr)
read = seq.read(m_bit,1,open.ptr)
if m_bit=chr$(10) then
m_end = n
offset = seq.seek(m_start,0,open.ptr)
read = seq.read(m_string,m_end - m_start,open.ptr)
m_item = m_string(2;7)
m_type = m_string(9;17)
m_grade = m_string(26;28)
m_dima = m_string(54;5)
m_dimb = m_string(59;5)
m_wall = m_string(64;6)
m_length = m_string(70;8)
m_tol = m_string(78;7)
m_draw = m_string(85;27)
m_other = m_string(112;47)
|message(m_item)
|message(m_type)
|message(m_grade)
|message(m_dima)
|message(m_dimb)
|message(m_wall)
|message(m_length)
|message(m_tol)
|message(m_draw)
|message(m_other)
txtwrite(m_item,m_type,m_grade,m_dima,m_dimb,m_wall,m_length,m_tol,m_draw,m_other)
m_start = m_end + 1
endif
n = n + 1
m_pos = n
until m_bit = ""
return (false)
}
function txtwrite(string m_item(7), string m_type(17), string m_grade(28),
string m_dima(5), string m_dimb(5), string m_wall(6),
string m_length(8), string m_tol(7), string m_draw(27),
string m_other(47))
{
long ret
table ttttxt001
string m_text(4000)
|* Use text write function for each item but first set up text in tmp file
m_text= "TYPE - " & m_type & chr$(10) & chr$(13) &
"GRADE - " & m_grade & chr$(10) & chr$(13) &
"DIAMETER/DIM A - " & m_dima & chr$(10) & chr$(13) &
"DIM B - " & m_dimb & chr$(10) & chr$(13) &
"WALL - " & m_wall & chr$(10) & chr$(13) &
"LENGTH - " & m_length & chr$(10) & chr$(13) &
"LENGTH TOL. - " & m_tol & chr$(10) & chr$(13) &
"DRAWING - " & m_draw & chr$(10) & chr$(13) &
"OTHER REQUIREMENTS - " & m_other
ret = seq.open("/triappiv/exchange/pur003/textfile/text.log","a+")
seq.puts("",ret)
seq.puts(m_item,ret)
seq.puts(m_text,ret)
seq.puts("",ret)
seq.close(ret)
ret = seq.open("/triappiv/exchange/pur003/textfile/" & m_item & ".txt", "w+")
seq.puts(m_text,ret)
seq.close(ret)
select tiitm001.item,tiitm001.seak,tiitm001.seab,tiitm001.txta from tiitm001 for update
where tiitm001._index1 ={:m_item}
selectdo
ret = text.rewrite("tiitm001.txta","2","Item text G", tiitm001.seak, tiitm001.seab,
tiitm001.item,"text","text", "/triappiv/exchange/pur003/textfile/" & m_item & ".txt")
db.update(ttiitm001,DB.RETRY)
endselect
commit.transaction()