how can i make a faster report on items sales transfer?

I want a items sales and transfer report. it is based on Item
Sales Line
Sales Invoice Line
Transfer line
Transfer shipment line.

Report will be filter by location code and date.

Report output will be as like following:

Item No---------------- Quantity---------------------Type

item code----------------total quanatity-------------sales/purchase

I add item table as a data item. but it loops all item and it is very slow.

how can i make it?

OBJECT Report 50008 Item Sales and Transfer
{
OBJECT-PROPERTIES
{
Date=13.12.11;
Time=14:23:06;
Modified=Yes;
Version List=Monir;
}
PROPERTIES
{
}
DATAITEMS
{
{ PROPERTIES
{
DataItemTable=Table27;
DataItemTableView=SORTING(No.);
OnPreDataItem=BEGIN
Slno:=0;

//Window.OPEN( Text001 + ‘@1@@@@@@@@@@@@@@@@@@@@@’);
//window.OPEN(’#1################### @2@@@@@@@@@@@@@’);
//window.OPEN(’@1@@@@@@@@@@’);
window.OPEN(’@1@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@’,intProgress);
timProgress := TIME;
//window.UPDATE(1,0);
END;

OnAfterGetRecord=BEGIN

Item.RESET;

LineCount:=LineCount+1;
NoOfRecords:=Item.COUNT;

IF timProgress < TIME - 1000 THEN BEGIN // every second
timProgress := TIME;
intProgress := ROUND( LineCount/ NoOfRecords * 10000,1);
window.UPDATE;
END;

// ItemLedgerEntry.RESET;
// ItemLedgerEntry.SETFILTER(ItemLedgerEntry.“Location Code”,LocationCode);
// ItemLedgerEntry.SETRANGE(ItemLedgerEntry.Positive, TRUE);
// ItemLedgerEntry.SETRANGE( ItemLedgerEntry.Open,TRUE);

// IF ((startdate <> 0D ) AND( enddate <>0D)) THEN BEGIN
// ItemLedgerEntry.SETRANGE(“Posting Date”,startdate,enddate);

// END;

// ItemLedgerEntry.SETRANGE(“Item No.”,Item.“No.”) ;

itemno:=Item.“No.”;
SLquantity:=0;
TRquantity:=0;
totalquantity:=0;

//IF ItemLedgerEntry.FIND(’-’) THEN BEGIN
“Sales Line”.RESET;
“Sales Line”.SETFILTER(“Location Code”,LocationCode);
“Sales Line”.SETRANGE(“Shipment Date”,startdate,enddate);

“Sales Line”.SETRANGE(“No.”,itemno) ;

WITH “Sales Line” DO BEGIN

IF “Sales Line”.FIND(’-’) THEN BEGIN

REPEAT

SLquantity:=SLquantity+“Sales Line”.Quantity;

UNTIL “Sales Line”.NEXT<=0;
END;

END;

SalesInvoiceLine.RESET;
SalesInvoiceLine.SETFILTER(“Location Code”,LocationCode);
SalesInvoiceLine.SETRANGE(“Posting Date”,startdate,enddate);
SalesInvoiceLine.SETRANGE(“No.”,itemno) ;
WITH SalesInvoiceLine DO BEGIN

IF SalesInvoiceLine.FIND(’-’) THEN BEGIN

REPEAT

SLquantity:=SLquantity+SalesInvoiceLine.Quantity;

UNTIL SalesInvoiceLine.NEXT<=0;
END;

END;
TLine.RESET;
TLine.SETFILTER(“Transfer-from Code”,LocationCode);

TLine.SETRANGE(“Shipment Date”,startdate,enddate);

TLine.SETRANGE(“Item No.” ,itemno) ;

//////////////
WITH TLine DO BEGIN

IF TLine.FIND(’-’) THEN BEGIN

REPEAT

TRquantity:=TRquantity+TLine.Quantity;

UNTIL TLine.NEXT<=0;
END;

END;

TSLine.RESET;
TSLine.SETFILTER(“Transfer-from Code”,LocationCode);
TSLine.SETRANGE(“Shipment Date”,startdate,enddate);
TSLine.SETRANGE(“Item No.” ,itemno) ;

WITH TSLine DO BEGIN

IF TSLine.FIND(’-’) THEN BEGIN

REPEAT

TRquantity:=TRquantity+ TSLine.Quantity;

UNTIL TSLine.NEXT<=0;
END;

END;

//END;

/////////

IF ((SLquantity>0) OR (TRquantity>0)) THEN BEGIN
Slno:= Slno+1;
itemno:= Item.“No.”;

totalquantity:= SLquantity+ TRquantity ;
Description:=Item.Description;

IF( TRquantity>0) THEN BEGIN
type:=‘Transfer’;
END ELSE
type:=‘Sales’;

END;

END;

OnPostDataItem=BEGIN
window.CLOSE;
END;

}
SECTIONS
{
{ PROPERTIES
{
SectionType=Header;
SectionWidth=22050;
SectionHeight=1692;
}
CONTROLS
{
{ 1000000005;Label ;11850;1269 ;4050 ;423 ;CaptionML=ENU=Quantity }
{ 1000000000;Label ;2250 ;1269 ;3150 ;423 ;CaptionML=ENU=Item Description }
{ 1000000002;Label ;6300 ;1269 ;4800 ;423 ;CaptionML=ENU=Item No }
{ 1000000006;Label ;17100;1269 ;2850 ;423 ;CaptionML=ENU=Type }
{ 1000000008;Label ;150 ;1269 ;1800 ;423 ;CaptionML=ENU=SL# }
}
}
{ PROPERTIES
{
SectionType=Body;
SectionWidth=22050;
SectionHeight=1269;
OnPreSection=BEGIN
//
END;

OnPostSection=BEGIN
CurrReport.SHOWOUTPUT(totalquantity > 0);
END;

}
CONTROLS
{
{ 1000000001;TextBox;2250 ;0 ;3150 ;423 ;HorzAlign=Left;
SourceExpr=Description }
{ 1000000003;TextBox;6300 ;0 ;4800 ;423 ;HorzAlign=Left;
SourceExpr=itemno }
{ 1000000004;TextBox;11850;0 ;4200 ;423 ;HorzAlign=Left;
SourceExpr=totalquantity }
{ 1000000007;TextBox;17100;0 ;2850 ;423 ;HorzAlign=Left;
SourceExpr=type }
{ 1000000009;TextBox;150 ;0 ;1800 ;423 ;HorzAlign=Left;
SourceExpr=Slno }
}
}
}
}
}
REQUESTFORM
{
PROPERTIES
{
Width=13750;
Height=4950;
OnOpenForm=BEGIN
IF ((startdate=0D) AND (enddate=0D)) THEN BEGIN
startdate:= WORKDATE;
enddate:= WORKDATE;
END;

LocationCode:=‘CHEMISAXLI’;
END;

}
CONTROLS
{
{ 1000000000;TextBox;5280 ;770 ;4510 ;440 ;Editable=No;
InPage=-1;
CaptionML=ENU=Location;
SourceExpr=LocationCode }
{ 1000000001;Label ;1870 ;770 ;3300 ;440 ;ParentControl=1000000000 }
{ 1000000002;Label ;1870 ;1430 ;3300 ;440 ;InPage=-1;
CaptionML=ENU=Start Date }
{ 1000000003;TextBox;5280 ;1430 ;4510 ;440 ;SourceExpr=startdate }
{ 1000000004;Label ;1870 ;2090 ;3300 ;440 ;InPage=-1;
CaptionML=ENU=End Date }
{ 1000000005;TextBox;5280 ;2090 ;4510 ;440 ;SourceExpr=enddate }
}
}
REQUESTPAGE
{
PROPERTIES
{
}
CONTROLS
{
}
}
CODE
{
VAR
Slno@1000000000 : BigInteger;
LocationCode@1000000001 : Code[10];
ErrorText@1000000003 : Text[250];
ItemLedgerEntry@1000000004 : Record 32;
totalquantity@1000000005 : BigInteger;
itemno@1000000006 : Code[20];
description@1000000007 : Text[30];
SLquantity@1000000008 : BigInteger;
ledgeritemno@1000000009 : Code[20];
“Sales Line”@1000000010 : Record 37;
SalesInvoiceLine@1000000011 : Record 113;
TRquantity@1000000012 : Integer;
TLine@1000000013 : Record 5741;
TSLine@1000000014 : Record 5745;
PWSH@1000000015 : Record 7322;
type@1000000016 : Text[30];
LineCount@1000000017 : BigInteger;
NoOfRecords@1000000018 : BigInteger;
window@1000000019 : Dialog;
timProgress@1000000020 : Time;
intProgress@1000000021 : Integer;
star

Remove Windows.update from report

Create keys on table u r using.

Which db are you using ? Native or SQL ?

There are many aspect like HW and size of db’s table; but if you are using SQL, probably you can get a nice speed-up creating a dedicated view and then a report just to make some data filters and display.

Bye

Can you start by posting a better description of the report you are trying to create? The code you have posted makes no sense based on the short description you’ve posted.

Report Request form:

Location code:===
Start date===
End date=====

Report Data Item: Item table


Record variable: sales line table, sales invoice line, Transfer line, Transfer shipment line.

I add this table as a record varaible for retrieving total quantity of items sales and transfer.

Report outlook:

Serial---------Item Description----------Item No---------Quantity---------------Type
1---------------Parki patara -------------0000---------------99-----------------------Transfer
2-------------sasachuqre------------------0013-500--------1-------------------------Purchase