Programming Microsoft Dynamics NAV 2009 - David Studebaker - E-Book

Programming Microsoft Dynamics NAV 2009 E-Book

David Studebaker

0,0
55,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

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.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB

Seitenzahl: 753

Veröffentlichungsjahr: 2009

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Programming Microsoft® Dynamics™ NAV 2009
Credits
About the Author
Acknowledgement
About the Reviewers
Foreword
Preface
A business history timeline
The beginning
Single user PC Plus
Multi-user Navigator
Navision Financials for Windows
Growth and mergers
Continuous enhancement
C/AL's roots
What you should know
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Errata
Piracy
Questions
1. A Short Tour through NAV 2009
NAV 2009: An ERP system
Financial Management
Manufacturing
Supply Chain Management (SCM)
Business intelligence and reporting
Relationship Management (RM)
Human Resource management
Project management
Significant changes in NAV 2009
Two-tier versus three-tier
Role Tailored Client
SSRS-compatible report viewer
Web services
NAV 2009: A set of building blocks and development tools
NAV object types
The C/SIDE Integrated Development Environment
Object Designer tool icons
NAV object and system elements
NAV functional terminology
User interfaces
An introduction to development
Our scenario for development exercises
Getting started with application design
Application tables
Designing a simple table
Creating a simple table
Field numbering
Pages/Forms
List pages
Card pages
Document pages
Journal/Worksheet pages
Standard elements of pages
Creating a Card page
Creating a List page
Keyboard shortcuts
Run a table
Reports
Creating a List format report
Codeunits
MenuSuites
Dataports
XMLports
Integration tools
Backups and documentation
Summary
Review questions
2. Tables
Overview of tables
Components of a table
Table naming
Table numbering
Table properties
Table triggers
Keys
SumIndexFields
Field Groups
Expanding our sample application
Creating and modifying tables
Assigning a TableRelation property
Creating Forms for testing
Creating a Card form
Creating List Forms
The ZUP file
Testing a TableRelation property
Adding Secondary keys
Adding some activity-tracking tables
New tables
Keys and SumIndexFields in our examples
Table integration
Types of tables
Wholly modifiable tables
Master
Journal
Template
Ledger
Reference
Register
Posted Document
Setup
Temporary
Content-modifiable tables
System
Read-Only tables
Virtual
Summary
Review questions
3. Data Types and Fields for Data Storage and Processing
Basic definitions
Fields
Field properties
Field numbering
Changing the data type of a field
Field triggers
Data structure examples
Variable naming
Data types
Fundamental data types
Numeric data
String data
Date/Time data
Complex data types
Data structure
Objects
Automation
Input/Output
DateFormula
References and other
Data type usage
FieldClass property options
Filtering
Defining filter syntax and values
Filtering on equality and inequality
Filtering by ranges
Filtering with Boolean operators
Filtering with wildcards
Filtering with combinations
Experimenting with filters
Accessing filter controls
Classic Client filter access
RoleTailored Client filter access
Find-As-You-Type filtering
Summary
Review questions
4. Pages—Tools for Data Display
What is a page?
Controls
Bound and unbound
Pages—a stroll through the gallery
A sample RoleTailored Client page
Types of pages
List page
Card page
Document page
FastTab
List+ page
Journal/Worksheet page
Confirmation (Dialog) page
Request page
Navigate page
Departments page
Role Center page
Page parts
FactBoxes
Card parts and List parts
Chart pane
Page names
Accessing the Page Designer
What makes up a page?
Page properties
Types of page controls
Inheritance
Page control details
Container controls
Group controls
Field controls
Using page controls in a Card page
Page Part controls
Creating a Card Part FactBox
Page Control triggers
Adding more List pages to our ICAN application
Creating a simple list page
Creating related List and Card pages
Learning more about pages
UX (User Experience) Guidelines
Creative plagiarism
Experimenting with page controls and control properties
Help searching
Experimentation
Testing
Design
Summary
Review questions
5. Reports
What is a report?
Two NAV report designers
A hybrid report designer
NAV report—look and feel
NAV report types
Report types summarized
Report naming
Report components overview
The components of a report description
Report Data Flow
The elements of a report
Report properties
Report triggers
Data Items
Data item properties
Data item triggers
Data item Sections
Creating RTC reports via the Classic Report Wizard
Learn by experimentation
Runtime formatting
Inheritance
Other ways to create RTC reports
Modify an existing RTC report
The Visual Studio Report Designer layout screen
Table Elements—icons and purpose
Report Items
Make the report changes
Some interactive report capabilities
Page Header fields
Request Page
Processing-Only reports
Creating a report from scratch
Creative report plagiarism
Summary
Review questions
6. Introduction to C/SIDE and C/AL
Essential navigation
Object Designer
Starting a new object
Table Designer
Page Designer
Report Designer
XMLport Designer
Codeunit Designer
MenuSuite Designer
Some designer navigation pointers
Exporting objects
Importing objects
Text objects
Object number licensing
Some useful practices
Changing data definitions
Saving and compiling
Some C/AL naming conventions
Variables
Global identifiers
Local identifiers
Function local identifiers
Other local identifiers
Special working storage variables
Temporary tables
Arrays
Initialization
System-defined variables
A definition of programming in C/SIDE
Functions
Basic C/AL syntax
Assignment and punctuation
Wildcards
Expressions
Operators
Arithmetic operators and functions
Boolean operators
Relational operators and functions
Precedence of operators
Some basic C/AL
MESSAGE, ERROR, CONFIRM, and STRMENU functions
MESSAGE function
ERROR function
CONFIRM function
STRMENU function
SETCURRENTKEY function
SETRANGE function
GET function
FIND
FIND ([Which]) options and the SQL Server alternates
BEGIN—END compound statement
IF—THEN—ELSE statement
Indenting code
Some simple coding modifications
Adding a validation to a table
Adding code to enhance a report
Summary
Review questions
7. Intermediate C/AL
Some C/AL development tools
C/AL Symbol Menu
Internal documentation
Computation and Validation utility functions
TESTFIELD
FIELDERROR
VALIDATE
ROUND
TODAY, TIME, and CURRENTDATETIME functions
WORKDATE function
Data conversion functions
FORMAT function
EVALUATE function
DATE functions
DATE2DMY function
DATE2DWY function
DMY2DATE and DWY2DATE functions
CALCDATE function
FlowField-SumIndexField functions
CALCFIELDS function
CALCSUMS function
CALCFIELDS and CALCSUMS comparison
Flow control
REPEAT—UNTIL control structure
WHILE—DO control structure
CASE—ELSE statement
WITH—DO statement
QUIT, BREAK, EXIT, SKIP, and SHOWOUTPUT functions
QUIT function
BREAK function
EXIT function
SKIP function
SHOWOUTPUT function
Input and Output functions
NEXT function with FIND or FINDSET
INSERT function
MODIFY function
Rec and xRec
DELETE function
MODIFYALL function
DELETEALL function
Filtering
SETRANGE function
SETFILTER function
COPYFILTER and COPYFILTERS functions
GETFILTER and GETFILTERS functions
MARK function
CLEARMARKS function
MARKEDONLY function
RESET function
Filter Groups
InterObject communication
Communication via data
Communication through function parameters
Communication via object calls
Using the new knowledge
A development challenge for you
Creating more ICAN test data
"Donor Giving" report design
Beginning development
Eliminating the Request form/page
Working storage definition
Defining the C/AL code
Developing the Donor Recognition Status report
Using the Report Wizard
Beginning the C/AL coding for the report
Retrofitting date filtering capability
Adding code for CALCFIELDS processing
Adding code to print addresses
Summary
Review questions
8. Advanced NAV Development Tools
NAV process flow
Data preparation
Transactions entry
Testing and Posting the Journal batch
Accessing the data
Ongoing maintenance
Role Center pages
Role Center structure
Role Center activities page
Cue Groups and Cues
Cue source table
Cue Group Actions
System Part
Page Part
Navigation Pane and Action Menus
Departments
MenuSuite levels
MenuSuite structure
MenuSuite development
MenuSuite transformation
Configuration and personalization
Creating new C/AL routines
Callable functions
Codeunit 358—Date Filter-Calc
Codeunit 359—Period Form Management
Codeunit 365—Format Address
Codeunit 396—NoSeriesManagement
Codeunit 397—Mail
Codeunit 408—Dimension Management
Codeunit 412—Common Dialog Management
Sampling of function models to review
Codeunit 228—Test Report-Print
Codeunit 229—print documents
Other objects to review
Management codeunits
Documenting modifications
Multi-language system
Multi-currency system
Code analysis and debugging tools
Developer's Toolkit
Relations to Tables
Relations from Objects
Source Access
Where Used
Trying it out
Working in exported text code
Using Navigate
Testing with Navigate
Modifying for Navigate
The C/SIDE Debugger
The C/SIDE Code Coverage tool
Client Monitor
Debugging NAV in Visual Studio
Dialog function debugging techniques
Debugging with MESSAGE
Debugging with CONFIRM
Debugging with DIALOG
Debugging with text output
Debugging with ERROR
C/SIDE test driven development
Summary
Review questions
9. Extend, Integrate, and Design—into the Future
Interfaces
XMLports
XMLport components
XMLport properties
XMLport triggers
XMLport data lines
XMLport line properties
SourceType as Text
SourceType as Table
SourceType as Field
Element or attribute
NodeType as an Element
TagType as an Attribute
XMLport line triggers
DataType as Text
DataType as Table
DataType as Field
XMLport Request Page
Advanced interface tools
Automation Controller
NAV Communication Component
Linked Server Data Sources
C/OCX
C/FRONT
NAV Application Server (NAS)
Client Add-ins
Client Add-in definition
Client Add-in construction
Client Add-in comments
Web services
Exposing a web service
Publishing a web service
Determining what was published
Customizing Help
NAV development projects
Knowledge is key
Different approaches for different scopes
Advantages of designing new functionality
Modifying an existing functional area
NAV development time planning
Data-focused design
Determining the data needs
Defining the needed data views
Designing the data tables
Designing the user data access interface
Designing the data validation
Data design review and revision
Designing the Posting processes
Designing the supporting processes
Double-check everything
Design for efficiency
Disk I/O
Locking
Design for updating
Customization project recommendations
One change at a time
Testing thoroughly
Database testing approaches
Testing in production
Using a testing database
Testing techniques
Deliverables
Finishing the project
Plan for upgrading
Benefits of upgrading
Coding considerations
Careful naming
Good documentation
Low-impact coding
The upgrade process
Upgrade executables only
Full upgrade
Supporting material
Sure Step
RIM
Other reference material
Into the future...
Summary
Review questions
A. Answers
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Index

