AXForum  
Вернуться   AXForum > Microsoft Dynamics NAV > NAV: Программирование
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.09.2008, 13:54   #1  
by_HT is offline
by_HT
Участник
 
195 / 10 (1) +
Регистрация: 12.10.2007
DataItem
Item <Item>
OnPreDataItem
code_1
OnAfterGetrecord
OnPostDataItem

Integer BOMLoop
OnPreDataItem
code_2
OnAfterGetrecord
code_3
OnPostDataItem

Integer <Integer>
OnPreDataItem
OnAfterGetrecord
code_4
OnPostDataItem
code_5


Код:
Item - OnPreDataItem()
ItemFilter := Item.GETFILTERS;

SETFILTER("Production BOM No.",'<>%1','');

Item - OnAfterGetRecord()

Item - OnPostDataItem()


Код:
BOMLoop - OnPreDataItem()
Level := 1;
ProdBOM.GET(Item."Production BOM No.");

VersionCode[Level] := VersionMgt.GetBOMVersion(Item."Production BOM No.","Calc.Date",FALSE);
CLEAR(BomComponent);
BomComponent[Level]."Production BOM No." := Item."Production BOM No.";
BomComponent[Level].SETRANGE("Production BOM No.",Item."Production BOM No.");
BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]);
BomComponent[Level].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
BomComponent[Level].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
NoList[Level] := Item."No.";
Quantity[Level] :=
  UOMMgt.GetQtyPerUnitOfMeasure(Item,Item."Base Unit of Measure") /
  UOMMgt.GetQtyPerUnitOfMeasure(
	Item,
	VersionMgt.GetBOMUnitOfMeasure(
	  Item."Production BOM No.",VersionCode[Level]));
UpperLevelItem := Item;

BOMLoop - OnAfterGetRecord()
MESSAGE('1');
WHILE BomComponent[Level].NEXT = 0 DO BEGIN
  Level := Level - 1;
  IF Level < 1 THEN
	CurrReport.BREAK;
  IF NOT UpperLevelItem.GET(NoList[Level]) THEN
	UpperLevelItem."Production BOM No." := NoList[Level];
  BomComponent[Level].SETRANGE("Production BOM No.",UpperLevelItem."Production BOM No.");
  BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]);
END;

NextLevel := Level;
CLEAR(CompItem);
QtyPerUnitOfMeasure := 1;
CASE BomComponent[Level].Type OF
  BomComponent[Level].Type::Item:
	BEGIN
	  CompItem.GET(BomComponent[Level]."No.");
	  IF CompItem."Production BOM No." <> '' THEN BEGIN
		NextLevel := Level + 1;
		CLEAR(BomComponent[NextLevel]);
		NoList[NextLevel] := CompItem."No.";
		VersionCode[NextLevel] :=
		  VersionMgt.GetBOMVersion(CompItem."Production BOM No.","Calc.Date",FALSE);
		BomComponent[NextLevel].SETRANGE("Production BOM No.",CompItem."Production BOM No.");
		BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]);
		BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
		BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
		QtyPerUnitOfMeasure :=
		  UOMMgt.GetQtyPerUnitOfMeasure(
			Item,
			Item."Base Unit of Measure") /
		  UOMMgt.GetQtyPerUnitOfMeasure(
			CompItem,
			VersionMgt.GetBOMUnitOfMeasure(
			  CompItem."Production BOM No.",VersionCode[NextLevel]));
	  END;
	  IF Level > 1 THEN BEGIN
		IF BomItem.GET(BomComponent[Level - 1]."No.") THEN BEGIN
		  QtyPerUnitOfMeasure :=
			UOMMgt.GetQtyPerUnitOfMeasure(BomItem,BomComponent[Level - 1]."Unit of Measure Code")
			/
			UOMMgt.GetQtyPerUnitOfMeasure(
			  BomItem,VersionMgt.GetBOMUnitOfMeasure(BomItem."Production BOM No.",VersionCode[Level]));
		END;
	  END;
	END;
  BomComponent[Level].Type::"Production BOM":
	BEGIN
	  ProdBOM.GET(BomComponent[Level]."No.");
	  NextLevel := Level + 1;
	  CLEAR(BomComponent[NextLevel]);
	  NoList[NextLevel] := ProdBOM."No.";
	  VersionCode[NextLevel] := VersionMgt.GetBOMVersion(ProdBOM."No.","Calc.Date",FALSE);
	  BomComponent[NextLevel].SETRANGE("Production BOM No.",NoList[NextLevel]);
	  BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]);
	  BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
	  BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
	END;
END;

IF NextLevel <> Level THEN
  Quantity[NextLevel] := BomComponent[NextLevel - 1].Quantity * QtyPerUnitOfMeasure * Quantity[Level];

BOMLoop - OnPostDataItem()

Код:
Integer - OnPreDataItem()

Integer - OnAfterGetRecord()
BOMQty := Quantity[Level] * QtyPerUnitOfMeasure * BomComponent[Level].Quantity;

Integer - OnPostDataItem()
Level := NextLevel;

