SETCURRENTKEY Problems

AlkroAlkro Member Posts: 115
I have readed old posts, but i don't find a solve...

This code:
TempILE --> Record - Item Ledger Entry
TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
IF TempILE.FIND('-') THEN BEGIN
.......
.......

With this code, in TempILE, i have 134 records...

But when i add this:
TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
IF TempILE.FIND('-') THEN BEGIN
   TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type");
I only have 72 records...

Why? How can i apply filters with a secondary key, and then change to another key.

BR

Answers

  • SogSog Member Posts: 1,023
    You could copy the records in a new temporary table, and change the key.
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • MalajloMalajlo Member Posts: 294
    No need for temp table. Just do FINDFIRST after changing key.
  • AlkroAlkro Member Posts: 115
    Malajlo wrote:
    No need for temp table. Just do FINDFIRST after changing key.
    But Report is tooooooooo slow.

    For 5 days data, report is thinking about 2-3 minutes.
    TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
    TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
    TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
    TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
    TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type");
    IF TempILE.FINDFIRST THEN BEGIN
    .....
    

    :(
  • MBergerMBerger Member Posts: 413
    Alkro wrote:
    Malajlo wrote:
    No need for temp table. Just do FINDFIRST after changing key.
    But Report is tooooooooo slow.

    For 5 days data, report is thinking about 2-3 minutes.
    TempILE.SETCURRENTKEY("Entry Type","Item No.","Variant Code","Source Type","Source No.","Posting Date");
    TempILE.SETRANGE(TempILE."Entry Type",TempILE."Entry Type"::Output);
    TempILE.SETFILTER(TempILE."Source No.",ItemFilter);
    TempILE.SETRANGE(TempILE."Posting Date",StartDate,EndDate);
    TempILE.SETCURRENTKEY("Prod. Order No.","Prod. Order Line No.","Prod. Order Comp. Line No.","Entry Type");
    IF TempILE.FINDFIRST THEN BEGIN
    .....
    
    :(
    Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.
  • AlkroAlkro Member Posts: 115
    MBerger wrote:
    Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.
    :(
    :S

    But, how can i apply filters with a key an then order with another key and the report not very slow????...
  • MBergerMBerger Member Posts: 413
    Alkro wrote:
    MBerger wrote:
    Remember that it doesn't matter in which order you put the SetRange and Setcurrentkey lines...the corresponding query will be built when you ask the DB for your records ( with a find or findfirst ), so in the above example the first setcurrentkey is totally wasted.
    :(
    :S

    But, how can i apply filters with a key an then order with another key and the report not very slow????...
    The only viable way is to make a key that's usable for both ! which in your case would be :
    Entry type, Source No., Posting Date, Prod. Order No. , Prod. Order Line No. , Prod. Order Comp. Line No.
  • AlkroAlkro Member Posts: 115
    Problem is i want sort about "Prod. Order No.", and can have many Outputs in different dates.

    Solved with copy all filtered records (Only "Prod. Order No.") to a own table with a temporary record and then this record order by "Prod. Order".

    Thanks!
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Alkro, did you bother to read the very first reply to your question #-o
    Sog wrote:
    You could copy the records in a new temporary table, and change the key.
    David Singleton
  • AlkroAlkro Member Posts: 115
    Alkro, did you bother to read the very first reply to your question #-o
    Is the problem when anybody has many windows opened in Navigator...

    Excuse me (Sog)
    :(
Sign In or Register to comment.