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: 

Convert SmartForm to Word File.

Former Member
0 Kudos

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 won’t 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 won’t 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

10 REPLIES 10

Former Member
0 Kudos

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

meikandan_krishnan2
Participant
0 Kudos

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

0 Kudos

Hi Meikandan

What a cool idea!

Cheers

Gareth

0 Kudos

Hi,

Did this solution work? What function modules did you use?

Kind Regards

Deon

0 Kudos

Hi Deon,

I have not resolved the problem.

Regards,

Vikas

0 Kudos

This message was moderated.

0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Hi

The DOC format will not work. The only format modelled in CONVERT_OTF is PDF and ASCII.

former_member210804
Active Participant
0 Kudos

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