monica1
15th July 2011, 15:11
I have a new multi ocurrence screen. This screen has a table fields and a new program variable.
I want that this new program variable changes a new table related with the main table will be changed.
The problem is when there is more than one record changed in all the records appears the same valor of the program variable.
How can I do that?
|****************************** DECLARATION SECTION ***************************
declaration:
table ttcmcs031 | Sectores
table tcasap124 | Sector - Actividad cliente - Actividad obra
table tcasap104 | Actividad cliente
table tcasap114 | Actividad obra
extern domain tcmcs.str2 actc fixed
extern domain tcmcs.str2 acto fixed
domain tcmcs.long i
main.table.io:
before.write:
for i = 1 to filled.occ
do.occ(i, modificar)
endfor
before.rewrite:
for i = 1 to filled.occ
do.occ(i, modificar)
endfor
before.delete:
for i = 1 to filled.occ
if mark.table(i) then
do.occ(i, borrar)
endif
endfor
|****************************** FUNCTION SECTION ***************************
functions:
function borrar()
{
select casap124.*
from casap124 for update
where casap124._index1 = {:tcmcs031.cbrn}
selectdo
db.delete(tcasap124, db.retry)
endselect
}
function modificar()
{
select casap124.*
from casap124 for update
where casap124._index1 = {:tcmcs031.cbrn}
selectdo
casap124.actc = actc
casap124.acto = acto
db.update(tcasap124, db.retry)
selectempty
casap124.cbrn = tcmcs031.cbrn
casap124.actc = actc
casap124.acto = acto
db.insert(tcasap124, db.retry)
endselect
}
I want that this new program variable changes a new table related with the main table will be changed.
The problem is when there is more than one record changed in all the records appears the same valor of the program variable.
How can I do that?
|****************************** DECLARATION SECTION ***************************
declaration:
table ttcmcs031 | Sectores
table tcasap124 | Sector - Actividad cliente - Actividad obra
table tcasap104 | Actividad cliente
table tcasap114 | Actividad obra
extern domain tcmcs.str2 actc fixed
extern domain tcmcs.str2 acto fixed
domain tcmcs.long i
main.table.io:
before.write:
for i = 1 to filled.occ
do.occ(i, modificar)
endfor
before.rewrite:
for i = 1 to filled.occ
do.occ(i, modificar)
endfor
before.delete:
for i = 1 to filled.occ
if mark.table(i) then
do.occ(i, borrar)
endif
endfor
|****************************** FUNCTION SECTION ***************************
functions:
function borrar()
{
select casap124.*
from casap124 for update
where casap124._index1 = {:tcmcs031.cbrn}
selectdo
db.delete(tcasap124, db.retry)
endselect
}
function modificar()
{
select casap124.*
from casap124 for update
where casap124._index1 = {:tcmcs031.cbrn}
selectdo
casap124.actc = actc
casap124.acto = acto
db.update(tcasap124, db.retry)
selectempty
casap124.cbrn = tcmcs031.cbrn
casap124.actc = actc
casap124.acto = acto
db.insert(tcasap124, db.retry)
endselect
}