dromeo
3rd November 2017, 17:52
Hello,
I'm trying to compare Items on a report script, on a before.field, to retrieve the same items, and then if they are equal and have a negative planned qty and positive planned qty (so, planned requirement and planned receipt) on the same Item put a flag, that can be a string (Yes).
I'm having doubts on which could be the best an practical way to achieve this. If by using a for --> ex.
for i = 1 to n??
if whinp100.item = item AND whinp100.kotr = tckotr.requirement AND
whinp100.kotr = tckotr.receipt then
test = "Yes"
else
test = "No"
endif
endfor
or with a Do-While, but I don't know if with Baan Language I could use this type of condition.
To take into account that the items are sorted ascending, so the same Items appear in a block.
Thank you for any advice or help!! :)
mark_h
6th November 2017, 14:28
Is this a report script or a session script? In a report script it will read each record from a file - so you have to track somethings yourself. To see what happens in a report script just put one in debug mode and step thru it watching it print..
dromeo
6th November 2017, 16:27
Is this a report script or a session script? In a report script it will read each record from a file - so you have to track somethings yourself. To see what happens in a report script just put one in debug mode and step thru it watching it print..
Hello Mark!
Thank you very much for your reply! Very appreciated as always!
It's a report script! I didn't really understood when you say --> "so you have to track somethings yourself !??!"
I will follow your advice anyway to see what's happen in debug mode, although it can be a little complicated because the extraction output of the report it's a little bit large to track 1 by 1. Maybe 200 records.
Thank you :)
Daniel Romeo
mark_h
6th November 2017, 18:15
If this is in a report script then the records will be read one at a time - and for example probably printed in the detail layout. So as the first record gets printed in the layout you would need to track the item number and information you want. A better option might be to just read the input file yourself and add information to the file. I have to find the thread that shows that. So let me look for that thread for you to look at.
mark_h
6th November 2017, 18:21
Here are a couple of threads http://www.baanboard.com/baanboard/showthread.php?threadid=9090 and http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1908 - both offer options to working in the report script itself and the type of things you could do. Neither are options for the feint of heart. It takes some work.
For something like this I would rather work in the session script, but that is not always an option.
dromeo
6th November 2017, 23:40
Here are a couple of threads http://www.baanboard.com/baanboard/showthread.php?threadid=9090 and http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1908 - both offer options to working in the report script itself and the type of things you could do. Neither are options for the feint of heart. It takes some work.
For something like this I would rather work in the session script, but that is not always an option.
Hello Mark!
Thanks for the reply!
I think that you're right! Using the .tmp file seems like a better idea instead. So having the data already in the output and do the reading of the file with all the items already there.
But I do have some doubts regarding the script that you wrote on the thread you linked to me --> http://www.baanboard.com/baanboard/showthread.php?s=&threadid=1908
after.receive.data:
if(first=0) then
r.o = seq.open (r.datafile$ & ".tmp","w")
r.reccount = 0
while e = 0
select tipgc001.cplb
from tipgc001
where tipgc001._index1 = {:tisfc001.ccot.a,
:tisfc001.mitm}
selectdo
endselect
l = seq.puts(concat$("",
tipgc001.cplb,
tisfc001.pdno,
tisfc001.ccot.a,
tisfc001.mitm,
error.message,r.reccount),r.o)
r.reccount = r.reccount + 1
r.read.seq.file()
endwhile
l = seq.flush (r.o)
l = seq.close (r.lfn)
l = seq.close (r.o)
l = run.baan.prog( "sort","-t +0n
-1 +1n -2 " & r.datafile$ & ".tmp -o " &
r.datafile$ & ".tmp", RP_WAIT)
r.lfn = seq.open (r.datafile$ & ".tmp" ,"a+")
r.read.seq.file()
first = 1
endif
after.program:
l = seq.unlink(r.datafile$ & ".tmp")
Could I use: after.report instead??? which will be the difference???
I don't understand some of the functions, and if they are usable with Infor 10.4. ???
l = seq.flush (r.o) --> honestly I don't know what this function does. I can guess by the name "flush" but still....
l = run.baan.prog( "sort","-t +0n
-1 +1n -2 " & r.datafile$ & ".tmp -o " &
r.datafile$ & ".tmp", RP_WAIT)
--> I could use this code as it is?
l = seq.unlink(r.datafile$ & ".tmp") ??
Do you have maybe a tutorial link to understand the meaning of these functions? So I can study them and then apply them. This is the first time that I have to do a file manipulation of a .tmp
You are right, working directly from the session script would be better, but this is a session that I can't customize.
Thank you very much!!!
Daniel Romeo
mark_h
7th November 2017, 17:00
In my case I do not have source code and we wanted another field on the report that was not selected in the session script. On top of that they wanted this new field to be a sort field. So what I am doing is adding a field into the report data using the report script. The seq.flush just causes any buffered data to be written to that file. The run.baan.prog is actually doing the sort on the data in the file to get it in the correct order before it starts reading and printing the data. So it basically opens a file with .tmp and writes the new records into that file. Then it sorts the .tmp file back into the original file name baan uses (r.datafile$). The seq.unlink just deletes the .tmp file.
I cannot guarantee this will work on your version of baan - plus we run on UNIX and it looks like you are on windows for an os. So not really sure how that works - the two threads are two different hacks that basically do the same thing. I think the thread by günther is actually a little cleaner. I have only ever used this on one session.