IF CompItem."Production BOM No." <> '' THEN
  UpperLevelItem := CompItem;
я сделал так:

Код:
ItemPresents.COPY(Rec);
REPEAT
ItemPresents.SETFILTER("Production BOM No.",'<>%1','');
REPEAT
Level := 1;
ProdBOM.GET(ItemPresents."Production BOM No.");

VersionCode[Level] := VersionMgt.GetBOMVersion(ItemPresents."Production BOM No.","Calc.Date",FALSE);
CLEAR(BomComponent);
BomComponent[Level]."Production BOM No." := ItemPresents."Production BOM No.";
BomComponent[Level].SETRANGE("Production BOM No.",ItemPresents."Production BOM No.");
BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]);
BomComponent[Level].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
BomComponent[Level].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
NoList[Level] := ItemPresents."No.";
Quantity[Level] :=
  UOMMgt.GetQtyPerUnitOfMeasure(ItemPresents,ItemPresents."Base Unit of Measure") /
  UOMMgt.GetQtyPerUnitOfMeasure(
	ItemPresents,
	VersionMgt.GetBOMUnitOfMeasure(
	  ItemPresents."Production BOM No.",VersionCode[Level]));

UpperLevelItem := ItemPresents;


WHILE BomComponent[Level].NEXT = 0 DO BEGIN
  Level := Level - 1;
  IF Level < 1 THEN
	EXIT;
  IF NOT UpperLevelItem.GET(NoList[Level]) THEN
	UpperLevelItem."Production BOM No." := NoList[Level];
  BomComponent[Level].SETRANGE("Production BOM No.",UpperLevelItem."Production BOM No.");
  BomComponent[Level].SETRANGE("Version Code",VersionCode[Level]);
END;

NextLevel := Level;
CLEAR(CompItem);
QtyPerUnitOfMeasure := 1;
CASE BomComponent[Level].Type OF
  BomComponent[Level].Type::Item:
	BEGIN
	  CompItem.GET(BomComponent[Level]."No.");
	  IF CompItem."Production BOM No." <> '' THEN BEGIN
		NextLevel := Level + 1;
		CLEAR(BomComponent[NextLevel]);
		NoList[NextLevel] := CompItem."No.";
		VersionCode[NextLevel] :=
		  VersionMgt.GetBOMVersion(CompItem."Production BOM No.","Calc.Date",FALSE);
		BomComponent[NextLevel].SETRANGE("Production BOM No.",CompItem."Production BOM No.");
		BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]);
		BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
		BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
		QtyPerUnitOfMeasure :=
		  UOMMgt.GetQtyPerUnitOfMeasure(
			ItemPresents,
			ItemPresents."Base Unit of Measure") /
		  UOMMgt.GetQtyPerUnitOfMeasure(
			CompItem,
			VersionMgt.GetBOMUnitOfMeasure(
			  CompItem."Production BOM No.",VersionCode[NextLevel]));
	  END;
	  IF Level > 1 THEN BEGIN
		IF BomItem.GET(BomComponent[Level - 1]."No.") THEN BEGIN
		  QtyPerUnitOfMeasure :=
			UOMMgt.GetQtyPerUnitOfMeasure(BomItem,BomComponent[Level - 1]."Unit of Measure Code")
			/
			UOMMgt.GetQtyPerUnitOfMeasure(
			  BomItem,VersionMgt.GetBOMUnitOfMeasure(BomItem."Production BOM No.",VersionCode[Level]));
		END;
	  END;
	END;
  BomComponent[Level].Type::"Production BOM":
	BEGIN
	  ProdBOM.GET(BomComponent[Level]."No.");
	  NextLevel := Level + 1;
	  CLEAR(BomComponent[NextLevel]);
	  NoList[NextLevel] := ProdBOM."No.";
	  VersionCode[NextLevel] := VersionMgt.GetBOMVersion(ProdBOM."No.","Calc.Date",FALSE);
	  BomComponent[NextLevel].SETRANGE("Production BOM No.",NoList[NextLevel]);
	  BomComponent[NextLevel].SETRANGE("Version Code",VersionCode[NextLevel]);
	  BomComponent[NextLevel].SETFILTER("Starting Date",'%1|..%2',0D,"Calc.Date");
	  BomComponent[NextLevel].SETFILTER("Ending Date",'%1|%2..',0D,"Calc.Date");
	END;
END;

IF NextLevel <> Level THEN
  Quantity[NextLevel] := BomComponent[NextLevel - 1].Quantity * QtyPerUnitOfMeasure * Quantity[Level];

	REPEAT
BOMQty := Quantity[Level] * QtyPerUnitOfMeasure * BomComponent[Level].Quantity;
Level := NextLevel;
IF CompItem."Production BOM No." <> '' THEN
  UpperLevelItem := CompItem;

	UNTIL BomComponent[Level].NEXT =0;
 UNTIL BomComponent[Level].NEXT =0;
UNTIL ItemPresents.NEXT =0;
Ну он выдает только последнию строчку таблицы....
 


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 22:16.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.