dorleta
11th July 2006, 18:12
When baan is running a report, the report is saved in a tmp file, this tmp file is sent to the device when the report is closed.
This solution is based in the modification of this tmp file before is sent to the device. In a first step I count the times that the "tag" "Página" (Spanish version" ) appear. (It is posible avoid this step exporting the total pages from the report script) and after rewrite this tmp file adding the total pages.
It´s a primitive solution but works fine.
In the program script :
choice.print.data:
on.choice:
if open.report(1,"",1) then
read.mcs010.leq()
paginar()
close.reports()
else
choice.again()
endif
and the function ( one include maybe a smart solution)
function paginar()
{
table tttaad320
#define RECORD.LENGHT 2000
long fichero
| string carro(10)
#define NEW.PAGE.ID "Página"
long mipag
domain tcmcs.str100 file.name, file.tmp.str
long file, file.tmp, ret , car
string record(RECORD.LENGHT)
| carro = ff$()
| mipag = lattr.pageno
mipag = 0
seq.close(g.lfn)
file.name = g.tmp.file
| ** contar el número de páginas tb podría obtenerse exportando desde listado
file = seq.open( file.name, "r")
seq.gets( record, RECORD.LENGHT, file)
while not seq.eof(file)
car = rpos( record, NEW.PAGE.ID )
if car then
mipag = mipag + 1
endif
seq.gets( record, RECORD.LENGHT, file)
endwhile
seq.close(file)
| **
file.tmp.str = creat.tmp.file$(bse.tmp.dir$() )
file = seq.open( file.name, "r")
file.tmp = seq.open(file.tmp.str, "w")
seq.gets( record, RECORD.LENGHT, file)
while not seq.eof(file)
car = rpos( record, "Página")
if car then
record = record & cf$(1) & " de " & str$(mipag) & cf$(0)
endif
seq.puts( record, file.tmp)
record = ""
seq.gets( record, RECORD.LENGHT, file)
endwhile
seq.puts( record, file.tmp)
seq.close(file)
seq.close(file.tmp)
ret = file.cp(file.tmp.str, file.name)
}
This solution is based in the modification of this tmp file before is sent to the device. In a first step I count the times that the "tag" "Página" (Spanish version" ) appear. (It is posible avoid this step exporting the total pages from the report script) and after rewrite this tmp file adding the total pages.
It´s a primitive solution but works fine.
In the program script :
choice.print.data:
on.choice:
if open.report(1,"",1) then
read.mcs010.leq()
paginar()
close.reports()
else
choice.again()
endif
and the function ( one include maybe a smart solution)
function paginar()
{
table tttaad320
#define RECORD.LENGHT 2000
long fichero
| string carro(10)
#define NEW.PAGE.ID "Página"
long mipag
domain tcmcs.str100 file.name, file.tmp.str
long file, file.tmp, ret , car
string record(RECORD.LENGHT)
| carro = ff$()
| mipag = lattr.pageno
mipag = 0
seq.close(g.lfn)
file.name = g.tmp.file
| ** contar el número de páginas tb podría obtenerse exportando desde listado
file = seq.open( file.name, "r")
seq.gets( record, RECORD.LENGHT, file)
while not seq.eof(file)
car = rpos( record, NEW.PAGE.ID )
if car then
mipag = mipag + 1
endif
seq.gets( record, RECORD.LENGHT, file)
endwhile
seq.close(file)
| **
file.tmp.str = creat.tmp.file$(bse.tmp.dir$() )
file = seq.open( file.name, "r")
file.tmp = seq.open(file.tmp.str, "w")
seq.gets( record, RECORD.LENGHT, file)
while not seq.eof(file)
car = rpos( record, "Página")
if car then
record = record & cf$(1) & " de " & str$(mipag) & cf$(0)
endif
seq.puts( record, file.tmp)
record = ""
seq.gets( record, RECORD.LENGHT, file)
endwhile
seq.puts( record, file.tmp)
seq.close(file)
seq.close(file.tmp)
ret = file.cp(file.tmp.str, file.name)
}