Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in sending amount field in excel via mail.

0 Kudos

Hi,

I have declared field in internal table as:

Amount type p length 15 decimal 2.

I am sending this field in excel for sending mail.

Its is working fine when ilthere are positive values. But it is giving issue when there are -ve values.

Suppose if in the table i ha e 1000.00-

Then in excel i am getting -1.00.00-

I am using .xlsx format.

Can any 1 guide how can i send value -1000.00 in xlsx.

Thanks !

3 REPLIES 3

AmanSaxena
Participant
0 Kudos

To display negative values correctly in Excel when sending data from SAP, you can use the following approach:
1. Format the cell explicitly as text: Excel tends to interpret certain data formats automatically, which can lead to incorrect display of negative values. By formatting the cell explicitly as text, Excel will treat the value as a text string rather than a number.

2. Prepend the minus sign ('-') to the value: Add the minus sign to the beginning of the value to indicate that it is a negative number. By doing so, Excel will recognize and display the value correctly.

Here's an example of how you can modify your code to address this issue:

DATA: lv_amount TYPE p LENGTH 15 DECIMALS 2,
lv_formatted_amount TYPE string.
lv_amount = -1000.00.
IF lv_amount < 0.
lv_formatted_amount = '-' && CONV string( ABS( lv_amount ) ).
ELSE.
lv_formatted_amount = CONV string( lv_amount ).
ENDIF.

" Export the formatted value to Excel or send it via email


By using the above approach, you can ensure that negative values are correctly displayed in Excel as text, without any unwanted formatting changes or truncation.

0 Kudos

Storing numbers as texts is the last solution to retain because in business Excel is usually used to do calculations on numbers (sum, etc.), which can't be done on texts.

Sandra_Rossi
Active Contributor
0 Kudos

Don't you mean the .xlsx file extension? File format and file extension are 2 completely different things.

Please explain exactly how you generate ".xlsx format"?

NB: your issue is not about the email, it's only about the way you generate the Excel file.