Hi guys,
I am creating an excel file as attachment with the email,but the values(separators i,e ',and .') tend to change depending on client settings.
SO i need to convert the numbers in excel to string after the file is being created so that the value remains same on all systems.
In excel there is a functionality to add apostrophe'
and then the number converts to a string.
Can we achieve this via ABAP coding?
I tried to concatenate apostrophe' with my rates but it does not work as the value is not converted and the ' appears with the numbers in the excel file.
Example: 1.02125 is noted as '1.02125.
Attaching the code snippet for the above code:
* Variables Declarations
TYPES: BEGIN OF ty_me_mail,
rate_type TYPE kurst_curr,
from_curr TYPE fcurr_curr,
to_currncy TYPE tcurr_curr,
valid_from TYPE gdatu_cur,
exch_rate TYPE p LENGTH 16 DECIMALS 5,"string,
from_factor TYPE ffact_curr,
to_factor TYPE tfact_curr,
exch_rate_v TYPE p LENGTH 16 DECIMALS 5,"string,
from_factor_v TYPE ffact_curr,
to_factor_v TYPE tfact_curr,
END OF ty_me_mail.
DATA: gv_str1 TYPE char4,
gv_str2 TYPE string,
gv_str3 TYPE string,
gv_str4 TYPE string,
gv_str5 TYPE string,
gv_str6 TYPE string,
gv_str7 TYPE string,
gv_str8 TYPE string,
gv_me_mail TYPE string,
gt_me_mail TYPE STANDARD TABLE OF ty_me_mail.
IF NOT gt_me_mail IS INITIAL.
CONCATENATE 'Rate Type' gc_tab 'From-Currency' gc_tab 'To-Currency'
gc_tab 'Direct Exchage Rate' gc_tab 'Indirect Exchange Rate'
gc_tab 'Valid From' gc_tab 'From-Factor' gc_tab 'To-Factor' gc_crlf
INTO gv_me_mail.
LOOP AT gt_me_mail INTO gw_me_mail.
gv_str1 = gw_me_mail-rate_type.
gv_str2 = gw_me_mail-from_curr.
gv_str3 = gw_me_mail-to_currncy.
IF NOT gw_me_mail-exch_rate IS INITIAL.
gv_str4 = gw_me_mail-exch_rate.
ELSE.
gv_str8 = gw_me_mail-exch_rate_v.
ENDIF.
gv_str5 = gw_me_mail-valid_from.
IF NOT gw_me_mail-from_factor IS INITIAL.
gv_str6 = gw_me_mail-from_factor.
ELSE.
gv_str6 = gw_me_mail-from_factor_v.
ENDIF.
IF NOT gw_me_mail-to_factor IS INITIAL.
gv_str7 = gw_me_mail-to_factor.
ELSE.
gv_str7 = gw_me_mail-to_factor_v.
ENDIF.
CONCATENATE gv_me_mail
gv_str1 gc_tab
gv_str2 gc_tab
gv_str3 gc_tab
gv_str4 gc_tab
gv_str8 gc_tab
gv_str5 gc_tab
gv_str6 gc_tab
gv_str7 gc_crlf
INTO gv_me_mail.
CLEAR: gv_str1, gv_str2, gv_str3, gv_str3, gv_str4, gv_str5,
gv_str6 ,gv_str7,gw_me_mail,gv_str8.
ENDLOOP.
ENDIF.
* Attachment for E-mail
IF NOT gv_me_mail IS INITIAL.
TRY.
cl_bcs_convert=>string_to_solix(
EXPORTING
iv_string = gv_me_mail
iv_codepage = gc_4103
iv_add_bom = gc_x
IMPORTING
et_solix = gt_binary4
ev_size = gv_size1 ).
CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.
ENDIF
Thanks & Regards in Advance.
Sunit Kelkar
You may also try with a text as a formula: =314159/100000 for getting 3.14159 or 3,14159 depending on client setting.
Hi Sunil,
I have not tried any of the below options, it might not work at all but you can give it a try:
1. Before assigning exchange rate to string variable, do another assignment to a char variable. Then assign character variable to string.
2. In the character variable, concatenate a space to the exchange rate before assigning to string.
Hi Sunit,
I have also faced the same problem, and I have resolved it by converting number in String in ABAP code itself.
Use Function Module 'HRCM_AMOUNT_TO_STRING_CONVERT' to convert number to string.
Sample code :
CALL FUNCTION 'HRCM_AMOUNT_TO_STRING_CONVERT'
EXPORTING
betrg = ld_number
IMPORTING
string = ld_string.
Then you can concatenate this ld_string in your final string.
Hope this helps.😊
Add a comment