cancel
Showing results for 
Search instead for 
Did you mean: 

Pedido de Compras vía mail

Former Member
0 Kudos

Hola,

Estoy trabajando en un servidor ECC 6.0, y estamos se está implementando que se le envíe a los proveedores el pedido vía mail, tenemos una clase de mensaje para eso, sin embargo, el correo que llega es básico y se quiere colocar cuerpo del mensaje, que lea automáticamente el correo del proveedor y la verdad no se si exista algún manual o algo donde se pueda uno guíar.

Si alguien me puede ayudar con eso, lo agradeceria.

Saludos...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Buenas, amigo yo tenia el mismo problema y lo solucione con un programa abap que se dispara en el programa de impresion y envia el mail via SMTP, convitiendo la OTF a pdf y haciendo un attach del mismo, te adjunto el codigo y los parametros del programa, saludos

Parametros:

E-mail (mail del destinastario)

Nro. Spool

Titulo (Subject)

Nombre archivo (Nombre del attach)

Lista de distribución

Usuario emisor

VC_LISTA (envio inmediato del mail)

Codigo:

report zmm_uti_envia_mail.

parameters: vc_email type somlreci1-receiver,

  • vn_spool type tsp01-rqident obligatory,

vc_titul type so_obj_des obligatory,

vc_file type so_obj_des obligatory,

vc_obje like somlreci1-receiver,

vc_uname type uname,

vc_lista type checkbox.

data: ti_message type standard table of solisti1 initial size 0

with header line.

data: ti_attach type standard table of solisti1 initial size 0

with header line,

ti_attachx type standard table of solisti1 initial size 0

with header line,

ti_datos type tline occurs 1000 with header line,

ti_pdf_content type standard table of bapiascont.

data: ti_packing_list like sopcklsti1 occurs 0 with header line,

ti_contents like solisti1 occurs 0 with header line,

ti_receivers like somlreci1 occurs 0 with header line,

ti_attachment like solisti1 occurs 0 with header line,

ti_object_header like solisti1 occurs 0 with header line,

vi_cnt type i,

vc_sent_all(1) type c,

es_doc_data like sodocchgi1,

vn_error type sy-subrc,

vi_pdf_bytecount type i,

vi_reciever type sy-subrc.

start-of-selection.

if vc_lista is not initial.

perform build_html_data_table.

else.

perform build_pdf_data_table.

endif.

end-of-selection.

perform populate_email_message_body.

perform send_file_as_email_attachment

tables ti_message

ti_attach

using vc_email

vc_titul

'PDF'

vc_file

' '

vc_uname

' '

changing vn_error

vi_reciever.

perform initiate_mail_execute_program.

*&----


*

*& Form BUILD_XLS_DATA_TABLE

*&----


*

  • Build data table for .xls document

*----


*

form build_pdf_data_table.

call function 'CONVERT_OTFSPOOLJOB_2_PDF'

exporting

src_spoolid = vn_spool

importing

pdf_bytecount = vi_pdf_bytecount

tables

pdf = ti_datos

exceptions

err_no_otf_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_dstdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

others = 12.

if sy-subrc = 0.

refresh ti_attach.

  • perform sb_via_local.

  • perform sb_transfer_dsn.

perform sb_comvertir_bin.

endif.

endform. " BUILD_PDF_DATA_TABLE

*&----


*

*& Form SEND_FILE_AS_EMAIL_ATTACHMENT

*&----


*

  • Send email

*----


*

form send_file_as_email_attachment tables pit_message

pit_attach

using p_email

p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type

changing p_error

p_reciever.

data: ld_error type sy-subrc,

ld_reciever type sy-subrc,

ld_mtitle like sodocchgi1-obj_descr,

ld_email like somlreci1-receiver,

ld_format type so_obj_tp ,

ld_attdescription type so_obj_nam ,

ld_attfilename type so_obj_des ,

ld_sender_address like soextreci1-receiver,

ld_sender_address_type like soextreci1-adr_typ,

ld_receiver like sy-subrc.

ld_email = p_email.

ld_mtitle = p_mtitle.

ld_format = p_format.

ld_attdescription = p_attdescription.

ld_attfilename = p_filename.

ld_sender_address = p_sender_address.

ld_sender_address_type = p_sender_addres_type.

  • Fill the document data.

es_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

es_doc_data-obj_langu = sy-langu.

es_doc_data-obj_name = 'SAPRPT'.

es_doc_data-obj_descr = ld_mtitle .

es_doc_data-sensitivty = 'F'.

  • Fill the document data and get size of attachment

clear es_doc_data.

read table pit_attach index vi_cnt.

es_doc_data-doc_size =

( vi_cnt - 1 ) * 255 + strlen( pit_attach ).

  • es_doc_data-OBJ_NAME = 'ACT_PROVEEDO'. "vc_obje.

es_doc_data-obj_langu = sy-langu.

es_doc_data-obj_name = 'SAPRPT'.

