‎2009 Jul 06 7:26 AM
Hi,
In a Portal, when I selected a Purchase Order, a pop-up is shown for Open, Save or Cancel this Purchase Order. The information is showed from a Smartform in PDF format. We requisite is show the Purchase Order in DOC format. I dont know if it is possible or not, any help is welcome.
Regards,
Jose.
‎2009 Jul 06 7:30 AM
‎2009 Jul 06 8:06 AM
Hi Jose,
Try to use this code, it will be helpful.
************************************************************************
* 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_WORDRegards,
Amit.
‎2009 Jul 06 9:30 AM
Hi,
I am going to study your proposals and I will tell you if ok
Thank you very much.
‎2009 Jul 06 10:55 AM
The code doesnt read a spool when is a Smartform.
In my system, i dont have definied printers of type XSF. I have asked it. A solution will be use Adobe Interactive Forms, but for us it is imposible, due to the license payment.
Another solution?
Thanks.
Jose.