Programming Microsoft® Dynamics™ NAV 2009

David Studebaker

Programming Microsoft® Dynamics™ NAV 2009

Copyright © 2009 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: November 2009

Production Reference: 1271009

Published by Packt Publishing Ltd.

32 Lincoln Road

Olton

Birmingham, B27 6PA, UK.

ISBN 978-1-847196-52-1

www.packtpub.com

Cover Image by Faiz Fattohi (<[email protected]>)

Credits

Author

David Studebaker

Reviewers

Mark J. Brummel

Steven Renders

Acquisition Editor

Douglas Paterson

Development Editor

Ved Prakash Jha

Technical Editors

Aanchal Kumar

Charumathi Sankaran

Copy Editor

Sanchari Mukherjee

Indexer

Rekha Nair

Editorial Team Leader

Gagandeep Singh

Project Team Leader

Lata Basantani

Project Coordinator

Joel Goveya

Proofreaders

Claire Cresswell-Lane

Erica Mukherjee

Graphics

Nilesh Mohite

Production Coordinator

Aparna Bhagat

Cover Work

Aparna Bhagat

About the Author

David Studebaker is Chief Technical Officer and the owner of Liberty Grove Software, Inc., with his partner Karen Studebaker. Liberty Grove Software, a Microsoft Partner, provides development, consulting, training, and upgrade services for Microsoft Dynamics NAV resellers and firms using Dynamics NAV internally.

