Add

Saturday, August 29, 2009

System Defined Variables

C/SIDE automatically declares and initializes a number of variables that you can use when you develop applications. The following details describes the system-defined variables.

Rec
When a record is modified, this variable specifies the current record, including the changes that are made.
xRec
When a record is modified, this variable specifies the original values of the record, before the changes.
CurrForm
This variable specifies the current form. You can access the controls of the form through this variable and set the dynamic properties of the form and its controls.
CurrReport
This variable specifies the current report.
RequestOptionsForm
This variable specifies the request options form for the current report.

Tuesday, August 25, 2009

Add a Function to a Codeunit

1. Select the C/AL Editor, click View, and then click C/AL Globals.
2. In the C/AL Globals window, click the Functions tab.
3. Enter a name for each function that you want to add.
4. Click Locals to define the parameters, return value, local variables, and text constants in the C/AL Locals window.
5. In the C/AL Locals window, click the Parameters tab and specify the calling method, name, and data type of each parameter. You can also specify a subtype and a length, but this is optional.
The calling method can be specified as Var, which means that the parameter is passed by reference rather than by value. The value of a variable can only be changed by a function when it is passed to the function by reference. When the parameter is not specified as Var, only a copy of the variable is passed to the function. If the function changes that value, the change only affects the copy and not the variable itself.
If the type that you select corresponds to an application object, you must also add a subtype, that is, the name of a specific object in the database. If you select text or code you have to define a length. The default length is 10 characters for code and 30 characters for text.
6. In the C/AL Locals window, click the Return Value tab and specify the return value for your new function. Enter a name for the return value and select a data type from the drop-down list. If the data type is text or code, you can also select a length.
7. n the C/AL Locals window, click the Variables tab and define local variables.
8. In the C/AL Locals window, click the Text Constants tab and define text constants for the function.

Monday, August 24, 2009

C/SIDE Temporary Table

A temporary table is a temporary variable that holds a table. A temporary table is used as a buffer for table data in your C/AL programs.
You can use a temporary table just like you use a database table. The differences between a temporary table and a database table are:
1. A temporary table is not stored in the database, but is only held in memory until the table is closed.
2. The write transaction principle that applies to a database table does not apply to a temporary table.
Advantage of a Temporary Table
The advantage of using a temporary table is that all the interaction with a temporary table takes place on the client. This reduces the load on both the network and the server.
When you need to perform many operations on the data in a specific table in the database, you can load the data into a temporary table while you modify it. Loading the data into a temporary table speeds up the process because all the operations are performed locally on the client.
Defining a Temporary Table
You must define the temporary table before you can use it in your C/AL code. The variable that holds a temporary table is defined just like any other global or local variable.
1. On the Tools menu, click Object Designer, and then create a new table.
2. Click View, and then click C/AL Globals or C/AL Locals, depending on whether your variable is going to be global or local.
3.Enter a name for the temporary table variable, and enter or select Record as the data type. Use the lookup button in the Subtype field to select the table to copy.
4. With the cursor still on the line that defines the temporary table, click View, and then click Properties (SHIFT+F4) to display the Properties window.
5.Change the value of the Temporary property to Yes.
After you have created a temporary table, you can use it in your C/AL code.


Special C/SIDE Tables

C/SIDE has three types of tables that serve special purposes in C/SIDE applications. These types of tables are:
  1. Temporary
  2. System
  3. Virtual

Temporary tables are used as a repository for temporary information at run time. System and virtual tables are system generated tables that provide information about the current state of the system.

Guidelines for Implementing Record Level Security

The following guidelines are some general rules for implementing record level security:
  1. Record level security and the business logic of the application must work together.
  2. For forms, reports, and dataports that are run by properties and not code, the security filters that you apply at user level are sufficient.
  3. For forms, reports, and dataports that run code, assign an extra indirect read permission at user level.
  4. For codeunits, assign the extra indirect read permissions at user level and at object level.
  5. Permissions are cumulative and not mutually exclusive.

Thursday, August 20, 2009

Defining Keys to Improve Performance

When you write a query that searches through a subset of the records in a table, you need to be careful when you define the keys both in the table and in the query so that Microsoft Dynamics NAV can quickly identify this subset. For example, the entries for a specific customer will usually be a small subset of a table containing entries for all the customers.
Defining Keys to Improve Performance
The time that it takes to complete a query depends on the size of the subset. If a subset cannot be located and read efficiently, performance will deteriorate.
To maximize performance, you must define the keys in the table so that they facilitate the queries that you will have to run. These keys must then be specified correctly in the queries.

