adi28_rai
21st October 2010, 12:03
why AFS is not used with MMTsession ??

MilindV
21st October 2010, 14:42
Hi,

Why you want to use AFS for MMT session?
If you are working with MMT. It means you have DAL as well.
So why not use DAL/DAL2 functions instead??

May be you can give more details for your requirement...
Which can justify your question...

Regards,
MilindV

adi28_rai
22nd October 2010, 07:44
I just wanted to know the reason for it ....thnks nyways for bothering abt it.
hey cn u tell me how i can count the total no of lines in the detail section of my report actually i want to print a report of type 2 with the page no in form of Mof N eg 1of 4

MilindV
22nd October 2010, 08:42
Assumption: That your report has single header layout, single footer layout.

Let 'X' be No of lines available for printing detail layout:
'X' can be calculated as follows.
X = spool.pg.length - No of lines in Header Layout - No of line in Footer Layout - r.bottom.mrg - r.top.mrg

Where r.bottom.mrg and r.top.mrg are report variable which gives you the top and bottom margin of the report.

Let 'Y' be no of lines in detail layout: (Y = 1 can be a best case.)
Then no of lines than can be printed in detail layout with in a page = X / Y.

Finding out total no of pages in advance that will get printed in report is a thing to think.

Regards,
MilindV

adi28_rai
22nd October 2010, 12:00
the no of pages that will be printed according to me can be known by using count in the select do.The value of count will be incremented every time a record in loop is encountered........

baan_guru
22nd October 2010, 13:35
Here is the code I developed which is working fine on BaaN IV c4
This code calculates number of pages depend on the occurrance of word "page" on report; you can use any other special word for the same.


Also process variable need to be declared in report script to get process id of report in program script so that we can kill unopened ttstpdisplay processes.


Declaration:
table ttaad320

extern domain tcmcs.str100 file.name

domain tcncmp ncmp
domain tcmcs.long brp_id, file, process
domain ttaad.user username



choice.print.data:
on.choice:
if rprt_open() then
|**********Start to get report data file name
select ttaad320.*
from ttaad320 for update
where ttaad320._index1 = {:1}
and ttaad320.comp = :2
and ttaad320.spac = :package e.g. "td"
and ttaad320.smod = :module e.g. "pur"
and ttaad320.sses = :session e.g. "4404m000"
and ttaad320.rpac = :package of report e.g. "td"
and ttaad320.rmod = :module of report e.g. "pur"
and ttaad320.repc = :report e.g. "440411000"
and ttaad320.rdte = :spool.date
and ttaad320.stat = 7
and ttaad320._compnr = 0
order by ttaad320._index1 desc
as set with 1 rows
wherebind(1, logname$)
wherebind(2, get.compnr())
selectdo
file = ttaad320.tlfn
ttaad320.tmpf = creat.tmp.file$(bse.tmp.dir$())
ttaad320.tlfn = seq.open(ttaad320.tmpf, "w")
| ttaad320.tlfn = 0
file.name = ttaad320.tmpf
db.update(tttaad320, db.retry)
commit.transaction()
endselect
|**********End to get report data file name

import("process", process) |This is process id of report need to be define in report script separately.


send.data.to.report()


rprt_close()

string prgname(512)
long info(PSMAXSIZE)
process = process - 1 |Since process id of device is previous to that of report.
pstat(process, prgname, info)
if prgname = "ttstpdisplay " then
if ps.group(info) = Process then
kill(process)
endif
endif
seq.close(ttaad320.tlfn)
seq.close(file)
brp_id = brp.open(spool.report, spool.device , 0)
get.page()
brp.close(brp_id)
else
choice.again()
endif


functions:


function get.page()
{
long tot.page
domain tcmcs.str100 file.tmp.str
long file.tmp, ret
string record(2048), command(2048)


|************Start page count.
tot.page = 0
file = seq.open( file.name, "r")
ret = seq.gets( record, 2048, file)
while not seq.eof(file)
ret = rpos( record, "Page" )
if ret then
tot.page = tot.page + 1
endif
seq.gets( record, 2048, file)
endwhile
seq.close(file)
|***********End page Count


|*************Start modify report file
file.tmp.str = creat.tmp.file$(bse.tmp.dir$())
file.tmp = seq.open(file.tmp.str, "w") |Open new file in write mode
file = seq.open( file.name, "r") |Open file containing report data in read mode
ret = seq.gets( record, 2048, file)
while not seq.eof(file)
ret = rpos( record, "Page")
if ret then
record = record & cf$(1) & " of " & str$(tot.page) & cf$(0)
endif |this will append "of y" at the end of "page x" making it "page x of y" for every occurence of page word in report file.
seq.puts( record, file.tmp)
record = ""
seq.gets( record, 2048, file)
endwhile
seq.puts( record, file.tmp)
seq.close(file)
seq.close(file.tmp)
ret = file.cp(file.tmp.str, file.name)
|**************End modify report file

select ttaad320.*
where ttaad320._index1 = {:1}
and ttaad320.comp = :2
and ttaad320.spac = :package e.g. "td"
and ttaad320.smod = :module e.g. "pur"
and ttaad320.sses = :session e.g. "4404m000"
and ttaad320.rpac = :package of report e.g. "td"
and ttaad320.rmod = :module of report e.g. "pur"
and ttaad320.repc = :report e.g. "440411000"
and ttaad320.rdte = :spool.date
and ttaad320.stat = 7
and ttaad320._compnr = 0
order by ttaad320._index1 desc
as set with 1 rows
wherebind(1, logname$)
wherebind(2, get.compnr())
selectdo
file.cp(file.name, ttaad320.tmpf)
endselect
seq.close(ttaad320.tlfn)
}

mark_h
22nd October 2010, 15:40
I just wanted to know the reason for it ....thnks nyways for bothering abt it.
hey cn u tell me how i can count the total no of lines in the detail section of my report actually i want to print a report of type 2 with the page no in form of Mof N eg 1of 4

There is one example in this post and I believe there are more examples posted in the code and utilities forum.

My recommendation - if possible talk the user out of doing this. I have never seen a good solution. Just my personal opinion.