Mass update Job scrap

We are based on the material parts and production qty to select different scrap from a UD table. I write a 4GL code in BMP as click the Job Relase then execute the procedure list as below.
However it popup the “JobMtl has not changed” and did not update the scrap. If I remove ‘RUN ChangeJobMtlEstScrap IN hJobEntry({&input-output_dataset_JobEntryDataSet})’ statement, it can update the scrap but did not recalculate and the requried qty still unchanged.
And then I replace “ASSIGN JobMtl.EstScrap=dEstScrap” with “ASSIGN ttJobMtl.EstScrap=dEstScrap”. It have not dispaly the “JobMtl has not changed” message but still not update the scrap. Pls advise which incorrected. Many Thanks!!

DEFINE VARIABLE hJobEntry AS HANDLE NO-UNDO.
DEFINE VARIABLE dJobHeadIUM LIKE JobHead.IUM.
DEFINE VARIABLE dScrapGroup LIKE Part.Character01.
DEFINE VARIABLE dParentSign AS CHARACTER.
DEFINE VARIABLE dGrandSign AS CHARACTER.
DEFINE VARIABLE dParentType LIKE JobAsmbl.PartNum.
DEFINE VARIABLE dGrandType LIKE JobAsmbl.PartNum.
DEFINE VARIABLE dGrandAsmSeq LIKE JobAsmbl.AssemblySeq.
DEFINE VARIABLE dEstScrap LIKE Jobmtl.EstScrap.
DEFINE VARIABLE dEstScrapType LIKE Jobmtl.EstScrapType.
DEFINE VARIABLE dParentQty LIKE JobAsmbl.RequiredQty.

RUN bo/JobEntry/JobEntry.p PERSISTENT SET hJobEntry.
IF NOT VALID-HANDLE(hJobEntry) THEN QUIT.
FOR EACH ttJobHead NO-LOCK:
FOR EACH JobMtl EXCLUSIVE-LOCK WHERE JobMtl.Company=ttJobHead.Company AND JobMtl.JobNum=ttJobHead.JobNum:
FOR EACH Part NO-LOCK WHERE Part.Company=JobMtl.Company AND Part.PartNum=JobMtl.PartNum AND Part.TypeCode=“P”:
dScrapGroup = Part.Character01.
FIND FIRST JobAsmbl WHERE JobAsmbl.Company=JobMtl.Company AND JobAsmbl.JobNum=JobMtl.JobNum AND JobAsmbl.AssemblySeq=JobMtl.AssemblySeq.
IF AVAILABLE JobAsmbl THEN DO:
dParentQty = JobAsmbl.RequiredQty.
IF dScrapGroup=“M” THEN DO:
/ASSIGN dParentType = IF LOOKUP(SUBSTRING(JobAsmbl.PartNum,1,2),“PE,PS”,",")=0 THEN “ALL” ELSE SUBSTRING(JobAsmbl.PartNum,1,2)./
dParentSign = IF LOOKUP(SUBSTRING(JobAsmbl.PartNum,1,2),“PE,PS”,",")=0 THEN “<>” Else “=”.
IF JobAsmbl.Parent<>0 THEN DO:
dGrandAsmSeq = JobAsmbl.Parent.
FIND FIRST JobAsmbl WHERE JobAsmbl.Company=JobMtl.Company AND JobAsmbl.JobNum=JobMtl.JobNum AND JobAsmbl.AssemblySeq=dGrandAsmSeq.
IF AVAILABLE JobAsmbl THEN dGrandSign = IF LOOKUP(SUBSTRING(JobAsmbl.PartNum,1,2),“PE,PS”,",")=0 THEN “<>” ELSE “=”.
ELSE dGrandSign = “<>”.
END.
ELSE dGrandSign = “<>”.
END.
ELSE DO:
dParentSign = “=”.
dGrandSign = “=”.
END.
END.

		dJobHeadIUM = IF LOOKUP(ttJobHead.IUM,"PC,SET,PPK",",")=0 THEN "SET" ELSE ttJobHead.IUM.
		FIND FIRST UD100 WHERE UD100.Company=ttJobHead.Company AND UD100.Character01=dScrapGroup AND UD100.Character02=dParentSign 
			AND UD100.Character04=dGrandSign AND UD100.Character06=dJobHeadIUM.
		IF AVAILABLE UD100 THEN DO:
			FIND FIRST UD100A WHERE UD100A.Company=UD100.Company AND UD100A.Key1=UD100.Key1 AND UD100A.Key2=UD100.Key2 AND UD100A.Key3=UD100.Key3 
				AND UD100A.Key4=UD100.Key4 AND UD100A.Key5=UD100.Key5 AND UD100A.Number02<=ttJobHead.ProdQty AND UD100A.Number03>=ttJobHead.ProdQty.
				IF AVAILABLE UD100A THEN DO:
					dEstScrap = UD100A.Number01.
					dEstScrapType = IF UD100A.CheckBox01 THEN "Q" ELSE "%".
				END.
				ELSE dEstScrap = 0.
		END.
		ELSE dEstScrap = 0.

		IF JobMtl.EstScrap<>dEstScrap THEN DO.
			ASSIGN JobMtl.EstScrap=dEstScrap.
			RUN ChangeJobMtlEstScrap IN hJobEntry({&input-output_dataset_JobEntryDataSet}).
		END.
		IF JobMtl.EstScrapType<>dEstScrapType THEN DO.
			ASSIGN JobMtl.EstScrapType=dEstScrapType.
			RUN ChangeJobMtlEstScrapType IN hJobEntry({&input-output_dataset_JobEntryDataSet}).
		END.
		/*ASSIGN JobMtl.RequiredQty = IF JobMtl.EstScrapType="%" THEN dParentQty * JobMtl.QtyPer * (1 + JobMtl.EstScrap / 100) ELSE dParentQty * JobMtl.QtyPer + JobMtl.EstScrap.*/
	END.
