Book Image

Programming Microsoft Dynamics NAV 2009

Book Image

Programming Microsoft Dynamics NAV 2009

Overview of this book

Microsoft Dynamics NAV is a well established Enterprise Resource Planning (ERP) application, part of the Microsoft Dynamics family. Dynamics NAV is installed worldwide, with well over one million users. Version 2009 contains many major new features and structures, requiring even experienced Dynamics NAV developers to refresh their NAV development knowledge. Renowned for its challenging learning curve, Dynamics NAV is a complex piece of software with a unique design structure. For developers learning to modify or enhance Dynamics NAV for vital business purposes, the task can sometimes be intimidating. This book is an in-depth step-by-step guide to programming NAV, designed to ease you through the complexities of NAV application development. You will learn the skills and develop the confidence to tackle your own critical NAV applications. This book will act as your experienced NAV programming mentor, helping you to become productive as a NAV developer much more quickly. NAV development is quite complex, with a steep learning curve. This book makes it easy for you. From basic NAV terminology and concept definitions, through the essential building blocks of NAV data structure and objects, you will gain an understanding of the fundamental underlying concepts of NAV. You will learn practical details about NAV object construction and the tools available, including table, page, and report design. You will learn how to use NAV's tools to effectively navigate through the various features of objects, including properties, triggers, and C/AL code, and receive practical guidance on ways to develop and test in the unique NAV C/SIDE development environment. Extensive guidance on software design for NAV is provided along with tips for efficient design of new NAV applications or enhancing existing applications. With its comprehensive collection of NAV information and distillation of years of NAV development experience, this book is not only designed to help you learn, but to act as a reference as well.
Table of Contents (18 chapters)
Programming Microsoft® Dynamics™ NAV 2009
Credits
About the Author
Acknowledgement
About the Reviewers
Foreword
Preface
Index

Preface

To exist is to change, to change is to mature, to mature is to go on creating oneself endlessly—Henri Bergson

By choosing to study C/AL and C/SIDE for NAV 2009, you are once again choosing to embrace change. The knowledge you gain here about these tools can be applied for your and others' benefit. The information in this book will shorten your learning curve on how to program for the NAV 2009 ERP system using the C/AL language, the C/SIDE integrated development environment, and all the new capabilities therein.

By embarking on the study of NAV and C/AL, you are joining a high-quality, worldwide group of experienced developers. There is a collegial community of C/AL developers on the Web who readily and frequently share their knowledge. There are formal and informal organizations of NAV-focused users, developers, and vendor firms both on the Web and in various geographic locations. The NAV product is one of the best on the market and it continues to grow and prosper. Welcome aboard and enjoy the journey.

A business history timeline

The current version of Microsoft Dynamics NAV is the result of much inspiration and hard work along with some good fortune and excellent management decision making over the last quarter century or so.

The beginning

Three college friends, Jesper Balser, Torben Wind, and Peter Bang, from Denmark Technical University (DTU) founded their computer software business in 1984 when they were in their early twenties. That business was Personal Computing & Consulting (PC & C) and its first product was called PC Plus.

Single user PC Plus

PC Plus was released in 1985 with a primary goal of ease of use. An early employee said its functional design was inspired by the combination of a manual ledger journal, an Epson FX 80 printer, and a Canon calculator. Incidentally, Peter Bang is the grandson of one of the founders of Bang & Olufsen, the manufacturer of home entertainment systems par excellence.

PC Plus was PC DOS-based, a single user system. PC Plus' design features included the following:

  • An interface resembling the use of documents and calculators

  • Online help

  • Good exception handling

  • Minimal computer resources required

The PC Plus product was marketed through dealers in Denmark and Norway.

Multi-user Navigator

In 1987, PC & C released a new product, the multi-user Navigator and a new corporate name, Navision. Navigator was quite a technological leap forward. It included:

  • Client/Server technology

  • Relational database

  • Transaction-based processing

  • Version management

  • High-speed OLAP capabilities (SIFT technology)

  • A screen painter tool

  • A programmable report writer

