Upload
santosh-kumar-singh
View
232
Download
4
Embed Size (px)
Citation preview
Table of Contents
INTRODUCTION............................................................................................................................................3
CODING OF VARIABLES AND FUNCTIONS...........................................................................................4
MARKING OF OBJECTS AND CHANGES................................................................................................9
VERSION LIST..............................................................................................................................................12
TERMINOLOGY...........................................................................................................................................13
GUI...................................................................................................................................................................14
C/SIDE STATEMENTS................................................................................................................................15
Coding_Patterns_Doc 1
Introduction
Purpose
Audience
ReferencesReference Description Source
Terminology Handbook
The Terminology Handbook explains the concept of terminology and how we work with it. It also describes the underlying structure of Navision and outlines our naming conventions for objects.
C/AL Programming Guide
The C/Al Programming Guide describes the guidelines for writing C/AL code.
GUI Guide The GUI Guide describes the graphical user interface components of Navision Attain and states how these components must be used to form the graphical user interface of the application.
The main purpose of the GUI Guide is to enhance the usability of Navision Attain and add-on products to Navision Attain by ensuring visual and functional consistency across applications based on the Client/Server Integrated Development Environment (C/SIDE.)
Coding_Patterns_Doc 2
Coding of variables and functions
FieldsA meaningful name is used to define new fields to existing or new tables. The name is equal to the caption (US English) of the field.
VariablesNew variables are declared according to the following syntax:
<name>_<scope><type><application>
Name = Name of the variable
Scope = l(ocal) or g(lobal), i(nput), v(ar)
Type = type of the variable (see table below)
Application = Tmp for temporay tables, Arr for arrays.
Coding_Patterns_Doc 3
Nr. Control Abbreviation
1. Action Act
2. Automation Aut
3. BigInteger Bgi
4. BigText Bgt
5. Binary Bin
6. Boolean Bln
7. Char Chr
8. Code Cod
9. Codeunit Cdu
10.
Dataport Dpt
11.
DateFormula Dtf
12.
DateTime Dat
13.
Decimal Dec
14.
Dialog Dlg
15.
Duration Dur
16.
FieldRef Frf
17.
File Fil
18.
Form Frm
19.
GUID Gui
20.
InStream Ism
21.
Integer Int
22.
KeyRef Krf
23 OCX Ocx
24.
Option Opt
25 Outstream Osm
Coding_Patterns_Doc 4
Nr. Control Abbreviation
.
26.
Record Rec
27.
RecordID Rid
28.
RecordRef Rrf
29.
Report Rep
30.
System Sys
31.
Text Txt
32.
Time Tim
33.
TransactionType Trt
34.
Variant Var
35.
XMLport Xml
Coding_Patterns_Doc 5
Text ConstantsNew text constants are declared according to the following syntax:
<name>_<scope>Ctx
Scope = l(ocal) or g(lobal)
FunctionsNew functions are declared according to the following syntax:
<name>_<scope>Fnc
Scope = l(ocal) or g(lobal)
Controls
In some case it is required to add a name to controls on a form (e.g. for sub forms). The name that is assigned should follow the next rule:
<Name>_ C<Type>
Name : Speaking Name.
c : C(ontrol).
Type : Type, see table below.
Coding_Patterns_Doc 6
Nr. Control Abbreviation
1. Label Lbl
2. Text Box Txb
3. Check Box Cbx
4. Option Button Obt
5. Command Button Cbt
6. Menu Button Mbt
7. List Box Lbx
8. Frame Fme
9. Image Img
10.
Picture Box Pbx
11.
Shape Shp
12.
Indicator Ind
13.
Tab Control Tab
14.
Subform Sfm
15.
Table Box Tbx
16.
Matrix Box Mbx
17.
Report Frame Rfr
Coding_Patterns_Doc 7
Marking of objects and changes
Document trigger-------------------------------------------------------------------------------Columbus IT
-------------------------------------------------------------------------------
ID Date Author
-------------------------------------------------------------------------------
T-JJJ-xxx-vv, dd-mm-yyyy, <Name> <Description>
-------------------------------------------------------------------------------
T = Type (I = Initial, R=Revision, B=Bugfix).
JJJ = Job No. – Can be Alpha-Numeric
XXX = Job Task Number
Vv = Sequence Number
Changes
Syntax: <type>-<Job><Task>-<sequence>.<change>
Type = I(nitial), R(evision), B(ugfix)
Job = Job number (3 alpha numeric characters)
Sequence = Sequence number (2 digits)
Change = n, o, ns & ne, os & oe
n New
o Old
ns New start
ne New end
os Old start
oe Old end
Markings should be indented according to the indention of the source, except when only a single line is altered.
Coding_Patterns_Doc 8
Function descriptionYou can add a short description at the beginning of a function if the function contains a complex routine. The description contains:
The purpose of the function including the steps that are carried out.
The pre-condition of the function.
The post-condition of the function.
For complex functions:
//I-JEN-009-01.ns
//Purpose : The function does something.
//Pre : --
//Post : --
BEGIN
<..>
<..>
END;
//I-JEN-009-01.ne
Coding_Patterns_Doc 9
For simple functions:
//I-JEN-009-01.ns
BEGIN
<..>
<..>
END;
//I-JEN-009-01.ne
Coding_Patterns_Doc 10
Version ListThe version list of an object should be filled with a code, according to the rules below.
For existing objects:
<Standard Navision Code>,[Name]<JJJ.MM.mm>
For new objects:
[Name]<JJJ.MM.mm>
Name : In a multiple development scenario, where many developers are working on the same development server, the Developer’s Name is added so that other users are aware that the particular object is being worked upon. Once completed, the Name is removed.
JJJ : Job Code.
MM : Major Version.
mm : Minor Version.
Note that the date and time should be set to the current date, respectively 12.00 hrs. before the object is released.
Coding_Patterns_Doc 11
C/SIDE Statements
Get records from database
Introduction The new C/SIDE functions for reading records in a SQL Server environment are not backwards compatible with older Navision versions. This means a technical upgrade to NA401 is necessary. Paragraphs , , are only applicable for Navision 4.00 SP1 and beyond.
FINDFIRSTThis function should be used instead of FIND('-') when you only need the first record.For instance: IF Item_lRec.FINDFIRST THEN ItemMgt_lCdu.CopyItem(Item_lRec);
FINDLASTThis function should be used instead of FIND('+') when you only need the last record.For instance:IF ValueEntry_lRec.FINDLAST THEN LastEntryNo_lInt := ValueEntry_lRec.”Entry No.”;
FINDSETUse this function to find a set of records in a table based on the current key and filter. The records can only be retrieved in ascending order.Syntax: Ok := Record.FINDSET([ForUpdate][, UpdateKey])
ForUpdateData type: booleanSet this to FALSE if you don't intend to modify any records in the set.Set this to TRUE if you want to modify some records in the set.If you set this parameter to TRUE, a LOCKTABLE is immediately performed on the table before the records are read.
UpdateKeyData type: booleanThis only applies if ForUpdate is set to TRUE.If you want to modify any field value within the current key, set this parameter to TRUE.
Coding_Patterns_Doc 14
This function is designed to optimize finding and updating sets. If you set any or both of the parameters to FALSE, you can still modify the records in the set but these updates will not be performed optimally.This function actually replaces the FIND / REPEAT-UNTIL construction which we used until now. Example 1: Looping through a set without updating it.SalesLine_lRec.SETFILTER("Purch. Order Line No.",'<>0');IF SalesLine_lRec.FINDSET THEN BEGIN REPEAT CopyLine_lFnc(SalesLine_lRec); UNTIL SalesLine_lRec.NEXT = 0;END; Example 2 Looping through a set and update a field that is not part of the current keySalesLine_lRec.SETRANGE("Document Type",DocumentType);SalesLine_lRec.SETRANGE("Document No.",DocumentNo);IF SalesLine_lRec.FINDSET(TRUE, FALSE) THEN BEGIN REPEAT SalesLine_lRec."Location Code" := lFncGetNewLocation(SalesLine); SalesLine_lRec.MODIFY; UNTIL SalesLine_lRec.NEXT = 0;END; Example 3: Loop through a set and update a field that is part of the current keySalesShptLine_lRec.SETRANGE("Order No.", SalesLine_lRec."Document No.");SalesShptLine_lRec.SETRANGE("Order Line No.", SalesLine_lRec."Line No.");SalesShptLine_lRec.SETCURRENTKEY("Order No.","Order Line No.");IF SalesShptLine_lRec.FINDSET(TRUE, TRUE) THEN BEGIN REPEAT SalesShptLine2_lRec := SalesShptLine_lRec; SalesShptLine2_lRec."Order Line No." :=
SalesShptLine_lRec."Order Line No." + 10000; SalesShptLine2_lRec.MODIFY; UNTIL SalesShptLine_lRec.NEXT = 0;END;
Coding_Patterns_Doc 15