#include Prod.Product Test Kill Cache Merge Cache=^MRPRESLog(66697,31235,"FETCH") Set CRef=$na(Cache) Do SwitchEcopackToBox Quit SwitchEcopackToBox New PRNr Set PRNr="" For Set PRNr=$O(@CRef@("SCANONE",PRNr)) Quit:PRNr="" Do . Set ReplacePRNrs=$$GeefVervangProducten(PRNr) . If ReplacePRNrs'="" Do . . Set FabKey="" . . Kill ToeQty . . For Set FabKey=$O(@CRef@("SCANONE",PRNr,FabKey)) Quit:FabKey="" Do . . . Set ToeQty($P(FabKey,";"))=$G(ToeQty($P(FabKey,";")))+$P(@CRef@("SCANONE",PRNr,FabKey),"/") . . . . Set MultipleQty=$$$ProductGet($P(ReplacePRNrs,";"),$$$GrootVerpakking) . . Set TOENr="" . . For Set TOENr=$O(ToeQty(TOENr)) Quit:TOENr="" Do . . . If ToeQty(TOENr)>MultipleQty Do . . . . Write TOENr," ",ToeQty(TOENr),! . . . . Do SplitQty(PRNr,ToeQty(TOENr),ReplacePRNrs,.ReplaceLijst) . . . . zw ReplaceLijst . . . . Do ReplaceInCache(CRef,PRNr,TOENr,.ReplaceLijst) . . zw @CRef@("SCANONE",2258629) . . zw @CRef@("SCANONE",1811826) . . zw @CRef@("SCANONE",1811828) GeefVervangProducten(PRNr) Quit:PRNr=2258629 "1811826;1811828" Quit "" SplitQty(PRNr,Qty,ReplacePRNrs,ReplaceLijst) ; ReplaceLijst via .Local Set MultipleQty=$$$ProductGet($P(ReplacePRNrs,";"),$$$GrootVerpakking) Set ReplaceQty=Qty\MultipleQty*MultipleQty Set RestQty=Qty-ReplaceQty Kill ReplaceLijst Set:RestQty>0 ReplaceLijst(PRNr)=RestQty For I=1:1:$L(ReplacePRNrs,";") Do . Set ReplaceLijst($P(ReplacePRNrs,";",I))=ReplaceQty Quit ReplaceInCache(CRef,PRNr,TOENr,ReplaceLijst) ; ReplaceLijst via .Local ; Verwijder Toelevering Set FabKey=TOENr_";" For Set FabKey=$O(@CRef@("SCANONE",PRNr,FabKey)) Quit:FabKey="" Quit:$P(FabKey,";")'=TOENr Do . Kill @CRef@("SCANONE",PRNr,FabKey) ; Add nieuw aantallen Set NewPRNr="" Set FabKey=TOENr_";999" For Set NewPRNr=$O(ReplaceLijst(NewPRNr)) Quit:NewPRNr="" Do . Set @CRef@("SCANONE",NewPRNr,FabKey)=ReplaceLijst(NewPRNr) Quit