For example,
You would like to retrieve the entries for a specific customer. To do this, you apply a filter to the Customer No. field in the Cust. Ledger Entry table. In order to run the query efficiently on SQL Server, you need to define a key in the table that has Customer No. as the first field. You must also specify this key in the query.

The table could have these keys.
Entry No.,Customer No.,Posting Date

The query could look like the following.
SETCURRENTKEY("Customer No.");
SETRANGE("Customer No.",'1000');
IF FIND('-') THEN
REPEATUNTIL NEXT = 0;

Tuesday, August 18, 2009

How to create a Dataport

To create a dataport
1. Click Tools, and then click Object Designer.
2. In Object Designer, click Dataport, and then click New.
3. In the Properties window for the new dataport, set the following properties.

PropertyValue
FileFormat PropertyVariable
FieldStartDelimiter Property"
FieldEndDelimiter Property"
FieldSeparator Property;

*The format of the external file is variable and uses a semicolon as the field separator. This is because the external editor is Microsoft Excel, and for this use, a .csv file is appropriate.You have created a dataport and must now specify which tables and fields will be used in the dataport.

For Eg:

To add a data item for the Item table

1. In Dataport Designer, in the first DataItem field, click the AssistButton, and then select the Item table.
2. In the Properties window of the Item data item, in the DataItemTableView property, click the AssistButton.
3. In the Table View window, in the Key field, click the AssistButton, and in the Key List window, select the No. field.
4. Click View, and then click C/AL Globals.
5. In the C/AL Globals window, create a global variable called Tariff Number of data type Record, with the Tariff Number table as the subtype.

Next, you add fields to the data item.

To add fields to the Item data item

1. In Dataport Designer, select the Item data item, click View, and then click Dataport Fields.
2. In Field Designer, in the first row, in the SourceExpr field, click the AssistButton, and then in the Field List window, select the No. field.
3. Repeat step 2 to add the more Fields.
4. Save and compile the dataport.

Dataport Design

You build the data model by designing data items. A data item corresponds to a table. When you are exporting data, each data item is iterated for all the records in the underlying table, and you can set up sort order, keys, and table views to use. You can decide whether each record should be written to the external file.
When you are importing data, the records read from the external file can be inserted into tables that correspond to the data items. You can examine the records before inserting them and you can specify:
1. If the records should be inserted.
2. If the records should be inserted automatically.
3. If the records that are already in the database should be overwritten or updated when a record with the same primary key is read from the external file.
Designing a dataport consists primarily of setting various properties. The following sections explain which properties to use, and how to use them.
Dataport componentDescription
Dataport descriptionA complete description of the dataport including how data is collected, how data is formatted when written to the output file, and so on. The dataport description is stored in the database.
Data itemA data item corresponds to a table in the database. You define data items so that you can retrieve information from the tables in the database. A dataport must contain at least one data item, and each data item defines one or more fields.
FieldA dataport field can be a field in a data item (a database table), a field in a file from which data is to be imported, or a source expression to be executed during import or export. Fields in the external file are defined either as having a fixed length, or as being delimited by certain characters that you define.
Request formA request form is a form that is run before the dataport is executed. The request form is used to gather requests and options from the user, for example, the name and location of the external file.
PropertyThe dataport itself, and data items, fields, and the request form have properties that characterize the object in some way. For example, the length and position of a field in a line during import, or whether the OnValidate trigger of a field should be executed when inserting imported data into a table.

The FileFormat property determines the format of the external file and defines how a record is read from or written to the file. The RecordSeparator property defines how the file is broken into records, and the FileFormat property then defines how to break each record into fields. Finally, the DataItemSeparator property defines how data items should be separated if the dataport has more than one data item.

Dataport Fundamentals

Dataports enable you to import data from external text files to the Microsoft Dynamics NAV database and export data from the Microsoft Dynamics NAV database to text files in cases where XML is not supported.
Defining Dataports
A dataport object defines the data that must be exported from or imported into the Microsoft Dynamics NAV database. When you are importing data, you can control what happens if a record in the file being imported has the same value in the key as an existing record in the database table. In addition, at field level, you can control if the OnValidate trigger for each field should be run.
Dataports can be dynamic, meaning that when you execute the dataport, you specify if it must import or export data, and you specify the name of the file to read from or write to. This can be achieved either by defining options that the user sets in the request form or by programming.

