‎2010 Apr 09 10:01 AM
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!
‎2010 Apr 09 10:41 AM
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.
‎2010 Apr 09 10:12 AM
‎2010 Apr 09 10:31 AM
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.
‎2010 Apr 09 2:19 PM
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 ?
‎2010 Apr 09 10:41 AM
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.
‎2010 Apr 09 2:21 PM
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
‎2010 Apr 09 5:20 PM
Hello
See this example: SAPRDEMO_FORM_INTERFACE
Kleber Santos
‎2010 Apr 13 9:38 AM
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.
‎2010 Apr 16 3:10 PM
‎2010 May 07 2:22 PM
>
> Thanks for the help.
>
> Problemo Solvedo!
Can you please provide the solution..It would be of kind help for me.
Thanks
Abhisek
‎2010 May 13 7:15 AM