David has been recognized by Microsoft as a Certified Professional for NAV in all areas—Development, Applications, and Installation & Configuration. He has been honored as a Lead Certified Microsoft Trainer for NAV. He has been programming since 1962 and developing in C/AL since 1996. David has been an active participant in each step of computing technology—from the early mainframes to today's technology, from binary assembly language coding to today's C/AL and C#.

David's special achievements include the development of the very first production SPOOLing system in 1967. Application areas in which David has worked include manufacturing, distribution, retail, engineering, general accounting, association management, professional services billing, distribution/inventory management, freight carriage, data collection, and production management among others.

David has had a wide range of development, consulting, sales, and management roles throughout his career. He has been partner or owner and manager of several software development businesses, while always maintaining a significant role as a business applications developer.

David has a BS in Mechanical Engineering from Purdue University and an MBA from the University of Chicago. He has been writing for publication since his undergraduate college days. David has been a member of the Association for Computing Machinery since 1963 and was a founding officer of two local chapters of the ACM.

Acknowledgement

I would like to especially thank my partner in life and at work, Karen Studebaker, for her unflagging support and encouragement in all ways since those early days at Purdue. No one could have a more wonderful partner or spouse. I would like to acknowledge the guidance and love that I received from my parents as well as the enthusiastic support and love of my wonderful children and other family members. Finally, though there are far too many individuals to list, whatever I have been able to accomplish would not have been possible without the help of many, many friends, mentors, and associates along the way. Life would be very poor without all the kind and generous folks I have met. I also wish to thank the great people at Microsoft and Packt who assisted me with their contributions and advice throughout the creation of this book. May you enjoy this book and find it useful.

