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: 

Write MS Word Document into Internal Table

Former Member
0 Kudos

Hi,

I have to upload an ms word document into an internal table, change its contents and write the internal table to word document again. I am able to do this with .txt file but not with .doc. Any suggestions?

Thnx in advance!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

To upload data from doc file to internal table you can use the function module GUI_UPLOAD ....

declare P_DATA as :

P_DATA(255) type c.

and give the file location in it

for example : P_DATA = 'C:\text.doc'

or you can say

constant : P_DATA(255) type c value 'C:\text.doc'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_DATA

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

tables

data_tab = IT_TAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

Please do not forget to mention HAS_FIELD_SEPARATOR = 'X'

This is the one which should solve your problem.

10 REPLIES 10

Former Member
0 Kudos

Refer

rainer_hbenthal
Active Contributor
0 Kudos

Open you worddocument with notepad and have a look at the mess you're getting. You cant do meaninggful changes to this. What you can see in notepad is what you're getting in your ABAP.

0 Kudos

Thanks for your reply.

Well my requirement is actually to modify and save a word document using ABAP code. Using internal table was the one started with. If that is not posible can you suggest any other method ?

Former Member
0 Kudos

To upload data from doc file to internal table you can use the function module GUI_UPLOAD ....

declare P_DATA as :

P_DATA(255) type c.

and give the file location in it

for example : P_DATA = 'C:\text.doc'

or you can say

constant : P_DATA(255) type c value 'C:\text.doc'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = P_DATA

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

tables

data_tab = IT_TAB

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

OTHERS = 17

.

IF sy-subrc <> 0.

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

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

ENDIF.

Please do not forget to mention HAS_FIELD_SEPARATOR = 'X'

This is the one which should solve your problem.

0 Kudos

I tried the same code but it did not work. The text was still gibberish. Is there any other way to modify and save a word document using ABAP Code.

Edited by: tshouri on Apr 9, 2010 6:52 PM

0 Kudos

Hello

See this example: SAPRDEMO_FORM_INTERFACE

Kleber Santos

0 Kudos

Hi Kleber,

thanks for the reply.I tried the program but am not able to understand how to link the program parameters to word file parameters.Please help me out with this.Thank you.

0 Kudos

Thanks for the help.

Problemo Solvedo!

0 Kudos

>

> Thanks for the help.

>

> Problemo Solvedo!

Can you please provide the solution..It would be of kind help for me.

Thanks

Abhisek

0 Kudos

See this example: SAPRDEMO_FORM_INTERFACE