Scheduling Function

I am creating a function where I want to feed it with a Job Number and Start Date and get it to reschedule the job forward from the start date.
I have run a trace and need to use Erp.Proxy.BO.ScheduleEngineImpl
MoveJobItem

The input for this is a ‘ScheduleEngineTableset’ - could anyone help point me in the direction of how I create this in the function please.

Or does anyone have a function that I can use as a basis ?

I am on prem, Kinetic 2024.2.13

Based on the BO I would guess that you would do something like this:

CallService<Erp.Contracts.ScheduleEngineSvcContract>( svc => {

    var ts = new Erp.Tablesets.ScheduleEngineTablset();

    // change tableset Table Fields

    svc.MoveJobItem( ref ts );

});
1 Like

I built this function to move individual ops to the top of the schedule (and to the actual machine being used) when someone on the floor makes a flex call. There is a LINQ call above this that selects records from Erp.ResourceTimeUsed and dumps it into a variable called “sched”.

var SchedEngTs = new Erp.Tablesets.ScheduleEngineTablset();
//These variables are for setting a start time of right now.
TimeSpan sinceMidnight = DateTime.Now.AddSeconds(-DateTime.Now.Second)
						- DateTime.Today;
int startTime = (int)(sinceMidnight.TotalSeconds);
string warn;

var row = new Erp.Tablesets.ScheduleEngineRow();
row.Company = "YourCompany";
row.JobNum = Job;
row.AssemblySeq = AssmSq;
row.OprSeq = OprSq;
row.OpDtlSeq = sched.OpDtlSeq;
row.StartDate = BpmFunc.Today();
row.StartTime = startTime; //See variables above.
row.SchedTypeCode = "oo"; //Whether you move entire jobs or single ops is controlled by this string
row.ScheduleDirection = "Start";
row.ResourceGrpID = sched.ResourceGrpID;
row.ResourceID = Resource;
row.AllocNum = sched.AllocNum;
row.UpdateJobOpDtl = true; //Writes back to Job. Doesn't work if you disallow changes to engineered jobs.
row.RowMod = "A";

SchedEngTs.ScheduleEngine.Add(row);

CallService<Erp.Contracts.ScheduleEngineSvcContract>(svc =>
{
	//Probably not necessary if you're just moving items.
	svc.SetMachines(SchedEngTs);
	SchedEngTs.ScheduleEngine.FirstOrDefault().ResourceID = Resource;
	//MoveJobItem should also work, but this method moves scheduled items too.
	//I vaguely recall running into problems with MoveJobItem
	svc.ChangeResource(SchedEngTs,
					   SchedEngTs.ScheduleEngine.FirstOrDefault().AllocNum,
					   Resource,
					   false
					   ,out warn);
	//Accept changes to move from WhatIf sched to Actual
	svc.AcceptChanges("", SchedEngTs);
});
2 Likes

Thank you, I will take a look and see if I can adapt this :slightly_smiling_face: