_Ralph_
22nd November 2006, 13:47
Hello friends, :)
Have you ever experienced something like that?:rolleyes:
I would like to make something that gets the data on a txt. file and put it on a table. Withouts the tools of the database
For example.
I was using a software that export the data of a business partner in txt. I want to alocate this on our erp.
LN will read the txt file and get the "name" on the txt and put on the columm "name" inside the ln.
The same way for the phone, email, address and so on...
I know that the position of the chars in txt are importat but how can i start that??:confused:
Thank you all =)
george7a
22nd November 2006, 17:52
Hi,
Can you please explain what do you mean by "Withouts the tools of the database"?
Do you want to write a (Baan) script to import a text file into the Baan tables?
- George
_Ralph_
22nd November 2006, 17:56
Thats right. Just using Baan Script :o
george7a
22nd November 2006, 17:58
Read here about Baan SQL (http://www.baanboard.com/programmers_manual_baanerp_help_functions_database_handling_baan_sql)
You also can use AFS to do so. You will find a lot of information in the AFS/DDC/OLE: Function servers Forum (http://www.baanboard.com/baanboard/forumdisplay.php?f=59).
I hope it helps,
- George
_Ralph_
22nd November 2006, 18:40
I think that AFS it's not the apropriate way to do this.
AFS just works with data already inserted on the baan server. Isn't right?
I need to import information from outside of baan. They are in a .txt file.
your knowledge will be apreciatte :D
george7a
23rd November 2006, 08:23
I think that AFS it's not the apropriate way to do this.
AFS just works with data already inserted on the baan server. Isn't right?
No. You can use AFS to import new data to Baan. Check this link & the documents in it:
http://www.baanboard.com/baanboard/showthread.php?t=7251
I hope it helps,
- George
en@frrom
23rd November 2006, 10:20
Actually,I find the easiest way either setting up in Exchange or just a (Baan-) script. The way this shall be done: well, any ascii file containing data has either fixed positions of each field, or delimiters between them.
2 basic examples:
1)
the file contains two fields, with fixed spacing:
pos1-9: business partner
pos10-39: business partner name
Code:
|******************************************************************************
|* Script Type: 3GL (without stnd. program)
|******************************************************************************
|****************************** DECLARATION SECTION ***************************
table ttccom100 | Business partners
extern domain tcmcs.long ret
extern domain tcmcs.long fileid
extern domain tcmcs.long count
extern domain tccom.bpid bpid
extern domain tcnama nama
string curr.line(40)
#define PATH "${BSE}/tmp/customers.txt"
function main()
{
ret = 0
count = 0
fileid = seq.open(PATH, "rt")
if fileid < 0 then
message("Can not open file")
else
db.retry.point()
while ret = 0
ret = seq.gets(curr.line, 40, fileid)
bpid = curr.line(1;9)
nama = curr.line(10;30)
select tccom100
from tccom100 for update
where tccom100._index1 = {:bpid}
order by tccom100._index1
as set with 1 rows
selectdo
tccom100.nama = nama
db.update(ttccom100, db.retry)
selectempty
db.set.to.default(ttccom100)
tccom100.bpid = bpid
tccom100.nama = nama
tccom100.seak = nama
etc... fill all fields
db.insert(ttccom100, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
endif
}
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
2)
the file contains two fields, ";"-seperated (.csv):
field1: business partner
field2: business partner name
Code:
|******************************************************************************
|* Script Type: 3GL (without stnd. program)
|******************************************************************************
|****************************** DECLARATION SECTION ***************************
table ttccom100 | Business partners
extern domain tcmcs.long ret
extern domain tcmcs.long fileid
extern domain tcmcs.long count
extern domain tccom.bpid bpid
extern domain tcnama nama
string curr.line(40)
#define PATH "${BSE}/tmp/customers.csv"
#define TR(x) strip$(shiftl$(x))
function main()
{
ret = 0
count = 0
fileid = seq.open(PATH, "rt")
if fileid < 0 then
message("Can not open file")
else
db.retry.point()
while ret = 0
ret = seq.gets(curr.line, 40, fileid)
string.scan(curr.line, "%s;%s", bpid, nama)
bpid = TR(bpid)
nama = TR(nama)
select tccom100
from tccom100 for update
where tccom100._index1 = {:bpid}
order by tccom100._index1
as set with 1 rows
selectdo
tccom100.nama = nama
db.update(ttccom100, db.retry)
selectempty
db.set.to.default(ttccom100)
tccom100.bpid = bpid
tccom100.nama = nama
tccom100.seak = nama
etc... fill all fields
db.insert(ttccom100, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
endif
}
|****************************** PROGRAM SECTION ***************************
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION ***************************
|****************************** CHOICE SECTION ***************************
|****************************** FIELD SECTION ***************************
|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
I hope this helps. Don't hesitate to ask if you still have questions.
Regards,
Eli Nager
_Ralph_
23rd November 2006, 13:22
That was it!
Thank you man!!
very much!
:) :) :)
en@frrom
23rd November 2006, 13:40
Pleasure "MAN"...
Hitesh Shah
29th November 2006, 15:37
Besides the other suggestions , if text import / export for any table under some conditions is the goal , u can use general dll functions in general record level extract functions (http://www.baanboard.com/baanboard/showthread.php?t=24217&highlight=extract+daemon)