2008 Mar 14 11:52 AM
Hi All,
I'm using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send mail to SAP office inbox and to the external Email-ID's.
I have a internal table and i want to send the content of it as PDF attachement to a SAP user.
Did anybody worked on this?
Regards,
Hi All,
I'm using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send mail to SAP office inbox and to the external Email-ID's.
I have a internal table and i want to send the content of it as PDF attachement to a SAP user.
Did anybody worked on this?
Regards,
2008 Mar 14 11:55 AM
Hi,
Check this code...
This program will allowed you to send email with attachment.
First, specify the attachment file from your local hardisk and execute.
Next, specify the sender email address and click the send button.
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
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.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
.
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
.
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
REWARD POINTS IF HELPFUL,
KUMAR
2008 Mar 14 11:57 AM
Refer this link,
http://www.erpgenie.com/phpBB2/viewtopic.php?p=3522&sid=d373175401fa74d7916f1f5f35e77896
Hope it helps,
Cheers,
Phani
2008 Mar 14 11:57 AM
Try below code...
DATA: BEGIN OF ITAB OCCURS 0,
TEXT(72),
END OF ITAB.
*
DATA: PDF_FILESIZE TYPE I.
DATA: BIN_FILESIZE TYPE I.
*
DATA: PARAMS LIKE PRI_PARAMS,
VALID TYPE C.
*
DATA: SPOOL_NR LIKE TSP01-RQIDENT,
SPOOL_NR_DEL LIKE TSP01_SP0R-RQID_CHAR.
*
DATA: BEGIN OF PDF_OUTPUT OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF PDF_OUTPUT.
*
DATA: DATEI TYPE STRING VALUE 'C:\TESTPDF.PDF'.
*
DATA: RC TYPE I.
*
START-OF-SELECTION.
*
here you can fill your itab as you want.
READ REPORT 'ZGRO_ITAB_PDF_SPOOL' INTO ITAB.
*
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = 'LOCA'
LINE_SIZE = 080
IMMEDIATELY = ' '
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = PARAMS
VALID = VALID.
*
CHECK VALID SPACE.
*
NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG NO-TITLE NO-HEADING.
*
LOOP AT ITAB.
WRITE:/ ITAB.
ENDLOOP.
*
NEW-PAGE PRINT OFF.
*
SPOOL_NR = SY-SPONO.
*
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = SPOOL_NR
IMPORTING
PDF_BYTECOUNT = PDF_FILESIZE
TABLES
PDF = PDF_OUTPUT.
*
SPOOL_NR_DEL = SPOOL_NR.
*
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
SPOOLID = SPOOL_NR_DEL.
*
BIN_FILESIZE = PDF_FILESIZE.
*
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
BIN_FILESIZE = BIN_FILESIZE
FILENAME = DATEI
FILETYPE = 'BIN'
CHANGING
DATA_TAB = PDF_OUTPUT[].
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>EXECUTE
EXPORTING
DOCUMENT = DATEI.
*
END-OF-SELECTION.
2008 Mar 14 11:58 AM
Thams kumar,
But i dont have any local file ..
i have only a filled internal table and i want to send the content of it as pdf attachement.
2008 Mar 14 11:59 AM
2008 Mar 14 12:01 PM
hi Use this FM to get ur PDF ready for attachment.
CALL FUNCTION 'QCE1_CONVERT'
TABLES
t_source_tab = lt_pdf
t_target_tab = it_attachment
EXCEPTIONS
CONVERT_NOT_POSSIBLE = 1
OTHERS = 2.
2008 Mar 14 12:21 PM
Hi Adel,
pls check following links.....
it will be helpful to u.
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
don't forget to give point if it is helpful 2 u.
Regards,
Arpit
2008 Mar 14 1:56 PM
Hi all,
Thanks all for uw answers.
The following code gives a error :
types : begin of ty_itab,
text(72) type c,
end of ty_itab.
DATA:
wa_itab type ty_itab,
ITAB type table of ty_itab,
PDF_FILESIZE TYPE i,
PARAMS LIKE PRI_PARAMS,
VALID TYPE C,
SPOOL_NR LIKE TSP01-RQIDENT,
SPOOL_NR_DEL LIKE TSP01_SP0R-RQID_CHAR,
RC TYPE I.
DATA: BEGIN OF PDF_OUTPUT OCCURS 0.
INCLUDE STRUCTURE TLINE.
DATA: END OF PDF_OUTPUT.
START-OF-SELECTION.
wa_itab-text = 'test'.
append wa_itab to itab.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
DESTINATION = 'LOCA'
LINE_SIZE = 080
IMMEDIATELY = ' '
NO_DIALOG = 'X'
IMPORTING
OUT_PARAMETERS = PARAMS
VALID = VALID.
NEW-PAGE PRINT ON PARAMETERS PARAMS NO DIALOG NO-TITLE NO-HEADING.
LOOP AT ITAB into wa_itab.
WRITE:/ wa_itab-text.
ENDLOOP.
NEW-PAGE PRINT OFF.
SPOOL_NR = SY-SPONO.
CALL FUNCTION
'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = SPOOL_NR
IMPORTING
pdf_bytecount = PDF_FILESIZE
TABLES
pdf = 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.
The FM 'CONVERT_ABAPSPOOLJOB_2_PDF'
returns sy-subrc = 4 and pdf_output is empty.
Someone knows the solution of this problem?
any suggestions ?
Regards,
2008 Mar 17 3:39 PM
Hi all,
The conversion of a spool to rdf is now ok .
i m trying now to send the pdf to a sap user, when i m sending it to myself its ok
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = sy-uname.
t_receivers-rec_type = 'B'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.
But if i change the receiver to another sap user , the function gives sy-subrc = 0 (ok)
but no document is sent.
Some suggestions ? maybe configuration issues ?
Thanks
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |