richard
31st May 2006, 15:02
Hello,

We made a session to print which job session is printed on a specific device or device list.
We have some printers with more than one hundred outputs, so it's easy for the user or administrator to see all sessions in one shot.
ttaad5400 gives also the information but not summarized.

|******************************************************************************
|* tcsss5400_940 0 VRC B40O c4 prod
|* Liste des job liés à une imprimante donnée
|* guth
|* 17/05/06 [10:35]
|******************************************************************************
|* Script Type: 4
|******************************************************************************

|****************************** DECLARATION SECTION ***************************
declaration:

table tttaad501 |-- Session par job --
table tttaad503 |-- Var entrée par job --
table tttaad510 |-- Historique Job
table tttaad511 |-- Détails historique job
table tttadv380 |-- Query

extern domain tcedi.prnt dev.f, dev.t
extern domain tcyesno uniq.histo
extern domain tcyesno incl.inact
extern domain tcncmp societe
extern domain tcmcs.st13 sess.query
extern domain tcmcs.str60 desc.s.q
domain tcedi.prnt max.z
long sig.eg

|****************************** PROGRAM SECTION ***************************
before.program:
max.z = string.set$("~", 50)
|****************************** ZOOM FROM SECTION ***************************
|****************************** FORM SECTION **************************
form.1:
init.form:
get.screen.defaults()

|****************************** CHOICE SECTION ***************************
choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
liste()
rprt_close()
else
message("Traitement abandonné !")
choice.again()
endif
|****************************** FIELD SECTION ***************************
field.dev.f:
when.field.changes:
dev.t = spes(dev.f) & max.z

field.uniq.histo:
check.input:
if uniq.histo = empty then
message("Saisie obligatoire !")
set.input.error("")
endif

field.incl.inact:
check.input:
if incl.inact = empty then
message("Saisie obligatoire !")
set.input.error("")
endif

|****************************** MAIN TABLE SECTION ***************************
|****************************** FUNCTION SECTION ***************************
functions:

function domain tcmcs.str100 spes(domain tcmcs.str100 entrant)
{
return( strip$(shiftl$(entrant)) )
}

function liste()
{
societe = get.compnr()

select ttaad501.cjob, ttaad501.cpac, ttaad501.cmod, ttaad501.cses,
ttaad501.devc, ttaad501.acti, ttaad500.desc
from ttaad501, ttaad500
where ttaad501.devc inrange :dev.f and :dev.t
and ttaad501.cjob refers to ttaad500
selectdo
if incl.inact = tcyesno.no and ttaad501.acti <> ttyeno.yes then
continue
endif
sess.query = ttaad501.cpac & ttaad501.cmod & ttaad501.cses
tt.session.desc(sess.query, desc.s.q)
remonte.dernier.histo.job(compnr)
endselect


if societe = 0 then
return
endif
societe = 000

select ttaad501.cjob, ttaad501.cpac, ttaad501.cmod, ttaad501.cses,
ttaad501.devc, ttaad501.acti, ttaad501.seri, ttaad500.desc
from ttaad501, ttaad500
where ttaad501.devc inrange :dev.f and :dev.t
and ttaad501.cjob refers to ttaad500
and ttaad500._compnr = 000
and ttaad501._compnr = 000
selectdo
if incl.inact = tcyesno.no and ttaad501.acti <> ttyeno.yes then
continue
endif
sess.query = ttaad501.cpac & ttaad501.cmod & ttaad501.cses
tt.session.desc(sess.query, desc.s.q)
if ttaad501.cpac = "tt" and
ttaad501.cmod = "adv" and
ttaad501.cses = "3180m000" then
select ttaad503.rcrd
from ttaad503
where ttaad503._index1 = {:ttaad501.cjob, :ttaad501.seri}
and ttaad503._compnr = 000
as set with 1 rows
selectdo
sig.eg = pos(ttaad503.rcrd, "=")
sess.query = ttaad503.rcrd((sig.eg + 2); 9)
select ttadv380.cqur,
ttadv380.desc
from ttadv380
where ttadv380._index1 = {:sess.query}
and ttadv380._compnr = 000
selectdo
sess.query = "Q: " & spes(ttadv380.cqur)
desc.s.q = ttadv380.desc
selectempty
endselect
endselect
endif
remonte.dernier.histo.job(000)
endselect
}

function remonte.dernier.histo.job(domain tcncmp soc)
{
if soc = 0 then
select ttaad511.cjob, ttaad511.edte, ttaad511.stim,
ttaad511.sdts, ttaad511.stis,
ttaad511.rerr
from ttaad511
where ttaad511._index1 = {:ttaad501.cjob}
and ttaad511.cpac = :ttaad501.cpac
and ttaad511.cmod = :ttaad501.cmod
and ttaad511.cses = :ttaad501.cses
and ttaad511._compnr = 000
order by ttaad511.cjob, ttaad511.edte desc, ttaad511.stim desc
as set with 1 rows
selectdo
rprt_send()
selectempty
if uniq.histo = tcyesno.no then
ttaad511.edte = 0
ttaad511.sdts = 0
ttaad511.stim = 0
ttaad511.stis = 0
ttaad511.rerr = empty
rprt_send()
endif
endselect
else
select ttaad511.cjob, ttaad511.edte, ttaad511.stim,
ttaad511.sdts, ttaad511.stis,
ttaad511.rerr
from ttaad511
where ttaad511._index1 = {:ttaad501.cjob}
and ttaad511.cpac = :ttaad501.cpac
and ttaad511.cmod = :ttaad501.cmod
and ttaad511.cses = :ttaad501.cses
order by ttaad511.cjob, ttaad511.edte desc, ttaad511.stim desc
as set with 1 rows
selectdo
rprt_send()
selectempty
if uniq.histo = tcyesno.no then
ttaad511.edte = 0
ttaad511.sdts = 0
ttaad511.stim = 0
ttaad511.stis = 0
ttaad511.rerr = empty
rprt_send()
endif
endselect
endif
}


regards