In 1990, Navision was expanding its marketing and dealer recruitment efforts into Germany, Spain, and the United Kingdom. Moreover, in 1990, V3 of Navigator was released. Navigator V3 was still a character-based system, albeit a very sophisticated one. If you had an opportunity to study Navigator V3.x, you would instantly recognize the roots of today's NAV product. By this time, the product included:

  • A design based on object-oriented concepts

  • Integrated 4GL Table, Form, and Report Design tools (the IDE)

  • Structured exception handling

  • Built-in resource management

  • The original programming language that became C/AL

  • Function libraries

  • The concept of regional or country-based localization

When Navigator V3.5 was released, it also included support for multiple platforms and multiple databases. Navigator V3.5 would run on both Unix and Windows NT networks. It supported Oracle and Informix databases as well as the one that was developed in-house.

At about this time, several major strategic efforts were initiated. On the technical side, the decision was make to develop a GUI-based product. The first prototype of Navision Financials (for Windows) was shown in 1992. At about the same time, a relationship was established that would take Navision into distribution in the United States. The initial release in the US in 1995 was V3.5 of the character-based product, rechristened Avista for US distribution.

Navision Financials for Windows

In 1995, Navision Financials V1.0 for Microsoft Windows was released. This product had many (but not all) of the features of Navigator V3.5. It was designed for complete look and feel compatibility with Windows 95. There was an effort to provide the ease of use and flexibility of development of Microsoft Access. The new Navision Financials was very compatible with Microsoft Office and was thus sold as "being familiar to any Office user". Like any V1.0 product, it was fairly quickly followed by a V1.1 that worked much better.

In the next few years, Navision continued to be improved and enhanced. Major new functionalities were added:

  • Contact Relation Management (CRM)

  • Manufacturing (ERP)

  • Advanced Distribution (including Warehouse Management)

Various Microsoft certifications were obtained, providing muscle to the marketing efforts. Geographic and dealer base expansion continued apace. By 2000, according to the Navision Annual Report of that year, the product was represented by nearly 1,000 dealers (Navision Solution Centers) in 24 countries and used by 41,000 customers located in 108 countries.

Growth and mergers

In 2000, Navision Software A/S and its primary Danish competitor, Damgaard A/S, merged. Product development and new releases continued for the primary products of both original firms (Navision and Axapta). In 2002, the now much larger Navision Software, with all its products (Navision, Axapta, and the smaller, older C5 and XAL) was purchased by Microsoft, becoming part of the Microsoft Business Systems division along with the previously purchased Great Plains Software business and its several product lines. Since that time, one of the major challenges for Microsoft has been to meld these previously competitive businesses into a coherent whole. One aspect of that effort was to rename all the products as Dynamics software, with Navision being renamed to Dynamics NAV.

Fortunately for those who have been working with Navision, Microsoft has not only continued to invest in the product, but has increased the investment. This promises to be the case for the foreseeable future.

Continuous enhancement

As early as 2003, research began with the Dynamics NAV development team planning moves to further enhance NAV, taking advantage of various parts of the Microsoft product line. Goals were defined to increase integration with products such as Microsoft Office and Microsoft Outlook. Goals were also set to leverage the functional capabilities of Visual Studio and SQL Server, among others. All the while, there has been a determination not to lose the strengths and flexibility of the base product.

This was a massive change that required almost a complete rewrite of the underlying code, the foundation that's normally not visible to the outside world. To accomplish that while not destroying the basic user interface, the business application model, or the development environment, was a major effort. The first public views of this new version of the system, a year or two later, were not greeted with universal enthusiasm from the NAV technical community. But the Dynamics NAV development persevered and Microsoft continued supporting the investment, until NAV 2009 was released in late 2008. With the addition of Service Pack 1 in mid-2009, the biggest hurdles to the new technologies have been cleared. More new capabilities and features are yet to come, taking advantage of all these efforts.

The new product will take ever-increasing advantage of SQL Server technologies. Development will become more and more integrated with Visual Studio and be more and more .NET compliant. The product is becoming more open and, at the same time, more sophisticated, supporting features like Web Services access, integration of third-party controls, RDLC reporting, and so on. In our industry, it would be appropriate to say To survive is to change. Change and survive are part of what Dynamics NAV does very well.

