12. Dezember 2006 15:25
SalesLine.INIT;
SalesLine."Document Type":=SalesLine."Document Type"::Order;
SalesLine."Document No.":='1001';
SalesLine."Line No.":=10000;
SalesLine.Type:=SalesLine.Type::Item;
SalesLine."No.":='1';
SalesLine.INSERT;
SalesLine.INIT;
MESSAGE(FORMAT(SalesLine));
12. Dezember 2006 15:30
INIT (Record)
Use this function to initialize a record in a C/SIDE table.
Record.INIT
Record
Data type: record
The record you want to initialize.
This function assigns default values to each field in the record. The values the system assigns in the record correspond to those defined when the table was created. If no value was assigned when the table was created, the system assigns values based on the data type, as shown in this table:
If the data type is...
The default value is...
Boolean
No
Option
0
Integer
0
Decimal
0.0
Date
0D (Undefined date)
Time
0T (Undefined time)
Code
'' (empty string)
Text
'' (empty string)
Binary
<Empty>
BLOB
<Empty>
DateFormula
'' (empty string)
TableFilter
<Empty>
BigInteger
0
Duration
0
DateTime
0DT (Undefined )
GUID
00000000-0000-0000-0000-000000000000
RecordID
<Empty>
Comments
The system does not initialize primary key or timestamp fields.
After the system executes this function, you can change the values in any or all of the fields before you call the INSERT function to enter the record in the table. Be sure that the fields that make up the primary key contain values that make the total primary key unique. If the primary key is not unique (record already exists), the system rejects the record.
Example
These C/AL examples show how to use the INIT function. Assume that the primary key includes the "No." field:
Scenario 1
Customer.INIT;
Customer."No." := '1120';
Customer.INSERT;
Scenario 2
Customer."No." := '1120';
Customer.INIT;
Customer.INSERT;
Since INIT does not initialize the primary key fields, the order of the statements in situation 1 and 2 is not important. Situation 1 causes the same result as situation 2.
12. Dezember 2006 15:32
12. Dezember 2006 15:33