Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

PDF with SO_NEW_DOCUMENT_ATT_SEND_API1

Former Member
0 Likes
1,025

Hi again.

I want to send a PDF that is on my hard drive by using SO_NEW_DOCUMENT_ATT_SEND_API1 email.

The internal table with the PDF is 132 characters and send it by email need to be 255, I think that conversion is wrong.

Sometimes I get the email and others do not. And if I get, I can not open it tells me is wrong encrypted or corrupted.

I put the code in two post so you can see well.

Thanks in advance

TYPES: ty_receiv TYPE somlreci1,

ty_packing TYPE sopcklsti1,

ty_cont_txt TYPE solisti1,

ty_tb_receivers TYPE TABLE OF ty_receiv,

ty_tb_packing TYPE TABLE OF ty_packing,

ty_tb_cont_txt TYPE TABLE OF ty_cont_txt.

DATA: li_receivers TYPE ty_tb_receivers,

li_packing_list TYPE ty_tb_packing,

li_contents_txt TYPE ty_tb_cont_txt,

lw_receivers TYPE ty_receiv,

lw_packing_list like sopcklsti1 occurs 0 with header line,

lw_document_data TYPE sodocchgi1,

lw_contents_txt TYPE ty_cont_txt,

lv_lines_txt TYPE i,

lv_cuerpo_email TYPE string,

lv_ano TYPE par_afano,

lv_wrbtr_c TYPE char16.

CONSTANTS: lc_mail_externo LIKE somlreci1-rec_type VALUE 'U',

lc_marca LIKE somlreci1-express VALUE 'X',

lc_uno TYPE i VALUE 1,

lc_cero TYPE i VALUE 0,

lc_valor_constante TYPE i VALUE 256, "0,

lc_raw_document LIKE sopcklsti1-doc_type VALUE 'RAW'.

lw_document_data-obj_descr = text-006.

lw_document_data-doc_size = ( sy-tfill - lc_uno ) * lc_valor_constante.

  • CUERPO DEL EMAIL

CLEAR lv_cuerpo_email.

CONCATENATE lv_cuerpo_email text-007 INTO lv_cuerpo_email SEPARATED BY space.

lw_contents_txt = lv_cuerpo_email.

APPEND lw_contents_txt TO li_contents_txt.

DESCRIBE TABLE li_contents_txt LINES lv_lines_txt.

  • opciones para mandar el email

CLEAR lw_packing_list-transf_bin.

lw_packing_list-head_start = lc_uno.

lw_packing_list-head_num = lc_cero.

lw_packing_list-body_start = lc_uno.

lw_packing_list-body_num = lv_lines_txt.

lw_packing_list-doc_type = lc_raw_document.

APPEND lw_packing_list TO li_packing_list.

  • Persona a la que se le envía el mail

lw_receivers-receiver = 'emailAemail.com'.

lw_receivers-rec_type = lc_mail_externo.

lw_receivers-express = lc_marca.

APPEND lw_receivers TO li_receivers.

Hi again.

I want to send a PDF that is on my hard drive by using SO_NEW_DOCUMENT_ATT_SEND_API1 email.

The internal table with the PDF is 132 characters and send it by email need to be 255, I think that conversion is wrong.

Sometimes I get the email and others do not. And if I get, I can not open it tells me is wrong encrypted or corrupted.

I put the code in two post so you can see well.

Thanks in advance

TYPES: ty_receiv TYPE somlreci1,

ty_packing TYPE sopcklsti1,

ty_cont_txt TYPE solisti1,

ty_tb_receivers TYPE TABLE OF ty_receiv,

ty_tb_packing TYPE TABLE OF ty_packing,

ty_tb_cont_txt TYPE TABLE OF ty_cont_txt.

DATA: li_receivers TYPE ty_tb_receivers,

li_packing_list TYPE ty_tb_packing,

li_contents_txt TYPE ty_tb_cont_txt,

lw_receivers TYPE ty_receiv,

lw_packing_list like sopcklsti1 occurs 0 with header line,

lw_document_data TYPE sodocchgi1,

lw_contents_txt TYPE ty_cont_txt,

lv_lines_txt TYPE i,

lv_cuerpo_email TYPE string,

lv_ano TYPE par_afano,

lv_wrbtr_c TYPE char16.

CONSTANTS: lc_mail_externo LIKE somlreci1-rec_type VALUE 'U',

lc_marca LIKE somlreci1-express VALUE 'X',

lc_uno TYPE i VALUE 1,

lc_cero TYPE i VALUE 0,

lc_valor_constante TYPE i VALUE 256, "0,

lc_raw_document LIKE sopcklsti1-doc_type VALUE 'RAW'.

lw_document_data-obj_descr = text-006.

lw_document_data-doc_size = ( sy-tfill - lc_uno ) * lc_valor_constante.

  • CUERPO DEL EMAIL

CLEAR lv_cuerpo_email.

