编辑:我可以使用下面的代码导入,除了现在我有两个非常烦人的问题: 1.当同一文件中有多个配方ID时,在自定义表中交换配对值** 2.我应该为每个通过HandleAlternateBOM函数创建的bom和prod顺序提供1个配方ID。不知何故,我最终得到了339个prod订单和441个配方ID的boms。我做错了什么?
以下是原帖,但不再适用... {我即将失去理智,试图解决这个问题。我们有一个 一直在像发条一样工作的XML端口,以及一个XML文件 几分钟前就被导入了。我们确实修改了XML端口 当我们在我们添加的其中一个解析函数上出现错误时 我们立即恢复到备份的原始副本。
所以据说XML端口和XML文件和以前一样,那么导入现在怎么可能失败呢?
It fails at a line of code that simply reads the inbound item number, and check to make sure it's in the correct format. The
format checking failed because the item number is now showing up as
blank value?
Appreciate any insight.
** }
custom-attribute - Import::OnAfterAssignVariable()
//RecipeID := '' ;
EText1 := '';
EText2 := '';
IsPreSale := '';
TempAlternateBOM.RESET;
{
//AlternateBOM.SETCURRENTKEY("Recipe ID","Item No.","Variant Code","Location Code","Unit of Measure Code","Production BOM No.");
AlternateBOM.SETCURRENTKEY("Recipe ID","Item No.");
AlternateBOM.SETRANGE("Recipe ID",AlternateBOM."Recipe ID");
AlternateBOM.SETRANGE("Item No.",AlternateBOM."Item No.");
//AlternateBOM.SETRANGE("Variant Code",AlternateBOM."Variant Code");
AlternateBOM.SETFILTER("Location Code",'%1','1');
AlternateBOM.SETFILTER("Unit of Measure Code",'%1','EA');
AlternateBOM.SETFILTER("Production BOM No.",'<>%1','');
IF NOT AlternateBOM.FIND THEN BEGIN
}
WITH TempAlternateBOM DO BEGIN
"Item No." := ItemNo;
CASE (Item_CustomAttributeID) OF
'fluidConfigureRecipeID':
BEGIN
IF EVALUATE("Recipe ID",Item_CustomAttribute) AND (STRLEN(Item_CustomAttribute) > 1)
THEN "Recipe ID" := Item_CustomAttribute;
VALIDATE("Production BOM No.","Recipe ID");
TempAlternateBOM."Alternative Item No." := "Recipe ID";
RecipeID := "Recipe ID";
"Variant Code" := VariantCode;
"Location Code" := '1';
TempAlternateBOM.INSERT(TRUE);
END;
'fluidConfigureResourceURL':
"Recipe URL" :=Item_CustomAttribute;
'fluidConfigureDnaBezelSKU':
//IF EVALUATE("Bezel SKU",Item_CustomAttribute) THEN
"Bezel SKU" := Item_CustomAttribute;
'fluidConfigureDnaBandSKU':
// IF EVALUATE("Band SKU",Item_CustomAttribute) THEN
"Band SKU" := Item_CustomAttribute;
'fluidConfigureDnaCaseSKU':
//IF EVALUATE("Case SKU",Item_CustomAttribute) THEN
"Case SKU" := Item_CustomAttribute;
'fluidConfigureQuantity':
EVALUATE(Quantity,Item_CustomAttribute);
'fluidConfigurePrice':
EVALUATE(Price,Item_CustomAttribute);
'fluidConfigureResourceURL':
"Recipe URL" :=Item_CustomAttribute;
'isPreorder':
BEGIN
IF EVALUATE(TempAlternateBOM.Preorder,Item_CustomAttribute) THEN
TempAlternateBOM.Preorder := Item_CustomAttribute;
IF TempAlternateBOM.Preorder = 'true' THEN BEGIN
TempSalesHeader."Sales Type Code" := 'PREORDER';
END;
END;
'fluidConfigureDnaEngravingSKU':
//IF EVALUATE("Engraving SKU",Item_CustomAttribute) THEN
"Engraving SKU" := Item_CustomAttribute;
'fluidConfigureDnaEngravingText1':
//BEGIN
//IF STRLEN(Item_CustomAttribute) <> 0 THEN
// IF EVALUATE(TempAlternateBOM.EngravingText1,Item_CustomAttribute) THEN
// END;
'fluidConfigureDnaEngravingText2':
// BEGIN
/// IF STRLEN(Item_CustomAttribute) <> 0 THEN
// IF EVALUATE(TempAlternateBOM.EngravingText2,Item_CustomAttribute) THEN
TempAlternateBOM.EngravingText2 := Item_CustomAttribute;
// END;
'fluidConfigureImageURL':
// IF EVALUATE("Image URL",Item_CustomAttribute) THEN
"Image URL" := Item_CustomAttribute;
END;
TempAlternateBOM."Unit of Measure Code" := 'EA';
TempAlternateBOM."Created Date" := WORKDATE;
TempAlternateBOM."DWRE Order No." := OrderNo;
TempAlternateBOM."SO No." := SalesHeader."No.";
IF TempAlternateBOM."Recipe ID" <> '' THEN
// TempAlternateBOM.MODIFY(TRUE);
IF NOT TempAlternateBOM.INSERT(TRUE)
THEN TempAlternateBOM.MODIFY(TRUE);
HandleAlternateBOMs;
//HandleProdBOM;
COMMIT;
END;
ClearFluidAttribute;
HandleAlternateBOMs功能:
IF (TempAlternateBOM.FINDSET) AND (TempAlternateBOM."Recipe ID" <> '') THEN BEGIN
REPEAT
AlternateBOM.INIT;
AlternateBOM.VALIDATE("Item No.", TempAlternateBOM."Item No.");
AlternateBOM.VALIDATE("Alternative Item No.", TempAlternateBOM."Alternative Item No.");
AlternateBOM.VALIDATE("Variant Code", TempAlternateBOM."Variant Code");
AlternateBOM.VALIDATE("Location Code", TempAlternateBOM."Location Code");
//AlternateBOM.INSERT;
AlternateBOM."Recipe ID" := TempAlternateBOM."Recipe ID";
AlternateBOM."Production BOM No." := TempAlternateBOM."Production BOM No.";
AlternateBOM."Created Date" := TempAlternateBOM."Created Date";
//AlternateBOM.INSERT(TRUE);
// AlternateBOM.VALIDATE("Alternate Item No.", TempAlternateBOM."Alternate Item No.");
AlternateBOM."Unit of Measure Code" := TempAlternateBOM."Unit of Measure Code";
AlternateBOM."DWRE Order No." := TempAlternateBOM."DWRE Order No.";
AlternateBOM."SO No." := TempAlternateBOM."SO No.";
AlternateBOM."Recipe URL" := TempAlternateBOM."Recipe URL";
AlternateBOM."Case SKU" := TempAlternateBOM."Case SKU";
AlternateBOM."Band SKU" := TempAlternateBOM."Band SKU";
AlternateBOM."Bezel SKU" := TempAlternateBOM."Bezel SKU";
AlternateBOM."Engraving SKU" := TempAlternateBOM."Engraving SKU";
AlternateBOM.EngravingText1 := TempAlternateBOM.EngravingText1;
AlternateBOM.EngravingText2 := TempAlternateBOM.EngravingText2;
AlternateBOM."Image URL" := TempAlternateBOM."Image URL";
AlternateBOM.Quantity := TempAlternateBOM.Quantity;
AlternateBOM.Price := TempAlternateBOM.Price;
AlternateBOM.Preorder := TempAlternateBOM.Preorder;
IF NOT AlternateBOM.INSERT THEN
AlternateBOM.MODIFY;
UNTIL (TempAlternateBOM.NEXT = 0);
//Create new BOM using Production BOM No. as No.
ProdBOMHeader.RESET;
ProdBOMHeader.SETRANGE("No.",AlternateBOM."Production BOM No.");
IF NOT ProdBOMHeader.GET(AlternateBOM."Production BOM No.") THEN BEGIN
ProdBOMHeader.INIT;
ProdBOMHeader."No." := AlternateBOM."Production BOM No.";
ProdBOMHeader.Status := ProdBOMHeader.Status::New;
ProdBOMHeader.VALIDATE(Description,OrderNo + ' ' + AlternateBOM."Production BOM No.");
ProdBOMHeader."Unit of Measure Code" := 'EA';
ProdBOMHeader.INSERT;
//Get Item No & Variant for Case SKU
// IF STRLEN(RecipeID) = 8 THEN
ProdBOMLine.SETRANGE("Production BOM No.",AlternateBOM."Production BOM No.");
IF NOT ProdBOMLine.FIND THEN BEGIN
ProdBOMLine.INIT;
ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
//MESSAGE(ProdBOMHeader."No." + 'confirm');
//MESSAGE(AlternateBOM."Case SKU");
ProdBOMLine."Version Code" := '';
ProdBOMLine."Line No." := 10000;
ProdBOMLine.Type := ProdBOMLine.Type::Item;
IF (STRPOS(AlternateBOM."Case SKU", '-') > 0) THEN
CaseSKU := COPYSTR(AlternateBOM."Case SKU", 1, STRPOS(AlternateBOM."Case SKU", '-') - 1)
ELSE
ERROR('Case SKU is not in expected format. Value expected XXXX-YYY-ZZZ. Value received: %1', AlternateBOM."Case SKU");
IF (CaseSKU <> '') THEN
CaseVariant := COPYSTR(AlternateBOM."Case SKU", STRLEN(CaseSKU) + 2)
ELSE
ERROR('No item number provided!');
ProdBOMLine.VALIDATE("No.",CaseSKU);
ProdBOMLine.VALIDATE("Variant Code",CaseVariant);
ProdBOMLine.VALIDATE("Quantity per",1);
ProdBOMLine.INSERT(TRUE);
END;
//Get Item No & Variant for Bezel SKU
ProdBOMLine.SETRANGE("Production BOM No.",ProdBOMHeader."No.");
IF ProdBOMLine.FINDLAST THEN BEGIN
ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
ProdBOMLine."Version Code" := '';
ProdBOMLine."Line No." := 20000;
ProdBOMLine.Type := ProdBOMLine.Type::Item;
IF (STRPOS(AlternateBOM."Bezel SKU", '-') > 0) THEN
BezelSKU := COPYSTR(AlternateBOM."Bezel SKU", 1, STRPOS(AlternateBOM."Bezel SKU", '-') - 1)
ELSE
ERROR('Bezel SKU is not in expected format. Value expected XXXX-YYY-ZZZ. Value received: %1', AlternateBOM."Bezel SKU");
IF (BezelSKU <> '') THEN
BezelVariant := COPYSTR(AlternateBOM."Bezel SKU", STRLEN(BezelSKU) + 2)
ELSE
ERROR('No item number provided!');
ProdBOMLine.VALIDATE("No.",BezelSKU);
ProdBOMLine.VALIDATE("Variant Code",BezelVariant);
ProdBOMLine.VALIDATE("Quantity per",1);
ProdBOMLine.INSERT(TRUE);
END;
//Get Item No & Variant for Band SKU
ProdBOMLine.SETRANGE("Production BOM No.",ProdBOMHeader."No.");
IF ProdBOMLine.FINDLAST THEN BEGIN
ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
ProdBOMLine."Version Code" := '';
ProdBOMLine."Line No." := 30000;
ProdBOMLine.Type := ProdBOMLine.Type::Item;
IF (STRPOS(AlternateBOM."Band SKU", '-') > 0) THEN
BandSKU := COPYSTR(AlternateBOM."Band SKU", 1, STRPOS(AlternateBOM."Band SKU", '-') - 1)
ELSE
ERROR('Band SKU is not in expected format. Value expected XXXX-YYY-ZZZ. Value received: %1', AlternateBOM."Band SKU");
IF (BandSKU <> '') THEN
BandVariant := COPYSTR(AlternateBOM."Band SKU", STRLEN(BandSKU) + 2)
ELSE
ERROR('No item number provided!');
ProdBOMLine.VALIDATE("No.",BandSKU);
ProdBOMLine.VALIDATE("Variant Code",BandVariant);
ProdBOMLine.VALIDATE("Quantity per",1);
ProdBOMLine.INSERT(TRUE);
END;
//Get Item No & Variant for Engraving SKU
ProdBOMLine.SETRANGE("Production BOM No.",ProdBOMHeader."No.");
IF ProdBOMLine.FINDLAST THEN BEGIN
ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
ProdBOMLine."Version Code" := '';
ProdBOMLine."Line No." := 40000;
ProdBOMLine.Type := ProdBOMLine.Type::Item;
IF (STRPOS(AlternateBOM."Engraving SKU", '-') > 0) THEN
EngravingSKU := COPYSTR(AlternateBOM."Engraving SKU", 1, STRPOS(AlternateBOM."Engraving SKU", '-') - 1)
ELSE
ERROR('Engraving SKU is not in expected format. Value expected XXXX-YYY-ZZZ. Value received: %1', AlternateBOM."Band SKU");
IF (EngravingSKU <> '') THEN
EngravingVariant := COPYSTR(AlternateBOM."Engraving SKU", STRLEN(EngravingSKU) + 2)
ELSE
ERROR('No item number provided!');
ProdBOMLine.VALIDATE("No.",EngravingSKU);
ProdBOMLine.VALIDATE("Variant Code",EngravingVariant);
CASE ProdBOMLine."Variant Code" OF
'E001*':
ProdBOMLine.Description := AlternateBOM.EngravingText1;
'E002*':
BEGIN
ProdBOMLine.Description := AlternateBOM.EngravingText1;
ProdBOMLine."Description 2" := AlternateBOM.EngravingText2;
END;
'E003*..E022*':
//ProdBOMLine.VALIDATE(Description,AlternateBOM.EngravingText1);
ProdBOMLine."Description 2" := AlternateBOM."Image URL";
//ELSE
//ProdBOMLine.VALIDATE(Description,AlternateBOM."Image URL");
//IF STRLEN(AlternateBOM.EngravingText1) > 1 THEN
// ProdBOMLine.VALIDATE(Description,AlternateBOM.EngravingText1);
//ProdBOMLine.VALIDATE("Description 2",AlternateBOM.EngravingText2);
END;
ProdBOMLine.VALIDATE("Quantity per",1);
ProdBOMLine.INSERT(TRUE);
END;
//Get Default phantom BOM
ProdBOMLine.SETRANGE("Production BOM No.",ProdBOMHeader."No.");
IF ProdBOMLine.FINDLAST THEN BEGIN
ProdBOMLine."Production BOM No." := ProdBOMHeader."No.";
ProdBOMLine."Version Code" := '';
ProdBOMLine."Line No." := 50000;
ProdBOMLine.Type := ProdBOMLine.Type::"Production BOM";
ProdBOMLine.VALIDATE("No.",'DEFAULT');
ProdBOMLine.VALIDATE("Quantity per",1);
ProdBOMLine.INSERT(TRUE);
END;
ProdBOMLine.MODIFY;
ProdBOMHeader.Status := ProdBOMHeader.Status::Certified;
ProdBOMHeader.MODIFY;
END;
//Create new Production order using Recipe ID/Production BOM No. as key
//IF STRLEN(RecipeID) > 0 THEN BEGIN
//MESSAGE(RecipeID);
ProdOrder.SETRANGE("No.",AlternateBOM."Production BOM No.");
IF NOT ProdOrder.FIND THEN BEGIN
ProdOrder.INIT;
ProdOrder.VALIDATE("No.",AlternateBOM."Production BOM No.");
ProdOrder.Status := ProdOrder.Status::Released;
ProdOrder."Source Type" := ProdOrder."Source Type"::Item;
ProdOrder."Source No." := AlternateBOM."Item No.";
ProdOrder."Source Variant Code" := AlternateBOM."Variant Code";
ProdOrder.VALIDATE("Source No."); //populate other fields
ProdOrder.Description := OrderNo + ' ' + AlternateBOM."Production BOM No.";
ProdOrder.Quantity := AlternateBOM.Quantity;
ProdOrder."Due Date" := SalesHeader."Shipment Date";
IF ProdOrder."Due Date" = 0D THEN
ProdOrder."Due Date" := WORKDATE;
ProdOrder."Location Code" := '1';
ProdOrder."Bin Code" := 'CUSTOM';
MFGSetup.GET;
ProdOrder."Starting Time" := MFGSetup."Normal Starting Time";
ProdOrder."Ending Time" := MFGSetup."Normal Ending Time";
IF NOT ProdOrder.INSERT
THEN ProdOrder.MODIFY;
END;
END;
答案 0 :(得分:0)
如果 NAV 2009 R2 并且您使用 XMLPort 我可以想象它在这种情况下使用 RTC客户端可能不会很好地恢复对象 RTC客户端。
因此,如果您重新启动de NAV服务,然后尝试运行此 XMLport 工作正常。