05-08-2007 3:32 PM
I need your help in sending mail in ABAP4.
Please provide me some help on this.
I have some files in the server eg. /tmp/file1 and /tmp/file2
I want to zip those 2 files file1 and file2 into a single file namely output.zip and email output.zip as attachment.
Thanks,
Kasi
Message was edited by:
Kasi Reddy
05-08-2007 3:38 PM
Hai Kasi Reddy,
Welcome to SDN.
You can post the file on the application server by first saving it as on a notepad file on you system as below:
Go to the transaction CG3Y,
Give the path of the file on the application server and
the path of the file on your sytem as a text file.
Now email it as an attachement.
Hope now you can email it.
Reward points if it helps you.
Regards,
Rama chary.Pammi
05-08-2007 3:38 PM
Hi,
Here is the perfect Program, look at the link,
http://www.sap-img.com/abap/sending-email-with-attachment.htm
Regards
Sudheer
05-08-2007 4:21 PM
Hi sudheer,
My requirement is,
I have some files in the server eg. /tmp/file1 and /tmp/file2
I want to zip those 2 files file1 and file2 into a single file namely output.zip and email output.zip as attachment.
Could you provide some help on this.
05-08-2007 4:57 PM
Hi Kasireddy,
Why dont u develop two interface programs . One for downloading the two files tmp1 and tmp2 to local workstation, Zip those two files into single zip file, The other interface should be used to mail those files as an attachment.
SO_NEW_DOCUMENT_ATT_SEND_API
Use the function module for sending the file as attachment.
If any one knows any zipping function in SAP, Please Explore.
Thanks.
05-08-2007 5:27 PM
If you are working in SAP 46C version then zip functionality in not avaliable. If you are working on higher version the you can user SAP standard ZIP class and use SAP standard function module - SO_NEW_DOCUMENT_ATT_SEND_API1 for sending email from SAP.
05-08-2007 5:37 PM
Hi,
Check this code..GIve the input file path and give the email address...Then execute..
PARAMETERS: p_file(50) LOWER CASE.
PARAMETERS: p_email(50).
START-OF-SELECTION.
Data declarations.
DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: document_data LIKE sodocchgi1.
DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA: real_type LIKE soodk-objtp.
DATA: sp_lang LIKE tst01-dlang.
DATA: line_size TYPE i VALUE 255.
DATA: v_name LIKE soextreci1-receiver.
DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
Get the file data.
OPEN DATASET p_file FOR INPUT IN TEXT MODE.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error in opening file'.
LEAVE LIST-PROCESSING.
ENDIF.
DO.
READ DATASET p_file INTO so_ali-line.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND so_ali.
ENDDO.
CLOSE DATASET p_file.
Prepare the data.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 0.
plist-body_num = 0.
plist-doc_type = 'RAW'.
plist-obj_descr = 'Test ALV'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
DESCRIBE TABLE so_ali LINES plist-body_num.
plist-doc_type = 'RAW'.
Get the size.
READ TABLE so_ali INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( so_ali ).
APPEND plist.
Move the receiver address.
MOVE: p_email TO rec_tab-receiver,
'U' TO rec_tab-rec_type.
APPEND rec_tab.
IF NOT sp_lang IS INITIAL.
document_data-obj_langu = sp_lang.
ELSE.
document_data-obj_langu = sy-langu.
ENDIF.
v_name = sy-uname.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'B'
TABLES
packing_list = plist
contents_bin = so_ali
receivers = rec_tab
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 e208(00) WITH 'Error'.
ENDIF.
COMMIT WORK.
Send the email immediately.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
Thanks,
Naren