Monday, August 17, 2009

CLEAR Function

Clears the value of a single variable. Also clears all the filters that were set if the variable is a record and resets the key to the primary key.
The identifier (variable) of any C/AL data type, including simple and composite data types. The following rules apply when you run the CLEAR function:
1. A number variable is set to 0 (zero)
2. A string variable is set to empty string
3. A date variable is set to 0D (undefined date)
4. A time variable is set to 0T (undefined time)
5. A Boolean variable is set to FALSE
For Eg:
Consider a Variable 'Name' which has value-'xyz'.
Name := 'xyz';
CLEAR(Name);

Thursday, August 13, 2009

Modifying a Codeunit

The Procedure for modifiying an existing codeunit is geven below.
1. In the Tools menu, click Object Designer.
2. In Object Designer, click Codeunit.
3. Select the codeunit that you want to modify, and then click Design.
4. In the C/AL Editor, modify the codeunit by changing the existing functions or by adding new functions.

Wednesday, August 12, 2009

How to define Primary and Secondary Key in Navision

A maximum of 20 distinct fields can be used to define a primary key. The number of fields used in the primary key limits the number of fields in the secondary keys. Fields used by one key can also be used in another key; however, no more than 20 unique fields can be used to create primary or secondary keys.
This means that if your primary key includes four distinct fields, your secondary keys can include these four fields, and at most 16 other fields. Correspondingly, if your primary key consists of 20 distinct fields, then your secondary keys must consist only of combinations of these fields.
When you create a table in Table Designer, by default C/SIDE uses the field with the lowest field number as the primary key. Use the following procedure to define a different primary key.
To define a primary key
1. On the Tools menu, click Object Designer.
2. Click Table.
3. Select a table from the list and then click Design.
4. Select the first empty line and then from the View menu, click Keys.
5. In the first line of the Keys window, enter the primary key as a comma-delimited list; for example, "ID Number, Name".

Defining Secondary Keys

Up to 40 keys can be defined for a table. The first key defined is the primary key. All the other keys are secondary keys and are optional. Secondary keys are used to view records in an order that is different from the order defined by the primary key fields.
To define a secondary key
1. On the Tools menu, click Object Designer.
2. Click Table.
3. Select a table from the list and then click Design.
4. Select the first empty line and then from the View menu, click Keys.
5. The first line shows the primary key. Enter the secondary keys on the following lines as comma-separated lists; for example: Name, Address.

Table Properties in Navision

A table in C/SIDE has a number of properties that determine the behavior of the table. When you create a table, C/SIDE automatically defines a number of default values for these properties. Depending on what the table is going to be used for and how it is related to other application objects, you may want to change these default values. C/SIDE contains the following table properties.
Property NameDescription
ID PropertySets a unique identifier for the table.
Name PropertyDefines the table name, which is used as the table caption.
Caption PropertyDisplays the table caption in the currently selected language. This value is taken from the CaptionML Property, if a value is set.
CaptionML PropertyProvides the text that is used to identify a control or other object in the user interface. This property is multilanguage enabled and can contain a list of text in different languages. The text that is actually used is selected according to the current language setting of the user.
Description PropertyInclude an optional description of the table. This description is for internal purposes only and is not visible to the end user. A short description of the table’s purpose makes it easier to maintain the application.
DataPerCompany PropertyDetermines whether data in this table is available to all companies or only the current company.

Yes if data is available only to this company; otherwise, No. The default value is Yes.
Permissions PropertyDefines extended permissions for the table.
LookupFormID PropertyDefines the ID of the form you want to use as a lookup.
DrillDownFormID PropertyDefines the ID of the form you want to use as a drill down.
DataCaptionFields PropertyDefines a list of fields to be used as captions when a record from this table is displayed in a form or a page.
PasteIsValid PropertyUse this property to enable inserting records into this table using the paste command.

Yes if you want to allow insert by pasting; otherwise, No. The default is Yes.
LinkedObject PropertyUse this property to link to SQL Server objects.

Yes to link the table to an existing SQL Server object.
LinkedInTransaction PropertyDetermines whether the table can read and modify data from linked data sources, such as Microsoft Office Excel, Access, or another SQL server.

This property is only visible when the value of the LinkedObject Property is set to Yes.

Field Properties in Navision

