El problema que me surge es en el momento en que intento abrir el fichero adjunto después de utilizar 'SO_DOCUMENT_SEND_API1'.
Me sale un mensaje "El fichero no puede abrirse porque es un archivo no permitido o está dañado.
A ver si alguien sabe por qué pasa...
Operativa que sigo:
-Impresión de mensajes de Factura en fondo y ejecución del programa RSTXPDFT4 para grabar un fichero pdf por cada factura en el servidor. Esto debe seguir haciéndose así, porque los clientes pueden acceder a ver sus facturas a través de un programa no-sap.
-El segundo paso es buscar los archivos pdf del servidor y enviarlos por mail. El código es el siguiente:
DATA: BEGIN OF res_adjunto,
raw(255) TYPE x,
END OF res_adjunto.
DATA: it_adjunto LIKE res_adjunto OCCURS 0 WITH HEADER LINE.
DATA: wa_cabecera LIKE sodocchgi1,
it_cuerpo TYPE TABLE OF solisti1 WITH HEADER LINE,
it_paquete LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_receptores LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
wa_cuerpo LIKE it_cuerpo-line,
lineas LIKE sy-tabix,
indice LIKE sy-tabix.
OPEN DATASET v_pathfile FOR INPUT IN binary MODE.
DO.
READ DATASET v_pathfile INTO it_adjunto.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND it_adjunto.
ENDDO.
CLOSE DATASET v_pathfile.
.
.
CLEAR: wa_cabecera, it_cuerpo.
REFRESH it_cuerpo.
* Cabecera y cuerpo
wa_cabecera-obj_langu = sy-langu.
wa_cabecera-obj_name = 'SAPRPT'.
wa_cabecera-sensitivty = 'F'.
wa_cabecera-obj_descr = 'Facturas abril'.
*
it_cuerpo-line = 'Estimado cliente. Le adjuntamos las facturas del mes..'.
APPEND it_cuerpo.
CLEAR it_paquete.
REFRESH it_paquete.
* Cuerpo del mensaje
indice = 1.
it_paquete-transf_bin = space.
it_paquete-head_start = indice.
it_paquete-body_start = 1.
DESCRIBE TABLE it_cuerpo LINES it_paquete-body_num.
it_paquete-doc_type = 'RAW'.
APPEND it_paquete.
* Archivo adjunto
indice = indice + 1.
CLEAR: it_paquete.
it_paquete-transf_bin = 'X'.
it_paquete-head_start = 1.
it_paquete-body_start = 1.
DESCRIBE TABLE it_adjunto LINES it_paquete-body_num.
it_paquete-doc_type = 'pdf'.
it_paquete-obj_descr = 'Nombre_adjunto'.
DESCRIBE TABLE it_adjunto LINES lineas.
READ TABLE it_adjunto INDEX lineas.
it_paquete-doc_size = ( lineas - 1 ) * 255 + STRLEN( it_adjunto ).
APPEND it_paquete.
* Creamos el mail
DESCRIBE TABLE it_cuerpo LINES lineas.
READ TABLE it_cuerpo INDEX lineas.
wa_cabecera-doc_size = ( lineas - 1 ) * 255 + STRLEN( it_cuerpo )
+ it_paquete-doc_size. PERFORM cargar_receptores.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_cabecera
put_in_outbox = 'X'
sender_address = pa_emiso
sender_address_type = 'INT'
commit_work = 'X'
* IMPORTING
* SENT_TO_ALL = ''
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
packing_list = it_paquete
* OBJECT_HEADER =
contents_txt = it_cuerpo
contents_hex = it_adjunto
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receptores
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
El fichero se envía pero cuando lo quiero abrir desde la transacción SCOT me dice que no se permite el formato o hay que descodificarlo. ¿Alguien me puede ayudar?
He probado de pasar el fichero del servidor al pc mediante CuteFTP y cuando lo abro no tengo problema.
Muchas gracias.
Me sale un mensaje "El fichero no puede abrirse porque es un archivo no permitido o está dañado.
A ver si alguien sabe por qué pasa...
Operativa que sigo:
-Impresión de mensajes de Factura en fondo y ejecución del programa RSTXPDFT4 para grabar un fichero pdf por cada factura en el servidor. Esto debe seguir haciéndose así, porque los clientes pueden acceder a ver sus facturas a través de un programa no-sap.
-El segundo paso es buscar los archivos pdf del servidor y enviarlos por mail. El código es el siguiente:
DATA: BEGIN OF res_adjunto,
raw(255) TYPE x,
END OF res_adjunto.
DATA: it_adjunto LIKE res_adjunto OCCURS 0 WITH HEADER LINE.
DATA: wa_cabecera LIKE sodocchgi1,
it_cuerpo TYPE TABLE OF solisti1 WITH HEADER LINE,
it_paquete LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_receptores LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
wa_cuerpo LIKE it_cuerpo-line,
lineas LIKE sy-tabix,
indice LIKE sy-tabix.
OPEN DATASET v_pathfile FOR INPUT IN binary MODE.
DO.
READ DATASET v_pathfile INTO it_adjunto.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND it_adjunto.
ENDDO.
CLOSE DATASET v_pathfile.
.
.
CLEAR: wa_cabecera, it_cuerpo.
REFRESH it_cuerpo.
* Cabecera y cuerpo
wa_cabecera-obj_langu = sy-langu.
wa_cabecera-obj_name = 'SAPRPT'.
wa_cabecera-sensitivty = 'F'.
wa_cabecera-obj_descr = 'Facturas abril'.
*
it_cuerpo-line = 'Estimado cliente. Le adjuntamos las facturas del mes..'.
APPEND it_cuerpo.
CLEAR it_paquete.
REFRESH it_paquete.
* Cuerpo del mensaje
indice = 1.
it_paquete-transf_bin = space.
it_paquete-head_start = indice.
it_paquete-body_start = 1.
DESCRIBE TABLE it_cuerpo LINES it_paquete-body_num.
it_paquete-doc_type = 'RAW'.
APPEND it_paquete.
* Archivo adjunto
indice = indice + 1.
CLEAR: it_paquete.
it_paquete-transf_bin = 'X'.
it_paquete-head_start = 1.
it_paquete-body_start = 1.
DESCRIBE TABLE it_adjunto LINES it_paquete-body_num.
it_paquete-doc_type = 'pdf'.
it_paquete-obj_descr = 'Nombre_adjunto'.
DESCRIBE TABLE it_adjunto LINES lineas.
READ TABLE it_adjunto INDEX lineas.
it_paquete-doc_size = ( lineas - 1 ) * 255 + STRLEN( it_adjunto ).
APPEND it_paquete.
* Creamos el mail
DESCRIBE TABLE it_cuerpo LINES lineas.
READ TABLE it_cuerpo INDEX lineas.
wa_cabecera-doc_size = ( lineas - 1 ) * 255 + STRLEN( it_cuerpo )
+ it_paquete-doc_size. PERFORM cargar_receptores.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = wa_cabecera
put_in_outbox = 'X'
sender_address = pa_emiso
sender_address_type = 'INT'
commit_work = 'X'
* IMPORTING
* SENT_TO_ALL = ''
* NEW_OBJECT_ID =
* SENDER_ID =
TABLES
packing_list = it_paquete
* OBJECT_HEADER =
contents_txt = it_cuerpo
contents_hex = it_adjunto
* OBJECT_PARA =
* OBJECT_PARB =
receivers = it_receptores
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
OTHERS = 8
El fichero se envía pero cuando lo quiero abrir desde la transacción SCOT me dice que no se permite el formato o hay que descodificarlo. ¿Alguien me puede ayudar?
He probado de pasar el fichero del servidor al pc mediante CuteFTP y cuando lo abro no tengo problema.
Muchas gracias.