cancel
Showing results for 
Search instead for 
Did you mean: 

CTX Tag to show the Amount in words.

vrjadhav
Participant
0 Kudos

Hello,

I need to display Quote TotalNetPrice in Words in the CPQ Document. Is there a CTX tag that shows the price/amount in words in accordance with the currency?

Thank you,
Vaibhav Jadhav

Accepted Solutions (1)

Accepted Solutions (1)

yogananda
Product and Topic Expert
Product and Topic Expert

Hi vrjadhav

hope below code will solve your question .. can you vote, accept this solution and close this thread.

netprice = Quote.Total.TotalAmount
def convert(num):
    units = ("", "one ", "two ", "three ", "four ","five ", "six ", "seven ","eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ","sixteen ", "seventeen ", "eighteen ", "nineteen ")
    tens =("", "", "twenty ", "thirty ", "forty ", "fifty ","sixty ","seventy ","eighty ","ninety ")
    if num < 0:
        return "minus "+convert(-num)
    if num<20:
        return  units[num] 
    if num<100:
        return  tens[num // 10]  +units[int(num % 10)] 
    if num<1000:
        return units[num // 100]  +"hundred " +convert(int(num % 100))
    if num<1000000: 
        return  convert(num // 1000) + "thousand " + convert(int(num % 1000))
    if num < 1000000000:    
        return convert(num // 1000000) + "million " + convert(int(num % 1000000))
    return convert(num // 1000000000)+ "billion "+ convert(int(num % 1000000000))


inwords= (convert(int(netprice)))
vrjadhav
Participant
0 Kudos

yoganandamuthaiah , thank you. I was primarily seeking for a CTX tag that I could utilize directly on the Document level without having to write any code. Now I've discovered that there isn't a special CTX tag for this. It might be a future SAP Team upgrade. Once again, thank you for your speedy response.

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

vrjadhav

let script store the value in a custom field and use CTX Tag in output document template.

vrjadhav
Participant
0 Kudos

Hello yoganandamuthaiah ,

I had implemented the same 🙂

Answers (1)

Answers (1)

Stevica
Advisor
Advisor

Hi Vaibhav

You should use this Tag:

<Q_TAG(<*CTX( Quote.Total.TotalNetPrice.DefaultDisplay)*>)>

Also, you can involve any CTX tag in the form of the Q Tag. More info, you can find here:

https://help.sap.com/docs/SAP_CPQ/884885f05e6b4c8082254d4d9d63f19b/37fa369968d748cc848b1785c65cc290....

Q Tag is part of the Document Generation Tags.

Regards

Stevica

vrjadhav
Participant
0 Kudos

Greetings, stevica

In the document, I'll have to show the TotalNetPrice in words. Please see the sample below.

TotalNetPrice : RS 11,300

looking for a CTX tag that will display the value (Eleven Thousand Three Hundred Rupees)

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos

Do you want like this ?? vrjadhav

<*CTX( Number(<*CTX( Quote.Total.TotalNetPrice.DefaultDisplay)*>).ToWords )*>