A special thanks to these helpful people at Microsoft:

Microsoft Technical Reviewers:

Overall Coordination—Michael Nielsen, Director of Engineering, Microsoft Dynamics NAV.

Chapter 1: A Short Tour through NAV 2009 - Esben Nyhuus Kristoffersen

Chapter 2: Tables - Thomas Hejlsberg

Chapter 3: Data Types and Fields for Data Storage and Processing - Thomas Hejlsberg

Chapter 4: Pages—Tools for Data Display - Esben Nyhuus Kristoffersen

Chapter 5: Reports - Yuri Belenky

Chapter 6: Introduction to C/SIDE and C/AL - Lars Hammer

Chapter 7: Intermediate C/AL - Lars Hammer

Chapter 8: Advanced NAV Development Tools - Lars Hammer, Hans Kierulff

Chapter 9: Extend, Integrate, and Design—into the Future - Christian Abeln, Bardur Knudsen

Dynamics NAV Help documentation: Paul Chapman, Dynamics NAV 2009 Documentation Manager, and his team, including Jill Frank, Søren Groes-Petersen, John Swymer, and Bob Papsdorf

Dynamics NAV UX Guide: Hans Roed Mark, UX Manager, Microsoft Dynamics User Experience Team

About the Reviewers

Mark J. Brummel is an all-round Microsoft Dynamics NAV specialist. He started in 1997 as an end user but quickly moved to the other side of the table. During ten years, he has worked for resellers where designing and maintaining add-on systems was his specialization. Some of these add-on systems exceed the standard product where it comes to size and complexity. In addition, coaching colleagues and troubleshooting 'impossible' problems is his passion and part of day to day work. Mark has trained most of the experienced NAV developers for the NAV 2009 product in The Netherlands and Belgium. Today he is working freelance, is hired by almost every NAV reseller in the Benelux area, and is also frequently asked to help out in escalated implementations by end users. Mark is an associate in the Liberty Grove Software network and a business partner of SQL Perform Benelux. Mark was the first to use the NAV 2009 (CTP3) product in a production system feeding back valuable information to Microsoft.

