How to count machine center correctly with some filter?

klum
klum Member Posts: 102
Hi All,

I need help please. Can anybody correct my code? I filter sales line with field : "work center filter" which i created new field, this field is flowfield :Min("Routing Line"."Work Center No." WHERE (Routing No.=FIELD(No.),Operation No.=CONST(10)))

I filter sales line."Work Center Filter" = 1|5 but when count machine center so they count not only work center no. :1 and no. 5 but count no.3 too. I don't know why i setup "work center filter" 1|5 but when i got the value of "COUNTMACHINE" it filter "1|3|5".

Work Center no. 1 have 5 machine center.
Work Center no. 5 have 4 machine center.

"COUNTMACHINE" should be 9 machine center. but value also count work center no. 3 which have 3 machine center so make value incorrect = 12 machine center.

TempMacCenter.RESET;
TempMacCenter.DELETEALL;

SalesLine.RESET;
SalesLine.COPYFILTERS("Sales Line");
IF SalesLine.FIND('-') THEN BEGIN
  REPEAT
    IF ItemRec.GET(SalesLine."No.") THEN BEGIN
      RoutingLine.RESET;
      RoutingLine.SETRANGE("Routing No.",ItemRec."Routing No.");
      RoutingLine.SETRANGE("Operation No.",'10');
      IF RoutingLine.FIND('-') THEN BEGIN
        IF WorkCenter.GET(RoutingLine."Work Center No.") THEN BEGIN
          MacCenter.RESET;
          MacCenter.SETRANGE("Work Center No.",WorkCenter."No.");
          MacCenter.SETRANGE(Blocked,FALSE);
          IF MacCenter.FIND('-') THEN BEGIN
            REPEAT
              IF NOT TempMacCenter.GET(MacCenter."No.") THEN BEGIN
                TempMacCenter.INIT;
                TempMacCenter.TRANSFERFIELDS(MacCenter);
                TempMacCenter.INSERT;
                CountMachine += 1;
              END;
            UNTIL MacCenter.NEXT = 0;
          END;
        END;
      END;
    END;
  UNTIL SalesLine.NEXT = 0;
  CountMachine +=MacCenter.COUNT;
  END;

Please help me :) Thank in advance....
Klum

Comments

  • lubost
    lubost Member Posts: 633
    You wrote:

    Work Center no. 1 have 5 machine center.
    Work Center no. 5 have 4 machine center.

    "COUNTMACHINE" should be 9 machine center.

    but your code goes thru work centers from routing lines and routing lines can not include all workcenters and each workcenter can be used more then once.
  • klum
    klum Member Posts: 102
    I just want to count machine center from each work center. So each work center have many machine center.
    but your code goes thru work centers from routing lines and routing lines can not include all workcenters and each workcenter can be used more then once.

    You're right that in routing lines I will got only one workcenter but in this only one workcenter have many machine center that what i want to count. By this code :
    RoutingLine.RESET; 
          RoutingLine.SETRANGE("Routing No.",ItemRec."Routing No."); 
          RoutingLine.SETRANGE("Operation No.",'10'); 
          IF RoutingLine.FIND('-') THEN BEGIN 
            IF WorkCenter.GET(RoutingLine."Work Center No.") THEN BEGIN 
              MacCenter.RESET; 
              MacCenter.SETRANGE("Work Center No.",WorkCenter."No."); 
              MacCenter.SETRANGE(Blocked,FALSE); 
              IF MacCenter.FIND('-') THEN BEGIN 
    

    So why I cannot count machine center correctly? Anybody can help me? or I ask question didn't clear? Please fix my code and suggest me ....thank alot