code syntax remove comma from decimal in RecRef

need to convert 11,375.75 to 11375.75 in Recref

can someone give me guidance.

Answers

  • serdarulutasserdarulutas Member Posts: 50
    I am not 100% sure but does it not depend on your OS regional settings by default?

    https://resrequest.helpspot.com/index.php?pg=kb.page&id=279
  • AlexDenAlexDen Member Posts: 85
    Hi,
    EVALUATE(DecimalValue, DELCHR('11,375.75','=',','),9);
    FieldRef.Value := DecimalValue;
    

    But be aware that for 11375,75 this code returns 1137575 as a result.
    For 11 375,75 a conversion error will occur.
  • TryzubTryzub Member Posts: 2
    Decimal C/AL type variable/field can be easily formatted without thousand separator which depend on the OS Regional Settings.

    I would use the Format function with XML settings (last parameter is 9).

    String := FORMAT(Value [, Length] [, FormatStr/FormatNumber])


    // Sample
    T17_Temp.INIT;
    T17_Temp.Amount := 11375.75;
    RecRef.GETTABLE(T17_Temp);
    FldRef := RecRef.FIELD(17);
    testDecimal := FldRef.VALUE;

    // by default is formatted with <Integer Thousand> i.e. Format 0
    MESSAGE(FORMAT(testDecimal));

    // comma or any other thousand separator is removed - Format 9
    MESSAGE(FORMAT(testDecimal,0,9));


    More elaborated formatting could be achieved by composing the relevant FormatStr
  • TomSLTomSL Member Posts: 4
    my code is this.

    IF (TableID = 271) AND (BankMapRec."Field No." = 17) THEN
    IF EVALUATE(testDecimal,FORMAT(RecField)) THEN BEGIN
    RecField.VALUE(FORMAT(ABS(testDecimal),0,9));

    But this is not going correctly. Still appear thosusand thousand separator. what should I do?
  • AlexDenAlexDen Member Posts: 85
    You have to format string during conversion to decimal:
    IF EVALUATE(testDecimal,FORMAT(RecField,0,9)) THEN BEGIN
      RecField.VALUE(FORMAT(ABS(testDecimal),0,9));
    
  • TomSLTomSL Member Posts: 4
    Alex,

    Still appearing for thousand separator this too.
Sign In or Register to comment.