A special project and passion is performance tuning of the Dynamics NAV product on SQL Server. Since 2007, he is involved in the development of the 'SQL Perform Tools'. A specialist's toolset which allows both trend and escalation analysis of key elements for systems speed. As a unique specialist, he has done break-through research in improving the performance of Dynamics NAV on SQL Server.

In his free time, Mark maintains his blog on www.brummelds.com. This blog contains a wide range of articles about both the Microsoft Dynamics NAV and SQL Server product. He is also a frequent speaker at Microsoft events. In 2006, Mark was rewarded by Microsoft with the Most Valuable Professional award for his contribution to the online and offline communities. In 2007, he also reviewed Programming Microsoft® Dynamics™ NAV.

Steven Renders is a Microsoft Certified Trainer in Microsoft Dynamics NAV. He has more than 12 years of business and technical experience. He joined Plataan in 2006, where he provides training and consultancy focused on Microsoft Dynamics NAV development, Microsoft SQL Server, Business Intelligence solutions, Microsoft SQL Server Reporting Services, and Database Performance Tuning. He is also an expert on Dynamics NAV 2009, on which he has already delivered many training sessions. Steven has also developed content for Microsoft Learning.

Foreword

Since the first version of Dynamics NAV, simplicity has always been the biggest asset of the product, and the goal has always been that it should be easy to learn, easy to use, and easy to develop. For the NAV developers, this has been accomplished by limiting the number of concepts they have to learn.

The first is to use the concepts which are well known from real life, for example, Form, Page, Table, and Report. The next is to introduce a programming language C/AL, which is targeted at writing business logic and not device drivers. The third is to add an integrated development environment, which removes the need for "plumbing" logic, which typically pollutes the code in a normal development environment. The fourth is to add automatic transaction and error handling, which saves the developers a lot of time since they don't have to write "clean up" code. The fifth and probably most important, is to reuse code constructs across the application, so that once you have learned one subsystem, it is easy to understand and master the rest. The latter is the secret sauce of NAV and what makes it possible to master doing customization across the whole NAV application.

This is, in very few words, what David's book is all about and what Dynamics NAV is all about.

Michael Nielsen,

Director of Engineering,

Microsoft Dynamics NAV

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:

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.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 possibleUnderstands business applications and the associated softwareHas significant programming experienceHas access to NAV including at least the Designer granules and a standard Cronus demo databaseIs 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 programmingDoes 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 <[email protected]>, 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 <[email protected]>.

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 <[email protected]> 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 <[email protected]> if you are having a problem with any aspect of the book, and we will do our best to address it.

Chapter 1. A Short Tour through NAV 2009

The toughest thing about being a success is that you've got to keep on being a success—Irving Berlin

Microsoft Dynamics NAV (including the earlier Navision generation) has been a successful product line for over two decades. During the 2008-2009 fiscal year, Microsoft Dynamics NAV crossed the milestone of more than 1,250,000 installed users, a major achievement for any application software.

At the end of calendar 2008, Microsoft Dynamics NAV 2009 was released—a major new version of the product. While this new version contains the same business application functionality as the previous release (V5 Service Pack 1), it is based on a completely new infrastructure and presents a dramatically different face, the Role Tailored Client, to users. Our focus in this book is the NAV 2009 system, including the new three tier Role Tailored Client.

In this chapter, we will take a short tour through NAV 2009. Our path will be along the following trail:

NAV 2009 from a functional point of view as an ERP systemWhat's new in NAV 2009Definitions of terms as used in NAVThe C/SIDE development environment and toolsA development introduction to the various NAV object typesOther useful NAV development information

Your goal in this chapter is to gain a reasonably complete, "big picture" understanding of NAV. When you complete this chapter, you should be able to communicate to a business manager or owner about the capabilities NAV can provide to help them manage their firm. This will also give you a context for what follows in this book.

A product as complex and flexible as NAV can be considered from several points of view. One can study the NAV application software package as a set of application functions designed to help a business manage information about operations and finances. One can also look at NAV as a stack of building blocks from which to extend or build applications—and the tools with which to do the construction.

