Skip to main content

msdyn365bc Preprocessor Directives - Pragma Directives.

Hi Readers,

In the Introduction article of series we understand different types of Preprocessor  directives available in Business Central.

Preprocessor Directives are available starting Business Central 2020 Release Wave 2. 

You can read other articles in this series using this link.

In this article we will understand how to use Pragma Directives.

The #pragma directive gives the compiler special instructions for the compilation of the file in which it appears. 

The #pragma directive has a number of actions that can be used with the pragma instructions below, these are disable, restore, and enable.

AL supports the following pragma instructions:

  • Pragma Warning
  • Pragma ImplicitWith 

What Pragma Warning Does?

  • The #pragma warning instruction can enable or disable certain warnings. 
  • This can be used as a solution to avoid getting warnings. 
  • With the #pragma warning disable statement you disable the emit of the warning for a specific location in code, and with #pragma warning restore you restore the warning back to it's original state. 
  • If you do not restore, the disable instruction is valid for the rest of the file.

** It is important to be aware that most warnings are there for a reason, and suppressing them could lead to sudden impact if warnings are changed to errors, such as obsoletes.

How to Implement Pragma Warning Directives?

  • Global Implementation 
    • We have to use app.json file.
    • Parameter Name suppressWarnings.

    • Local Implementation
      • We can set that in any object using two directive. 
      • #pragma warning disable warning-list 
      • #pragma warning restore warning-list


    What Pragma ImplicitWith Does?

    How to Implement ImplicitWith?

    Hope you like this series. 

    If you have any questions, add as comments to this article.

    Regards,
    Saurav Dhyani
    www.sauravdhyani.com

    Comments

    Popular posts from this blog

    Welcome - Microsoft Dynamics 365!

    Hi All, In this article we will discuss the new introduced member of Dynamics Family. Yes you heard it correctly, one more new member with Name "Microsoft Dynamics 365" . #ProjectMadeira   #Dynamics365

    Send Mail with Attachment From Navision.

    Hi all, We have seen how to save a report into PDF and how to send mail to a customer. Let's link these two post in one i.e. Mailing statement to a customer into PDF Format. This article is part of the Series. Please Refer  Table of Content here . If you have the old objects set let me brief you what I will be changing - 

    NAV 2013 Credential Type - How to Use?

    Hi all, Please do these activities when you have time, its a long activity and i would suggest do all activities in one go. So be clam and lets start. For NAV 2013 R2 Refer Here. For NAV 2016 Steps have been Reduced Please Refer Here. I have installed NAV 2013 and its work great with my windows credentials. I was checking the service console (Microsoft Dynamics NAV Administration) in NAV 2013 and found out that Credentials Type have multiple Options.