# Data Directive to Write SO or Job Number During MLP Run **Category:** [Epicor ERP 9](https://www.epiusers.help/c/e9/7) **Created:** 2017-02-04 22:57 UTC **Views:** 738 **Replies:** 5 **URL:** https://www.epiusers.help/t/data-directive-to-write-so-or-job-number-during-mlp-run/37163 --- ## Post #1 by @John_Mitchell Has anyone ever written a Data Directive to write the pegged sales order or job number to a job during an Multi Level Pegging run? We build all jobs to inventory before shipping but there is always a problem matching the job to what is driving the demand. I have a BPM when you get the job number with Job Entry but I haven't had any luck with getting the demand numbers written in with a Data Directive on the Peg tables. Thanks, John --- ## Post #2 by @gpayne I tried using PegDmdMst to move info and ended up using PartDtl instead. Depending on how quickly you need the data on the job, you can use a sql routine once a day or every x minutes. ( below ) or something like. For Each ttpartDtl. For each PartDtl fields ( PartNum DueDate JobNum ) where PartDtl.Company = ttPartDtl.Company and PartDtl.Plant = ttPartDtl.Plant and PartDtl.DueDate >= ttPartDtl.DueDate and PartDtl.PartNum = ttSugPODtl.PartNum and PartDtl.RequirementFlag = true. For first JobHead fields ( ShortChar20 ) where JobHead.Company = ttSugPODtl.Company and JobHead.Plant = ttPartDtl.Plant and JobHead.JobNum = PartDtl.JobNum. Assign ShortChar20 = PartDtl.JobNum. End. End. End. Greg update JobHead Set ShortChar20 = --select top 1000 pd.JobNum, isnull((select top 1 convert(varchar,pdo.OrderNum) + '/'+ convert(varchar,pdo.OrderLine) + '/'+convert(varchar,pdo.OrderRelNum) as OrderLineRel from PartDtl pdo where pdo.PartNum=pd.PartNum and pdo.DueDate>=pd.DueDate and pdo.SourceFile='OR' and pdo.RequirementFlag=1) ,isnull((select top 1 pdm.JobNum from PartDtl pdm where pdm.PartNum=pd.PartNum and pdm.DueDate>=pd.DueDate and pdm.SourceFile='JM' and pdm.RequirementFlag=1),'')) from PartDtl pd inner join JobHead jh on pd.JobNum=jh.JobNum where pd.SourceFile='jh' and jh.JobReleased=1 and jh.JobComplete=0 --- ## Post #3 by @John_Mitchell Greg, Thanks a lot. Does it allow the sales order demand dates to change and change the job due dates accordingly? John --- ## Post #4 by @gpayne It doesn’t change dates it looks at the next release after the job due date and matches them up. I would not use an outside sql routine to change Epicor dates. You could make a dashboard that had the job and the order/line/release it was calculated to and highlight dates less or more than you want the jobs to finish apart. Those kind of date changes should show on the Planning Workbench. Greg --- ## Post #5 by @John_Mitchell Greg, I mean if SO 1 demand is pegged to Job A but then the dates of the sales order are pushed back, or SO 2 is moved up would your method now peg Job a to SO 2 demand? My understanding is MLP is running the scheduling engine to link the demand and supply together on a schedule. Thanks, --- ## Post #6 by @gpayne Yes, it will find the next order each run. This is not related to MLP, PartDtl is updated by Orders, Jobs and POs real time. --- **Canonical:** https://www.epiusers.help/t/data-directive-to-write-so-or-job-number-during-mlp-run/37163 **Original content:** https://www.epiusers.help/t/data-directive-to-write-so-or-job-number-during-mlp-run/37163