Just like tables, all the fields in C/SIDE have a number of properties that determine their behavior. When you create a field, C/SIDE automatically suggests a number of default values for these properties. Depending on the purpose of the field, you will sometimes want to change these default values.
The above table list the properties that are common to most field types.
PropertyNameDescription
Field No. PropertyAssigns a unique numeric ID to this Field.
Name PropertySpecifies the name of the field.
Caption PropertySpecifies the text used to identify a control based on the field.
CaptionML PropertySpecifies the text that is used to identify a control or other object in the user interface. The CaptionML property is multilanguage enabled and can contain a list of text in different languages. The text that is used is selected according to the current language setting of the user.
CaptionClass PropertyControls the caption that is used in the label of a field in a database table or in the label of a control on a form.
Description PropertyIncludes an optional description of the field. This description is for internal purposes only and is not visible to the end user.
Data Type PropertySpecifies the data type of a table field.
Enabled PropertyDetermines whether the field is enabled.


A field may have additional properties, depending on its data type. The following table lists properties that apply to various field types.
PropertyNameDescription
DataLength PropertySpecifies the maximum length of the data stored in a code or text field.
InitValue PropertyDefines an initial value for a field.
FieldClass PropertyDefine the class for a field. That is, specifies whether it is a normal field, a FlowField, or a FlowFilter field.
CalcFormula PropertyDefines a formula used by a FlowField.
AltSearchField PropertyDefines an alternative search field.
DecimalPlaces PropertySets the number of decimal places shown to the user. This property also performs validation of whether user input conforms to this setting.
Editable PropertyDetermines whether a field can be edited.
NotBlank PropertyForces the user to make a non-blank entry in this field.
BlankNumbers PropertyDetermines whether a range of numbers will be set to blank as they are formatted.
Numeric PropertyForces the user to enter numbers in this field.
CharAllowed PropertySets the characters you will allow the user to enter in this field.
DateFormula PropertyValidates the syntax of a date expression entered by the user.
Standard day/time unit PropertySpecifies the unit of measure that is used when you enter data into Duration fields.
MinValue PropertySets the minimum value for the contents of a field.
MaxValue PropertySets the maximum value for the contents of a field.
Title PropertyAdds a title to a field. The first letter in each word is capitalized.
ValuesAllowed PropertySpecifies the values you want to allow in the field. Can be specified either as a range or as distinct values, or as a combination of these.
AutoIncrement PropertySpecifies whether each field value is automatically given a new number that is greater than the number given to the previous value.
TableRelation PropertyDefines relationships to other tables.
TestTableRelation PropertyIndicates whether the field is included in table relationship tests.
TableIDExpr PropertySpecifies the ID of the table to which you want to apply a table filter.
BlankZero PropertyDetermines whether the fields appears blank if the value is 0 (zero) or FALSE.
DataLength PropertyDefines the length of a data field.
OptionString PropertyDefines an option string (a comma-separated string of options). The maximum size is 1000 characters.
ClosingDates PropertyDetermines whether closing dates are allowed.
AutoFormatType PropertyDetermines how data is formatted.
AutoFormatExpr PropertyDetermines how data is formatted.
OptionCaption PropertyDefines the text string options that are displayed to the user.

How to Design a Table in Navision

When you first create a table, it does not contain any data. Nevertheless, when you create the table you must also decide what types of information you want to store in it. The information is held in fields, and each field can be declared as one of the data types that are available.
To create a table
1. On the Tools menu, click Object Designer.
2. Click Table and then click New.
In the Table Designer, for each field you add to the table, you enter the field number, name, data type, and optionally, a length and a description.
How to: Add Fields to a Table
Designing a field means assigning a number of characteristics to it. These characteristics depend on what you intend to use the field for. After you have added fields to a table in Table Designer, you must save the table before you can add any records. After you have saved a table, it appears in the list of tables in Object Designer.
To add a field to a table
1. On the Tools menu, click Object Designer.
2. Click Table and then click New.
3. In the first empty row, enter a Field Name and a Field No. Enter a Data type and appropriate Length. Description is optional.
To Save a New Table
When you design the fields and keys for a new table, you need to save the table in the database before you can use it. After you have saved a table, it appears in the list of tables shown in Object Designer.
To save a table
1. With the focus on Table Designer, on the File menu, click Save.
The Save As dialog box opens.
2. In the ID field, enter a number that will serve as a unique table identification.Note
3. In the Name field, enter the name of the table.
4. Clear the Compiled check box if you do not want the table to be compiled when it is saved.

