2023 Feb 09 8:06 AM
Hi all,
I am using FM 'SO_DOCUMENT_SEND_API1' to send a mail to recipients with excel file attached. The issue is that the data which I am populating in the attachment table and passing to TABLES parameter CONTENTS_BIN is only accepting character data due to which the decimal values that I have to add in excel cells cannot be added. I am passing the decimal value to numeric character and then appending it to the table but then because of this, decimal is being lost and values like 54.80 is now appended in excel cell as 5480.
Please suggest a way in which I can send the excel document in mail that includes numeric data as well.
Below is a snippet of what I am doing to create the attachment table that is being passed to CONTENTS_BIN.
DATA: lv_min(25) type n, lv_max(25) type n.
CLEAR: lv_min, lv_max.
lv_max = lv_max_amt.
lv_min = lv_min_amt.
CONCATENATE lv_acnum lv_acc_name lv_comp lv_accurr lv_max lv_maxdate lv_min lv_mindate INTO gs_attachment SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
CONCATENATE cl_abap_char_utilities=>newline gs_attachment INTO gs_attachment.
APPEND gs_attachment TO gt_attachment.
2023 Feb 09 8:59 AM
You mean the format Tab-delimited values. "Excel format" is meaningless, because Excel supports many formats.
Please use the parameter CONTENTS_HEX. CONTENTS_BIN is deprecated (was used in the old non-Unicode systems).
You must encode the characters into code page UTF-16LE as it is the best code page supported by Excel + add a byte order mark = SAP code page 4103.
This can be achieved easily with CL_BCS_CONVERT=>STRING_TO_SOLIX.
Generally speaking, use BCS instead of old SO function modules.
2023 Feb 09 9:21 AM
Can you send me an example of code that uses content_hex and how it can be used to in my case as above?
2023 Feb 09 9:34 AM
Concerning how the values in format Tab-delimited values are interpreted by Excel, it's very simple, you can check by yourself directly in Excel. Type the value in Excel, save it as "Tab delimited" format, check what it contains via Notepad, and open it in Excel to make sure it's displayed as you wish.
In your program, replicate the same formatting as the one you see in Notepad.
Be careful, depending on region, the dot character means 2 different things either decimal point or thousands separator.
If you want to force a given text, you may wrap it between double quotes, e.g.
field1→"54.80"→field3
field1 on second line→"100"→field3
Possibly, you may use other Excel formats, like XLSX, which give you full control of Excel. Lots of posts about it in the forum.
2023 Feb 09 9:38 AM
Don't use the FM. It's so old and problematic. Use the CL_BCS classes instead. So much easier. There are blogs about it.