Last version from a record list

I have a table with 3 records with the same Order no. and each one with a version nº, how can I get the record that have the last version?

Regards

you can sort it by version no and by using FINDLAST

In my report I have only one data Item = Table 5109.

I Created a New Key (No., Version No.)

Order my DataItem by this key and order ascending

On My
Purchase Header Archive - OnAfterGetRecord()

PurchaseHeaderArchive.SETCURRENTKEY(“No.”,“Version No.”);
IF PurchaseHeaderArchive.FINDLAST THEN

PurchaseHeaderArchive.GET(“No.”,"Version No.);

But this returns on error :frowning:

What is the need of above?

I need all recods from table 5109 with the last version of each Order No.

Thanks

Above will give you only one record, because GET works on primary key.

To get all records from 5109 with the last version only, what do you suggest?

Group 5109 with No. and in Group Footer use FindLast as above…

I think what they are saying is your code already finds the last record now what do you want to do with it?

IF PurchaseHeaderArchive.FINDLAST THEN
…Then What?
txtLastVerion := “Version No.”;

Lose This>>PurchaseHeaderArchive.GET(“No.”,"Version No.);

Like this IF PurchaseHeaderArchive.FINDLAST THEN

I get in my report all records for the same Purchase Order no., with all versions :(, and I need only the most recently version = last version

Thanks

Like this IF PurchaseHeaderArchive.FINDLAST THEN

I get in my report all records for the same Purchase Order no., with all versions :(, and I need only the most recently version = last version

Thanks

Did you try this?

I hope it will show only last version per Purchase Order no,.

Hy

I tried this
IF “Purchase Header Archive”.FINDLAST THEN;

Valor := “Purchase Header Archive”.Amount;

and only one record appears in my report, and value variable = 0 :frowning:

Thanks

Hello

JQPL allows one to get the MAX value of a field, e.g. “select max(o.id) from item o”. Although it does not return an item object, but the return max value can be used to retrieve the item.

JohnMiller

Payroll Software

Hello

JQPL allows one to get the MAX value of a field, e.g. “select max(o.id) from item o”. Although it does not return an item object, but the return max value can be used to retrieve the item.

JohnMiller

Payroll Software

As you said, you wull get only one recoed per Document No.

and also user

“Purchase Header Archive”.CALCFIELD(Amount);

before

Valor := “Purchase Header Archive”.Amount;

as Amount is a FlowField