Monday, August 10, 2009

List Of DataTypes

File : Basic file manipulation.
OCX : OCX object reference.
Automation : COM object reference.
InStream : Stream for reading.
OutStream : Stream for writing.
Variant : Equivalent to BASIC's Object datatype.
Codeunit : Equivalent to a Class object containing public and private Methods.
Form : Equivalent to a windows form.
Record : ORM implementation for Navision Tables.
RecordRef : A reference to a record(Navision Table).
RecordID : A representation of the primary key fields of a record.
Dataport : Specialized units for importing/exporting data through textfiles.
Boolean : Datatype boolean.
Option : Equivalent to an ENUM structure.
Integer : Datatype 16-bit integer.
Decimal : Datatype decimal.
BigInteger : Datatype 32-bit integer.
Char : Equivalent to datatype char.
Text : Datatype String.
Code : Datatype String (Capitalized).
Date : Datatype Short date.
Time : Datatype Short Time.
Datetime : Equivalent to SQL datatype Datetime
Binary : Equivalent to Byte Array

Guidlines For C/AL Coding.

The following are simple guidelines for placing C/AL code:
In general, place the code as close as possible to the object on which it will operate. This implies that code which modifies records in the database should normally be placed in the triggers of the table fields that are involved.
In reports, always maintain a clear distinction between logical and visual processing and position your C/AL code accordingly. This implies that it is acceptable to have C/AL code in a section trigger if that code controls either the visual appearance of the controls or whether the section should be printed. Never place code that manipulates data in section triggers.
The principle of placing code near the object on which it operates can be overruled in some situations. One reason to overrule this principle is security. Normal users do not have direct access to tables that contain sensitive data, such as the General Ledger Entry table. If you place the code that operates on the general ledger in a codeunit, give the codeunit access to the table, and give the user permission to execute the codeunit, you will not compromise the security of the table and the user will be able to access the table.
There are reasons other than security for putting a posting function in a codeunit. A function that is placed in a codeunit can be called from many places in the application, including, perhaps, some that you did not anticipate when you first designed the application.

Friday, August 7, 2009

Security In Navision

The Navision security system allows you to control which objects (tables and so on)each individual user can access within each database. You can specify the type ofaccess that each user has to these tables and records – whether they are able toread, modify or enter data.
Furthermore, in the SQL Server Option you can specify which particular records thatare stored in these tables each individual user is allowed to access. In other words,permissions can be allocated at both table level and at record level in the SQL ServerOption for Navision.
The Navision security system contains information about the permissions that havebeen granted to each individual user who can access each particular database. Thisinformation includes the roles that the users have been assigned as well as anyparticular permissions that they have been granted as individual users.
The Navision security system, even though it is a homogenous integrated system, canbe said to consist of four different levels of security:·
1. Database Level Security·
2. Company Level Security·
3. Object Level Security·
4. Record Level Security

Thursday, August 6, 2009

Objects In Navision

Objects
Table Data: The actual data that is stored in the tables.Table The tables themselves.
Form: The forms that are used to view and enter data.
Report: The reports that are used to present the data.
Dataport: The dataports that are used to import and export data.
Codeunit: The codeunits that are used in the database.
XMLport: The XMLports that are used to import and export data in XML format.
MenuSuite: The object that contains the menus that are displayed in the NavigationPane. System: The system tables in the database that allow the user to make backups,change license file and so on.

Zoom Funtion In Navision

In the Classic client, you use the Zoom feature on a form to view all fields for the current record that are in the table on which the form is based. For example, if you open a sales order form, click the Tools menu, and then click Zoom, then the Sales Header - Zoom window opens. The Sales Header - Zoom window shows all fields in the Sales Header table and the value of each field for the current record.
You can use the Zoom feature in the Classic client to help you troubleshoot and debug issues. For example, if you create a new form and need to troubleshoot the data that is displayed on the form, then you can use the Zoom feature to view all fields for the current record.

Tuesday, August 4, 2009

How To Create a New CodeUnit

Open the Object Designer by selecting Tools, Object Designer from the MenuBar. Press the Codeunit button to view all codeunits. Now press the New button located at the bottom of the Object Designer. The C/AL Editor window will appear, completely blank. Now close the C/AL Editor window. A questionwindow will appear asking "Do you want to save the changes to the codeunit"?Click Yes. The Save As window will now be displayed. Give The CodeUnit ID No:(Between 50000-99999) and the Name (CodeUnit Name).
Click OK. Now, scroll down to the bottom of the Object Designer window and find your new codeunit. Select it and press the Design button.
Define a Variable
To define global variables in an object, select View, C/AL Globals on the MenuBar once you are designing that object. A window like the following will appear:


