2007 Dec 14 9:06 AM
HI,
I am sending the text file as an attachment to a aexternal mai. mailing is going with text file attachment, but text file is empty. No information in the file is going, only empty text file is going. I am sending the code iam using. Please suggest, if I need to change any passing parameters orany other other solution.
tables: knb1,kna1,adr6,ITEMSET,bsid,TSP01.
*
INTERNAL TABLES
*
DATA: BEGIN OF it_kna1 occurs 0,
KUNNR LIKE KNA1-KUNNR,
ADRNR LIKE KNA1-ADRNR,
END OF it_kna1.
DATA: BEGIN OF it_email occurs 0,
ADDRNUMBER LIKE ADR6-ADDRNUMBER,
SMTP_ADDR LIKE ADR6-SMTP_ADDR,
END OF it_email.
DATA: BEGIN OF it_bsid occurs 0,
KUNNR LIKE BSID-KUNNR,
BUKRS LIKE BSID-BUKRS,
END OF it_bsid.
DATA: BEGIN OF it_final occurs 0,
KUNNR LIKE KNA1-KUNNR,
ADRNR LIKE ADR6-ADDRNUMBER,
EMAIL LIKE ADR6-SMTP_ADDR,
END OF it_final.
DATA: BEGIN OF BUFFER OCCURS 10000,
TEXT(255) TYPE C,
END OF BUFFER.
data:xtext type solix_tab." occurs 0 with header line."line.
data:xi_pdf type soli_tab.
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,
RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE,
DOC_CHNG LIKE SODOCCHGI1,
PARAMS LIKE PRI_PARAMS,
ARPARAMS LIKE ARC_PARAMS,
DAYS(1) TYPE N VALUE 8,
COUNT(3) TYPE N VALUE 1,
VALID TYPE C,
RECEIVER(30),
STR(256).
data: spoolid type tsp01-rqident,
pdf_table like tline occurs 0 with header line,
v_bytecount type i,
itab_pdf like tline occurs 10 with header line,
xi_pdf like tline occurs 0 with header line,
xi_pdf like buffer occurs 0 with header line,
xi_pdf_1 like xi_pdf,
v_length(2) type p,
html like solisti1 occurs 0 with header line,
xi_temp like bapiqcmime occurs 0 with header line,
xi_mime(255) type c occurs 0 with header line.
*
VARIABLES
*
data: g_email type adr6-smtp_addr,
TAB_LINES LIKE SY-TABIX,
G_FLAG(1) TYPE C.
g_norm(1) TYPE C,
g_shbv(1) TYPE C,
g_merk(1) TYPE C,
g_park(1) TYPE C,
g_apar(1) TYPE C.
data: l_lines type i,
line1 type i,
l_temp(500) type c,
l_offset type p,
l_lineslen(2) type p,
l_mimelen(2) type p,
v_spono like tsp01-rqident,
l_tabix like sy-tabix.
*****VIA SELECTION-SCREEN
ENDFORM. " SEND_TO_SPOOL
&----
*& Form GET_SPOOL_ID
&----
*& Form CONVERT_SPOOL_TO_PDF
&----
&----
*& Form SEND_MAIL
&----
FORM SEND_MAIL .
data:l_lin like sy-tabix,
l_lint like sy-tabix,
it_list like abaplist occurs 0,
l_newline(2) type x value '0D0A'.
*--Data for the status output after sending
data: user_address like sousradri1 occurs 1 with header line,
sent_to_all like sonv-flag.
clear: reclist, reclist[],
objtxt , objtxt[],
objpack, objpack[],
objbin , objbin[],
doc_chng.
*--move list to office table objbin
*--Start of Changes to support PDF attachments - UB20030116
loop at html.
objbin-line = html-line.
append objbin.
clear objbin.
endloop.
loop at xi_pdf.
objbin-line = xi_pdf-text.
append objbin.
clear objbin.
endloop.
*--We may write additional text to the main document
*--For faxing this will be the cover page. Like sending from SAPoffice
*--the layout set Office-Telefax will be used.
objtxt-line = 'NOTE : Please Consider the below Headers'.
append objtxt.
clear objtxt.
objtxt-line = 'Assignment --> Purchase order number '.
append objtxt.
clear objtxt.
objtxt-line = 'Document --> Invoice No '.
append objtxt.
clear objtxt.
objtxt-line = 'Amount In DC --> Amount Due '.
append objtxt.
clear objtxt.
objtxt-line = ' '.
append objtxt.
clear objtxt.
objtxt-line = ' '.
append objtxt.
clear objtxt.
objtxt-line = 'Please find attached statement for this week'.
append objtxt.
clear objtxt.
objtxt-line = ' '.
append objtxt.
clear objtxt.
objtxt-line = 'This is an AUTO GENERATED MAIL'.
concatenate objtxt-line 'Please Do not reply to this mail' into
objtxt-line separated by ' '.
append objtxt.
clear objtxt.
describe table objtxt lines tab_lines.
read table objtxt index tab_lines.
*--Create the document which is to be sent
doc_chng-obj_name = 'List'.
doc_chng-obj_name = 'SAPRPT'.
doc_chng-obj_descr = 'Customer statement for the week'.
concatenate 'Customer statement for '
sy-datum into
doc_chng-obj_descr
separated by ' '.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + strlen( objtxt ).
*--Fill the fields of the packing_list for the main document:
*--It is a text document
clear objpack-transf_bin.
*--The document needs no header (head_num = 0)
objpack-head_start = 1.
objpack-head_num = 0.
*--but it has a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
*--of type RAW
objpack-doc_type = 'RAW'.
append objpack.
*--Create the attachment (the list itself)
describe table objbin lines tab_lines.
*--Fill the fields of the packing_list for the attachment:
*--It is binary document
objpack-transf_bin = 'X'.
*--we need no header
objpack-head_start = 1.
objpack-head_num = 0.
*--but a body
objpack-body_start = 1.
objpack-body_num = tab_lines.
*--of type G_DOC_TYPE
objpack-doc_type = 'PDF'. "commented on 12/13/2007
objpack-doc_type = 'TXT'. "commented on 12/13/2007
objpack-obj_name = 'Attachment'.
objpack-obj_descr = 'Customer Statement'.
concatenate 'Customer Statement' sy-datum into objpack-obj_descr.
objpack-doc_size = tab_lines * 255.
append objpack.
reclist-receiver = g_email.
reclist-rec_type = 'U'.
reclist-com_type = 'FAX'.
append reclist.
data:xi type soli.
xi-line = 'haisdgsfsdf'.
append xi to xi_pdf.
xi-line = 'haisdfdsfd'.
append xi to xi_pdf.
xi-line = 'haisfgsdfsd'.
append xi to xi_pdf.
xi-line = 'haisdfsgfsdgg'.
append xi to xi_pdf.
*xi_pdf-text = 'hai'.
*append xi_pdf.
*
*xi_pdf-text = 'hai'.
*append xi_pdf.
*xi_pdf-text = 'hai'.
*append xi_pdf.
*xi_pdf-text = 'hai'.
*append xi_pdf.
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = xi_pdf[]
IMPORTING
EP_SOLIXTAB = xtext[].
**--Send the document by calling the SAPoffice API1 module for sending
**--documents with attachments
call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
IMPORTING
sent_to_all = sent_to_all
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
contents_hex = xtext
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
others = 99.
2007 Dec 14 9:22 AM
HI,
There are lots of bugs.
Please refer this sample program to fix it.
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
Best regards,
Prashant
2007 Dec 14 9:22 AM
HI,
There are lots of bugs.
Please refer this sample program to fix it.
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
Best regards,
Prashant