CodeUnit summarize "Qty. on Sales Order"

SV_WillSV_Will Member Posts: 12
Hi there experts,

I´m trying to sum "Qty. on Sales Order" within a CodeUnit. The Sum should be stored in "Bedarf" (Global Variabel - Integer);

I can count the number of Lines, but can not sum the Values within the Lines:


IF item.FIND('-') THEN

REPEAT
Bedarf := item."Qty. on Sales Order" + Bedarf;
UNTIL item.NEXT = 0;

THANKS :)

Answers

  • crisnicolascrisnicolas Member Posts: 177
    yo need to do a CALCFIELDS on that field...
  • DenSterDenSter Member Posts: 8,305
    The "Qty. on Sales Order" field is a flowfield, and when you use flowfields in C/AL code, you must calculate the value first.
    IF item.FINDSET THEN BEGIN
      REPEAT
        Item.CALCFIELDS("Qty. on Sales Order");
        Bedarf := item."Qty. on Sales Order" + Bedarf;
      UNTIL item.NEXT = 0; 
    END;
    
Sign In or Register to comment.