monica1
8th November 2007, 11:12
I need the total field of a report. There is any way to obtein it througth AFS?
I know how to print it, but I don“t know if it is possible.

Thank you for advance,

jp.aalders
8th November 2007, 13:38
Just a total? For usage in some other application or report? While printing the report you can write the neccesary information to a sequential file using seq.write/seq.put commands. Afterwards you can obtain the values needs from any report or application you like. The report itself can periodically run in a job or even executed from another session.

Good luck!

monica1
8th November 2007, 13:45
I write this code:

stpapi.put.field("cagldca009l04", "divisa", str$(i.ccur))
stpapi.put.field("cagldca009l04", "fecha.f", str$(date.to.num(i.year ,1, 1)))
stpapi.put.field("cagldca009l04", "fecha.t", str$(date.to.num(i.year + 1 ,1, 1) - 1))
stpapi.put.field("cagldca009l04", "bpid.f", i.bpid)
stpapi.put.field("cagldca009l04", "bpid.t", i.bpid)
stpapi.put.field("cagldca009l04", "cuenta.desde", i.leac)
stpapi.put.field("cagldca009l04", "cuenta.hasta", i.leac)
stpapi.put.field("cagldca009l04", "acreedores", str$(etol(tcyesno.yes)))
stpapi.put.field("cagldca009l04", "deudores", str$(etol(tcyesno.no)))
stpapi.put.field("cagldca009l04", spool.fileout, file.name)
stpapi.set.report("cagldca009l04", "rcagldca0094000", "ASCIF", err.msg)
if isspace(err.msg) then
stpapi.form.command("cagldca009l04", 5, "exec.cont.process", err.msg)
error.code = stpapi.get.mess.code("cagldca009l04",err.msg)
endif
stpapi.end.session("cagldca009l04")



and I want to obtein a field called saldo that it has created in the source of the report. How can I obtein this field?

mark_h
8th November 2007, 13:56
Actually what I do is run the report to disc and then read it back in using the seq.open, and seq.gets. In my case I now what fields to read . In your code you have stpapi.put.field("cagldca009l04", spool.fileout, file.name), all you need to typically do is spool.fileout = somedir & file.name. I say typically because sometimes spool.fileout will not get reset - probably a bug in baan on our version, but I have worked around it. Let me see if I can find a sample.

mark_h
8th November 2007, 14:06
Here is where I read a report back in:

function process.bom.file()
{
long file.in, num.level, some.seqn, i
string textbuff(255), dummy(32),read.item(32),read.net(32),read.stoc(32), read.level(8),
some.level(6), read.mbcs(4), read.ordr(32)

some.seqn = 1
file.in = seq.open(spool.fileout,"r")
while not seq.eof(file.in)
e = seq.gets(textbuff,255,file.in)
| Skip headings
if( textbuff(1;4) = "Date" or textbuff(1;4) ="----" or
textbuff(1;4) = "BaaN" or isspace(textbuff(1;4)) or
textbuff(1;4) = "Manu" or textbuff(1;4) = "Effe" or
textbuff(1;4) = "Revi" or textbuff(1;4) = " L" or
textbuff(1;4) = "Proj" or textbuff(1;4) = "MAX " or
textbuff(1;4) = "BAE ") then
continue
endif
|Item|Desc|Item Type|Planner|lead time|No units|Net quantity|gross qty|inv unit
rc = string.scan(textbuff,"%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s",
read.level, read.item, dummy, dummy,
read.mbcs, dummy, dummy, dummy, dummy, dummy,
read.net, read.stoc, read.ordr,dummy)

some.level = ""
for i = 1 to 8
if read.level(i;1) <> "." then
some.level = some.level & read.level(i;1)
|else
| break
endif
endfor
num.level = val(some.level)


if num.level = 1 then
track.level = 1
hold.level = 1
track.item(1,track.level) = tiudi017.mitm
else
if num.level > hold.level then
| Adding a new level
track.level = track.level + 1
track.item(1, track.level) = hold.item
else
| subtrack a level
if num.level < hold.level then
track.level = track.level - 1
endif
endif
endif
| Item for the level
hold.level = num.level
hold.item = read.item
tiudi018.assy = track.item(1, track.level)


tiudi018.lvel = num.level
tiudi018.mitm = tiudi017.mitm
tiudi018.seqn = some.seqn
tiudi018.item = read.item
tiudi018.qana = val(read.net)
tiudi018.stoc = val(read.stoc)
tiudi018.ordr = val(read.ordr)
tiudi018.mbcs = read.mbcs
db.insert(ttiudi018)
commit.transaction()
some.seqn = some.seqn + 1
endwhile
}

monica1
9th November 2007, 09:13
Thank you very much. I do it and it works fine.