Code Convertieren in Integer

8. April 2007 00:44

Hallo,

ich habe eine Nummernserie vom Typ Code in der Momentan nur Zahlen vorkommen. Ich müsste hin und wieder den Feldinhalt des Code Feldes in einen "Integer" wert konvertieren damit ich diesen ZAhlenwert in eine andere TAbelle einfügen kann.

Würde sowas funktionieren?

8. April 2007 00:53

JA,
sofern der Wert 'nur' Numerisch ist!
(Buchstaben und Sonderzeichen könnte man aber auch abfangen, ist nur aufwendiger!)

Mit dem Befehl EVALUATE , sollte es gehen. Diesen nutze ich oft in Dataports.

Hier ein Auszug aus der Navision-Hilfe:
Navision Online-Hilfe hat geschrieben:EVALUATE (Variable)
Use this function to evaluate a string representation of a value into its normal representation. The system assigns the result to a variable.

[Ok :=] EVALUATE(Variable, String[, Number])
Ok

Data type: boolean

A return code that tells you whether or not an error occurred during the evaluation of the string.

If Ok is...
It means...

TRUE
No errors occurred during the evaluation of the string. The system assigned the value to Variable.

FALSE
Errors occurred during the evaluation of the string. The system did not modify the original value of Variable.


If you omit this optional return value and an error occurs during the evaluation of the string, a run-time error occurs. If you include it, the system assumes you will handle any errors.

Variable

Data type: boolean, integer, option, date, time, text constant, code or GUID.

Any type of variable. The value of the string is assigned to the variable.

String

Data type: text constant or code

A string containing a value of any simple C/AL data type.

Number

Data type: integer

This optional value can be used when exporting data with an XMLport. The only valid value is 9 and this indicates that the data must be converted from XML format to C/SIDE format.

Example
This example shows how the EVALUATE function works when called with three different types of variables.

Value := '010196';
Ok1 := EVALUATE(VarInteger, Value);
Ok2 := EVALUATE(VarDate, Value);
Ok3 := EVALUATE(VarYesNo, Value);
MESSAGE(Text000 + Text001 + Text002,
VarInteger, Ok1, VarDate, Ok2, VarYesNo, Ok3)

Create the following text constants in the C/AL Globals window:

Text Constant
ENU Value

Text000
'VarInteger = #1######, and the return code is: %2\'

Text001
'VarDate = #3######, and the return code is: %4\'

Text002
'VarYesNo = #5######, and the return code is: %6'


The message window shows:

VarInteger = 10196 , and the return code is: Yes
VarDate = 01/01/96, and the return code is: Yes
VarYesNo = No , and the return code is: No

This example shows that while the system can interpret Value ('010196') as both an integer and a date expression, it cannot interpret it as a boolean expression. This causes an error, shown in the return code Ok3 (=FALSE).

Gruß Mikka