In NAV 2009, which has two quite different user interface options available, one must consider how the user interface affects both the application design and the presentation to the user. This requirement overlaps both the application viewpoint and the construction viewpoint.

You should know the different object types that make up a NAV system and the purposes of each. You should also have at least a basic idea of the tools that are available to you, in order to enhance (small changes) or extend (big changes) an NAV system. In the case of NAV, the Integrated Development Environment (IDE) includes essentially all of the tools needed for NAV application development. Later in this book, we will discuss where the IDE can be supplemented.

Prior versions of NAV were two-tier systems. One of the tiers was the database server, the other tier was the client. As the traditional two-tier NAV Client (now referred to as the Classic Client) is still an integral part of the system, we will cover the aspects of where it must be used for development and support. All development and much of the system administration uses the Classic Client. So, even though our focus is on developing for the Role Tailored Client (aka "the RTC"), many of the images scattered throughout this book will be of Classic Client displays. In brief, the RTC is for users, and as a developer, you will generally use the Classic Client for your work.

NAV 2009: An ERP system

If you look at NAV 2009 from the point of view of a firm using NAV to help run its business, you will see it as an integrated set of business applications software.

Microsoft Dynamics NAV is generally characterized as an ERP System. ERP stands for Enterprise Resource Planning. An ERP system is a set of integrated application software components designed to track and coordinate a wide variety of business activities, especially those involving products, orders, production and finances. An ERP system will typically include the following:

Basic accounting functions (for example, general ledger, accounts payable, accounts receivable)Order processing and inventory (for example, sales orders, purchase orders, shipping, inventory, receiving)Relationship management (for example, vendors, customers, prospects, employees, contractors, and so on)Planning (for example MRP, sales forecasting, production forecasting)Other critical business areas (for example, manufacturing, warehouse management, fixed assets)

The integration of an ERP system is supported by a common database, by an "enter once, use everywhere" data philosophy, by a modular software design, and with data extraction and analysis tools. The following image is a view of an ERP system from the highest level:

The design of Microsoft Dynamics NAV addresses all the points in the above description and more. The NAV ERP system includes integrated modules covering the breadth of business functions for a wide range of business types. These modules share a common database and, where appropriate, share common data.

In the NAV system, there is a considerable overlap of components across application areas, with individual functions showing up in multiple different "modules". For example, in NAV, Inventory is identified as part of Financial management, but it is also, obviously, an integral part of Manufacturing, Supply Chain, and others.

The particular grouping of individual functions into modules that follows is based on Microsoft marketing materials. Some of these assignments are a bit arbitrary. What's important is for you to obtain a reasonable understanding of the overall set of application components that make up the NAV ERP system. In several of the following groupings, menu screenshots are included as examples. These are from the Role Tailored Client Departments menu screen.

Financial Management

Financial Management is the foundation of any ERP system. No matter what the business is, the money must be kept flowing, and the flow of money must be tracked. The tools which help to manage the capital resources of the business are included in NAV's Financial Management module. These include all or part of the following application functions:

General Ledger—managing the overall finances of the firmAccounts receivable—tracking the incoming revenueAccounts payable—tracking the outgoing fundsAnalytical accounting—analyzing the various flows of fundsCash management and banking—managing the inventory of moneyInventory and fixed assets—managing the inventories of goods and equipmentMulti-Currency and Multi-Language—supporting international business activities

Manufacturing

NAV Manufacturing is general purpose enough to be appropriate for Make to Stock (MTS), Make to Order (MTO), and variations such as Assemble to Order, and so on. While off-the-shelf NAV is not particularly suitable for most process manufacturing and high-volume assembly line operations, there are third party add-on and add-in enhancements available for these. As with most of the NAV application functions, manufacturing can be installed in parts or as a whole, and can be used in a simplistic fashion or in a more sophisticated manner. NAV Manufacturing includes the following functions:

