cancel
Showing results for 
Search instead for 
Did you mean: 

exporting smartform into word document

Former Member
0 Kudos

how to export smartform into word document . i tried converting into pdf and then download but it showing run time error that conversion is not possible and also it tells that otf command // missing. is it not possible to export directly to word document instead of pdf.plz give clear description of what to be done exactly with sample codes.

marks will be rewarded.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Lavanya,

Converting the output from Spool to Word is possible.

Here is the sample code.

I cut pasted a code from a link i got in the website, see if it helps.

ZSPOOL2WORD

Genera un fichero Word a partir de una orden de spool

************************************************************************

  • MÓDULO : FI *

  • TIPO : Listado *

  • TITULO : Generación fichero Word

  • DESCRIPCION : Genera un fichero Word a partir de una orden de spool

*

  • AUTOR: Andres Picazo FECHA: 24/03/2003 *

  • MODIFICACIONES *

  • -------------- *

  • FECHA NOMBRE DESCRIPCION *

  • -------------------------------------------------------------------- *

************************************************************************

REPORT ZSPOOL2WORD

NO STANDARD PAGE HEADING

LINE-COUNT 065

LINE-SIZE 080.

INCLUDE OLE2INCL.

*----TABLAS/ESTRUCTURAS--


*

*----TABLAS INTERNAS--


*

DATA I_BUFFER(132) OCCURS 1000000 WITH HEADER LINE.

*----VARIABLES--


*

*----PARAMETER/SELECT-OPTIONS EN PANTALLA--


*

SELECTION-SCREEN BEGIN OF BLOCK BLK_PAR WITH FRAME TITLE TEXT-SEL. "Pará

PARAMETERS: P_SPOOL LIKE TSP01-RQIDENT OBLIGATORY.

SELECTION-SCREEN END OF BLOCK BLK_PAR.

SELECTION-SCREEN BEGIN OF BLOCK BLK_WOR WITH FRAME TITLE TEXT-WOR.

PARAMETERS: P_WORD AS CHECKBOX DEFAULT 'X'.

PARAMETERS: P_FWOR LIKE RLGRAP-FILENAME DEFAULT 'C:MAYOR.DOC'.

PARAMETERS: P_PLAN LIKE RLGRAP-FILENAME

DEFAULT 'D:DATOSAPISMAYORPLANTILLA LIBRO MAYOR.DOC'.

SELECTION-SCREEN END OF BLOCK BLK_WOR.

SELECTION-SCREEN BEGIN OF BLOCK BLK_FIC WITH FRAME TITLE TEXT-FIC.

PARAMETERS: P_CTXT AS CHECKBOX DEFAULT ''.

PARAMETERS: P_FTXT LIKE RLGRAP-FILENAME DEFAULT 'C:MAYOR.TXT'.

SELECTION-SCREEN END OF BLOCK BLK_FIC.

************************************************************************

*

  • LOGICA DEL PROGRAMA

*

************************************************************************

*----


*

  • INITIALIZATION

*----


*

INITIALIZATION.

*----

-


  • START-OF-SELECTION.

*----


*

START-OF-SELECTION.

PERFORM LEER_SPOOL.

IF NOT P_CTXT IS INITIAL.

PERFORM GRABA_FICHERO.

ENDIF.

IF NOT P_WORD IS INITIAL.

PERFORM LANZA_WORD.

ENDIF.

************************************************************************

*

  • FORMS ADICIONALES

*

************************************************************************

*&----


*

*& Form LEER_SPOOL

*&----


*

  • Lee la orden de spool en el buffer

*----


*

FORM LEER_SPOOL.

CALL FUNCTION 'RSPO_RETURN_ABAP_SPOOLJOB'

EXPORTING

RQIDENT = P_SPOOL

FIRST_LINE = 1

LAST_LINE = 9999999

TABLES

BUFFER = I_BUFFER

EXCEPTIONS

NO_SUCH_JOB = 1

NOT_ABAP_LIST = 2