es_doc_data-obj_descr = ld_mtitle.

es_doc_data-sensitivty = 'F'.

clear ti_attachment.

refresh ti_attachment.

ti_attachment[] = pit_attach[].

  • Describe the body of the message

clear ti_packing_list.

refresh ti_packing_list.

ti_packing_list-transf_bin = space.

ti_packing_list-head_start = 1.

ti_packing_list-head_num = 0.

ti_packing_list-body_start = 1.

describe table pit_message lines ti_packing_list-body_num.

ti_packing_list-doc_type = 'RAW'.

append ti_packing_list.

  • Create attachment notification

ti_packing_list-transf_bin = 'X'.

ti_packing_list-head_start = 1.

ti_packing_list-head_num = 1.

ti_packing_list-body_start = 1.

describe table ti_attachment lines ti_packing_list-body_num.

ti_packing_list-doc_type = ld_format.

ti_packing_list-obj_descr = p_filename.

ti_packing_list-obj_name = 'Obj_pdf'.

ti_packing_list-doc_size = ti_packing_list-body_num * 255.

append ti_packing_list.

  • Add the recipients email address

clear ti_receivers.

refresh ti_receivers.

if ld_email is not initial.

ti_receivers-receiver = ld_email.

ti_receivers-rec_type = 'U'.

ti_receivers-com_type = 'INT'.

ti_receivers-notif_del = 'X'.

ti_receivers-notif_ndel = 'X'.

append ti_receivers.

endif.

if not vc_obje is initial.

  • add the recipients email address

clear ti_receivers.

ti_receivers-receiver = vc_obje.

ti_receivers-rec_type = 'C'.

ti_receivers-com_type = 'INT'.

ti_receivers-notif_del = 'X'.

ti_receivers-notif_ndel = 'X'.

append ti_receivers.

endif.

call function 'SO_DOCUMENT_SEND_API1'

exporting

document_data = es_doc_data

put_in_outbox = 'X'

sender_address = ld_sender_address

sender_address_type = ld_sender_address_type

commit_work = 'X'

importing

sent_to_all = vc_sent_all

tables

packing_list = ti_packing_list

contents_bin = ti_attachment

contents_txt = pit_message

receivers = ti_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.

ld_error = sy-subrc.

loop at ti_receivers.

ld_receiver = ti_receivers-retrn_code.

endloop.

endform. "send_file_as_email_attachment

*&----


*

*& Form INITIATE_MAIL_EXECUTE_PROGRAM

*&----


*

form initiate_mail_execute_program.

if vc_lista eq space.

wait up to 2 seconds.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endif.

endform. " INITIATE_MAIL_EXECUTE_PROGRAM

*&----


*

*& Form POPULATE_EMAIL_MESSAGE_BODY

*&----


*

form populate_email_message_body.

refresh ti_message.

ti_message = 'Por favor revise el documento adjunto, saludos.'.

append ti_message.

clear ti_message.

append ti_message.

ti_message = 'Empresa XXX'.

append ti_message.

clear ti_message.

endform. " POPULATE_EMAIL_MESSAGE_BODY

*&----


*

*& Form SB_VIA_LOCAL

*&----


*

form sb_via_local .

call function 'GUI_DOWNLOAD'

exporting

filename = 'ZZSPOOL.PDF'

filetype = 'BIN'

tables

data_tab = ti_datos

exceptions

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

others = 22.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

call function 'GUI_UPLOAD'

exporting

filename = 'ZZSPOOL.PDF'

filetype = 'BIN'

tables

data_tab = ti_attach

exceptions

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

others = 17.

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. " SB_VIA_LOCAL

*&----


*

*& Form SB_TRANSFER_DSN

*&----


*

form sb_transfer_dsn .

data: vc_file type string value `ZZSPOOL.PDF`, vn_largo type i value 255.

field-symbols to ti_attach.

else.

exit.

endif.

enddo.

endif.

endform. " SB_TRANSFER_DSN

*&----


*

*& Form SB_COMVERTIR_BIN

*&----


*

form sb_comvertir_bin .

call function 'SX_TABLE_LINE_WIDTH_CHANGE'

exporting

line_width_src = 134

line_width_dst = 255

transfer_bin = 'X'

tables

content_in = ti_datos

content_out = ti_attach

exceptions

err_line_width_src_too_long = 1

err_line_width_dst_too_long = 2

err_conv_failed = 3

others = 4.

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. " SB_COMVERTIR_BIN

*&----


*

*& Form BUILD_HTML_DATA_TABLE

*&----


*

form build_html_data_table .

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

exporting

src_spoolid = vn_spool

importing

pdf_bytecount = vi_pdf_bytecount

tables

pdf = ti_datos

exceptions

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

others = 12.

refresh ti_attach.

perform sb_comvertir_bin.

endform.

Answers (1)

Answers (1)

Former Member
0 Kudos

Mira la nota 191470 a ver si te ayuda.