Product design (BOMs and Routings)—managing the structure of product components and the flow of manufacturing processesCapacity and supply requirements planning—tracking the intangible and tangible manufacturing resourcesProduction scheduling (infinite and finite),execution, and tracking—tracking the planned use manufacturing resources, both on an unconstrained and constrained basis

Supply Chain Management (SCM)

Obviously, some of the functions categorized as part of NAV Supply Chain Management (for example sales, purchasing, and so on) are actively used in almost every NAV implementation. As a whole, these constitute the base components of a system appropriate for a distribution operation. The Supply Chain applications in NAV include parts of the following applications:

Sales order processing and pricing—supporting the heart of every business—entering, pricing, and processing sales ordersPurchasing (including Requisitions)—planning, entering, pricing, and processing purchase ordersInventory management—managing inventories of goods and materialsWarehouse management including receiving and shipping—managing the receipt, storage, retrieval, and shipment of material and goods in warehouses

Business intelligence and reporting

Although Microsoft marketing materials identify Business Intelligence (BI) and reporting as though it were a separate module within NAV, it's difficult to physically identify it as such. Most of the components that are used for BI and reporting purposes are (appropriately) scattered throughout various application areas. In the words of one Microsoft document, "Business Intelligence is a strategy, not a product." Functions within NAV that support a Business Intelligence strategy include the following:

Standard Reports—distributed ready-to-use by end usersReport wizards—tools to create simple reports or foundations for complex reportsAccount schedules and analysis reports—a very specialized report writer for General Ledger dataAnalysis by dimensions—a capability embedded in many of the other toolsInterfaces into Microsoft Office including Excel—communications of data either into NAV or out of NAVSQL server reporting services compatible report viewer—provides the ability to present NAV data in a variety of textual and graphic formats, includes user interactive capabilitiesInterface capabilities such as Automation Controllers and web services—technologies to support interfaces between NAV 2009 and external software productsNAV Business Analytics—an OLAP cube based data analysis tool option

Relationship Management (RM)

NAV's Relationship Management (RM) functionality is definitely the "little brother" (or, if you prefer, "little sister") to the fully featured standalone Microsoft CRM system. The big advantage of RM is its tight integration with NAV customer and sales data.

Also falling under the heading of Customer Relationship module is the NAV Service Management (SM) functionality. While the RM component shows up in the menu as part of sales and marketing, the SM component is identified as an independent function in the menu structure.

(RM) Marketing campaigns—plan and manage promotions(RM) Customer activity tracking—analyze Customer orders(RM) To do lists—manage what's to be done and track what's been done(SM) Service contracts—support service business operations(SM) Labor and part consumption tracking—track the resources consumed by the service business(SM) Planning and dispatching—managing service calls

Human Resource management

NAV Human Resources (HR) is a small module, but relates to a critical component of the business, the people. Basic employee data can be stored and reported via the master table (in fact, one could use HR to manage data about individual contractors in addition to employees). A wide variety of individual employee attributes can be tracked by use of dimensions fields.

Employee tracking—maintain basic employee description dataSkills inventory—inventory of the capabilities of employeesAbsence tracking—maintain basic attendance informationEEOC statistics—tracking government required employee attribute data

Project management

The NAV Project management module consists of the jobs functionality supported by the resources functionality. Projects can be short or long term. They can be external (that is billable) or internal. This module is often used by third parties as the base for vertical market add-ons (for example, for construction or job oriented manufacturing). This application area includes parts or all of the following functions:

Budgeting and cost tracking—managing project financesScheduling—planning project activitiesResource requirements and usage tracking—managing people and equipmentProject accounting—tracking the results

Significant changes in NAV 2009

Even though the NAV 2009 release doesn't contain any significant changes in the business application functionality, the changes in the infrastructure are major. We will discuss those briefly now and in detail in the later chapters.

Two-tier versus three-tier

The two-tier (Classic Client) system has all the business logic in the client (first tier) and the database management in the database (second tier). The database can either be the Classic C/SIDE database or a SQL Server database. This is the mode of all NAV releases until Version 2009. The three-tier system, new with NAV 2009, has the Role Tailored Client as the first tier (minimal logic), the NAV Service Tier as the second tier (where all the business logic now resides), and the SQL Server database as the third tier.

