Posted: Fri Jan 25, 2008 12:56 pm Post subject: To send email with PDF attachment
Code:
REPORT z34332_mail_with_attachment1.
TYPES: BEGIN OF t_mara,
matnr TYPE mara-matnr,
matkl TYPE mara-matkl,
mtart TYPE mara-mtart,
meins TYPE mara-meins,
END OF t_mara.
DATA: gt_mara TYPE TABLE OF t_mara,
wa_mara LIKE LINE OF gt_mara,
it_packing_list TYPE TABLE OF sopcklsti1,
wa_packing_list LIKE LINE OF it_packing_list,
it_receivers TYPE TABLE OF somlreci1,
wa_receivers LIKE LINE OF it_receivers,
it_mailbody TYPE TABLE OF solisti1,
wa_mailbody LIKE LINE OF it_mailbody,
it_attachment TYPE TABLE OF solisti1,
wa_attachment LIKE LINE OF it_attachment.
DATA: la_doc TYPE sodocchgi1.
CONSTANTS:
con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
GET material
select matnr matkl mtart meins
into table gt_mara
from mara
up to 25 rows.
* Mail Body
CLEAR wa_mailbody.
REFRESH it_mailbody.
wa_mailbody-line = 'Please find the attachment'.
APPEND wa_mailbody TO it_mailbody.
* Mail attachmwnt
CLEAR wa_attachment.
REFRESH it_attachment.
CONCATENATE 'MATNR' 'MATKL' 'MTART' 'MEINS'
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment TO it_attachment.
LOOP AT gt_mara INTO wa_mara.
CONCATENATE wa_mara-matnr wa_mara-matkl
wa_mara-mtart wa_mara-meins
INTO wa_attachment SEPARATED BY con_tab.
CONCATENATE con_cret wa_attachment INTO wa_attachment.
APPEND wa_attachment TO it_attachment.
ENDLOOP.
* Describe the body of the message
CLEAR wa_packing_list.
REFRESH it_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
wa_packing_list-body_num = 1.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list TO it_packing_list.
* get the spool number
* Declaration of local variables.
DATA:
lv_rq2name LIKE tsp01-rq2name.
CONCATENATE sy-repid+0(8)
sy-uname+0(3)
INTO lv_rq2name SEPARATED BY '_'.
* Get the spool number.
SELECT * FROM tsp01 WHERE rq2name = lv_rq2name
ORDER BY rqcretime DESCENDING.
v_rqident = tsp01-rqident.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR v_rqident.
ENDIF
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.