08-09-2007 5:57 PM
hi,
iam sending the code for the converting the internal table to spool request.how it
the attachment is send as an pdf by using the functiional module.
SO_DOCUMENT_SEND_API1.
to which parameter i have to attachment.how it to be done.
DATA: BEGIN OF i_mara OCCURS 0,
matnr LIKE mara-matnr.
DATA: END OF i_mara.
data gd_bytecount type i.
data :it_pdf_output LIKE tline OCCURS 0 WITH HEADER LINE.
DATA: v_dest LIKE tsp01-rqdest,
v_handle LIKE sy-tabix,
v_spool_id LIKE tsp01-rqident,
v_rc TYPE c,
v_errmessage(100) TYPE c,
v_text(70) TYPE c.
SELECT matnr FROM mara INTO TABLE i_mara.
CALL FUNCTION 'RSPO_OPEN_SPOOLREQUEST'
EXPORTING
dest = 'LOCL'
LAYOUT =
NAME =
SUFFIX1 =
SUFFIX2 =
COPIES =
PRIO =
IMMEDIATE_PRINT =
AUTO_DELETE =
TITLELINE =
RECEIVER =
DIVISION =
AUTHORITY =
POSNAME =
ACTTIME =
LIFETIME = '8'
APPEND =
COVERPAGE =
CODEPAGE =
DOCTYPE =
IMPORTING
handle = v_handle
spoolid = v_spool_id
rc = v_rc
errmessage = v_errmessage.
LOOP AT i_mara.
v_text = i_mara-matnr.
CALL FUNCTION 'RSPO_WRITE_SPOOLREQUEST'
EXPORTING
handle = v_handle
text = v_text
LENGTH =
CODEPAGE =
TRUNCATE =
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
CALL FUNCTION 'RSPO_CLOSE_SPOOLREQUEST'
EXPORTING
handle = v_handle
IMPORTING
rc = v_rc
errmessage = v_errmessage
EXCEPTIONS
handle_not_valid = 1
OTHERS = 2.
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 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = v_spool_id
*no_dialog = c_no
*dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
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.
CHECK sy-subrc = 0.
please send the solution for this problem.
it is very urgent.
08-09-2007 6:02 PM
Hi
See the sample code and do accordingly
----
INCLUDE ZINCUSMAIL *
----
include <symbol>.
data : i_doc_data like sodocchgi1.
data : begin of i_pack_list occurs 0.
include structure sopcklsti1.
data : end of i_pack_list.
data : begin of i_receivers occurs 0.
include structure somlreci1.
data : end of i_receivers.
data : begin of i_contents occurs 0.
include structure solisti1.
data : end of i_contents.
data : begin of i_header occurs 0.
include structure solisti1.
data : end of i_header.
data : begin of i_att occurs 0.
include structure solisti1.
data : end of i_att.
Internal Table for Internet address.
data: begin of it_inad occurs 0,
kunnr like kna1-kunnr, " Customer Code
name1 like kna1-name1, " Customer Name
ssobl like knkk-ssobl, " Security Deposit
klimk like knkk-klimk, " Credit Limit
opbal like bsid-wrbtr, " Opening Balance
clbal like bsid-wrbtr, " Closing Balance
smtp like adr6-smtp_addr, " Internet mail (SMTP) address
end of it_inad.
data : pdf_line(134),
asdf like pdf_line occurs 0 with header line.
data : pdf_table like tline occurs 0 with header line,
pdf_fsize type i.
data : stuff(65000),
len type i,
pos type i,
tab_lines like sy-tabix.
data: spoolid type tsp01-rqident,
spdel type tsp01sys.
data: v_gjahrt like bsid-gjahr,
fmondest(10),
tmondest(10),
kunnr1 like kna1-kunnr,
gjah(4),
fmon(10).
&----
*& Form hide_write
&----
form hide_write.
new-page print on
line-size 160
line-count 58
no-title
no-heading
destination 'LOCL'
immediately ' '
new list identification 'X'
no dialog.
set blank lines on.
endform. " hide_write
&----
*& Form end_write
&----
form end_write using kunnr1.
set blank lines off.
new-page print off.
***Using Spoolid we are getting PDF formated file
spoolid = spdel-rqident = sy-spono.
spdel-sys = sy-sysid.
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = spoolid
no_dialog = 'X'
importing
pdf_bytecount = pdf_fsize
tables
pdf = pdf_table
exceptions
others = 0.
***Delleting Spool request
call function 'RSPO_IDELETE_SPOOLREQ'
exporting
spoolreq = spdel
exceptions
others = 2.
***Converting PDF table line size 134 into standard list size 255
loop at pdf_table into pdf_line.
if pos = 34170.
perform attach.
endif.
stuff+pos(134) = pdf_line.
add 134 to pos.
endloop.
if not ( stuff is initial ).
perform attach.
endif.
clear pdf_line.
clear pdf_table[].
describe table i_att lines tab_lines.
i_pack_list-transf_bin = 'X'.
i_pack_list-head_start = '1'.
i_pack_list-head_num = '1'.
i_pack_list-body_start = '1'.
i_pack_list-body_num = tab_lines.
i_pack_list-doc_type = 'PDF'.
i_pack_list-obj_name = 'LedgerMail'.
concatenate fmon '-' gjah into i_pack_list-obj_descr.
*i_pack_list-obj_descr = '2092-Oct03'.
i_pack_list-obj_langu = 'E'.
i_pack_list-doc_size = tab_lines * 255.
append i_pack_list.
***Data for receivers list
loop at it_inad where kunnr eq kunnr1.
i_receivers-receiver = it_inad-smtp.
i_receivers-rec_type = 'U'.
i_receivers-rec_date = sy-datum.
i_receivers-express = 'X'.
i_receivers-com_type = 'INT'.
i_receivers-notif_del = 'X'.
append i_receivers.
endloop.
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
exporting
document_data = i_doc_data
PUT_IN_OUTBOX = ' '
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
tables
packing_list = i_pack_list
object_header = i_header
contents_bin = i_att
contents_txt = i_contents
receivers = i_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
.
refresh i_att. clear i_att.
refresh i_receivers. clear i_receivers.
delete i_pack_list where doc_type = 'PDF'.
*refresh i_header.
*refresh i_contents.
*clear i_doc_data.
endform. " end_write
&----
*& Form doc_data
&----
form doc_data using fmondest v_gjahrt.
gjah = v_gjahrt.
fmon = fmondest.
***Data for Document Data
i_doc_data-obj_name = 'LedgerMail'.
concatenate 'Customer Ledger for : ' fmondest gjah
into i_doc_data-obj_descr separated by space.
i_doc_data-obj_langu = 'E'.
i_doc_data-obj_prio = '1'.
i_doc_data-no_change = 'X'.
i_doc_data-doc_size = '5101'.
***Data for Packing list
i_pack_list-head_start = '1'.
i_pack_list-head_num = '1'.
i_pack_list-body_start = '1'.
i_pack_list-body_num = '20'.
i_pack_list-doc_type = 'RAW'.
i_pack_list-obj_langu = 'E'.
append i_pack_list.
***Data for Header
i_header-line = 'Header'. append i_header.
***Data for contents
i_contents-line = 'Dear Customer,'. append i_contents.
i_contents-line = ' '. append i_contents.
concatenate 'Please find your enclosed Ledger for the month of : '
fmondest gjah into i_contents-line separated by space.
append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'This is a computer generated document and does not
require a signature.'. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'Note : If you do not have Acrobat Reader please click
on the below link.'. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = 'http://www.adobe.com/products/acrobat/readstep2.html'
. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
i_contents-line = ' '. append i_contents.
endform. " doc_data
&----
*& Form attach
&----
form attach.
clear pos.
len = strlen( stuff ).
while len > 0.
subtract 255 from len.
i_att = stuff+pos(255).
append i_att.
add 255 to pos.
endwhile.
clear pos.
clear stuff.
endform. " attach
<b>Reward points for useful Answers</b>
Regards
Anji