Skip to main content

Notifications

Business Central forum
Unanswered

Split PO Line Into Two

Posted on by 8
Hi all,
 
 previously i asked One question related Split Po line into Two line..
I splited line into two line .. but what my  question is how to handle line no for more than one original Po line record .. & how to split it ?
 
here i paste my code ..
anyone correct my code.
 
 
 
 
thanks In Advance .. 
 
Categories:
  • Netjacker2097 Profile Picture
    Netjacker2097 256 on at
    Split PO Line Into Two
    hi,
     
    please try this: 
     
    SplitQty := ABS(Rec."Quantity Received") / 2;
    IF SplitQty > 0 THEN BEGIN
        Rec.LOCKTABLE;
        
        WHILE (Rec."Quantity Received" > 0) DO BEGIN
            Newpurchaseline.INIT;
            Newpurchaseline.TRANSFERFIELDS(Rec);
            
            Newpurchaseline."Line No." := Rec."Line No." + (10000 * SplitCounter); 
            Newpurchaseline."Quantity Received" := MIN(SplitQty, Rec."Quantity Received");
            
            Rec."Quantity Received" -= Newpurchaseline."Quantity Received";
            
            Newpurchaseline.INSERT;
            
            SplitCounter += 1;
        END;
        MESSAGE('Split Line Complete');
    END;
    Thanks,
    M

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,888 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,247 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans