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.