trigger OnAfterModify()
begin
UpdateLotRes(0);
end;
var
TempLotDetail: Record /Lot Detail/ temporary;
TempQAHeader: Record /QA Header/ temporary;
procedure UpdateLotRes(_option: Option Insert,Delete,Rename)
var
_lotNoInfo: Record /Lot No. Information/;
begin
if _lotNoInfo.Get(/Source No./, /Source No. 2/, /Source No. 3/) then begin
_lotNoInfo./APTOCB_SampleResults/ := BuildVLStringRes(_option);
_lotNoInfo.Modify;
end;
end;
procedure BuildVLStringRes(_option: Option Insert,Delete,Rename): Text[1024]
var
_lotNoInfo: Record /Lot No. Information/;
_codeString: Code[1024];
_QAHeader: Record /QA Header/;
begin
TempLotDetail.Reset;
TempLotDetail.DeleteAll;
TempQAHeader.Reset();
TempQAHeader.DeleteAll();
if _lotNoInfo.Get(/Source No./, /Source No. 2/, /Source No. 3/) then begin
if _lotNoInfo.APTOCB_PreSampleItem = true then begin
_QAHeader.SetRange(/Source No./, /Source No./);
_QAHeader.SetRange(/Source No. 2/, /Source No. 2/);
_QAHeader.SetRange(/Source No. 3/, /Source No. 3/);
If _QAHeader.FindSet() then begin
repeat
if _option = _option::Insert then begin
InsertTempRes(_QAHeader.APTOCB_VendorLotSerialNo, 0);
InsertTempSample(_QAHeader.APTOCB_TempSample, 0);
end;
if _option = _option::Delete then begin
_lotNoInfo./APTOCB_SampleResults/ := '';
end;
if _option = _option::Rename then begin
if xRec.APTOCB_VendorLotSerialNo = _QAHeader.APTOCB_VendorLotSerialNo then begin
InsertTempRes(APTOCB_VendorLotSerialNo, 0);
InsertTempSample(TempQAHeader.SampleResults, 0);
end else begin
InsertTempRes(_QAHeader.APTOCB_VendorLotSerialNo, 0);
InsertTempSample(TempQAHeader.SampleResults, 0);
end;
end;
_codeString += ',' + TempLotDetail./Lot No./ + '-' + GetOptionText(TempQAHeader.APTOCB_TempSample);
until _QAHeader.Next = 0;
end;
_codeString := DelChr(_codeString, '<', '-');
_codeString := DelChr(_codeString, '<', ',');
exit(CopyStr(_codeString, 1, 250));
end else begin
TempLotDetail.Reset();
if TempLotDetail.FindSet then begin
repeat
if StrLen(_codeString + ',' + TempLotDetail./Lot No./ + '-' + GetOptionText(TempQAHeader.APTOCB_TempSample)) < 1024 then begin
_codeString := '0';
end
until TempLotDetail.Next = 0;
_codeString := DelChr(_codeString, '<', '-');
_codeString := DelChr(_codeString, '<', ',');
exit(CopyStr(_codeString, 1, 250));
end;
end;
end;
end;
procedure InsertTempRes(_lotNo: Code[20]; _sort: Integer)
begin
TempLotDetail.SetRange(/Lot No./, _lotNo);
if not TempLotDetail.FindFirst then begin
TempLotDetail.Init;
TempLotDetail./Lot No./ := _lotNo;
TempLotDetail.Insert;
end;
end;
local procedure InsertTempSample(_sample: Option; _sort: Integer)
begin
TempQAHeader.SetRange(/Source Type/, _sample);
if not TempQAHeader.FindFirst then begin
TempQAHeader.Init;
TempQAHeader.APTOCB_TempSample := _sample;
TempQAHeader.Insert;
end;
end;
local procedure GetOptionText(Sample: Option): Text
var
OptionText: Text;
begin
case SampleResults of
SampleResults::Pass:
OptionText := 'Pass';
SampleResults::/Pass - Brand/:
OptionText := 'Pass - Brand';
SampleResults::/Pass - Custom/:
OptionText := 'Pass - Custom';
SampleResults::/Pass - Private Label/:
OptionText := 'Pass - Private Label';
SampleResults::Reject:
OptionText := 'Reject';
SampleResults::Resample:
OptionText := 'Resample';
else
OptionText := '';
end;
exit(OptionText);
end;