C/AL's roots

One of the first questions often asked by developers and development managers new to C/AL is What other language is it like? The proper response is "Pascal". If the questioner is not familiar with Pascal, the next best response would be "C" or "C#".

At the time the three founders of Navision were attending classes at Denmark Technical University (DTU), Pascal was in wide use as a preferred language not only in computer courses, but in other courses where computers were tools and software had to be written for data analysis. Some of the strengths of Pascal as a tool in an educational environment also served to make it a good model for Navision's business applications development.

Perhaps coincidentally (perhaps not) at DTU in this same time period, a Pascal compiler called Blue Label Pascal was developed by Anders Hejlsberg. That compiler became the basis for what was Borland's Turbo Pascal, which was the "every man's compiler" of the 1980s because of its low price. Anders went with his Pascal compiler to Borland. While he was there, Turbo Pascal morphed into the Delphi language and IDE tool set under his guidance.

Anders later left Borland and joined Microsoft, where he led the C# design team. Much of the NAV-related development at Microsoft is now being done in C#. So the Pascal-C/AL-DTU connection has come full circle, only now it appears to be C#-C/AL. Keeping it in the family, Anders' brother, Thomas Hejlsberg also works at Microsoft on NAV and AX at the campus in Copenhagen. Each in their own way, Anders and Thomas continue to make significant contributions to Dynamics NAV.

In a discussion about C/AL and C/SIDE, Michael Nielsen of Navision and Microsoft, who developed the original C/AL compiler, runtime, and IDE, said that the design criteria were to provide an environment that could be used without:

  • Dealing with memory and other resource handling

  • Thinking about exception handling and state

  • Thinking about database transactions and rollbacks

  • Knowing about set operations (SQL)

  • Knowing about OLAP (SIFT)

Paraphrasing some of Michael's additional comments, the language and IDE design was to:

  • Allow the developer to focus on design, not coding, but still allow flexibility

  • Provide a syntax based on Pascal stripped of complexities, especially relating to memory management

  • Provide a limited set of predefined object types, reducing the complexity and learning curve

  • Implement database versioning for a consistent and reliable view of the database

  • Make the developer and the end user more at home by borrowing a large number of concepts from Office, Windows, Access, and other Microsoft products

Michael is still working as part of the Microsoft team in Denmark on new capabilities for NAV; this is another example of how, once part of the NAV community, most of us want to stay part of that community.

What you should know

This book will not teach you programming from scratch, nor will it tutor you in business principles. To get the maximum out of this book, you should come prepared with some significant experience and knowledge. You will benefit most if you already have the following attributes:

  • Experienced developer

  • Know more than one programming language

  • IDE experience

  • Knowledgeable about business applications

  • Good at self-directed study

If you have those attributes, then by careful reading and performance of the suggested exercises in this book, you should significantly reduce the time it will take you to become productive with C/AL and NAV. Those who don't have all these attributes, but want to learn about the development technology of Dynamics NAV, can still gain a great deal by studying Chapter 1 in detail and other chapters as the topics appear to apply to their situation.

This book's illustrations are from the W1 Cronus database V2009 SP1.

Hopefully this book will smooth the path to change and shine a little light on some of the challenges and the opportunities alike. Your task is to take advantage of this opportunity to learn, to change, and then use your new skills productively.

What this book covers

Chapter 1, A Short Tour through NAV 2009, covers basic definitions as they pertain to NAV and C/SIDE. In addition, an introduction to eight types of NAV objects, Page and Report Creation Wizards, and tools that we use to integrate NAV with external entities is provided. There is a brief discussion of how backups and documentation are handled in C/SIDE.

Chapter 2, Tables, focuses on the top level of NAV data structure: tables and their structures. You will work your way through hands-on creation of a number of tables in support of an example application. We will review most types of tables found in the out of the box NAV application.

