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: 

Conversion of flat file to word document

Former Member
0 Kudos

Hello,

I have a reqt where in I have data available in the flat file on the presentation server .

I want to extract some information based on some logic from the flat file and move it to the word document.

In case anyone has an idea how to go about it, please let me know.

Thanks.

1 ACCEPTED SOLUTION

former_member187255
Active Contributor
0 Kudos

Here is the sample report to open word doc with some testing message......

Report Test.
INCLUDE ole2incl.
 
DATA: word TYPE ole2_object, documentos TYPE
 
ole2_object,
documento TYPE ole2_object,
selection TYPE ole2_object,
font TYPE ole2_object.
 
CREATE OBJECT word 'WORD.APPLICATION'.
 
CALL METHOD OF word 'Documents' = documentos.
CALL METHOD OF documentos 'Add' = documento.
CALL METHOD OF documento 'Activate'.
GET PROPERTY OF word 'Selection' = selection.
GET PROPERTY OF selection 'Font' = font.
 
SET PROPERTY OF word 'Visible' = 1.
 
 
SET PROPERTY OF font 'Name' = 'Arial'.
SET PROPERTY OF font 'Size' = 12.
SET PROPERTY OF font 'Bold' = 1. "o 0
SET PROPERTY OF font 'Underline' = 1. "o 0
 
CALL METHOD OF selection 'TypeText' EXPORTING #1 = 'Word Doc Test'.
CALL METHOD OF selection 'TypeParagraph'.
 
CALL METHOD OF documento 'SaveAs' EXPORTING #1 = 'c:test.doc'.
CALL METHOD OF word 'Quit'.

Hope this will help.....

4 REPLIES 4

Former Member
0 Kudos

Hi,

I would do it with VBA/.Net modules. Built within your VBA application an RFC connection to your R/3 system. You need an user and password of course. Then access the data of the flatfile or the table via a function module. This function module has to be remote enabled that you can access it from outside. Then put with VBA/.Net commands the data in the word dokument where you need it.

See the RFC documentation of the ABAP part. It'S very helpful. There are some demos how to connect to an R/3 system. I'm sure you can find a lot of sample codes

Hope it gives an idea.

Regards,

Juergen

former_member187255
Active Contributor
0 Kudos

Here is the sample report to open word doc with some testing message......

Report Test.
INCLUDE ole2incl.
 
DATA: word TYPE ole2_object, documentos TYPE
 
ole2_object,
documento TYPE ole2_object,
selection TYPE ole2_object,
font TYPE ole2_object.
 
CREATE OBJECT word 'WORD.APPLICATION'.
 
CALL METHOD OF word 'Documents' = documentos.
CALL METHOD OF documentos 'Add' = documento.
CALL METHOD OF documento 'Activate'.
GET PROPERTY OF word 'Selection' = selection.
GET PROPERTY OF selection 'Font' = font.
 
SET PROPERTY OF word 'Visible' = 1.
 
 
SET PROPERTY OF font 'Name' = 'Arial'.
SET PROPERTY OF font 'Size' = 12.
SET PROPERTY OF font 'Bold' = 1. "o 0
SET PROPERTY OF font 'Underline' = 1. "o 0
 
CALL METHOD OF selection 'TypeText' EXPORTING #1 = 'Word Doc Test'.
CALL METHOD OF selection 'TypeParagraph'.
 
CALL METHOD OF documento 'SaveAs' EXPORTING #1 = 'c:test.doc'.
CALL METHOD OF word 'Quit'.

Hope this will help.....

Former Member
0 Kudos

Hi chandra,

Thanks for the inputs...

few clarifications:

1. When i am using your code, the word doc gets saved, but it also opens and then the system message appears the unable to perform the job "RETRY" or 'cancel'...

how do i get rid of this message

2. Also in the exporting parameter, call method of SELECTION, we could send an internal table as well right ?

thanks.

Former Member
0 Kudos

Hi Dhruv,

refer to the link below:

http://www.sap-img.com/fu038.htm

It contains the code as to How to Open files from the presentation server using Microsoft Word.

Hope this helps.

Reward if helpful.

Regards,

Sipra