Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

C/al code for report

Posted on by 950

Hi,
Refer to the attach pic and I want to have the sum of column 'Quantity' where Type = Resource and for Order No where Customer Group Code = GARANTIE.  Hence, I only want the Order NO where Customer Group Code = GARANTIE and to add the qty where Type = Resource

Please note that where type = Resource, Customer Group Code is blank.

Any idea how to do the above in C/AL CODE?

Thanks for your response

SLE.png

*This post is locked for comments

  • Suggested answer
    Rajasekhar@MS Profile Picture
    Rajasekhar@MS 5,567 on at
    RE: C/al code for report

    Try with If statement like

    If Type = Resource Then variableQuantity += respectivetable.Quantity;

  • Mosaheb Profile Picture
    Mosaheb 950 on at
    RE: C/al code for report

    Thanks Mahesh, but if I do a SETRANGE("Customer Group Code",'GARANTIE') Then I will not get the Type:Resource because for such record the Customer Group Code is blank.

    In fact, the common element between Type: Resource and Customer Group Code= GARANTIE is the ORDER NO

  • mmv Profile Picture
    mmv 11,465 on at
    RE: C/al code for report

    Hi

    You may write the code:-

    respectivetable.RESET;

    respectivetable.SETRANGE("Customer Group Code",'GARANTIE');

    respectivetable.SETRANGE(Type,respectivetable.Type::Resource);

    IF respectivetable.FINDSET THEN REPEAT

      variableQuantity += respectivetable.Quantity;

    UNTIL respectivetable.NEXT = 0;

    Otherwise if you have a key containing above fields, you may write as below (you may avoid the repeat statement):

    respectivetable.RESET;

    respectivetable.SETCURRENTKEY("Customer Group Code",Type);

    respectivetable.SETRANGE("Customer Group Code",'GARANTIE');

    respectivetable.SETRANGE(Type,respectivetable.Type::Resource);

    respectivetable.CALCSUMS(Quantity);

    variableQuantity := respectivetable.Quantity;

  • Mosaheb Profile Picture
    Mosaheb 950 on at
    RE: C/al code for report

    Thanks Rajasekhar for the reply.  In fact, I want all Order No where Customer Group Code = Garantie so that to sum Qty where Type = Resource.  Feel free to inform for any clarifications

  • Rajasekhar@MS Profile Picture
    Rajasekhar@MS 5,567 on at
    RE: C/al code for report

    Hi

    Type :: Resource - If customer Group code is blank in all the records then you will not get any records to add, the sum will be always zero, isn't it, or can you provide us details

    Regards

    Rajasekhar.Y

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans