tracylee
27th July 2015, 12:14
Hi,
Have anybody know the functionality to upload/import the excel file into server?
Please advise. Thanks
Ashok_elgi
27th July 2015, 14:40
try Exchange scheme for both upload and download flat files
bhushanchanda
27th July 2015, 16:56
Or, you can use seq.* functions to read and write file and process it.
tracylee
28th July 2015, 04:00
try Exchange scheme for both upload and download flat files
Basically, I want written coding to uploading the data from excel file to table, when user click the button then data will uploading the data from excel to table. My actual purpose is, without using exchange scheme, read the direct excel file (column wise) and insert record into table because user is not any idea about exchange scheme, transfer file from local machine to server and user has not permission all these things. Please advise. Thanks.
tracylee
28th July 2015, 04:39
Or, you can use seq.* functions to read and write file and process it.
Any function to browser the excel file and read it from local machine? Actually, I want user when click the button to choose the file and direct upload into table. Have any sample coding can I refer? Please advise. Thanks.
tracylee
28th July 2015, 06:47
Dear all,
I try use the coding as below to read my file and update to table but when run until seq.gets function, error -1 shown. Is it my coding got any problem? Please advise. thanks.
function extern import.request()
{
string local.path(1024)
long ret, ret1, fp, count
string filename(200)
string curr.line(2048)
ret1 = 0
count = 0
ret = seq.open.dialog.local(false, filename, "c:\test\", "Text Files (*.csv)|*.csv", local.path)
fp = seq.open.local(local.path, "w+")
message("A: %s",fp) | Here I can get the message >=0
if fp < 0 then
message("Cannot open file.")
else
db.retry.point()
while ret1 = 0
ret1 = seq.gets(curr.line, 2048, fp)
string.scan(curr.line, "%s,%s,%s,%d,%s,%s,%s,%s,%s", cono, pono, cofc, ddta, sqnb, qoor, orno, posi, lcmp)
cono = strip$(cono)
pono = pono
cofc = strip$(cofc)
ddta = ddta
sqnb = sqnb
qoor = qoor
orno = strip$(orno)
posi = posi
lcmp = lcmp
message("ret1: %s",ret1) | Here get -1
select tdsls304.*
from tdsls304 for update
where tdsls304.cono = :txlee123.cono and tdsls304.pono = :txlee123.pono
selectdo
message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
|tdsls304.ddta = ddta
|tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
|tdsls304.orno = orno
|tdsls304.posi = posi
|tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = ddta
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
endif
}
bhushanchanda
28th July 2015, 09:24
Hi,
I am assuming you are using CSV file to read and have proper permissions on this file. You can try this -
if fp >= 0 then
seq.rewind(fp)
while not seq.eof(fp)
data.str = ""
ret1 = seq.gets(data.str,2048,fp)
|** Do things
endwhile
endif
This will make sure, your pointer is set to the first position prior to start reading.
darkhorse
28th July 2015, 09:54
Hi,
You cannot use Client file access functions(seq.open.local() in your case) in combination with the seq.*.local() functions.Instead use client2server() and then seq.open().
Below I have pasted sample syntax for the same
ret2 = client2server(i.file.name, i.file.name1,false, false, true)
input.fp = seq.open(strip$(i.file.name1), "rt")
if input.fp < 1 then
mess("xiutlk00000013",1,(-1 * input.fp))
|* File can not be imported. System Error Code: < %1$s>
return
else
record.length = 2048
insert.records()
ret2 = seq.close(input.fp)
seq.unlink(i.file.name1)
endif
bhushanchanda
28th July 2015, 09:58
Hi,
You cannot use Client file access functions(seq.open.local() in your case) in combination with the seq.*.local() functions.Instead use client2server() and then seq.open().
Below I have pasted sample syntax for the same
ret2 = client2server(i.file.name, i.file.name1,false, false, true)
input.fp = seq.open(strip$(i.file.name1), "rt")
if input.fp < 1 then
mess("xiutlk00000013",1,(-1 * input.fp))
|* File can not be imported. System Error Code: < %1$s>
return
else
record.length = 2048
insert.records()
ret2 = seq.close(input.fp)
seq.unlink(i.file.name1)
endif
Go with it! Move file to server and read it.
tracylee
29th July 2015, 08:15
Hi,
You cannot use Client file access functions(seq.open.local() in your case) in combination with the seq.*.local() functions.Instead use client2server() and then seq.open().
Below I have pasted sample syntax for the same
ret2 = client2server(i.file.name, i.file.name1,false, false, true)
input.fp = seq.open(strip$(i.file.name1), "rt")
if input.fp < 1 then
mess("xiutlk00000013",1,(-1 * input.fp))
|* File can not be imported. System Error Code: < %1$s>
return
else
record.length = 2048
insert.records()
ret2 = seq.close(input.fp)
seq.unlink(i.file.name1)
endif
Hi, Thanks for your information. I already can import file into server but when i import the data from the file into table, it only import last line (without ddte and sqnb). If my coding with the (ddte and sqnb) then an error message prompt out and cannot import any data into table. Below is my coding with ddte and sqnb. Is it my ddte have any problem after convert to utc? Please advise. Thanks.
*noted : Contract No.: txlee123.cono,
Position : txlee123.pono
Both data is my prompt page fileds. If this both fields same as table fileds, then data will update/insert into this table
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand | Baan API Handler
#include <bic_dam>
#pragma used dll "ottdllbw"
table ttdsls304 | Sales Contract Delivery Lines
extern domain tccono cono, txlee123.cono
extern domain tcpono pono, txlee123.pono
extern domain tccwoc cofc
extern domain tcdate ddta
extern domain tcmcs.str15 date_string
extern domain tcpono sqnb
extern domain tcqrd3 qoor
extern domain tcorno orno
extern domain tcpono posi
extern domain tcncmp lcmp
extern domain tcmcs.str30m rev
|***************************** FUnction *******************
Functions:
function extern import.request()
{
string local.path(1024)
long ret1, count, ret2, input.fp
string filename(200),filename2(200)
string curr.line(2048)
string dat_year_string(4), dat_month_string(2), dat_day_string(2)
long dat_yearno, dat_monthno, dat_dayno, no_of_dat
ret1 = 0
filename2 = "${BSE}/tmp/Delivery Scheme.csv"
ret2 = client2server("", filename2, false, false,true)
input.fp = seq.open(strip$(filename2),"rt")
if input.fp < 1 then
message("File Cannot be imported.")
return
else
while ret1 = 0
ret1 = seq.gets(curr.line, 2048, input.fp)
string.scan(curr.line, "%s,%s,%s,%d,%d,%s,%s,%s,%s", cono, pono, cofc, ddta, sqnb, qoor, orno, posi, lcmp)
cono = strip$(cono)
pono = pono
cofc = strip$(cofc)
ddta = ddta
date_string = str$(ddta)
dat_year_string = date_string(1;4)
dat_month_string = date_string(5;2)
dat_day_string = date_string(7;2)
dat_yearno = lval(dat_year_string)
dat_monthno = lval(dat_month_string)
dat_dayno = lval(dat_day_string)
no_of_dat = date.to.utc(dat_yearno, dat_monthno, dat_dayno, 00, 00, 00)
sqnb = str$(sqnb)
qoor = qoor
orno = strip$(orno)
posi = posi
lcmp = lcmp
select tdsls304.*
from tdsls304 for update
where tdsls304.cono = :txlee123.cono and tdsls304.pono = :txlee123.pono
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = no_of_dat
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = ddta |error prompt out, stop my update data at this line
tdsls304.sqnb = sqnb |error prompt out, stop my update data at this line
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
ret2 = seq.close(input.fp)
endif
}
tracylee
29th July 2015, 08:20
Hi,
I am assuming you are using CSV file to read and have proper permissions on this file. You can try this -
if fp >= 0 then
seq.rewind(fp)
while not seq.eof(fp)
data.str = ""
ret1 = seq.gets(data.str,2048,fp)
|** Do things
endwhile
endif
This will make sure, your pointer is set to the first position prior to start reading.
Hi, Thanks for your information. Now i facing to update data into table. My coding as the above. Please help. Thanks.
bhushanchanda
29th July 2015, 08:55
Hi,
The way you are importing date is not right. The best way to import date is by string with a format like e.g. MM/DD/YYYY. Also, is your sqnb field a string field?
I am assuming it to be a number.
There are some other mistakes -
If your scanned field is a number you need to provide %d but I see some fields like qoor, posi,lcmp are having %s. So, the problem is not with only the date field but most of the fields.
Here's a modified one. You might need to make some changes.
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand | Baan API Handler
#include <bic_dam>
#pragma used dll "ottdllbw"
table ttdsls304 | Sales Contract Delivery Lines
extern domain tccono cono, txlee123.cono
extern domain tcpono pono, txlee123.pono
extern domain tccwoc cofc
extern domain tcdate ddta
extern domain tcmcs.str15 date_string
extern domain tcpono sqnb
extern domain tcqrd3 qoor
extern domain tcorno orno
extern domain tcpono posi
extern domain tcncmp lcmp
extern domain tcmcs.str30m rev
|***************************** FUnction *******************
Functions:
function extern import.request()
{
string local.path(1024)
long ret1, count, ret2, input.fp
string filename(200),filename2(200)
string curr.line(2048)
string dat_year_string(4), dat_month_string(2), dat_day_string(2)
long dat_yearno, dat_monthno, dat_dayno, no_of_dat
string date_in(20) |#B.sn
domain tcdate date_out |#B.en
ret1 = 0
filename2 = "${BSE}/tmp/Delivery Scheme.csv"
ret2 = client2server("", filename2, false, false,true)
input.fp = seq.open(strip$(filename2),"rt")
if input.fp < 1 then
message("File Cannot be imported.")
return
else
seq.rewind(fp) |#B.n
while ret1 = 0
curr.line = "" |#B.n
ret1 = seq.gets(curr.line, 2048, input.fp)
string.scan(curr.line, "%s,%d,%s,%s,%d,%d,%s,%d,%d", cono, pono, cofc, date_in, sqnb, qoor, orno, posi, lcmp) |#B.sn
string.scan(date_in,"%d/%d/%d",dat_monthno,dat_dayno,dat_yearno) |#B.en
cono = strip$(cono)
| pono = pono |#B.o
cofc = strip$(cofc)
| ddta = ddta |#B.so
| date_string = str$(ddta)
| dat_year_string = date_string(1;4)
| dat_month_string = date_string(5;2)
| dat_day_string = date_string(7;2)
| dat_yearno = lval(dat_year_string)
| dat_monthno = lval(dat_month_string)
| dat_dayno = lval(dat_day_string) |#B.eo
date_out = date.to.utc(dat_yearno, dat_monthno, dat_dayno, 00, 00, 00) |#B.n
| sqnb = str$(sqnb) |#B.n
| qoor = val(qoor) |#B.o
orno = strip$(orno)
posi = posi
lcmp = lcmp
select tdsls304.*
from tdsls304 for update
where tdsls304.cono = :txlee123.cono and tdsls304.pono = :txlee123.pono
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = no_of_dat
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = ddta |error prompt out, stop my update data at this line
tdsls304.sqnb = sqnb |error prompt out, stop my update data at this line
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
ret2 = seq.close(input.fp)
endif
}
tracylee
29th July 2015, 10:26
Hi,
The way you are importing date is not right. The best way to import date is by string with a format like e.g. MM/DD/YYYY. Also, is your sqnb field a string field?
I am assuming it to be a number.
There are some other mistakes -
If your scanned field is a number you need to provide %d but I see some fields like qoor, posi,lcmp are having %s. So, the problem is not with only the date field but most of the fields.
Here's a modified one. You might need to make some changes.
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand | Baan API Handler
#include <bic_dam>
#pragma used dll "ottdllbw"
table ttdsls304 | Sales Contract Delivery Lines
extern domain tccono cono, txlee123.cono
extern domain tcpono pono, txlee123.pono
extern domain tccwoc cofc
extern domain tcdate ddta
extern domain tcmcs.str15 date_string
extern domain tcpono sqnb
extern domain tcqrd3 qoor
extern domain tcorno orno
extern domain tcpono posi
extern domain tcncmp lcmp
extern domain tcmcs.str30m rev
|***************************** FUnction *******************
Functions:
function extern import.request()
{
string local.path(1024)
long ret1, count, ret2, input.fp
string filename(200),filename2(200)
string curr.line(2048)
string dat_year_string(4), dat_month_string(2), dat_day_string(2)
long dat_yearno, dat_monthno, dat_dayno, no_of_dat
string date_in(20) |#B.sn
domain tcdate date_out |#B.en
ret1 = 0
filename2 = "${BSE}/tmp/Delivery Scheme.csv"
ret2 = client2server("", filename2, false, false,true)
input.fp = seq.open(strip$(filename2),"rt")
if input.fp < 1 then
message("File Cannot be imported.")
return
else
seq.rewind(fp) |#B.n
while ret1 = 0
curr.line = "" |#B.n
ret1 = seq.gets(curr.line, 2048, input.fp)
string.scan(curr.line, "%s,%d,%s,%s,%d,%d,%s,%d,%d", cono, pono, cofc, date_in, sqnb, qoor, orno, posi, lcmp) |#B.sn
string.scan(date_in,"%d/%d/%d",dat_monthno,dat_dayno,dat_yearno) |#B.en
cono = strip$(cono)
| pono = pono |#B.o
cofc = strip$(cofc)
| ddta = ddta |#B.so
| date_string = str$(ddta)
| dat_year_string = date_string(1;4)
| dat_month_string = date_string(5;2)
| dat_day_string = date_string(7;2)
| dat_yearno = lval(dat_year_string)
| dat_monthno = lval(dat_month_string)
| dat_dayno = lval(dat_day_string) |#B.eo
date_out = date.to.utc(dat_yearno, dat_monthno, dat_dayno, 00, 00, 00) |#B.n
| sqnb = str$(sqnb) |#B.n
| qoor = val(qoor) |#B.o
orno = strip$(orno)
posi = posi
lcmp = lcmp
select tdsls304.*
from tdsls304 for update
where tdsls304.cono = :txlee123.cono and tdsls304.pono = :txlee123.pono
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = no_of_dat
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = ddta |error prompt out, stop my update data at this line
tdsls304.sqnb = sqnb |error prompt out, stop my update data at this line
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
ret2 = seq.close(input.fp)
endif
}
Hi, thanks for your reply. But still cannot be work. Actually my date of file data is yyyymmdd. But in the table field of date is tcdate (Data Type = UTC Date/Time). So, i convert it to like that. As i know the domain must be same only can update/insert it right? Nope, my sqnb is a numeric (integer).
My File Format:
PPC000001,10,SLPN,20120605,1,1296,,0,0
PPC000001,10,SLPN,20150131,2,200,,0,0
PPC000001,10,SLPN,20150228,3,300,,0,0
Field 1 (cono) - string
Field 2 (pono) - int
Field 3 (cofc) - string
Field 4 (ddta) - date
Field 5 (sqnb) - int
Field 6 (qoor) - double
Filed 7 (orno) - string
Field 8 (posi) - int
Field 9 (lcmp) - int
Please Advise. Thanks.
bhushanchanda
29th July 2015, 11:13
Hi,
You should not declare ddta as tcdate. It can be a string. Then, you can take the year, month and day out of it using your existing logic. And then use date.to.utc() as you are doing.
But, I can see, while updating you are using
tdsls304.ddta = no_of_dat
which is correct
but in selectempty you have
tdsls304.ddta = ddta
Which is wrong. I will suggest you to go through the changes I have made and do the corrections in your program. Debugging the program line by line is the best way to troubleshoot.
tracylee
29th July 2015, 12:49
Hi,
You should not declare ddta as tcdate. It can be a string. Then, you can take the year, month and day out of it using your existing logic. And then use date.to.utc() as you are doing.
But, I can see, while updating you are using
tdsls304.ddta = no_of_dat
which is correct
but in selectempty you have
tdsls304.ddta = ddta
Which is wrong. I will suggest you to go through the changes I have made and do the corrections in your program. Debugging the program line by line is the best way to troubleshoot.
Hi, thanks for your reply. I already change my coding as below. My file date format already change to mm/dd/yyyy, so for string.scan(date_in,"%d/%d/%d", dat_monthno, dat_dayno, dat_yearno) can work properly. I put a message shown the month,day,year are corretly but when run to update table that time then error prompt to stop. Is it still have any coding i written incorrectly? Below is my coding. Please advise. Thanks.
|******************************************************************************
|****************************** declaration section ***************************
declaration:
#pragma used dll ottstpapihand | Baan API Handler
#include <bic_dam>
#pragma used dll "ottdllbw"
table ttdsls304 | Sales Contract Delivery Lines
extern domain tccono cono, txlee123.cono
extern domain tcpono pono, txlee123.pono
extern domain tccwoc cofc
extern domain tcdate ddta
extern domain tcmcs.str15 date_string
extern domain tcpono sqnb
extern domain tcqrd3 qoor
extern domain tcorno orno
extern domain tcpono posi
extern domain tcncmp lcmp
extern domain tcmcs.str30m rev
|***************************** Function *******************
Functions:
function extern import.request()
{
string local.path(1024)
long ret1, count, ret2, input.fp
string filename(200),filename2(200)
string curr.line(2048)
string dat_year_string(4), dat_month_string(2), dat_day_string(2)
long dat_yearno, dat_monthno, dat_dayno, no_of_dat
string date_in(20)
domain tcdate date_out
ret1 = 0
filename2 = "${BSE}/dump/Delivery Scheme.csv"
ret2 = client2server("", filename2, false, false,true)
input.fp = seq.open(strip$(filename2),"rt")
if input.fp < 1 then
message("File Cannot be imported.")
return
else
seq.rewind(input.fp)
while ret1 = 0
|curr.line = "" |Pipe this line due to when run the session prompt error message
ret1 = seq.gets(curr.line, 2048, input.fp)
string.scan(curr.line, "%s,%d,%s,%s,%d,%d,%s,%d,%d", cono, pono, cofc, date_in, sqnb, qoor, orno, posi, lcmp)
string.scan(date_in,"%d/%d/%d", dat_monthno, dat_dayno, dat_yearno)
cono = strip$(cono)
pono = pono
cofc = strip$(cofc)
date_out = date.to.utc(dat_yearno, dat_monthno, dat_dayno, 00, 00, 00)
sqnb = sqnb
qoor = qoor
orno = strip$(orno)
posi = posi
lcmp = lcmp
message("dat_yearno: %s", dat_yearno) |can shown correct year Eg:2012
message("dat_monthno: %s", dat_monthno) |can shown correct month Eg:6
message("dat_dayno: %s", dat_dayno) |can shown correct day Eg:5
message("date_out: %s", date_out) |can shown data Eg:1338825600
select tdsls304.*
from tdsls304 for update
where tdsls304.cono = :txlee123.cono and tdsls304.pono = :txlee123.pono
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out |run until here then prompt error to stop
|tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out
|tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry)
endselect
count = count + 1
if count >= 250 then
count = 0
commit.transaction()
endif
endwhile
if count > 0 then
commit.transaction()
endif
ret2 = seq.close(input.fp)
endif
}
bhushanchanda
29th July 2015, 12:58
Hi,
The code seems alright now. What is the error shown?
tracylee
30th July 2015, 04:08
Hi,
The code seems alright now. What is the error shown?
Hi,
The error shown as below.
1: process 40 - Fatal error : Error 100 (Duplicate value) on tdsls304999 (No retry point specified)
2: process 40 - Fatal error : Can not continue in txlee3123m000 (import.request)[sql.exec]
3: process 40 - Error : txlee3123m000: A not terminated transaction is aborted (import.request() in object otxlee3123m000)
Noted: txlee3123m000 is customize session to import data to tdsls304 table.
Please advise. Thanks.
tracylee
30th July 2015, 08:09
Hi,
The code seems alright now. What is the error shown?
Hi,
Problem solved. I used another method to solved this problem, i think prompt this error is because the sqnb field and cannot be update the old data. So, i direct delete all the old data of the table and import the data file into table. It can be import/insert. Thanks for your help and information. At here i learn a lots. Thank you so much. :)
bhushanchanda
30th July 2015, 08:18
Glad it worked for you. But, instead of deleting I will suggest to check the record exists based on the imported data. Also, you can skip duplicates using db.skip.dupl inside your db.insert().
So, you main selection should be like this -
select tdsls304.*
from tdsls304 for update
where tdsls304._index3 = {:cono,:pono,:cofc,sqnb}
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out |run until here then prompt error to stop
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry,db.skip.dupl)
endselect
tracylee
30th July 2015, 09:59
Glad it worked for you. But, instead of deleting I will suggest to check the record exists based on the imported data. Also, you can skip duplicates using db.skip.dupl inside your db.insert().
So, you main selection should be like this -
select tdsls304.*
from tdsls304 for update
where tdsls304._index3 = {:cono,:pono,:cofc,sqnb}
selectdo
|message("A")
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out |run until here then prompt error to stop
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.update(ttdsls304, db.retry)
selectempty
message("B")
db.set.to.default(ttdsls304)
tdsls304.cono = cono
tdsls304.pono = pono
tdsls304.cofc = cofc
tdsls304.ddta = date_out
tdsls304.sqnb = sqnb
tdsls304.qoor = qoor
tdsls304.orno = orno
tdsls304.posi = posi
tdsls304.lcmp = lcmp
db.insert(ttdsls304, db.retry,db.skip.dupl)
endselect
Hi, thanks for your suggestion. I will try it. Thanks for your help. :)