Both the two-tier and the three-tier configurations are shown in the following image. In both cases, the database is SQL Server (a stand-alone two-tier configuration could have a Classic NAV database server). The server tier performs the same role in both instances. For the two-tier configuration, the Classic Clients handle authentication, object management, presentation/rending, and the processing of all code, triggers, and validation.

For the three-tier configuration, the Role Tailored Clients are limited to some state tracking, simple data type validation and, of course, all the presentation and rendering for the new user interface. The NAV Service tier (NAV Servers) handles authentication, object management, the processing of all code, triggers and validation, plus offers web services support.

The following image illustrates a possible configuration of the NAV 2009 system. It has both the two-tier and three-tier options running in parallel. The three-tier option has multiple NAV Servers installed for capacity reasons (one NAV Server is projected to handle 40 to 60 users). Finally, the NAV Service tier is providing web services to support Internet-based access to the system from mobile devices.

Role Tailored Client

The new Role Tailored Client (RTC) is quite different in look and feel from the Classic Client. The RTC brings with it a completely new approach to designing and coding for the user interface. As the name implies, the orientation of the new client is to present a user interface that focuses on the specific role of the individual user. We will spend quite a bit of time studying the design and development for the new client.

SSRS-compatible report viewer

The new RTC supports reporting through the use of Visual Studio report designer and a Report Renderer/Viewer that replicates much of the functionality of SQL Server Reporting Services. RTC reports provide a host of new capabilities. RTC reports can be dynamically sorted in review (on-screen) mode, include graphics and expand (detail)/collapse (summary) displays, have drill-down and drill-through capabilities, and generate PDF or .xls (that is, Excel) files. We will spend quite a bit of time in Chapter 5, Reports, studying the Reporting Services for NAV 2009.

Web services

Web services is a new major feature of the NAV 2009 three-tier implementation. There isn't much to learn within NAV about web services because the implementation design is incredibly simple. Publishing a page or codeunit as a web service only requires a single record entry in the appropriate table.

Web services is very powerful, because it allows us to take advantage of the NAV Service Tier and expose NAV business logic, user authentication, and data access/validation to external processes. It is the new API for any application that has the ability to consume web services provided by another application.

NAV 2009: A set of building blocks and development tools

If you look at NAV 2009 from the point of view of a developer, you may see it as a set of customizable off-the-shelf program objects (the building blocks) plus the IDE which allows you to modify those objects and create new ones (the C/SIDE development tools).

The NAV 2009 system is an object-based system, consisting of several thousand application objects, the building blocks, made up of the eight different object types available in NAV. NAV does not have all of the features of an object-oriented system. A full-featured object-oriented system would allow the definition and creation of new object types, while NAV only allows for the creation and modification of the predefined object types.

NAV object types

Let's start with some basic definitions of the object types that are part of NAV:

Table: Tables are the definers and containers of data.Form: Forms are the screen display constructs for the Classic Client user interface.Page: Pages are the screen display constructs for the Role Tailored Client user interface. Pages are designed and rendered (displayed) using technology that is new to NAV 2009.Report: Reports allow the display of data to the user in "hardcopy" format, either onscreen (preview mode) or via a printer device. Report objects can also update data in processes with or without accompanying data display output.Dataport: Dataports allow the importing and exporting of data from/to external files in the Classic Client.XMLport: XMLports are similar to Dataports. In the Classic Client, XMLports are specific only to XML files and XML formatted data. In the Role Tailored Client, XMLports handle the tasks of both XMLports and Dataports.Codeunit: Codeunits are containers for code, always structured in code segments called functions.MenuSuite: MenuSuites contain menus which refer in turn to other types of objects. MenuSuites are structured differently from other objects, especially since they cannot contain any code or logic. In the Role Tailored Client, MenuSuites are translated into Navigation Pane menu entries.