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: 

REPORT OUTPUT IN WORD OR EXCEL

ashok_kumar24
Contributor
0 Kudos

Hi,

I need to convert my report output to word document with a customised logo in the word document. Can anyone please help me out by providing the necessary procedure (step by step process or code in abap).

Thanks and Regards

AK

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Ashok ,

You just copy this Abap code and run it. The output is an excel file .

REPORT ZKUN_FILE6 .

TABLES: USR03,DD02L.

DATA: ZX030L LIKE X030L.

DATA BEGIN OF ZDFIES OCCURS 0.

INCLUDE STRUCTURE DFIES.

DATA END OF ZDFIES.

DATA: BEGIN OF FLDITAB OCCURS 0,

FLDNAME(11) TYPE C,

END OF FLDITAB.

DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.

DATA TNAME LIKE DD02L-TABNAME.

SELECT * FROM USR03 INTO TABLE ITABUSR03.

TNAME = 'USR03'.

PERFORM GETFIELEDS.

PERFORM SHOW123.

********************************************

FORM GETFIELEDS.

CALL FUNCTION 'GET_FIELDTAB'

EXPORTING

LANGU = SY-LANGU

ONLY = SPACE

TABNAME = TNAME

WITHTEXT = 'X'

IMPORTING

HEADER = ZX030L

TABLES

FIELDTAB = ZDFIES

EXCEPTIONS

INTERNAL_ERROR = 01

NO_TEXTS_FOUND = 02

TABLE_HAS_NO_FIELDS = 03

TABLE_NOT_ACTIV = 04.

CASE SY-SUBRC.

WHEN 0.

LOOP AT ZDFIES.

FLDITAB-FLDNAME = ZDFIES-FIELDNAME.

APPEND FLDITAB.

ENDLOOP.

WHEN OTHERS.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

with SY-SUBRC.

ENDCASE.

ENDFORM.

***********************************

FORM SHOW123.

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = 'C:\USR03.XLS'

DATA_SHEET_NAME = 'USER LIST'

TABLES

DATA_TAB = ITABUSR03

FIELDNAMES = FLDITAB

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_FILENAME = 6

INVALID_PIVOT_FIELDS = 7

DOWNLOAD_PROBLEM = 8

OTHERS = 9.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

Thanks and Regards,

Kunal.

( hope this solves your problem.)

9 REPLIES 9

former_member188685
Active Contributor
0 Kudos

0 Kudos

hi vijay,

Your link was very helpful .

can i do the same in a word document.

I need a sample ole program for that also.

I also need to embed my company logo in the word document.

Thanks and Regards

AK

0 Kudos

Hi ashok,

if you check the SAP standard ALV reports <b>BALVST02_GRID</b> there there is a Option Word Processing (CTRLSHFTF8)

Check it, it will display the list in Word, and you can show the report with colours also.

Regards

vijay

Former Member

Former Member
0 Kudos

Hi Ashok,

There is a wonderful pdf document which will help you in connecting Office Automation tools like MS Word and Excel with ABAP.

Just check this link.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c1d54348-0601-0010-3e98-bd2...

Regards,

SP.

0 Kudos

Hi prasad ,

your link was very helpful .

I could download all my report data into a word format.

Can i embed my company's logo as part of the report in word doc.

My requirement is to download my report content , with my company's logo embedded in the word doc as part of the report.

SO is this possible using ole .

Can anyone suggest me suitable procedures

AK

0 Kudos

Hi Ashok,

Check this link. It will give you useful information about Desktop Office Integration.

http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf

I think this document will guide you in satisfying your requirement.

Regards,

SP.

0 Kudos

Hi Kumar,

Even i have a requirement now to download report output to a microsoft word and then to add customized logo to it. The link which prasad mentioned was not accessible now. So, I request you to kindly send me the documents and a sample Program (if possible) for transferring report output to microsoft word. Kindly do the needful.

Regards,

Rajesh

Former Member
0 Kudos

Hi Ashok ,

You just copy this Abap code and run it. The output is an excel file .

REPORT ZKUN_FILE6 .

TABLES: USR03,DD02L.

DATA: ZX030L LIKE X030L.

DATA BEGIN OF ZDFIES OCCURS 0.

INCLUDE STRUCTURE DFIES.

DATA END OF ZDFIES.

DATA: BEGIN OF FLDITAB OCCURS 0,

FLDNAME(11) TYPE C,

END OF FLDITAB.

DATA ITABUSR03 LIKE USR03 OCCURS 0 WITH HEADER LINE.

DATA TNAME LIKE DD02L-TABNAME.

SELECT * FROM USR03 INTO TABLE ITABUSR03.

TNAME = 'USR03'.

PERFORM GETFIELEDS.

PERFORM SHOW123.

********************************************

FORM GETFIELEDS.

CALL FUNCTION 'GET_FIELDTAB'

EXPORTING

LANGU = SY-LANGU

ONLY = SPACE

TABNAME = TNAME

WITHTEXT = 'X'

IMPORTING

HEADER = ZX030L

TABLES

FIELDTAB = ZDFIES

EXCEPTIONS

INTERNAL_ERROR = 01

NO_TEXTS_FOUND = 02

TABLE_HAS_NO_FIELDS = 03

TABLE_NOT_ACTIV = 04.

CASE SY-SUBRC.

WHEN 0.

LOOP AT ZDFIES.

FLDITAB-FLDNAME = ZDFIES-FIELDNAME.

APPEND FLDITAB.

ENDLOOP.

WHEN OTHERS.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

with SY-SUBRC.

ENDCASE.

ENDFORM.

***********************************

FORM SHOW123.

CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'

EXPORTING

FILE_NAME = 'C:\USR03.XLS'

DATA_SHEET_NAME = 'USER LIST'

TABLES

DATA_TAB = ITABUSR03

FIELDNAMES = FLDITAB

EXCEPTIONS

FILE_NOT_EXIST = 1

FILENAME_EXPECTED = 2

COMMUNICATION_ERROR = 3

OLE_OBJECT_METHOD_ERROR = 4

OLE_OBJECT_PROPERTY_ERROR = 5

INVALID_FILENAME = 6

INVALID_PIVOT_FIELDS = 7

DOWNLOAD_PROBLEM = 8

OTHERS = 9.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM.

Thanks and Regards,

Kunal.

( hope this solves your problem.)