SAP - Problemas con SO_DOCUMENT_SEND_API1.

 
Vista:

Problemas con SO_DOCUMENT_SEND_API1.

Publicado por Adro (3 intervenciones) el 08/07/2009 20:32:11
Buen día, tengo un inconveniente con la función SO_DOCUMENT_SEND_API1.
Yo quiero enviar un archivo Excel (.csv ) Adjunto. La función me genera el archivo,
Pero no realiza los saltos de renglón, es decir me coloca todo en un solo renglón largo.

Vi en algunos ejemplos de la red que para solucionarlo Concatenaro un tipo de dato X, con el carácter de salto de renglón, al final del string. Pero cuando lo intente me tiro un error, ya que solo puede concatenar datos de tipo char.
Se les ocurre alguna solución ¿?

Ejemplo de solución:

CONSTANTS: con_cret TYPE x VALUE '0D'.

CONCATENATE:
text-002 text-003 text-004 text-005 text-006 text-007 text-008 text-009
INTO gv_file_lines SEPARATED BY gc_delim.

CONCATENATE con_cret gv_file_lines INTO it_attach.
APPEND it_attach.

Mi codigo.

*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* Obtenemos los datos de la tabla BSIK
*----------------------------------------------------------------------*
* <-- PTE_ANTI Nombre de la tabla de salida *
*----------------------------------------------------------------------*
FORM get_data CHANGING pte_anti TYPE tyt_anticipos.

data: le_anti TYPE tye_anticipos.

SELECT bukrs lifnr belnr blart xblnr umsks dmbtr budat
FROM bsik
INTO TABLE pte_anti
WHERE: bukrs IN so_soc
* AND umsks IN so_cme
AND rebzg = space
AND bschl = 31.

read table pte_anti into le_anti index 1.

delete pte_anti where: sociedad <> le_anti-sociedad
and proveedor <> le_anti-proveedor
and imp < le_anti-imp.


ENDFORM. " GET_DATA

*&---------------------------------------------------------------------*
*& Form CREATE_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GV_ANTI text
* <--P_GV_FILE_LINES text
*----------------------------------------------------------------------*
FORM create_file USING pti_anti TYPE tyt_anticipos.

DATA: le_anti TYPE tye_anticipos,
lv_imp(15) TYPE c.

data: w_crlf(4) type c value '0D0A'.

REFRESH gv_file_lines.

CONCATENATE:
text-002 text-003 text-004 text-005 text-006 text-007 text-008 text-009
INTO gv_file_lines SEPARATED BY gc_delim.

APPEND gv_file_lines.

LOOP AT pti_anti INTO le_anti.

CLEAR: gv_file_lines, lv_imp.
* Mapeo la linea

lv_imp = le_anti-imp.

CONCATENATE:
le_anti-sociedad
le_anti-proveedor
le_anti-nro_doc
le_anti-cl_doc
le_anti-ref
le_anti-ind_cme
lv_imp
le_anti-f_cont
INTO gv_file_lines SEPARATED BY gc_delim.

APPEND gv_file_lines.

ENDLOOP.


ENDFORM. " CREATE_FILE

*&---------------------------------------------------------------------*
*& Form F_GENERATE_MAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_generate_mail.

PERFORM f_create_mail.

PERFORM f_send_mail.


ENDFORM. " F_GENERATE_MAIL

*----------------------------------------------------------------------*
* Form F_CREATE_MAIL *
*----------------------------------------------------------------------*
* Se crea la cabecera del mail con los datos del proveedor *
*----------------------------------------------------------------------*
* --> p1 text *
* <-- p2 text *
*----------------------------------------------------------------------*
FORM f_create_mail.

* Datos que pueden ser modificados en un objeto.
CLEAR x_document_data.

x_document_data-obj_name = text-010.
x_document_data-obj_descr = ''.
x_document_data-to_do_out = 'X'.

* Destinatarios mail
CLEAR t_receivers.
REFRESH t_receivers.

t_receivers-receiver = '[email protected]'.
t_receivers-rec_type = 'U'.
t_receivers-express = 'X'.
APPEND t_receivers.

* Estructura del mail
CLEAR t_object_content.
REFRESH t_object_content.

ENDFORM. " F_CREATE_MAIL

*&---------------------------------------------------------------------*
*& Form F_SEND_MAIL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_send_mail.

DATA: ti_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.

CLEAR ti_attachment.
REFRESH ti_attachment.
ti_attachment[] = gv_file_lines[].

APPEND ti_attachment.

* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
*DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.

* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.

DESCRIBE TABLE ti_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = 'CSV'.
t_packing_list-obj_descr = 'Anticipos no vinculados.csv'.
t_packing_list-obj_name = 'Anticipos no vinculados'.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.

CLEAR t_receivers.
REFRESH t_receivers.

t_receivers-receiver = '[email protected]'.
t_receivers-rec_type = 'U'.
t_receivers-express = 'X'.
APPEND t_receivers.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = x_document_data
put_in_outbox = 'X'
commit_work = 'X'

TABLES
packing_list = t_packing_list
contents_bin = ti_attachment
contents_txt = t_object_content
receivers = t_receivers
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.

IF sy-subrc = 0.
WRITE :/ text-011.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM. " F_SEND_MAIL
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder