Processing-Only Report: Grouping according to some logic

davidecdavidec Member Posts: 63
Hello!
I have a problem making a report. Let me summarize as follows (just an example, the real thing is a bit more complex, but I can figure the rest out... I hope!):

I have a table which contains 5 fields:

Item No.
Posting Date
Reason Code
Entry Type
Quantity


I need to make a processing-only report which maps lines from this table into another, applying some logic:

- If "Entry type" is among certain values (let's say 1,4,5), lines must be mapped as they are
- If "Entry type" is among other values (let's say 2,3,6), I need to sum all quantities grouped by "Item No.", "Posting Date" and "Reason Code" and move just one line into the target table (containing "Item No.", "Posting Date", "Reason Code", the summed quantity and ignoring the "Entry Type")

My question is: Is there an efficent/standard way to achieve this, without parsing all the lines and summing "by hand"? I thought of using TotalFields and GroupTotalFields, but can't figure how to group just according to some values of "Entry Type"...

Thank you very much in advance for your help!

Comments

  • BeliasBelias Member Posts: 2,998
    How about 2 Dataitems filtered in a different way?the first with "simple" values, and the rest with "summed values"...
    ...the first thing come out of my head...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • djswimdjswim Member Posts: 277
    Disclaimer: What follows is pseudocode... if you copy/paste this into a database, the universe will probably collapse... you've been warned:

    IF EntryType = (1,4,5) THEN
    <code to move lines>
    
    <Filter to lines that are entry type 2,3,6>
    <Code to determine each unique combination of Item No., Posting Date, and Reason code (I can hash this out more if needed)>
    <Store unique combos in a temp table>
    n:=1;
    LOOP
        <Filter on unique combo #n>
            LOOP <run through and tally everything> END LOOP
        <Transfer first unique combo line>
        n := n + 1;
    END LOOP
    
    "OMG ALL MY DATA IS GONE"
    "Show All..."
    "Oh..."
  • davidecdavidec Member Posts: 63
    Thank you very much for your suggestions: neither came into my mind!
    I'll try them, probably both! :D
Sign In or Register to comment.