2007 Mar 12 2:36 PM
Hii Friends,
I am working on an OLE automation object, where my report program should call an Excel file using OLE connection.
Here I am able to print all the data in Excel, from SAP. However I am facing a problem in writting -ve values.
i.e
if value of a variable, say temp = -5 in ABAP, is should display (5) in Excel.
This is the requirement.
what I am doing is
concatenate '(' temp ')' into str_temp .
And passing it to Excel, bt in Excel it still shows -5.
Can somebody pls help me, how to fix this ?
Is thr any property to fix this?
Regards,
Hardik
2007 Mar 12 2:42 PM
2007 Mar 12 2:53 PM
2007 Mar 12 3:03 PM
Hi,
Try with replace
REPLACE '-' WITH space INTO temp.
concatenate '(' temp ')' into str_temp .
aRs
2007 Mar 12 3:13 PM
Hi
In Debugging mode, I can see my deta moves to Excel in correct format.
I mean, str_temp = (5). But if u open a blank Excel file and type (5) and press Enter. It will internally convert it to -5... that is what happening in my case.
In Excel if you go to, Format->Cells->Numbers, you can disable this option..
So is there a way or property or method in ABAP "Excel Object", I can do the same without manually doing it in Excel.
Hardik
2007 Mar 12 3:13 PM
Hi hardik,
why don't you change it in positive?
if temp < 0. tmep = temp * ( -1 ). endif.
Regards, Dieter
2007 Mar 12 3:22 PM
Hi Hardik,
try this:
Range as you need.
CALL METHOD OF H_EXCEL 'RANGE' = H_RANGE EXPORTING #1 = 'U1:U2'.
SET PROPERTY OF H_RANGE 'NumberFormat' = "#,##0.00". "You own format
Regards, Dieter
2007 Mar 12 3:27 PM
Hi,
Did you try to add a single quote in front of the value, e.g. '(5)?
Excel will consider this as an alpha value and not format it (it will be left justified though).
Thanks,
Guenther
2007 Mar 12 3:27 PM
Hi,
Otherwise try to use
CALL METHOD OF CELL 'SET_FORMAT' = TEXT.
SET PROPERTY OF TEXT 'CATEGORY' = 4.
aRs