In Chapter 3, Data Types and Fields for Data Storage and Processing, you will learn about the basic building blocks of NAV data structure, fields and their attributes, data fields that are available, and field structure elements (properties, triggers) for each type of field. This chapter covers the broad range of Data Type options as well as Field Classes. We will also discuss the concept of filtering and how it can be considered as you design your database structure.

In Chapter 4, Pages—Tools for Data Display, we will review different types of pages, work with some of these, and review all the controls that can be used in pages. You will learn to use the Page Wizard and have a good introduction to the Page Designer. You will expand your example system, creating a number of forms for data maintenance and inquiry.

In Chapter 5, Reports, we will learn about the structural and layout aspects of NAV Report objects using both the Classic Report Designer and the Visual Studio Report Designer. In addition, you will be experimenting with some of the tools and continue to expand your example application.

Chapter 6, Introduction to C/SIDE and C/AL, will help you learn about the general Object Designer Navigation as well as more specific Navision individual (Table, Form/Page, Report) Designers. This chapter also covers variables of various types created and controlled by the developer or by the system, basic C/AL syntax and some essential C/AL functions.

Chapter 7, Intermediate C/AL, covers a number of practical tools and topics regarding C/AL coding and development. You will learn about the C/AL Symbol Menu and how it assists in development. This chapter also discusses various Computation, Validation and Data Conversion functions, Dates, FlowFields and SIFT, Processing Flow Control, Input-Output, and Filtering functions.

In Chapter 8, Advanced NAV Development Tools, we will review some of most important elements of the Role Tailored User Experience, in particular Role Center Page construction. In addition, we will cover a number of tools and techniques aimed at making the life of a NAV developer easier and more efficient.

Chapter 9, Extend, Integrate, and Design—into the Future, covers a variety of interfaces, with special emphasis on XMLports and Web Services. It also discusses designing NAV modifications, creating a new functional area, or enhancing an existing functional area. Finally, this chapter provides tips for design efficiency, updating and upgrading the system, all with the goal of helping you to be a more productive NAV developer.

What you need for this book

You will need some basic tools, including at least the following:

  1. A license and database that you can use for development experimentation. An ideal license is a full Developer's license. If the license only contains the Form/Page, Report, and Table Designer capabilities, you will still be able to do many of the exercises, but you will not have access to the inner workings of Form/Pages and Tables.

  2. The best database for your development testing and study will be a copy of the NAV Cronus demo/test database, but you may want to have a copy of a production database at hand for examination as well. This book's illustrations are from the W1 Cronus database for V2009 SP1.

If you have access to other NAV manuals, training materials, websites, and experienced associates, those will obviously be of benefit as well. But they are not required for your time with this book to be a worthwhile investment.

Who this book is for

  • The business applications software designer/developer who:

    • Wants to become productive in NAV C/SIDE‑C/AL development as quickly as possible

    • Understands business applications and the associated software

    • Has significant programming experience

    • Has access to NAV including at least the Designer granules and a standard Cronus demo database

    • Is willing to do the exercises to get hands-on experience

  • The Reseller manager or executive who wants a concise, in-depth view of NAV's development environment and tool set

  • The technically knowledgeable manager or executive of a firm using NAV who is about to embark on a significant NAV enhancement project

  • The technically knowledgeable manager or executive of a firm considering purchase of NAV as a highly customizable business applications platform

  • The reader of this book:

    • Does not need to be expert in object-oriented programming

    • Does not need to have previous experience with NAV

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text are shown as follows: "Transactions are entered into a Journal table; data is preliminarily validated as it is entered, master and auxiliary data tables are referenced as appropriate."

A block of code is set as follows:

http://localhost:7047/DynamicsNAV/WS/Services
http://Isaac:7047/DynamicsNAV/WS/CRONUS_International_Ltd/Services

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking on the Next button moves you to the next screen".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an email to , and mention the book title via the subject of your message.

If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email .

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Tip

Downloading the example code for the book

Visit http://www.packtpub.com/files/code/6521_Code.zip to directly download the example code.

The downloadable files contain instructions on how to use them.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration, and help us to improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to any list of existing errata. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or web site name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.