Amount in Words

upasanisandipupasanisandip Member Posts: 405
Hi ,
How can I print Amount in Words in Purchase Order report?


Thanks & Regards,
Sandip.

Answers

  • Dennis_DecoeneDennis_Decoene Member Posts: 123
    I had to do that too once. I did not find anything in Dutch so I ended up doing it myself.

    But for English, here is a link to a VBA Macro for Excel:

    http://www.ozgrid.com/VBA/ValueToWords.htm

    Maybe you can adapt this to C/AL.
  • ara3nara3n Member Posts: 9,256
    Hello this is from US Check 1401. The following two function will create the amount into word
    FormatNoText(VAR NoText : ARRAY [2] OF Text[80];No : Decimal;CurrencyCode : Code[10])
    CLEAR(NoText);
    NoTextIndex := 1;
    NoText[1] := '****';
    
    IF No < 1 THEN
      AddToNoText(NoText,NoTextIndex,PrintExponent,Text026)
    ELSE BEGIN
      FOR Exponent := 4 DOWNTO 1 DO BEGIN
        PrintExponent := FALSE;
        Ones := No DIV POWER(1000,Exponent - 1);
        Hundreds := Ones DIV 100;
        Tens := (Ones MOD 100) DIV 10;
        Ones := Ones MOD 10;
        IF Hundreds > 0 THEN BEGIN
          AddToNoText(NoText,NoTextIndex,PrintExponent,OnesText[Hundreds]);
          AddToNoText(NoText,NoTextIndex,PrintExponent,Text027);
        END;
        IF Tens >= 2 THEN BEGIN
          AddToNoText(NoText,NoTextIndex,PrintExponent,TensText[Tens]);
          IF Ones > 0 THEN
            AddToNoText(NoText,NoTextIndex,PrintExponent,OnesText[Ones]);
        END ELSE
          IF (Tens * 10 + Ones) > 0 THEN
            AddToNoText(NoText,NoTextIndex,PrintExponent,OnesText[Tens * 10 + Ones]);
        IF PrintExponent AND (Exponent > 1) THEN
          AddToNoText(NoText,NoTextIndex,PrintExponent,ExponentText[Exponent]);
        No := No - (Hundreds * 100 + Tens * 10 + Ones) * POWER(1000,Exponent - 1);
      END;
    END;
    
    AddToNoText(NoText,NoTextIndex,PrintExponent,Text028);
    AddToNoText(NoText,NoTextIndex,PrintExponent,FORMAT(No * 100) + '/100');
    
    IF CurrencyCode <> '' THEN
      AddToNoText(NoText,NoTextIndex,PrintExponent,CurrencyCode)
    ELSE
      AddToNoText(NoText,NoTextIndex,PrintExponent,Text1020000);
    
    AddToNoText(VAR NoText : ARRAY [2] OF Text[80];VAR NoTextIndex : Integer;VAR PrintExponent : Boolean;AddText : Text[30])
    PrintExponent := TRUE;
    
    WHILE STRLEN(NoText[NoTextIndex] + ' ' + AddText) > MAXSTRLEN(NoText[1]) DO BEGIN
      NoTextIndex := NoTextIndex + 1;
      IF NoTextIndex > ARRAYLEN(NoText) THEN
        ERROR(Text029,AddText);
    END;
    
    NoText[NoTextIndex] := DELCHR(NoText[NoTextIndex] + ' ' + AddText,'<');
    

    Here is text constants
    Name	ConstValue
    Text026	ZERO
    Text027	HUNDRED
    Text028	AND
    Name	ConstValue
    Text032	ONE
    Text033	TWO
    Text034	THREE
    Text035	FOUR
    Text036	FIVE
    Text037	SIX
    Text038	SEVEN
    Text039	EIGHT
    Text040	NINE
    Text041	TEN
    Text042	ELEVEN
    Text043	TWELVE
    Text044	THIRTEEN
    Text045	FOURTEEN
    Text046	FIFTEEN
    Text047	SIXTEEN
    Text048	SEVENTEEN
    Text049	EIGHTEEN
    Text050	NINETEEN
    Text051	TWENTY
    Text052	THIRTY
    Text053	FORTY
    Text054	FIFTY
    Text055	SIXTY
    Text056	SEVENTY
    Text057	EIGHTY
    Text058	NINETY
    Text059	THOUSAND
    Text060	MILLION
    Text061	BILLION
    Name	ConstValue
    Text1020000	DOLLARS
    

    And here is how you use it.
    FormatNoText(DescriptionLine,CheckLedgEntry.Amount,BankAcc2."Currency Code");
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • nunomaianunomaia Member Posts: 1,153
    This function is from W1 version. It's exclusive from US Version :-D
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • ara3nara3n Member Posts: 9,256
    right it's W1 version. if it's in all the version, then I guess I didn't have to put the code. :oops:
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • real_ashwinreal_ashwin Member Posts: 5
    In what respect is CheckLedgEntry.Amount ?
    Is it a record or a text in c/al globals ?
Sign In or Register to comment.