11-13-2007 5:12 AM
Hi,
I have a requirement to convert a SmartForm to Word File.
I am suppressing the SmartForm Dialog box and the file name is hard coded.
There wont be any preview for SmartForm.
The below code works if , the format is PDF, but when I change the format to DOC, it does not work.
The doc file created is a 0 byte file.
Also, I wont be giving any spool requests..
What is the way to convert a Smart Form to Word document.
Regards,
Vikas
REPORT z_smart_form_2_ms_word .
DATA: cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
file_size TYPE i,
bin_filesize TYPE i.
DATA: tab_otf_data TYPE ssfcrescl,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
it_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
*" **************** suppressing the dialog box****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
PERFORM fetchdata.
END-OF-SELECTION.
PERFORM callsmartform.
tab_otf_final[] = tab_otf_data-otfdata[].
PERFORM createwordfile.
PERFORM savepdffile.
*&---------------------------------------------------------------------*
*& Form FetchData
*&---------------------------------------------------------------------*
FORM fetchdata .
SELECT * FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_ekpo
WHERE ebeln > '4500009071' AND ebeln < '4500009073' .
ENDFORM. " FetchData
*&---------------------------------------------------------------------*
*& Form CallSmartForm
*&---------------------------------------------------------------------*
FORM callsmartform .
CALL FUNCTION '/1BCDWB/SF00000234'
EXPORTING
control_parameters = cparam
output_options = outop
user_settings = space
* s_header = st_header
IMPORTING
job_output_info = tab_otf_data
TABLES
t_ekpo = it_ekpo
* EXCEPTIONS
.
IF sy-subrc <> 0.
MESSAGE 'Error in Calling Smart Form ' TYPE 'I'.
ENDIF.
ENDFORM. " CallSmartForm
*&---------------------------------------------------------------------*
*& Form createwordfile
*&---------------------------------------------------------------------*
FORM createwordfile .
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'DOC'
max_linewidth = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
* BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5
.
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. " createwordfile
*&---------------------------------------------------------------------*
*& Form savepdffile
*&---------------------------------------------------------------------*
FORM savepdffile .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = 'C:ab.doc'
filetype = 'BIN'
IMPORTING
filelength = file_size
TABLES
data_tab = pdf_tab
* EXCEPTIONS
* FILE_WRITE_ERROR = 1
* OTHERS = 22
.
IF sy-subrc <> 0.
MESSAGE 'Error while Saving' TYPE 'I'.
ENDIF.
ENDFORM. " savepdffile
11-13-2007 5:53 AM
Hi Vikas
Convert_OTF will not work: See the following line
CASE FORMAT.......
WHEN 'ASCII'.
WHEN 'PDF'.
WHEN OTHERS.
RAISE ERR_FORMAT. "format not supported
This means only ASCII and PDF are supported by this function.
What you could do is convert your output to RTF, but you would lose the formatting of the Smartform. You could also take a look at function PRINT_TEXT_FORMAT_DOC for more ideas, but this prints Standard (SO10) texts.
Regards
Gareth
11-13-2007 6:35 AM
Hi,
Try this,
Convert the Smartfom to XML .
Then
Convert XML to a word file.
Function modules are there .
Please check for the same.
Regards
Meikandan
11-13-2007 10:39 PM
12-11-2007 2:38 PM
Hi,
Did this solution work? What function modules did you use?
Kind Regards
Deon
12-12-2007 9:40 AM
07-16-2009 11:14 AM
09-10-2009 7:45 AM
Hello,
I used DOI technology to develop connection of Mail-merge technology of Microsoft and SAP ABAP class i_oi_document_proxy,with interfaceget_mail_merge_interface.
http://help.sap.com/saphelp_nw2004s/helpdata/EN/e9/0be775408e11d1893b0000e8323c4f/frameset.htm
Example:
http://www.sap2word.de/abap.html
Hope it helps
Edited by: Dimmy Kiir on Sep 11, 2009 2:47 PM
11-13-2007 10:43 PM
Hi Vikas,
use this
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'DOC'
IMPORTING
bin_filesize = v_pdf_len
TABLES
otf = output_data-otfdata
lines = pdf_table
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
if it doesn't work check the below thread
<b>Reward points for helpful answers</b>
Satish
Message was edited by:
Satish Panakala
11-13-2007 10:46 PM
Hi
The DOC format will not work. The only format modelled in CONVERT_OTF is PDF and ASCII.
11-22-2013 9:35 AM
Hi experts ,
I am having the same problem. I couldn't able to convert smart form data into word document and download it to system.
kindly resolve this issue.
Regards,
Rao