2006 Nov 15 3:02 PM
Hello,
I need to download an invoice from SAP to excel, so that the user can make any changes and then print it. I'm using OLE because the format of the invoice must be accurate. I want to be able to change the currency for the number fields depending of the invoice currency.
For instance, if i have one USD invoice i want to be able to format the amount cell of excel as a currency or accounting type with symbol USD.
Is this possible via ole ?
Any iddeas ?
Thanks In Advance!
2006 Nov 15 3:05 PM
Not sure of the solution, but the following blogs might give you some pointers
/people/sergio.ferrari2/blog/2006/06/12/spreadsheet-integration--which-approach-for-which-sap-technology
/people/sergio.ferrari2/blog/2006/06/11/downloading-data-into-excel-with-format-options-from-sap-web-applications
Regards,
Ravi
Note - Please mark all the helpful answers
2006 Nov 16 11:03 AM
I Found It !!
DATA : NUMBERFORMAT(70) TYPE C
VALUE '_-* #,##0.00 [$@@@]_-;-* #,##0.00 [$@@@]_-;_-'.
VALUE '_-* #,##0.00 [$@@@]_-;-* #,##0.00 [$@@@]_-;_-* ""-""?? [$@@@]_-;_-@_-'.
DATA : QUANTITY_FORMAT(70) TYPE C
VALUE '#,##0.++++ [$@@@]' .
PERFORM FORMAT_CURRENCY USING ROW_CNT COL_CNT
VBRK_WA-WAERK.
PERFORM FORMAT_QUANTITY USING ROW_CNT COL_CNT
ITEMS-VRKME.
FORM FORMAT_CURRENCY USING ROW
COL
U_CURRENCY.
DO 3 TIMES.
REPLACE '@@@' WITH U_CURRENCY(3) INTO NUMBERFORMAT.
ENDDO.
CALL METHOD OF HEXCEL 'Cells' = HCELL
EXPORTING
#1 = ROW
#2 = COL.
PERFORM ERR_HDL.
SET PROPERTY OF HCELL 'Style' = 'currency'.
PERFORM ERR_HDL.
SET PROPERTY OF HCELL
'NumberFormat' = NUMBERFORMAT.
PERFORM ERR_HDL.
ENDFORM. " format_currency
FORM FORMAT_QUANTITY USING ROW
COL
U_QUANTITY.
DATA : Q_FORMAT LIKE QUANTITY_FORMAT.
Q_FORMAT = QUANTITY_FORMAT.
SELECT SINGLE * FROM T006 WHERE MSEHI = U_QUANTITY.
CHECK : SY-SUBRC = 0.
IF T006-ANDEC = 0.
REPLACE '.++++ ' WITH ' ' INTO Q_FORMAT.
ELSE.
DO T006-ANDEC TIMES.
REPLACE '+' WITH '0' INTO Q_FORMAT.
ENDDO.
DO.
REPLACE '+' WITH ' ' INTO Q_FORMAT.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
ENDIF.
REPLACE '@@@' WITH U_QUANTITY(3) INTO Q_FORMAT.
CALL METHOD OF HEXCEL 'Cells' = HCELL
EXPORTING
#1 = ROW
#2 = COL.
PERFORM ERR_HDL.
SET PROPERTY OF HCELL 'Style' = 'currency'.
PERFORM ERR_HDL.
SET PROPERTY OF HCELL
'NumberFormat' = Q_FORMAT.
PERFORM ERR_HDL.
endform.