Please fill it If you press the F6 key while you are in theDataType column, you will see a list of data types that you can select.Once you have entered all of these, select the Variable name. To Set the Properties, Select the Varible Click on the Properties (Press SHIFT+F4) and like set all the properties for all variable.Now close the Properties window, then close theC/AL Globals window. Finally, close the Object Designer window.When it asksif you want to save, click Yes. T write the code in the CodeUnit Go to the Corresponding Codeunit Select the Design button and write the code in OnRun(). The Save it.

This Codeunit can be called from any of the Trigers in forms or Report sections.

Variable scope and initialization

Global and Local Variables
All variables have a defined "scope", that is, a defined set of places where itcan be accessed. A variable is said to have "global" scope if it can be accessedanywhere in an object. A variable is said to have "local" scope if it can only beaccessed in a single trigger in an object. No variables can be accessed outsideof the object in which they are defined.
System Defined Variables
Certain variables are automatically defined and maintained by the system. Anexample of this is the variable called Rec in table objects. Each object has itsown set of system-defined variables. The programmer can use these variableswhenever they need to without doing anything special to either create them orto initialize their values.
Variable Initialization
Before any C/AL code is executed, all programmer-defined variables areinitialized with certain values.
· For all variables with a numeric type, this value is 0.
· For string variables, the value is the empty string ('').
· For Boolean variables, the initial value is FALSE.
· For Date and Time type variables, this initial value is 0D (the undefineddate) and 0T (the undefined time) respectively.

Identifiers and Variables

Identifier
An identifier is a name for something, a way to identify it. Objects, variables,fields and functions all have identifiers. These Identifiers must be used whenreferring to these entities. Not all items found in a program have Identifiers.Among those that do not are constants, operators and certain reserved words.Instead, these items are referred to directly. One way to understand thedifference is that those programming elements that refer to something storedelsewhere in memory require an identifier to access them, while those that existin the programming code itself and do not refer to anything outside, do notneed an Identifier.
Variable
A variable is the reference to a data value that can vary while the user isrunning the application. A variable refers to an actual location in memory inwhich data is stored. A variable has a name, also called the identifier, whichthe programmer uses in the program rather than an actual memory address. Avariable also has a data type, which describes the kind of data that can bestored in that memory address. Finally, a variable has a value, which is theactual data currently stored in that memory address.

String Data Types

