How to Do this ?

navuser1navuser1 Member Posts: 1,329
Hi all,

I’m working in Nav 5.0 Sp1 (native).
We always use SETFILTER or SETRANGE to filter actual data we want. But if we can’t find
the actual data than how can we get the set of approximately same data.


Scenario

I just want to filter the Set of data 99…100
Asking value is 99.99

Table Data

99
100
120
Now or Never

Comments

  • kapamaroukapamarou Member Posts: 1,152
    Do you mean SETRANGE(MyField,90,100) or
    SETFILTER(MyField,'%1..%2',90,100) :?: :?:
  • jlandeenjlandeen Member Posts: 524
    I don't think there is anything that allows you to find "close" or "like" records in Navision. You have to explicitly filter for ranges or sets of data that you need.

    I haven't seen to many cases of where you would need to approximate something like that. Is there a specific requirement that you're trying to meet?
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • navuser1navuser1 Member Posts: 1,329
    kapamarou wrote:
    Do you mean SETRANGE(MyField,90,100) or
    SETFILTER(MyField,'%1..%2',90,100) :?: :?:


    Dear kapamarou,

    Thanks for your quick reply.

    This is hard coding. :mrgreen:
    My Scenario is an example :-$

    I think I have to write extra code for the goal.
    Now or Never
  • navuser1navuser1 Member Posts: 1,329
    jlandeen wrote:
    I don't think there is anything that allows you to find "close" or "like" records in Navision. You have to explicitly filter for ranges or sets of data that you need.

    I haven't seen to many cases of where you would need to approximate something like that. Is there a specific requirement that you're trying to meet?


    I agree with jlandeen. =;
    Thanks for your reply.
    Now or Never
  • garakgarak Member Posts: 3,263
    Do you mean this?

    DECField
    90,00
    91,00
    94,00
    95,50
    98,00
    98,50
    99,00
    99,56
    99,60
    99,87
    99,98
    106,00
    120,00
    filtergroup(2);
    setfilter(decField,'%1..%2',90,100);
    filtergroup(0);
    
    setfilter(decField,'>=%1|<=%1',99.99);
    
    if find('+') then;
    

    returns 99,98 because 99,99 is not found and 100 doesn't exist (in this example)

    Regards
    Do you make it right, it works too!
  • kapamaroukapamarou Member Posts: 1,152
    navuser1 wrote:
    This is hard coding. :mrgreen:

    How About this?

    MyRec.SETRANGE(MyField,TargetValue,TargetValue);
    IF MyRec.ISEMPTY THEN
    MyRec.SETRANGE(MyField,MyValue * (1 - MyTolerance / 100),MyValue * (1 + MyTolerance / 100) )

    Keep MyTolerance in a setup table and you can use it. you could also put this code in a loop and increase your range until you find records. It does require some code but I think it could help...
  • navuser1navuser1 Member Posts: 1,329
    garak wrote:
    Do you mean this?

    DECField
    90,00
    91,00
    94,00
    95,50
    98,00
    98,50
    99,00
    99,56
    99,60
    99,87
    99,98
    106,00
    120,00
    filtergroup(2);
    setfilter(decField,'%1..%2',90,100);
    filtergroup(0);
    
    setfilter(decField,'>=%1|<=%1',99.99);
    
    if find('+') then;
    

    returns 99,98 because 99,99 is not found and 100 doesn't exist (in this example)

    Regards

    Thnx garak;

    SETRANGE (decField, 99.99);
    IF find(‘-‘) THEN
    begin
    Abc…;
    Xyz…;
    End
    Else
    begin
    Setfilter(decField,’<%1’,99.99);
    IF findfirst then
    Var1;
    Setfilter(decField,’>%1’,99.99);
    IF findfirst then
    Var2;
    Setfilter(decField, Var1, Var2);
    If find(‘-‘) then
    Abc;
    Xyz;
    End;
    Now or Never
Sign In or Register to comment.