Issue in Report

Hi,

I am designing a report using “Sales Invoice Header” table. The report displays the “Cost Amount (Actual)” field from the “Item Ledger Entry” table which is a record variable. The report is giving proper values if there is a single lot no. but if it is multiple lots then the report is giving the value for any one lot. The “Prod. Order No.” for each lot differs. Have shown the following code in the body part of “Sales Invoice Header”.

recILE.RESET;
recILE.SETRANGE(recILE.“Document No.”,“Sales Invoice Line”.“Shipment No.”);
recILE.SETRANGE(recILE.“Item No.”,“Sales Invoice Line”.“No.”);
IF recILE.FINDFIRST THEN
LotNo := recILE.“Lot No.”;

recILE1.RESET;
recILE1.SETRANGE(recILE1.“Lot No.”,recILE.“Lot No.”);
recILE1.SETFILTER(recILE1.“Entry Type”,‘Output’);
IF recILE1.FINDFIRST THEN
RPONo := recILE1.“Prod. Order No.”;

CBQty :=0;
recILEntry.RESET;
recILEntry.SETRANGE(recILEntry.“Source No.”,“Sales Invoice Line”.“No.”);
recILEntry.SETRANGE(recILEntry.“Prod. Order No.”,recILE1.“Prod. Order No.”);
recILEntry.SETFILTER(recILEntry.“Entry Type”,‘Consumption’);
recILEntry.SETFILTER(recILEntry.“Item Category Code”,’%1|%2’,‘CB’,‘MB’);
IF recILEntry.FINDFIRST THEN
REPEAT
recILEntry.CALCFIELDS(“Cost Amount (Actual)”);
CBQty += recILEntry.“Cost Amount (Actual)”;
UNTIL recILEntry.NEXT=0;

How do I modify the code that it has to complete the whole cycle for one lot and again it has to go for the second lot with the same cycle? Can anyone help me out with this pls…

Thanks in advance…

hi Dywashree ,

What I dont see is how do you get from SIH to its lines . But we wont write a code for you . If you put pseudo code we can point out logical issues.

g.

I am sorry… Mistake by over sight. The report is designed using “sales Invoice Line” table itself.

I dont think this logic will work…

What if you have same item in line no 10000 and 30000?

It will pick up 10000 Item everytime…

You need to rethink of your logic…

Hi Mohan,

Ya… but for that issue I can SETRANGE “Document Line No.” of ILE with “Shipment Line No.” of SIL. But my issue is how to go on with the second lot.

You can try by REPEATing recILE instead of FINDFIRST…

Ok… Your asking to use REPEAT UNTILL right? But without FINDFIRST?

Use like below

IF recILE.find(’-’) then

begin

repeat

// Here you place youother coding so that the loop will continue till the lst lot No.

until recILE.next = 0

End;

Hi Marshal,

I tried with the code u said, but still its showing the value of only the first lot itself :frowning:

IF recILE.findSET then

repeat

// Here you place youother coding so that the loop will continue till the lst lot No.

// Close it at the end…

until recILE.next = 0

Hi Divya;

have you tried like this ??

recILE.RESET;
recILE.SETRANGE(recILE.“Document No.”,“Sales Invoice Line”.“Shipment No.”);
recILE.SETRANGE(recILE.“Item No.”,“Sales Invoice Line”.“No.”);
IF recILE.FIND(‘-’) THEN
begin
repeat
recILE1.RESET;
recILE1.SETRANGE(recILE1.“Lot No.”,recILE.“Lot No.”);
recILE1.SETFILTER(recILE1.“Entry Type”,‘Output’);
IF recILE1.FIND(‘-’) THEN
Begin
repeat
recILEntry.RESET;
recILEntry.SETRANGE(recILEntry.“Source No.”,“Sales Invoice Line”.“No.”);
recILEntry.SETRANGE(recILEntry.“Prod. Order No.”,recILE1.“Prod. Order No.”);
recILEntry.SETFILTER(recILEntry.“Entry Type”,‘Consumption’);
recILEntry.SETFILTER(recILEntry.“Item Category Code”,’%1|%2’,‘CB’,‘MB’);
IF recILEntry.FINDFIRST THEN
REPEAT
recILEntry.CALCFIELDS(“Cost Amount (Actual)”);
CBQty += recILEntry.“Cost Amount (Actual)”;
UNTIL recILEntry.NEXT=0;

until recILE1.next = 0;
end;
CBQty :=0;
until recILE.Next = 0;
End;

Thanks

Marshal. J

Thanks fa the reply… its working :slight_smile:

Welcome [:)]