Elrodyn
13th May 2009, 14:39
hello all,


i want to make a subtotal in report but i want to group it as variable i made in the script.

the example is:

the position number the variable(1st char of po.no) the qty
101 1 2
102 1 3
103 1 2
203 2 5

======================================================
i want to make it like this:

the position number the variable(1st char of po.no) the qty
101 1 2
102 1 3
103 1 2
-----------------------------------------------------------------------
totals : 7
203 2 5
-----------------------------------------------------------------------
totals : 5

the position number and the qty is already in the standart report.

i already put the variable as the input fields but i still can't group it, any tips i can use?

thanks

mark_h
13th May 2009, 15:44
In the session script just filter out the first character of position. Then send that to the report with each record and make the new field the sort. If necessary convert position to a string then get the first character.

Elrodyn
13th May 2009, 17:25
hello,


i already tried that with the po.no(1;1) ,stored it and use it as input fields.

but when i use the after field the report still doesn't group as one.

i don't think there's something wrong with the report script, the value are all correct.

i got the result like this the last time i tried:

the position number the variable(1st char of po.no) the qty
101 1 2
* 2
102 1 3
* 5
103 1 2
* 7
203 2 5
* 12

*=after field


:confused::confused::confused:

mark_h
13th May 2009, 22:18
Make sure the report is getting 1 character only for that position number. Make sure the primary or first sort is this field. Then make sure that the after.field is for this report field. This should work - I know I have done this a variety of ways.

shah_bs
14th May 2009, 00:26
So, let us call the fields as fieldA, fieldB, fieldC.

I will assume:
- all these fields are declared as EXTERN in the program script, or are fields of a table

Next, in Maintain Reports:
- in the Input Fields option, define sort for fieldB as Ascending Sort Seq 1 and define the sort for fieldA as Ascending Sort Seq 2

Next, in the Maintain Layouts
- define an After.Field layout for fieldB
- in the Edit Layout, add the column you want to sub-total and make sure it has the "Total" option set in the field definition

Next, still in Maintain Layouts
- add the After.Report layout
- in the Edit Layout, add the column you want to sub-total and again make sure it has the "Total" option set in the field definition

You can beautify the formatting as soon as you get this to work.

Elrodyn
19th May 2009, 05:49
Hi,

i already do the suggestions....but for unknown reason it still not grouping as i want.

the variable returned exactly one digits of the first position number.

the standart report code is ticpr2410000(print cost price(detail))

and the input field i made is:
1.groupc2(new variable)
2.dll2001.data

i'll post the script i made also


declaration:
extern domain tccopr dll2001.ch.cum | Surcharge cumulative
extern domain tccopr dll2001.ch.tot | Surcharge total
extern domain tccopr dll2001.base | Surcharge base
extern domain tcstr.12 groupc1
extern domain tcstr.12 groupc2
extern domain tcqana qtyc
extern domain tcpono qtyc2
extern domain tcamth amntc
extern domain tcamth dummyc

before.program:
dll2001.data = ""
dll2001.ch.tot = 0
dll2001.ch.cum = 0
qtyc=0
amntc=0
dummyc=0




detail.2:
before.layout:

groupc1=str$(tibom010.pono)
groupc2=groupc1(1;1) |<<<<this is the new variable i use
|qtyc2=groupc2
qtyc=dll2001.sitm.qana + qtyc

after.dll2001.data.10:
before.layout:
dll2001.cref = empty

after.dll2001.data.20:
before.layout:
dll2001.cref = empty

after.dll2001.data.30:
before.layout:
dll2001.cref = empty


after.qtyc2.1:
before.layout:
if qtyc=0 then lattr.print = false endif
|#106-124704.en
#ident "@(#)ticpr241010000 tiB52asy18 runner Rev.No. 1 12 Jun 01 bsp"
#ident "@(#)ticpr241010000 tiB52bsy03 runner Rev.No. 1 04 Jun 02 bsp"



this report make me very curious :confused::confused:

in logical way it should be correct....but i must have been missing something :(:(

any other tips?

thanks for the suggestions.

mark_h
19th May 2009, 15:53
You need to put this code:

groupc1=str$(tibom010.pono)
groupc2=groupc1(1;1)

into the session script and not in the report script. Once the variables make it to this part of the script sorting is already done. So pass groupc2 and group1c to the report. Then make groupc2 the primary sort following by groupc1 as the secondary sort.

This can be done in a report script, but it is a lot harder than you think and I do not recommend it unless you do not have a choice.

Elrodyn
20th May 2009, 05:32
Hi,

i see, thanks for the tip, i'll try the solution right away:).

but should i make the variable in the session script from now on?

and what if i don't have any choice and i must make it on the report?can you please tell me the logic of the script?just curious.

mark_h
20th May 2009, 15:33
If adding a sort to a report I recommend always adding to the session script.

I posted this code once before, basically to do it in the report script - you first re-read the records and write them back out with your new sort field. Then you run the sort command to re-sort the records. The last step is then to just let the report run. In the sort you will see -t and a control character - that is STX used as the record separator. This is baan 4 code and I do not know if it would work on LN.

declaration:
table ttipgc001
long l,r.o,first

|detail.1:
|before.layout:
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")

Elrodyn
30th May 2009, 04:28
hello,

bad news, i don't have the session script and i think i have to use your code.....

thanks for the code it's a great help.

mark_h
1st June 2009, 15:49
Well good luck - we have only had to use this in one place. So far I do not even think the run the report - close production orders. My recommendation the way the consultant and I worked it out was that we ran the report in debug mode multiple times to figure out each step. I know this works on our 4C4, but not sure about LN. There might be different baan variables names - so put the report in debug mode and step through it. Good luck and let us know how it goes.

Elrodyn
2nd June 2009, 07:48
yes, there's some syntax i really need to change, especially the run.baan.prog()

it has some strange character to pass, is it baanIV only?

mark_h
2nd June 2009, 15:37
I can not answer that since I have never worked on ln. I just know that in debug mode you see baan IV use this character as the field separator. So we just mimic what baan was doing - adding a new field, then resorting the data.

Hitesh Shah
2nd June 2009, 20:47
As I understand u do not have source , the report is by order and u need subtotals by series .

U need to do following .
1. Have the order in sort field
2. Have after.field layout for the order.
3. In report script , initialize and increment series and it's substotal in an array in after.receive.data section . Also store highest ordno for each series in same section which will later help u ascertain whether there is change of series or not. Please checkperformance dll (http://www.baanboard.com/baanboard/showthread.php?t=28569) for more help on that.
4. In the before layout of after.field section set lattr.print to false only if the highest order for series and current order are equal . And assign the corresponding sum figures to respective report fields.After.field layout should not have orderno as output field.
5. Declare the array variables in report script and do not use it as input fields.

U have the report the way u need .

Elrodyn
22nd June 2009, 17:58
Hi all,

sorry for not responding for so long

thanks for the tips, i'll be sure to try it. and i'll ask again if there's something i don't understand.

thank you again.:)