goesflavio
23rd April 2007, 20:08
Hi everybory,
I have done a report that show total purchase amount from the supplier into the year, separeded by month.
So, I could sum the values using the "after.field" with "Total" into the report field, but I cant sort by amount, because in the "Imput.field" I have sorted the field tdpur045.suno before tdpur045.amnt (because I need sum always values from supplier).
I dont know if its clear, but I need print a report that show who purchase more into the year, is it clear?

Someone would help me?
Best regards.

mark_h
23rd April 2007, 21:19
I think what you are asking for is a sort by supplier and grand total for the months. The easiest way to do this is to do the sum before calling the report - then you just add an input field to the report. There are other ways, but none of them are easier.

One way I did something like this once was to open a temporary report to do the sums I wanted and write them to an ascii file. I then read it and passed the records to the real report - in the after field instead of totals I used a different variable.

I have also used report tables to hold records to do things like this. For a standard baan session I have modified the report to trap the file, add a field, re-write the report temp file, sort the file and then let the report run like normal. I do not recommend this method - it is kind of complicated.

goesflavio
23rd April 2007, 23:39
Hi Mark, thanks for your reply.
I would not like to folow you first advise because I have more than 1 break, In fact I have break for year, kind of supplier, kindo of item and planing and delivery.
Is there a way to print a temp report (whitout the user see it) and after the first sort, made by report, I to sort by amount?

Best regards,
Flavio.

spartacus
24th April 2007, 10:11
Hi Flavio,

I think I doesn't realy understand exact what your report should do, but i sounds very complicated.
You talked already about a temp report, what about a temp table? With temp table I that you just create a table that meets your recuirements in view of key fields / sorting, maybe already calculating some totals.
You just empty this table direct before you use ist, so you still "a kind of" log after you print your report.

Hope that helps

mr_suleyman
24th April 2007, 10:40
I also think that best way is using temp table. In your main program script calculate total amount by suppliers and keep them on temp table and then send these data to report, sort by amount, supplier. Also you can try Mark's reading file suggestion.


G.Luck !

en@frrom
24th April 2007, 11:15
Mark's first suggestion will be the best one according to my opinion; i.e. first calculate the totals desired, store them into a variable, then print the rest of the report, and place the calculate total-variables onto the report layout.

Regards,
Eli Nager

goesflavio
25th April 2007, 00:31
Hi everybory, You've got a pointer there.
I did what you explain to me and worked very well (I did a temp table and sumed the values)
I dont like to work with many variables into the report, its a mess when you need to fix something, yes?

Thanks very much...
ps. I'll improve my report using a macro into excel that george7 post into the site.

Flavio.

en@frrom
26th April 2007, 10:55
So you create a new table for each report that has more than a couple of calculated fields...???!! I don't want to know what your database looks like then...

goesflavio
26th April 2007, 15:37
Hi en@frrom,
I did a report witch print a amount purchase by supplier and month, and this one needed sort by amount by supplier.
I made a sum in a table before print and work well.

Sorry for my English, I studing yet

Flavio.

en@frrom
27th April 2007, 10:44
I didn't doubt it would work well, just disagree about creating a new table just for the sake of printing calculated fields on a report, whilst you can perfectly achieve the results programmatically, without any new tables...

But ok, everyone with their own methods...