String Data Types
String data is data that is made up of strings of characters. The data that isplaced in word processors is string data.
In C/AL constants, the symbol used to distinguish string data is the single quote, also known as an apostrophe ('). All string constantsare surrounded by single quotes.
Text
A text is a string of 0 to 250 characters. The length of a text is the number ofcharacters in it.
Code
A code is a special kind of text. All letters are forced to upper case and allleading and trailing spaces are removed. In addition, when displayed to theuser, a code is automatically right justified if all characters in it are numbers.

Monday, August 3, 2009

Simple Data Types

Data

Data is known facts, known pieces of information. For our purposes, we will always use “data” to mean information that is available for us to manipulate in Navision Financials using C/SIDE.

Data Types

Data Types are the different kinds of information that may appear in C/SIDE. Different Data Types have different values, different meanings for those values and are manipulated differently.

Constants

Constants are data values that are written directly into our programming statements. They are called Constants because their values never change while the user is running the application. Constants can only be changed by changing the C/AL code.

Byte

A Byte is a unit of data storage space used in computers. One character stored in the computer takes up one byte of storage. Related terms are a Kilobyte (KB), which is 1024 bytes, a Megabyte (MB), which is 1024 Kb or 1,048,576 bytes and a Gigabyte (GB), which is 1024 Mb, or 1,073,741,824 bytes.

What is C/AL

Definition

C/AL (Client Application Language) is the programming language used in the Client / Server Integrated Development Environment (C/SIDE) included with Navision Solutions.

What is it used for?

The many purposes for which it is used are

. Data presentation is handled through the form objects and report objects.
· Data acquisition is mainly handled through form and dataport objects.
· Data storage and organization is handled by the table objects in conjunction with the built-in Database Management System (DBMS).

In C/SIDE, the main purpose of the programming language is data manipulation. Through C/AL, you can create business rules to insure that the data stored in the tables are meaningful and consistent with the way your customer does business. You can add new data or transfer data from one table to another (for example, a journal to a ledger). If data from multiple tables need
to be combined onto one report or displayed on one form, you will probably need to program this.
Another purpose of C/AL is to control the execution of the various C/SIDE objects. With C/AL you are able to coordinate them in a way that meets the business needs of your customer.

Validate, Testfield

TESTFIELD Function
TESTFIELD tests whether a field contains a specific value. It has the following syntax.
Record.TESTFIELD(Field, [Value])
If the test fails, that is, if the field does not contain the specified value, an error message is displayed and a runtime error is triggered. This means that any changes that were made to the record are discarded. If the value that you test against is an empty string, the field must have a value other than blank or 0 (zero).
One of the main feature of this function is that, if you want to check any field where value is their or not, You can Use this function, So that without giving any data to that particular field, System won't allow the user to Post the document. For this you can simply write
TestField(Fieldname);
VALIDATE Function
VALIDATE calls the OnValidate trigger of a field. It has the following syntax.
Record.VALIDATE(Field [, NewValue])

IF Then Else, Case in C/AL

IF THEN [ELSE]
A conditional statement is one type of control structure in C/AL.
Using Conditional Statements
By using a conditional statement, you can specify a condition and one or more commands that should be executed, according to whether the condition is evaluated as TRUE or FALSE. There are two types of conditional statements in C/AL:
1. IF THEN [ELSE], where there are two choices
2. CASE, where there are more than two choices.
IF THEN ELSE Statements
IF THEN ELSE statements have the following syntax.
IF (Condition) THEN (Statement1)
[
ELSE
(Statement2)
]
This means that if (Condition) is true, then (Statement1) is executed. If (Condition) is false, then (Statement2) is executed.
The square brackets around ELSE mean that this part of the statement is optional. The ELSE statement is used when different actions are executed, depending on the evaluation of (Condition).
You can build even more complex control structures by nesting IF THEN ELSE statements. The following example is a typical IF THEN ELSE statement.
IF (Condition1) THEN
IF (Condition2) THEN
Statement1;
ELSE
Statement2
Note: A semicolon preceding an ELSE is not allowed.
If 'Condition1' is false, then nothing is executed. If 'Condition1' and 'Condition2' are both true, then 'Statement1' is executed. If 'Condition1' is true and 'Condition2' is false, then 'Statement2' is executed.
Reading several nested IF THEN ELSE statements can be quite confusing but a general rule is that an ELSE belongs to the last IF that lacks an ELSE.
Example 1
The following example shows an IF statement without the optional ELSE part.
IF Amount (<) 1000 THEN Total := Total + Amount;
Example 2
The following example shows an IF statement with the optional ELSE part.
(1)...
(2) IF Amount (<1000) align="justify">(3) THEN BEGIN
(4) IF I > J THEN Max := I
(5) ELSE Max := J;
(6) Amount := Amount * Max;
(6) END
(7) ELSE
(8)...
A common error is to put an extraneous semicolon at the end of a line before an ELSE (line 4). As mentioned earlier, this is not valid according to the syntax of C/AL. The semicolon is used as a statement separator. (The end of line 4 is inside the inner IF statement.)
CASE Statements
CASE statements have the following syntax.
CASE (Expression) OF
(Value set 1) : (Statement 1);
(Value set 2) :(Statement 2);......
(Value set n) : (Statement n);
[ ELSE (Statement n+1) ]
CASE statements are also called multiple option statements and are typically used when you must choose between more than two different actions.
The function of the CASE statement is as follows:
1. The 'Expression' is evaluated, and the first matching value set executes the associated statement, if there is one.
2. If none of the value sets matches the value of the expression, and the optional ELSE part has been omitted, no action is taken. If the optional ELSE part is used, then the associated statement is executed.
The data type of the value sets must be the same as the data type of 'Expression' or at least be convertible to the same data type.
For Eg:
The following C/AL code prints various messages depending on the value of Number. If the value of Number does not match any of the entries in the CASE structure, the ELSE entry is used as the default.
CASE Number OF
1,2,9: MESSAGE('1, 2, or 9.');
10..100: MESSAGE('In the range from 10 to 100.');
ELSE MESSAGE('Neither 1, 2, 9, nor in the range from 10 to 100.');
END