JOB_CONTAINS_NO_DATA = 3

SELECTION_EMPTY = 4

NO_PERMISSION = 5

CAN_NOT_ACCESS = 6

READ_ERROR = 7

OTHERS = 8.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error' SY-SUBRC

'al leer la orden de spool' P_SPOOL.

ENDIF.

ENDFORM. " LEER_SPOOL

*&----


*

*& Form GRABA_FICHERO

*&----


*

  • Graba el contenido del spool a fichero de texto.

*----


*

FORM GRABA_FICHERO.

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE = ' '

  • CODEPAGE = ' '

FILENAME = P_FTXT

FILETYPE = 'ASC'

  • MODE = ' '

  • WK1_N_FORMAT = ' '

  • WK1_N_SIZE = ' '

  • WK1_T_FORMAT = ' '

  • WK1_T_SIZE = ' '

  • COL_SELECT = ' '

  • COL_SELECTMASK = ' '

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

DATA_TAB = I_BUFFER

  • FIELDNAMES =

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_WRITE_ERROR = 2

INVALID_FILESIZE = 3

INVALID_TABLE_WIDTH = 4

INVALID_TYPE = 5

NO_BATCH = 6

UNKNOWN_ERROR = 7

GUI_REFUSE_FILETRANSFER = 8

OTHERS = 9.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error' SY-SUBRC

'al grabar el fichero' P_FTXT.

ENDIF.

ENDFORM. " GRABA_FICHERO

*&----


*

*& Form LANZA_WORD

*&----


*

  • Abre la plantilla de Word y pega el contenido del portapapeles.

*----


*

FORM LANZA_WORD.

DATA: WORDAPP TYPE OLE2_OBJECT,

DOCUMENT TYPE OLE2_OBJECT,

SELECTION TYPE OLE2_OBJECT.

  • Copia el contenido del buffer en el portapeles

CALL FUNCTION 'CLPB_EXPORT'

TABLES

DATA_TAB = I_BUFFER

EXCEPTIONS

CLPB_ERROR = 1

OTHERS = 2.

  • Abre Word

CREATE OBJECT WORDAPP 'word.application'.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'No se ha podido abrir el Word'.

ENDIF.

  • Lo pone en visible

SET PROPERTY OF WORDAPP 'Visible' = 1.

  • Cogemes el objeto documento

CALL METHOD OF WORDAPP 'Documents' = DOCUMENT.

  • Abrimos el fichero plantilla

IF P_PLAN IS INITIAL.

CALL METHOD OF DOCUMENT 'Add'.

ELSE.

CALL METHOD OF DOCUMENT 'Open' EXPORTING #1 = P_PLAN.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error al leer el fichero plantilla'.

ENDIF.

ENDIF.

  • Coge el objeto selección

CALL METHOD OF WORDAPP 'Selection' = SELECTION.

  • Pega el contenido del portapapeles

CALL METHOD OF SELECTION 'Paste'.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error al pegar contenido del portapapeles'.

ENDIF.

  • Graba el fichero

CALL METHOD OF WORDAPP 'ActiveDocument' = DOCUMENT.

CALL METHOD OF DOCUMENT 'SaveAs' EXPORTING #1 = P_FWOR.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error al grabar el nuevo documento'.

ENDIF.

  • Cierra Word

CALL METHOD OF WORDAPP 'Quit'.

IF SY-SUBRC NE 0.

MESSAGE E398(00) WITH 'Error al cerrar Word'.

ENDIF.

ENDFORM. " LANZA_WORD

check this also.................

By using FM RSPO_RETURN_ABAP_SPOOLJOB you will be able to get the ASCII text of your Spool, which you can download to your local HD and open with M$ Word.

Check the function module

CALL FUNCTION 'RSPO_DOWNLOAD_SPOOLJOB'

EXPORTING

id = p_spool

fname = p_file.

Give the file extn as .DOC. it will downlaod it as a

Word doc.But I fear you wont get the table formats and

all.

~~Guduri