Purch. Lines Combine based on No. And Type

kenjeskenjes Member Posts: 76
Hi

Is there a function or a simple way to combine purchase lines based on "No." and "Type" values.

Thanks




Regards Kenneth

Answers

  • mohana_cse06mohana_cse06 Member Posts: 5,504
    in report or page itself?
    There is no such function.
  • kenjeskenjes Member Posts: 76
    On a page
  • mohana_cse06mohana_cse06 Member Posts: 5,504
  • kenjeskenjes Member Posts: 76
    edited 2016-01-13
    :)
    Okay, can you send me in the right direction... :)
    Some code ideas :)

    Thanks
  • postsauravpostsaurav Member Posts: 708
    Hi,
    purchase lines based on "No." and "Type"

    Just a thought -
    Create a Text Variable Say - NoandType on Purchase Order Subform.

    Add That in Page Designer and remove No. and Type.

    In OnAfterGetRecord you can write -

    NoandType := Format(Type) + ' ' + Format("No.");

    Hope this gives an Idea :smiley:

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • kenjeskenjes Member Posts: 76
    Hi - and thanks for your feedback :)

    I have done this code for the purpose :
    PurchaseLineOrg.SETCURRENTKEY("Document No.","Document Type","No.");
    PurchaseLineOrg.SETFILTER(PurchaseLineOrg."Document No.", Rec."No.");
    tmpItemNo       := '';
    tmpLineNo       := 10000000;
    
    IF PurchaseLineOrg.FINDSET THEN BEGIN
      REPEAT 
        IF PurchaseLineOrg.Type <> PurchaseLineOrg.Type::" " THEN BEGIN
          IF tmpItemNo <> PurchaseLineOrg."No." THEN BEGIN
            tmpItemNo := PurchaseLineOrg."No.";
            tmpLineNo := tmpLineNo + 10;
            PurchaseLineCombined := PurchaseLineOrg; 
            PurchaseLineCombined."Line No."           := tmpLineNo;
            PurchaseLineCombined.Quantity             := 1;
            PurchaseLineCombined."Line Amount"        := PurchaseLineOrg."Line Amount";
            PurchaseLineCombined."Direct Unit Cost"   := PurchaseLineOrg."Line Amount";
            IF PurchaseLineCombined.INSERT THEN;
          END ELSE BEGIN
              PurchaseLineCombined."Direct Unit Cost" := PurchaseLineCombined."Direct Unit Cost" + (PurchaseLineOrg."Line Amount");      
              PurchaseLineCombined."Line Amount"      := PurchaseLineCombined."Line Amount" + (PurchaseLineOrg."Line Amount");   
              PurchaseLineCombined.MODIFY;
          END;
        END;
      UNTIL PurchaseLineOrg.NEXT = 0 ;
    END;
    
    PurchaseLineOrg.SETFILTER(PurchaseLineOrg."Document No.", Rec."No.");
    IF PurchaseLineOrg.FINDSET(TRUE) THEN BEGIN
      REPEAT
        PurchaseLineOrg.DELETE;  
      UNTIL PurchaseLineOrg.NEXT = 0;
    END;
    
    PurchaseLineCombined.SETFILTER(PurchaseLineCombined."Document No.", Rec."No.");
    IF PurchaseLineCombined.FINDSET(TRUE) THEN BEGIN
      REPEAT 
        PurchaseLineOrg := PurchaseLineCombined;
        PurchaseLineOrg.VALIDATE(PurchaseLineOrg."Direct Unit Cost");
        IF PurchaseLineOrg.INSERT THEN;
      UNTIL PurchaseLineCombined.NEXT = 0 ;
    END;
    

    Local Variables :
    PurchaseLineOrg Record Purchase Line
    PurchaseLineCombined Record Purchase Line
    tmpItemNo Text
    tmpLineNo Integer

    I am a little newbie into NAV C/al.
    Does this code seem to be okay - or can it be compressed more, or done in another way ?

    THANKS
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    PurchaseLineCombined."Direct Unit Cost" := PurchaseLineCombined."Direct Unit Cost" + (PurchaseLineOrg."Line Amount");
    PurchaseLineCombined."Line Amount" := PurchaseLineCombined."Line Amount" + (PurchaseLineOrg."Line Amount");
    PurchaseLineCombined.MODIFY;


    It seems you have added only few fields and what about other fields like Quantity and discounts etc.?
  • kenjeskenjes Member Posts: 76
    Quantity is set to 1.
    Thats why adding Amount to lines with same ItemNo.
    All other fields is not nessecarry for now - the purpose is to have 1 line per Item, that kan be modified manually with job no, job task and so on :)

Sign In or Register to comment.