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: 

OLE - Format Cells Currency Via ABAP/4 - OLE

Former Member
0 Kudos
1,278

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!

2 REPLIES 2

Former Member
0 Kudos
228

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

Former Member
0 Kudos
228

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.