Hi
I have below data . With the below code Last Record Data not getting
Date Location Amount 04/01/2017 XYZ 6500 04/01/2017 XYZ 1 04/01/2017 XYZ 17500 06/01/2017 XYZ 16000 08/01/2017 XYZ 19306 09/01/2017 XYZ 88000 TEntry.RESET; TEntry.SETCURRENTKEY("Location No.",Date); TEntry.SETFILTER("Store No.","No."); TEntry.SETRANGE(TEntry.Date,StDate,EndDate); IF TEntry.FINDFIRST THEN BEGIN TempDate := TEntry.Date; Amount := 0; REPEAT IF TEntry.Date <> TempDate THEN BEGIN CDLine.INIT; CDLine.VALIDATE("Location No.","No."); CDLine.VALIDATE("Date",TempDate); CDLine.VALIDATE("Amount",Amount); CDLine.INSERT; TempDate := TEntry.Date; Amount := 0; END; Amount += TEntry."Amount"; UNTIL TEntry.NEXT=0; END;
*This post is locked for comments
Hi,
In this you need to keep a track of entries that are already taken into the CDline table by putting a binary field say entry_created in SalesLineTable.
Now, use the following code
SalesLineTable.RESET;
SalesLineTable.SETRANGE(entry_created,FALSE);
If SalesLineTable.FINDFIRST THEN
REPEAT
CDline.RESET;
CDline.SETRANGE(Date,SalesLineTable.PostingDate);
CDline.SETRANGE(Location,SalesLineTable.Location);
IF CDline.FINDFIRST THEN BEGIN
CDline.Amount := CDline.Amount + SalesLineTable.Amount;
CDline.MODIFY;
SalesLineTable.entry_created := TRUE;
SalesLineTable.MODIFY;
END
ELSE BEGIN
CDline.INIT;
CDline.Date := SalesLineTable.PostingDate;
CDline.Amount := SalesLineTable.Amount;
CDline.Location := SalesLineTable.Location;
CDline.INSERT;
SalesLineTable.entry_created := TRUE;
SalesLineTable.MODIFY;
END;
UNTIL SalesLineTable.NEXT = 0;
Hi
I have below Data say in Sales Line table.
Posting Date Location Amount
04/01/2017 XYZ 6500
04/01/2017 XYZ 1
04/01/2017 XYZ 17500
06/01/2017 XYZ 16000
08/01/2017 XYZ 19306
09/01/2017 XYZ 88000
In Custom table i want that data should be inserted like this means grouping by Date & Location.
04/01/2017 XYZ 24001
06/01/2017 XYZ 16000
08/01/2017 XYZ 19306
09/01/2017 XYZ 88000
Hi jsshivalik,
Could you be more specific more in terms of what you exactly want to do? If possible give some example.
As I have mentioned I am assuming those three as the Primary Key, if that is not your case then you just need to use the MODIFY statement.
RENAME function is used to modify the Value in the Primary Key Field.
Hi
What does this line does
CDLine.RENAME(TEntry.Date,TEntry."Location code",TEntry.Amount + CDLine.Amount);
Thanks
You might have to do something like this, in this I am assuming both tables has date, location code and Amount as the Primary Key.
TEntry.RESET;
TEntry.SETCURRENTKEY("Location code",Date);
TEntry.SETRANGE(TEntry.Date,010117D,123117D);
IF TEntry.FINDFIRST THEN BEGIN
First := TRUE;
REPEAT
IF First OR (TEntry.Date <> OldDate) OR (TEntry."Location code" <> OldLocationCode) THEN BEGIN
CDLine.INIT;
CDLine.VALIDATE("Location code",TEntry."Location code");
CDLine.VALIDATE(Date,TEntry.Date);
CDLine.VALIDATE(Amount,TEntry.Amount);
CDLine.INSERT;
END ELSE BEGIN
CDLine.RENAME(TEntry.Date,TEntry."Location code",TEntry.Amount + CDLine.Amount);
END;
First := FALSE;
OldLocationCode := TEntry."Location code";
OldDate := TEntry.Date;
UNTIL TEntry.NEXT=0;
END;
what is the store no. ? you are not storing Location code in the CDLine table
Yes. Wht is the issue in my code.
Are you trying to store the values in the CDline table group by location and Date.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156