END.
ASSIGN ttJobHead.CheckOff1 = TRUE.
ASSIGN ttJObHead.Date01 = TODAY.
ASSIGN ttJObHead.Date02 = ?.
ASSIGN ttJobHead.ShortChar01 = ttCallContextClient.CurrentUserId.
ASSIGN ttJobHead.ShortChar02 = "".
RUN Update IN hJobEntry({&input-output_dataset_JobEntryDataSet}).

END.
DELETE PROCEDURE hJobEntry NO-ERROR.

I am running 9.05.702A I don’t know about your version, but in the later versions you don’t need to reference the BOs like this. You can just update the ttJobMtl values. We don’t use scrap values, but I just changed one on a job and it updated the required quantity when I left the field.

So if your version supports this, you can just set the scrap type and value and let Epicor handle the rest.

Thankyou for your reply. Recently I upgraded from 9.05.607B to 9.05.702A of Progress Database version. I have tried to update ttJobMtl reference or not to BO still not work. If I change the ttJobHead anything it OK. I can update the scrap in JobMtl without reference to BO but does not recalculate the required qty. How can I trigger this action?

Well that was frustrating. Here is what I got to work.

I calculated the new required quantity and set it in the database and set the new scrap type and quantity in the ttJobMtl table. When I refreshed the job it had the new value and the time phase for the part had the new value, but that was as far as I tested.

Greg

/* reset est scrap based on part number01  */



Message " IN POST JOB RELEASED ".



for each ttJobHead where ttJobHEad.JobReleased:



						for each JobMtl where JobMtl.Company=ttJobHead.Company and JobMtl.JobNum=ttJobHead.JobNum and JobMtl.AssemblySeq=JobMtl.AssemblySeq and JobMtl.MtlSeq=JobMtl.MtlSeq,
							each Part where JobMtl.partNum = Part.PartNum and JobMtl.Company = Part.Company:
								
							
							
							 Assign JobMtl.EstScrap = Part.Number01
												JobMtl.RequiredQty = JobMtl.RequiredQty + part.Number01 
											JobMtl.EstScrapType = "Q".
											
							 Message "Jobmtl Est Scrap = " + string(JobMtl.EstScrap).
							 
							 
							END.
		



	for each ttJobMtl where ttJobMtl.Company=ttJobHead.Company and ttJobMtl.JobNum=ttJobHead.JobNum and ttJobMtl.AssemblySeq=ttJobMtl.AssemblySeq and ttJobMtl.MtlSeq=ttJobMtl.MtlSeq,
		each Part where ttJobMtl.partNum = Part.PartNum and ttJobMtl.Company = Part.Company:

					
				
						 Assign ttJobMtl.EstScrap = Part.Number01
									
										ttJobMtl.EstScrapType = "Q".
											
						Message "ttJobmtl Est Scrap = " + string(ttJobMtl.EstScrap).
											
	END.


END.


I have already tried your similar statement list as below, it can recalculate the required qty and found in Time Phase correctly. However I allocate part in Fulfillment Workbench, some parts were allocated very little qty even 100% available to fulfill . If I change the Job production qty then backwards to trigger the calculation, it can be allocated 100% fulfilled. Therefore I think the BO’s method ChangeJobMtlEstScrap not only recalculation and also update some where I didn’t know.

ASSIGN JobMtl.RequiredQty = IF JobMtl.EstScrapType="%" THEN dParentQty * JobMtl.QtyPer * (1 + JobMtl.EstScrap / 100) ELSE dParentQty * JobMtl.QtyPer + JobMtl.EstScrap.

You will have to turn on tracing to find the other files that are updated.