web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

SetFilter function is not working correctly in below code

(0) ShareShare
ReportReport
Posted on by

Dear All,
Below code  is written for checking whether any excess consumption is existing or not.

Code which is shown as bold is not working successfully.Any mistake in that code.If yes, plz help me to correct it.

Hopefully waiting for support.

Thanks & Regards,

Team.

RecWOLines.SETRANGE(RecWOLines.Status,RecProdOrder.Status);
RecWOLines.SETRANGE(RecWOLines."Prod. Order No.",RecProdOrder."No.");
IF RecWOLines.FIND('-') THEN
    RemQty := RecWOLines."Remaining Qty. (Base)";

RecWoComponents.RESET;
RecWoComponents.SETCURRENTKEY(RecWoComponents.Status,RecWoComponents."Prod. Order No.",
RecWoComponents."Prod. Order Line No.", RecWoComponents."Line No.");
RecWoComponents.SETRANGE(RecWoComponents.Status,RecProdOrder.Status);
RecWoComponents.SETRANGE(RecWoComponents."Prod. Order No.",RecProdOrder."No.");
RecWoComponents.SETFILTER(RecWoComponents."Quantity per",'<>%1',0);
IF RecWoComponents.FINDSET THEN
RecWoComponents.SETFILTER(RecWoComponents."Remaining Qty. (Base)",'>%1',
(RecWoComponents."Quantity per"*RemQty));
//the above code is not working .
test1 := RecWoComponents.COUNT; IF (RecWoComponents.COUNT > 0) THEN IF RecWoComponents.FINDFIRST THEN BEGIN IF CONFIRM(Text018) THEN frmRel_prodOrd.show_retn_comp(RecProdOrder."No.");//codeunit calling for displaying excess material END;


*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    I didnt understand why did you add SETFILTER code below FINDSET and there is no FINDSET after the SETFILTER.

  • Community Member Profile Picture
    on at

    I added findset because after doing Setfilter if we are checking the count it is not coming as nil though no lines existing.

    That is why i added  'RecWoComponents.COUNT' .

    Plz help .

  • Suggested answer
    Mohana Yadav Profile Picture
    61,005 Super User 2025 Season 2 on at

    It means there is no record with those filters before findset.

    1.can you comment the bold code and check whether it is working?

    2. Add a variable and calculate RecWoComponents."Quantity per"*RemQty before and check whether you have right value.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,245 Super User 2025 Season 2 on at

    You don't need FINDSET to get the count and in the SETFILTER you cannot usse RecWoComponents. Quantity Per

    Try below code

    RecWOLines.SETRANGE(RecWOLines.Status,RecProdOrder.Status);

    RecWOLines.SETRANGE(RecWOLines."Prod. Order No.",RecProdOrder."No.");

    IF RecWOLines.FIND('-') THEN

       RemQty := RecWOLines."Remaining Qty. (Base)";

    RecWoComponents.RESET;

    RecWoComponents.SETCURRENTKEY(RecWoComponents.Status,RecWoComponents."Prod. Order No.",

    RecWoComponents."Prod. Order Line No.", RecWoComponents."Line No.");

    RecWoComponents.SETRANGE(RecWoComponents.Status,RecProdOrder.Status);

    RecWoComponents.SETRANGE(RecWoComponents."Prod. Order No.",RecProdOrder."No.");

    RecWoComponents.SETFILTER(RecWoComponents."Quantity per",'<>%1',0);

    RecWoComponents.SETFILTER(RecWoComponents."Remaining Qty. (Base)",'>%1',

                                                                                   (1*RemQty));

    //the above code is not working .

    test1 := RecWoComponents.COUNT;

    IF (RecWoComponents.COUNT > 0) THEN

    IF RecWoComponents.FINDFIRST THEN

    BEGIN

    IF CONFIRM(Text018) THEN

    frmRel_prodOrd.show_retn_comp(RecProdOrder."No.");//codeunit calling for displaying  excess material

    END;

  • Community Member Profile Picture
    on at

    I applied the above code and now also not working.

    Plz help.

  • Suggested answer
    Rajasekhar@MS Profile Picture
    5,569 on at

    Hi

    Instead of applying Set filter, check the condition using if, after you find the RecWoComponents like below.

    RecWoComponents.RESET;

    RecWoComponents.SETCURRENTKEY(RecWoComponents.Status,RecWoComponents."Prod. Order No.",

    RecWoComponents."Prod. Order Line No.", RecWoComponents."Line No.");

    RecWoComponents.SETRANGE(RecWoComponents.Status,RecProdOrder.Status);

    RecWoComponents.SETRANGE(RecWoComponents."Prod. Order No.",RecProdOrder."No.");

    RecWoComponents.SETFILTER(RecWoComponents."Quantity per",'<>%1',0);

    IF RecWoComponents.FINDSET THEN Repeat

    IF RecWoComponents."Remaining Qty. (Base)" > (RecWoComponents."Quantityper"*RemQty) THEN

    // call cu;

    until RecWoComponents.next = 0;

  • Suggested answer
    Yogesh Kulkarni_ Profile Picture
    1,762 on at

    Try Below Code:

    RecWOLines.SETRANGE(RecWOLines.Status,RecProdOrder.Status);

    RecWOLines.SETRANGE(RecWOLines."Prod. Order No.",RecProdOrder."No.");

    IF RecWOLines.FIND('-') THEN

       RemQty := RecWOLines."Remaining Qty. (Base)";

    IF (RemQty > 0) THEN BEGIN

     RecWoComponents.RESET;

     RecWoComponents.SETCURRENTKEY(RecWoComponents.Status,RecWoComponents."Prod. Order No.",

     RecWoComponents."Prod. Order Line No.", RecWoComponents."Line No.");

     RecWoComponents.SETRANGE(RecWoComponents.Status,RecProdOrder.Status);

     RecWoComponents.SETRANGE(RecWoComponents."Prod. Order No.",RecProdOrder."No.");

     RecWoComponents.SETFILTER(RecWoComponents."Quantity per",'<>%1',0);

     RecWoComponents.SETFILTER(RecWoComponents."Remaining Qty. (Base)",'>%1',

                                                                                   (RecWoComponents."Quantity per"*RemQty));

     IF (RecWoComponents.COUNT > 0) THEN

     IF RecWoComponents.FINDFIRST THEN

     BEGIN

     IF CONFIRM(Text018) THEN

    //Call your codeunit

     END;

    END;

    Regards,

    Yogesh Kulkarni

    Please verify the answer, if it helps to resolve your issue.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans