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)

}

günther
13th July 2006, 15:04
Dorleta,

you've done a great job! I just got it to work on my system and it looks good.

I had to do the following changes:
1. Changed your #define NEW.PAGE.ID into german (...)
2. Changed the spanish string inside the second while-seq.gets-loop into the #define
3. added a seq.unlink(file.tmp.str) at the end of the function to remove the 2nd temp file

And while using the debugger and output to "DL" and "D", I deteced that directly to seq.close(g.lfn) the output got display with ttstpdisplay. So:
4. changed seq.close(g.lfn) into seq.flush(g.lfn)

What remains open:
* The added "of y" ("de y") is always on the right side of the line containing "page ...".
* The Label is hard-coded via a #define. That might become a problem within sessions that switch the language e.g. based on the customer's language.

But that is all for now. Thanks a lot!

Günther

günther
13th July 2006, 15:50
And here comes my problem: When I set one of the report input fields to Ascending or Descending, the report uses a second temp file for sorting. In that case g.lfn seems to behave different and page x of y does not work.

Any ideas?

Günther

raikar_raviraj
30th September 2006, 14:53
hi,

I had compiled the code which you had sent.. it gave some errors.. but actually when i ran the report.. it didnt show up any data.

i used the function as it is i.e panigar

The warnings that it gives are
return value of function seq.close ignored
return value of function seq.ret ignored
...
..

can u please help me solve this query

Regards

Raviraj

pralash
20th February 2018, 13:05
Can you please explain, which one is added to the header layout instead of special variable "page" for getting the page number as Page 1 of 5.... etc
Thanks in advance,
Pralash