CONCATENATE lv_cuerpo_email text-007 INTO lv_cuerpo_email SEPARATED BY space.

lw_contents_txt = lv_cuerpo_email.

APPEND lw_contents_txt TO li_contents_txt.

DESCRIBE TABLE li_contents_txt LINES lv_lines_txt.

  • opciones para mandar el email

CLEAR lw_packing_list-transf_bin.

lw_packing_list-head_start = lc_uno.

lw_packing_list-head_num = lc_cero.

lw_packing_list-body_start = lc_uno.

lw_packing_list-body_num = lv_lines_txt.

lw_packing_list-doc_type = lc_raw_document.

APPEND lw_packing_list TO li_packing_list.

  • Persona a la que se le envía el mail

lw_receivers-receiver = 'emailAemail.com'.

lw_receivers-rec_type = lc_mail_externo.

lw_receivers-express = lc_marca.

APPEND lw_receivers TO li_receivers.

5 REPLIES 5
Read only

Former Member
0 Likes
929

data: li_tline TYPE TABLE OF tline WITH HEADER LINE.

data: begin of it_pdf_output occurs 0.

include structure tline.

data: end of it_pdf_output.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\temp\OverviewBrochure.pdf'

FILETYPE = 'ASC' "'BIN'

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

TABLES

DATA_TAB = it_pdf_output.

data: it_mess_att like solisti1 occurs 0 with header line,

gd_buffer type string,

ld_format type so_obj_tp,

ld_attdescription type so_obj_nam ,

ld_attfilename type so_obj_des,

t_attachment like solisti1 occurs 0 with header line.

    • Transfer the 132-long strings to 255-long strings*

loop at it_pdf_output.

translate it_pdf_output using ' ~'.

concatenate gd_buffer it_pdf_output into gd_buffer.

endloop.

translate gd_buffer using '~ '.

do.

it_mess_att = gd_buffer.

append it_mess_att.

shift gd_buffer left by 255 places.

if gd_buffer is initial.

exit.

endif.

enddo.

ld_format = 'PDF'.

ld_attdescription = 'OverviewBrochure'.

refresh t_attachment.

t_attachment[] = it_mess_att[].

clear lw_packing_list.

Edited by: Jonatan25 on Jun 2, 2009 9:46 AM

Read only

0 Likes
929
    • Create attachment notification*

lw_packing_list-transf_bin = 'X'.

lw_packing_list-head_start = 1.

lw_packing_list-head_num = 1.

lw_packing_list-body_start = 1.

describe table t_attachment lines lw_packing_list-body_num.

lw_packing_list-doc_type = ld_format.

lw_packing_list-obj_descr = ld_attdescription.

lw_packing_list-obj_name = ld_attfilename.

*lw_packing_list-doc_size = lw_packing_list-body_num * 255.*

append lw_packing_list TO li_packing_list.

lw_packing_list-head_start = lc_uno.

lw_packing_list-head_num = lc_cero.

lw_packing_list-body_start = lc_uno.

lw_packing_list-body_num = lv_lines_txt.

lw_packing_list-doc_type = lc_raw_document.

APPEND lw_packing_list TO li_packing_list.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = lw_document_data "Asunto

put_in_outbox = lc_marca

commit_work = lc_marca

TABLES

packing_list = li_packing_list

CONTENTS_BIN = t_attachment

contents_txt = li_contents_txt "Cuerpo

receivers = li_receivers.

Sorry to put it so long, is to clarify the code.

Thank you

Read only

0 Likes
929

pls refer to the link :

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/mailsendthroughoutputcontrols

Read only

0 Likes
929

Thanks madhuri sonawane for your answer.

I have solved this way:

data: begin of it_pdf_output occurs 0.

include structure tline.

data: end of it_pdf_output.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\temp\java_basico.pdf'

FILETYPE = 'BIN'

HAS_FIELD_SEPARATOR = ' '

HEADER_LENGTH = 0

READ_BY_LINE = 'X'

DAT_MODE = ' '

CODEPAGE = ' '

TABLES

DATA_TAB = it_pdf_output

EXCEPTIONS

FILE_OPEN_ERROR = 1

...

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.

data: begin of lt_pdf occurs 0.

include structure solisti1.

data: end of lt_pdf.

CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

EXPORTING

  • LINE_WIDTH_SRC =

LINE_WIDTH_DST = '255'

  • TRANSFER_BIN = ' '

TABLES

CONTENT_IN = it_pdf_output[]

CONTENT_OUT = lt_pdf[]

EXCEPTIONS

ERR_LINE_WIDTH_SRC_TOO_LONG = 1

...

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.

Thanks.

Read only

0 Likes
929

Hello,

you can try the below FM,

TABLE_COMPRESS and TABLE_DECOMPRESS

The first FM compresses the given data and the second FM de-compresses the same.

But the output table of second FM is 255 chars.

Thus we get the data of any size into table of 255 char.

Regards,

Sachinkumar Mehta.