‎2007 Apr 18 8:51 PM
Hi,
i using <b>cl_document_bcs</b> to send e-mail attachments as pdf.
eventhough <b>CONTENT_TEXT-line</b> is 255 char length, it is splitting into two lines when have more than say 150 char. Is there a parameter or variable i need to set?
appreciate your replies.
Siva
‎2007 Apr 18 9:01 PM
Hi,
Here is a program I created to convert any programs output into PDF and emails it.
The input for the program will: Name of the report and its variant. This program will execute this report you specified and creates a spool and then convert the spool into PDF and mails.
May be you can use some parts of this report. This was developed in 46C.
REPORT zss_mail_report_in_pdf.
TABLES: tsp01.
DATA: w_print_parms LIKE pri_params,
w_valid(1) TYPE c,
w_bytecount TYPE i,
* w_length TYPE i,
w_repid LIKE sy-repid,
w_rqident LIKE tsp01-rqident.
DATA: i_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
i_temp LIKE bapiqcmime OCCURS 0 WITH HEADER LINE,
w_filename LIKE rlgrap-filename.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objtxt2 LIKE solisti1 OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
recipient_int LIKE sadrud,
recipient_rml LIKE sadr7d,
tab_lines LIKE sy-tabix,
doc_chng LIKE sodocchgi1,
sent_to_all LIKE sonv-flag.
PARAMETERS: p_repid LIKE sy-repid,
p_varnt LIKE rsvar-variant,
p_linsz LIKE sy-linsz,
p_paart LIKE sy-paart.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_mail AS CHECKBOX,
p_clist RADIOBUTTON GROUP ml1,
p_addr RADIOBUTTON GROUP ml1 DEFAULT 'X',
p_mailid LIKE sza5_d0700-smtp_addr.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_down AS CHECKBOX,
p_name LIKE rlgrap-filename.
START-OF-SELECTION.
IF NOT p_mail IS INITIAL
AND p_mailid IS INITIAL.
WRITE: / 'Need mail id for mailing the document.'.
STOP.
ENDIF.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
authority = space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '0'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = ' '
* new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
IMPORTING
out_parameters = w_print_parms
valid = w_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF w_print_parms-pdest = space.
w_print_parms-pdest = 'LPT1'.
ENDIF.
w_print_parms-linsz = p_linsz.
w_print_parms-paart = p_paart.
*** Create a Spool entry for the report
SUBMIT (p_repid) TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS w_print_parms
USING SELECTION-SET p_varnt
AND RETURN.
*** Retrive the Spool Request number
w_repid = sy-repid.
PERFORM get_spool_number USING w_repid
sy-uname
CHANGING w_rqident.
*** Convert the spool request to PDF format
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w_rqident
no_dialog = 'X'
dst_device = w_print_parms-pdest
IMPORTING
pdf_bytecount = w_bytecount
TABLES
pdf = i_pdf
EXCEPTIONS
OTHERS = 12.
IF sy-subrc <> 0.
WRITE: / 'Error converting Spool request to PDF.'.
STOP.
ENDIF.
*** Download the PDF document on to desktop
IF NOT p_down IS INITIAL.
IF p_name IS INITIAL.
CONCATENATE 'C:' p_repid '.pdf' INTO w_filename.
ELSE.
MOVE p_name TO w_filename.
ENDIF.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = w_bytecount
filename = w_filename
filetype = 'BIN'
IMPORTING
act_filename = w_filename
TABLES
data_tab = i_pdf
EXCEPTIONS
OTHERS = 8.
IF sy-subrc <> 0.
WRITE: / 'Error downloading the PDF file.'.
STOP.
ENDIF.
ENDIF.
*** Mail the PDF document
IF NOT p_mail IS INITIAL.
* Reformat the line to 255 characters wide (--code from SAP--)
* Data for converting PDF data from text table to MIME table
DATA: l_lines TYPE i,
l_temp(500) TYPE c,
l_offset TYPE p,
l_lineslen(2) TYPE p,
l_mimelen(2) TYPE p,
l_tabix LIKE sy-tabix.
CLEAR: l_temp, l_offset, i_temp.
DESCRIBE TABLE i_pdf LINES l_lines.
DESCRIBE FIELD i_pdf LENGTH l_lineslen.
DESCRIBE FIELD i_temp LENGTH l_mimelen.
LOOP AT i_pdf.
l_tabix = sy-tabix.
MOVE i_pdf TO l_temp+l_offset.
IF l_tabix = l_lines.
l_lineslen = strlen( i_pdf ).
ENDIF.
l_offset = l_offset + l_lineslen.
IF l_offset GE l_mimelen.
CLEAR i_temp.
i_temp = l_temp(l_mimelen).
APPEND i_temp.
SHIFT l_temp BY l_mimelen PLACES.
l_offset = l_offset - l_mimelen.
ENDIF.
IF l_tabix = l_lines.
IF l_offset GT 0.
CLEAR i_temp.
i_temp = l_temp(l_offset).
APPEND i_temp.
ENDIF.
ENDIF.
ENDLOOP.
* Mail message body or main document
objtxt = text-t01.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t02.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t05.
REPLACE '&' WITH p_repid INTO objtxt.
APPEND objtxt.
objtxt = text-t06.
REPLACE '&' WITH p_varnt INTO objtxt.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t03.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t04.
APPEND objtxt.
SELECT SINGLE name1 FROM usr03
INTO objtxt
WHERE bname = sy-uname.
APPEND objtxt.
objpack-transf_bin = ' '.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
DESCRIBE TABLE objtxt LINES objpack-body_num.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Create the document which is to be sent
doc_chng-obj_name = 'Report data in PDF format'.
doc_chng-obj_descr = text-t07.
REPLACE '&' WITH p_repid INTO doc_chng-obj_descr.
REPLACE '&' WITH p_varnt INTO doc_chng-obj_descr.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Fill the mail recipient list
recipient_int-address = p_mailid.
reclist-receiver = recipient_int.
IF p_clist IS INITIAL.
reclist-rec_type = 'U'.
ELSE.
reclist-rec_type = 'C'.
ENDIF.
APPEND reclist.
* Create the Attachement
objbin[] = i_temp[].
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
DESCRIBE TABLE objbin LINES objpack-body_num.
objpack-doc_size = objpack-body_num * 255.
objpack-doc_type = 'PDF'.
CONCATENATE p_repid '_' p_varnt '.PDF' INTO objpack-obj_descr.
APPEND objpack.
* Call the API to send mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
IMPORTING
sent_to_all = sent_to_all
TABLES
packing_list = objpack "filed with Att.list
object_header = objhead "
contents_bin = objbin "filed with bin.data
contents_txt = objtxt "
receivers = reclist "filed with mail ids
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.
RAISE mail_send_error.
ELSE.
SUBMIT rsconn01 AND RETURN.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form get_spool_number
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_REPID text
* -->P_SY_UNAME text
* <--P_w_rqident text
*----------------------------------------------------------------------*
FORM get_spool_number USING f_repid
f_uname
CHANGING f_rqident.
DATA: lc_rq2name LIKE tsp01-rq2name.
CONCATENATE sy-repid+0(9)
sy-uname+0(3)
INTO lc_rq2name.
SELECT * FROM tsp01
WHERE rq2name = lc_rq2name
ORDER BY rqcretime DESCENDING.
w_rqident = tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR w_rqident.
ENDIF.
ENDFORM. " get_spool_number
Regards,
Sumant.
‎2007 Apr 18 9:01 PM
Hi,
Here is a program I created to convert any programs output into PDF and emails it.
The input for the program will: Name of the report and its variant. This program will execute this report you specified and creates a spool and then convert the spool into PDF and mails.
May be you can use some parts of this report. This was developed in 46C.
REPORT zss_mail_report_in_pdf.
TABLES: tsp01.
DATA: w_print_parms LIKE pri_params,
w_valid(1) TYPE c,
w_bytecount TYPE i,
* w_length TYPE i,
w_repid LIKE sy-repid,
w_rqident LIKE tsp01-rqident.
DATA: i_pdf LIKE tline OCCURS 0 WITH HEADER LINE,
i_temp LIKE bapiqcmime OCCURS 0 WITH HEADER LINE,
w_filename LIKE rlgrap-filename.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objtxt2 LIKE solisti1 OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE,
recipient_int LIKE sadrud,
recipient_rml LIKE sadr7d,
tab_lines LIKE sy-tabix,
doc_chng LIKE sodocchgi1,
sent_to_all LIKE sonv-flag.
PARAMETERS: p_repid LIKE sy-repid,
p_varnt LIKE rsvar-variant,
p_linsz LIKE sy-linsz,
p_paart LIKE sy-paart.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_mail AS CHECKBOX,
p_clist RADIOBUTTON GROUP ml1,
p_addr RADIOBUTTON GROUP ml1 DEFAULT 'X',
p_mailid LIKE sza5_d0700-smtp_addr.
SELECTION-SCREEN SKIP 1.
PARAMETERS: p_down AS CHECKBOX,
p_name LIKE rlgrap-filename.
START-OF-SELECTION.
IF NOT p_mail IS INITIAL
AND p_mailid IS INITIAL.
WRITE: / 'Need mail id for mailing the document.'.
STOP.
ENDIF.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
authority = space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '0'
immediately = space
in_archive_parameters = space
in_parameters = space
layout = space
mode = ' '
* new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
IMPORTING
out_parameters = w_print_parms
valid = w_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF w_print_parms-pdest = space.
w_print_parms-pdest = 'LPT1'.
ENDIF.
w_print_parms-linsz = p_linsz.
w_print_parms-paart = p_paart.
*** Create a Spool entry for the report
SUBMIT (p_repid) TO SAP-SPOOL
WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS w_print_parms
USING SELECTION-SET p_varnt
AND RETURN.
*** Retrive the Spool Request number
w_repid = sy-repid.
PERFORM get_spool_number USING w_repid
sy-uname
CHANGING w_rqident.
*** Convert the spool request to PDF format
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = w_rqident
no_dialog = 'X'
dst_device = w_print_parms-pdest
IMPORTING
pdf_bytecount = w_bytecount
TABLES
pdf = i_pdf
EXCEPTIONS
OTHERS = 12.
IF sy-subrc <> 0.
WRITE: / 'Error converting Spool request to PDF.'.
STOP.
ENDIF.
*** Download the PDF document on to desktop
IF NOT p_down IS INITIAL.
IF p_name IS INITIAL.
CONCATENATE 'C:' p_repid '.pdf' INTO w_filename.
ELSE.
MOVE p_name TO w_filename.
ENDIF.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = w_bytecount
filename = w_filename
filetype = 'BIN'
IMPORTING
act_filename = w_filename
TABLES
data_tab = i_pdf
EXCEPTIONS
OTHERS = 8.
IF sy-subrc <> 0.
WRITE: / 'Error downloading the PDF file.'.
STOP.
ENDIF.
ENDIF.
*** Mail the PDF document
IF NOT p_mail IS INITIAL.
* Reformat the line to 255 characters wide (--code from SAP--)
* Data for converting PDF data from text table to MIME table
DATA: l_lines TYPE i,
l_temp(500) TYPE c,
l_offset TYPE p,
l_lineslen(2) TYPE p,
l_mimelen(2) TYPE p,
l_tabix LIKE sy-tabix.
CLEAR: l_temp, l_offset, i_temp.
DESCRIBE TABLE i_pdf LINES l_lines.
DESCRIBE FIELD i_pdf LENGTH l_lineslen.
DESCRIBE FIELD i_temp LENGTH l_mimelen.
LOOP AT i_pdf.
l_tabix = sy-tabix.
MOVE i_pdf TO l_temp+l_offset.
IF l_tabix = l_lines.
l_lineslen = strlen( i_pdf ).
ENDIF.
l_offset = l_offset + l_lineslen.
IF l_offset GE l_mimelen.
CLEAR i_temp.
i_temp = l_temp(l_mimelen).
APPEND i_temp.
SHIFT l_temp BY l_mimelen PLACES.
l_offset = l_offset - l_mimelen.
ENDIF.
IF l_tabix = l_lines.
IF l_offset GT 0.
CLEAR i_temp.
i_temp = l_temp(l_offset).
APPEND i_temp.
ENDIF.
ENDIF.
ENDLOOP.
* Mail message body or main document
objtxt = text-t01.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t02.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t05.
REPLACE '&' WITH p_repid INTO objtxt.
APPEND objtxt.
objtxt = text-t06.
REPLACE '&' WITH p_varnt INTO objtxt.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t03.
APPEND objtxt.
objtxt = ' '.
APPEND objtxt.
objtxt = text-t04.
APPEND objtxt.
SELECT SINGLE name1 FROM usr03
INTO objtxt
WHERE bname = sy-uname.
APPEND objtxt.
objpack-transf_bin = ' '.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
DESCRIBE TABLE objtxt LINES objpack-body_num.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Create the document which is to be sent
doc_chng-obj_name = 'Report data in PDF format'.
doc_chng-obj_descr = text-t07.
REPLACE '&' WITH p_repid INTO doc_chng-obj_descr.
REPLACE '&' WITH p_varnt INTO doc_chng-obj_descr.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
* Fill the mail recipient list
recipient_int-address = p_mailid.
reclist-receiver = recipient_int.
IF p_clist IS INITIAL.
reclist-rec_type = 'U'.
ELSE.
reclist-rec_type = 'C'.
ENDIF.
APPEND reclist.
* Create the Attachement
objbin[] = i_temp[].
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
DESCRIBE TABLE objbin LINES objpack-body_num.
objpack-doc_size = objpack-body_num * 255.
objpack-doc_type = 'PDF'.
CONCATENATE p_repid '_' p_varnt '.PDF' INTO objpack-obj_descr.
APPEND objpack.
* Call the API to send mail.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
IMPORTING
sent_to_all = sent_to_all
TABLES
packing_list = objpack "filed with Att.list
object_header = objhead "
contents_bin = objbin "filed with bin.data
contents_txt = objtxt "
receivers = reclist "filed with mail ids
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.
RAISE mail_send_error.
ELSE.
SUBMIT rsconn01 AND RETURN.
ENDIF.
ENDIF.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form get_spool_number
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SY_REPID text
* -->P_SY_UNAME text
* <--P_w_rqident text
*----------------------------------------------------------------------*
FORM get_spool_number USING f_repid
f_uname
CHANGING f_rqident.
DATA: lc_rq2name LIKE tsp01-rq2name.
CONCATENATE sy-repid+0(9)
sy-uname+0(3)
INTO lc_rq2name.
SELECT * FROM tsp01
WHERE rq2name = lc_rq2name
ORDER BY rqcretime DESCENDING.
w_rqident = tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR w_rqident.
ENDIF.
ENDFORM. " get_spool_number
Regards,
Sumant.
‎2007 Apr 18 9:11 PM
‎2007 Apr 18 9:29 PM
Hi,
this is an example I found here on the forum. Worked fine for me. Don't think I ran into the splitting issue:
*----------------------------------------------------------------------*
* CLASS-DEFINITIONS *
*----------------------------------------------------------------------*
DATA: send_request TYPE REF TO cl_bcs.
DATA: document TYPE REF TO cl_document_bcs.
DATA: sender TYPE REF TO cl_sapuser_bcs.
DATA: recipient TYPE REF TO if_recipient_bcs.
DATA: exception_info TYPE REF TO if_os_exception_info,
bcs_exception TYPE REF TO cx_bcs.
*----------------------------------------------------------------------*
* INTERNAL TABLES *
*----------------------------------------------------------------------*
DATA: l_mailtext TYPE soli_tab.
DATA: l_mailhex TYPE solix_tab.
DATA: iaddsmtp TYPE bapiadsmtp OCCURS 0 WITH HEADER LINE.
DATA: ireturn TYPE bapiret2 OCCURS 0 WITH HEADER LINE.
*----------------------------------------------------------------------*
* VARIABLES *
*----------------------------------------------------------------------*
DATA: mail_line LIKE LINE OF l_mailtext.
DATA: mailx_line LIKE LINE OF l_mailhex.
DATA: bapiadsmtp TYPE bapiadsmtp.
*----------------------------------------------------------------------*
* CONSTANTS *
*----------------------------------------------------------------------*
CONSTANTS:
kimball_domain(12) TYPE c VALUE '@kimball.com'.
CLASS cl_cam_address_bcs DEFINITION LOAD.
CLASS cl_abap_char_utilities DEFINITION LOAD.
TRY.
* Create persistent send request
send_request = cl_bcs=>create_persistent( ).
DATA: first(1) TYPE c.
CLEAR first.
DATA: documents_line LIKE LINE OF documents.
LOOP AT documents INTO documents_line.
IF first IS INITIAL.
MOVE 'X' TO first.
* Build the Main Document
IF documents_line-content_hex[] IS INITIAL.
document = cl_document_bcs=>create_document(
i_type = documents_line-type
i_text = documents_line-content_text
i_subject = documents_line-subject ).
ELSE.
document = cl_document_bcs=>create_document(
i_type = documents_line-type
i_hex = documents_line-content_hex
i_subject = documents_line-subject ).
ENDIF.
ELSE.
IF documents_line-content_hex[] IS INITIAL.
* Add Attachment
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = documents_line-type
i_attachment_subject = documents_line-subject
i_att_content_text = documents_line-content_text.
ELSE.
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = documents_line-type
i_attachment_subject = documents_line-subject
i_att_content_hex = documents_line-content_hex.
ENDIF.
ENDIF.
ENDLOOP.
* Add document to send request
CALL METHOD send_request->set_document( document ).
* Get sender object
sender = cl_sapuser_bcs=>create( sy-uname ).
* Add sender
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
DATA: recipients_line LIKE LINE OF recipients.
LOOP AT recipients INTO recipients_line.
IF recipients_line-c_address IS INITIAL.
* Create recipient
CLEAR iaddsmtp.
REFRESH iaddsmtp.
CLEAR bapiadsmtp.
CLEAR recipient.
* Read the E-Mail address for the user
CALL FUNCTION 'BAPI_USER_GET_DETAIL'
EXPORTING
username = recipients_line-uname
TABLES
return = ireturn
addsmtp = iaddsmtp.
LOOP AT iaddsmtp WHERE std_no = 'X'.
CLEAR bapiadsmtp.
MOVE iaddsmtp TO bapiadsmtp.
ENDLOOP.
* If no E-mail address was found, create one.
IF bapiadsmtp-e_mail = ''.
CONCATENATE recipients_line-uname kimball_domain
INTO recipients_line-c_address.
ELSE.
MOVE bapiadsmtp-e_mail TO recipients_line-c_address.
ENDIF.
ENDIF.
recipient = cl_cam_address_bcs=>create_internet_address( recipients_line-c_address ).
* Add recipient with its respective attributes to send request
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = recipients_line-i_express
i_copy = recipients_line-i_copy
i_blind_copy = recipients_line-i_blind_copy
i_no_forward = recipients_line-i_no_foward.
ENDLOOP.
* Set that you don't need a Return Status E-mail
DATA: status_mail TYPE bcs_stml.
status_mail = requested_status.
CALL METHOD send_request->set_status_attributes
EXPORTING
i_requested_status = requested_status
i_status_mail = status_mail.
* set send immediately flag
send_request->set_send_immediately( 'X' ).
* Send document
CALL METHOD send_request->send( ).
COMMIT WORK.
CATCH cx_bcs INTO bcs_exception.
RAISE EXCEPTION bcs_exception.
ENDTRY.
ENDFUNCTION.
Hope it helps,
Kevin.
‎2007 Apr 18 9:35 PM
Thanks kevin..i was using exactly same code..
what did u have on your documents_line-content_text is it more than 200 char and are you converting it to pdf?
Message was edited by:
Siva K
‎2007 Apr 19 7:44 AM
Hi,
I'm pretty sure my 'body' of the mail has occasionally more then 200 chars without a split.
What do you mean with conversion? I'm sending newly generated adobe forms pdf's as attachment so no real conversion from my side.
Cheers,
Kevin.
‎2007 Apr 21 7:14 AM
Here is what i'm trying to do..simple..
Data in my internal table>>need to send this out as pdf email attachment..
i have set my scot settings to pdf .
Now in documnets table..1 st line is header and if you have more it will become attachment right??..
documents_line-content_text-line this 255 char..when i fill this and send the email..then when i open my pdf file, the content is split/wrapped..
eg..should be like AAAAAAAAAABBBBBBBBBCCCCCC....DDDDD
but it's showing up as AAAAAAAAAABBBBBBBBBCCCCCC
...DDDDD
i will check my code again..otherwise will go back to old SO_....API FM.
Appreciate your help..
Thanks
Siva
Message was edited by:
Siva K
‎2007 Oct 05 7:06 AM
hi guru's
iam faceing a problem with sending pdf file through email.
in the above code
i have used FM CONVERT_ABAPSPOOLJOB_2_PDF to get pdf.
the pdf output is of type tline.
I need to convert tline pdf to hex to pass to belove method.
CALL METHOD document->add_attachment
EXPORTING
i_attachment_type = documents_line-type
i_attachment_subject = documents_line-subject
i_att_content_hex = documents_line-content_hex.
Iam unable to convert that , please help me in this issue , its very ugrent.
‎2007 Oct 16 1:07 PM
Hi,
If it_pdf_output is the output table of CONVERT_ABAPSPOOLJOB_2_PDF then following code convert the table so you can use it with the add_attachment method of the class cl_document_bcs:
FIELD-SYMBOLS <f> TYPE x.
DATA: lw_pdf_output TYPE tline.
DATA: lw_slen TYPE i.
DATA: lw_tlen TYPE i.
DATA: lw_spos TYPE i.
DATA: lw_tpos TYPE i.
DATA: lw_spoolsize TYPE sood-objlen.
DATA: lw_bodyx TYPE solix.
DATA: lt_bodyx TYPE solix_tab.
MOVE gd_bytecount TO lw_spoolsize.
DESCRIBE FIELD lw_pdf_output LENGTH lw_slen IN BYTE MODE.
DESCRIBE FIELD lw_bodyx LENGTH lw_tlen IN BYTE MODE.
lw_tpos = 0.
LOOP AT it_pdf_output INTO lw_pdf_output.
ASSIGN lw_pdf_output TO <f> CASTING.
CHECK sy-subrc = 0.
DO lw_slen TIMES.
lw_spos = sy-index - 1.
IF lw_tpos = lw_tlen.
APPEND lw_bodyx TO lt_bodyx.
FREE lw_bodyx.
lw_tpos = 0.
ENDIF.
MOVE <f>+lw_spos(1) TO lw_bodyx-line+lw_tpos(1).
ADD 1 TO lw_tpos.
ENDDO.
ENDLOOP.
IF lw_tpos > 0.
APPEND lw_bodyx TO lt_bodyx.
ENDIF.
Don't forget to pass pdf_bytecount from CONVERT_ABAPSPOOLJOB_2_PDF to cl_document_bcs methods
Regards