on 05-31-2009 9:09 PM
Dear Freinds,
As per requirement i am sending the data from internal to spool and from iam reading and sending the data to FM
call FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = mi_rqident
no_dialog = space
dst_device = mstr_print_parms-pdest
IMPORTING
pdf_bytecount = mi_bytecount
TABLES
pdf = mtab_pdf
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.
to be converted into the pdf and send at as email attachment in the form of pdf , for sending mail i have used as below
DATA: it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_recsize TYPE i,
gd_buffer TYPE string,
l_v_ltx TYPE fcktx,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Transfer the 132-long strings to 255-long strings
LOOP AT mtab_pdf.
TRANSLATE mtab_pdf USING ' ~'.
CONCATENATE gd_buffer mtab_pdf 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.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_mess_att[].
doc_chng-obj_name = 'PAYSLIP'.
MOVE 'PAYSLIP' TO doc_chng-obj_descr .
APPEND objtxt.
CLEAR objtxt.
APPEND objtxt.
MOVE 'Please find attached payslip ' TO objtxt-line.
APPEND objtxt.
CLEAR objtxt.
DESCRIBE TABLE objtxt LINES lv_tablines.
READ TABLE objtxt INDEX lv_tablines TRANSPORTING ALL FIELDS.
doc_chng-doc_size = ( lv_tablines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = lv_tablines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Pack to PDF.
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
DESCRIBE TABLE t_attachment LINES pdf_fsize.
objpack-body_num = pdf_fsize.
objpack-doc_type = 'PDF'.
objpack-obj_name = 'PAY'.
objpack-doc_size = pdf_fsize * 255.
objpack-obj_descr = 'Payslip'.
APPEND objpack.
CLEAR: wa_reclist.
REFRESH i_reclist[].
CLEAR wa_reclist.
wa_reclist-receiver = fp_wa_final-usrid_long.
wa_reclist-rec_type = 'U'.
APPEND wa_reclist TO i_reclist.
CLEAR wa_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = objpack
OBJECT_HEADER =
contents_bin = t_attachment "objbin
contents_txt = objtxt
contents_hex = objhex
receivers = i_reclist
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.
MESSAGE I000 WITH 'Error When Sending the File'.
endif.
But now i have got a serious problem , if iam having 3 records in internal table iam getting in the attachment as 3 times as pdf attachment and if iam having 10 records iam getting as 10 attachment . Requesting any body please help me what exactly it went wrong.
regards
divya
Done,
I got the solution by giving refresh and clear after the function module
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
check the below link its useful for you
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/email%2bfrom%2bsap
Regards,
Madhu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.