Options

Temporary table, Form and FlowField

EddieEddie Member Posts: 26
HI! Is anybody know a sulution for my problem? So it is...
I run the form on Temporary table. For example:

SalesLineTMP is defined as Temporary Table in Globals.

SalesLine.SETRANGE("Document No.","No.");
SalesLine.SETRANGE("Document Type," "Document Type");
IF SalesLine.FIND('-') THEN
REPEAT
SalesLineTMP.INIT
SalesLineTMP.TRANSFERFIELDS(SalesLine);
SalesLineTMP.INSERT;
UNTIL SalesLine.NEXT = 0;

FORM.RUN(12345,SalesLineTMP);

It works very nice!
When the Form is open, I can see inserted records. I can do some modifications for example changed the quantity or Unit price....
The result is that "Line Amount" is change as well. It is OK.
What I need is:

I need calculate "Line Amount" on all records shown in form. I need it use for something like a Statistics F9. How? Flowfield doesn't work... THX

Comments

  • Options
    krikikriki Member, Moderator Posts: 9,090
    You will need a function to read all records in the file to do that.
    When you get into your function, you have to save the current record, all it's filters and the currentkey. Then you can do a RESET and read all records to make your total, and then you have to restore the current record,filters and currentkey.
    Some exemple:
    Function CalculateLineAmount : OdecLineAmount : Decimal
    LrecSalesline.TRANSFERFILTERS(Rec);
    LrecSalesLine := Rec;
    OdecLineAmount := 0;
    RESET;
    IF FIND('-') THEN
      REPEAT
        OdecLineAmount += "Line Amount";
      UNTIL NEXT = 0;
    
    TRANSFERFILTERS(LrecSalesline);
    Rec := LrecSalesLine;
    

    PS : don't use
    FORM.RUN(12345,SalesLineTMP);
    
    But use
    FORM.RUN(FORM."My Form",SalesLineTMP);
    
    This is better when you have to do an upgrade,merge or someone else has to read your code.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.