Multiple attachment using SO_NEW_DOCUMENT_ATT_SEND_API1
HI geeks,
Can anyone pls tell me how to attach multiple files using function module SO_NEW_DOCUMENT_ATT_SEND_API1.
I have seen example of multiple attachments using same file type.I mean 1 or more files are same type like PDF or Excel.
But my requirement is i have to send multiple attachment,1 file as PDF and other three excel file.
Can anyone pls let me know,if anyone done this already,
Thanks in advance
Srini.
Hi Srinivasn,
Please see the below code u need to follow. In the object pack table u might specified the number of lines per each attachement. At the same time u need to specify the document type as PDF or XLS. Please see the below code which is wrote for two attachments as xls. In your case one attachment should be PDF. This can be specified in the field
LT_OBJPACK-DOC_TYPE = 'PDF'.
IF NOT LT_ATT_TAB[] IS INITIAL AND
NOT GV_ERR_REC IS INITIAL.
DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.
LV_TAB_LINES = LV_TAB_LINES - GV_SUC_REC.
READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.
LT_OBJPACK-DOC_SIZE =
( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).
LT_OBJPACK-TRANSF_BIN = 'X'.
LT_OBJPACK-HEAD_START = 1.
LT_OBJPACK-HEAD_NUM = 0.
LT_OBJPACK-BODY_START = 1.
LT_OBJPACK-BODY_NUM = LV_TAB_LINES.
LT_OBJPACK-DOC_TYPE = LC_XLS.
LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME2(50).
APPEND LT_OBJPACK.
ENDIF. " IF NOT lt_att_tab[] IS ...
File2 attachment for processed records.
IF NOT LT_ATT_TAB[] IS INITIAL AND
NOT GV_SUC_REC IS INITIAL.
CLEAR LT_OBJPACK.
DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.
LV_TAB_LINES = LV_TAB_LINES - GV_ERR_REC.
GV_ERR_REC = GV_ERR_REC + 1.
READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.
LT_OBJPACK-DOC_SIZE =
( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).
LT_OBJPACK-TRANSF_BIN = 'X'.
LT_OBJPACK-HEAD_START = GV_ERR_REC.
LT_OBJPACK-HEAD_NUM = 0.
LT_OBJPACK-BODY_START = GV_ERR_REC.
LT_OBJPACK-BODY_NUM = LV_TAB_LINES.
LT_OBJPACK-DOC_TYPE = LC_XLS.
LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'(009).
LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME(50).
APPEND LT_OBJPACK.
ENDIF. " IF NOT lt_att_tab[] IS ...
Thanks
IF NOT LT_ATT_TAB[] IS INITIAL AND
NOT GV_ERR_REC IS INITIAL.
DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.
LV_TAB_LINES = LV_TAB_LINES - GV_SUC_REC.
READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.
LT_OBJPACK-DOC_SIZE =
( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).
LT_OBJPACK-TRANSF_BIN = 'X'.
LT_OBJPACK-HEAD_START = 1.
LT_OBJPACK-HEAD_NUM = 0.
LT_OBJPACK-BODY_START = 1.
LT_OBJPACK-BODY_NUM = LV_TAB_LINES.
LT_OBJPACK-DOC_TYPE = LC_XLS.
LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'.
LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME2(50).
APPEND LT_OBJPACK.
ENDIF. " IF NOT lt_att_tab[] IS ...
File2 attachment for processed records.
IF NOT LT_ATT_TAB[] IS INITIAL AND
NOT GV_SUC_REC IS INITIAL.
CLEAR LT_OBJPACK.
DESCRIBE TABLE LT_OBJBIN LINES LV_TAB_LINES.
LV_TAB_LINES = LV_TAB_LINES - GV_ERR_REC.
GV_ERR_REC = GV_ERR_REC + 1.
READ TABLE LT_OBJBIN INDEX LV_TAB_LINES.
LT_OBJPACK-DOC_SIZE =
( LV_TAB_LINES - 1 ) * 255 + STRLEN( LT_OBJBIN ).
LT_OBJPACK-TRANSF_BIN = 'X'.
LT_OBJPACK-HEAD_START = GV_ERR_REC.
LT_OBJPACK-HEAD_NUM = 0.
LT_OBJPACK-BODY_START = GV_ERR_REC.
LT_OBJPACK-BODY_NUM = LV_TAB_LINES.
LT_OBJPACK-DOC_TYPE = LC_XLS.
LT_OBJPACK-OBJ_NAME = 'ATTACHMENT'(009).
LT_OBJPACK-OBJ_DESCR = LV_ATTACH_NAME(50).
APPEND LT_OBJPACK.
ENDIF. " IF NOT lt_att_tab[] IS ...
Venkat
Similar Messages
-
Multiple attachment using SendMailJPKG from PLSQL
Hi,
I am able to send single attachment using SendMailJPKG.sendmail routine by providing the parameter as
sendmailjpkg.attachments_list('/test/mail.pdf')
Is it possible to send multiple attachments if so what is the syntax for the same.
Kindly help.
RegardsHEllo i need help in this problem too, if anybody has another package's version i 'll aprecciate if you send me the code
thanks -
Hi,
I have a requirement to send the details of an internal table to External mail as an attachment. I have used fn.module 'SO_NEW_DOCUMENT_ATT_SEND_API1' to do so. I am getting the attachment but the data is stored in only one row when we checked it in SAP outbox. This is irrespective of TXT, XLS etc. I can not check the exact file in my external mail inbox as the connection is not established in dev & Quality systems. This question was raised earlier by other guys and there was no correct answer provided. If any of you encountered this type of problem & got the solution please help.
Thanks,
AshokHi Buddy,
Hope this piece of code will definately help you out, Its working at my end.
Thanks,
Krishna..
FORM p_send_email .
FIELD-SYMBOLS: <field> TYPE ANY.
DATA : BEGIN OF i_dload OCCURS 0 ,
dload(1000) ,
END OF i_dload .
DATA: it_receivers LIKE somlreci1 OCCURS 1 WITH HEADER LINE,
w_object_content LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: w_doc_data LIKE sodocchgi1 OCCURS 0 WITH HEADER LINE.
DATA :w_records TYPE zres_records.
DATA: w_rsnum(10),
w_bdmng(14),
w_meins(4).
DATA: ws_email LIKE adr6-smtp_addr. "for internal e_mail address
DATA: ws_email1 LIKE adr6-smtp_addr. "for external e_mail address
*--Internal table declaration
DATA: it_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: it_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: it_objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: it_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: it_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA: w_longtext(500) TYPE c.
DATA: v_date(10) TYPE c.
DATA: text(200) TYPE c.
DATA: w_text(50) TYPE c.
*--Get receipient address
CLEAR it_reclist.
*--To send error to internal mail
ws_email = p_email.
*--To send error to external mail
ws_email1 = p_email1.
*---setting name of file for csv
CONCATENATE text-003 p_bdoc text-004 INTO w_filename.
CONDENSE w_filename NO-GAPS.
IF flag <> 1.
IF p_email1 IS NOT INITIAL.
build body of message
CONCATENATE 'disply message ' ' ' INTO it_objtxt
SEPARATED BY space.
APPEND it_objtxt.
CLEAR it_objtxt.
it_reclist-receiver = ws_email1.
it_reclist-rec_type = c_u.
it_reclist-express = ' '.
it_reclist-com_type = 'INT'.
APPEND it_reclist.
Set title of object and email
CLEAR: w_text.
CONCATENATE 'Greenheck Packing List Data'
INTO w_text SEPARATED BY space.
doc_chng-obj_descr = text-005. "w_text.
doc_chng-obj_name = 'Inbound EDI'.
DESCRIBE TABLE it_objtxt LINES tab_lines.
READ TABLE it_objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_objtxt ).
*--Move the Report Name as the Heading line for email file
CLEAR: w_longtext.
MOVE: text-012 TO w_longtext.
w_longtext = 'name of report for testing'.
it_objbin = w_longtext.
APPEND it_objbin. CLEAR it_objbin.
*--Append Blank Lines
APPEND it_objbin. CLEAR it_objbin.
APPEND it_objbin. CLEAR it_objbin.
*User name
CLEAR text.
MOVE: 'User:' TO text,
sy-uname TO text+6.
it_objbin = text.
APPEND it_objbin. CLEAR it_objbin.
---appending heading to Internal table of Email
CLEAR: w_longtext, w_xblnr_1 , w_aubel_1, w_vemng_1,
w_matnr_1, w_harmdesc_1, w_hc_1, w_cooland1_1,
w_brgew_1, w_tknum_1, w_vbeln_1, w_vbeln1_1,
w_exidv_1, w_vhilm_1, w_pack_no_1,
w_brgew1_1, w_laeng_1, w_breit_1,
w_hoehe_1, w_vol_1.
w_xblnr_1 = 'Cust PO No.'.
w_aubel_1 = 'Sal Order'.
w_vemng_1 = 'Pack Qty'.
w_matnr_1 = 'Model no.'.
w_harmdesc_1 = 'Hrm Desc'.
w_hc_1 = 'Hrm Code'.
w_cooland1_1 = 'Country of Origin'.
w_brgew_1 = 'Net Wt.'.
w_tknum_1 = 'Shipment'.
w_vbeln_1 = 'Billing Doc'.
w_vbeln1_1 = 'Delivery'.
w_exidv_1 = 'Pkg ID'.
w_vhilm_1 = 'Pkg Desc'.
w_pack_no_1 = 'Pkg No.'.
w_brgew1_1 = 'Gross Wt'.
w_laeng_1 = 'Length'.
w_breit_1 = 'Width'.
w_hoehe_1 = 'Height'.
w_vol_1 = 'Cubic Mtr'.
CONCATENATE w_xblnr_1 w_aubel_1 w_vemng_1
w_matnr_1 w_harmdesc_1 w_hc_1 w_cooland1_1
w_brgew_1 w_tknum_1 w_vbeln_1 w_vbeln1_1
w_exidv_1 w_vhilm_1 w_pack_no_1
w_brgew1_1 w_laeng_1 w_breit_1
w_hoehe_1 w_vol_1
INTO w_longtext SEPARATED BY ','.
it_objbin = w_longtext.
APPEND it_objbin. CLEAR it_objbin.
LOOP AT it_tab.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE it_tab TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Look for Commas in the field value. If it exists, put quotes around
value so that the file opens correctly with all the columns aligned
in Excel.
SEARCH <field> FOR ',' IN CHARACTER MODE.
If search for commas was successful.
IF sy-subrc = 0.
CONCATENATE '"' <field> '"' INTO <field> IN CHARACTER MODE.
ENDIF.
IF sy-index = 1.
i_dload-dload = <field>.
SHIFT: i_dload-dload LEFT DELETING LEADING space.
ELSE.
Put Comma as a separator for values in IT_DLOAD internal table
SHIFT: i_dload-dload LEFT DELETING LEADING space.
CONCATENATE i_dload-dload <field> INTO i_dload-dload
SEPARATED BY ',' IN CHARACTER MODE.
ENDIF.
ENDDO.
it_objbin = i_dload-dload.
APPEND it_objbin. CLEAR it_objbin.
ENDLOOP.
flag = 1.
endif.
ENDIF.
---if to send error file.
IF p_email IS NOT INITIAL.
build body of message
CONCATENATE 'Errors in file ' ' ' INTO it_objtxt
SEPARATED BY space.
APPEND it_objtxt.
CLEAR it_objtxt.
it_reclist-receiver = ws_email.
it_reclist-rec_type = c_u.
it_reclist-express = ' '.
it_reclist-com_type = 'INT'.
APPEND it_reclist.
Set title of object and email
CLEAR: w_text.
CONCATENATE 'Greenheck Packing List Data'
INTO w_text SEPARATED BY space.
doc_chng-obj_descr = text-005.
doc_chng-obj_name = 'Inbound EDI'.
DESCRIBE TABLE it_objtxt LINES tab_lines.
READ TABLE it_objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_objtxt ).
*--Move the Report Name as the Heading line for email file
CLEAR: w_longtext.
MOVE: text-012 TO w_longtext.
w_longtext = 'name of report for testing'.
it_objbin = w_longtext.
APPEND it_objbin. CLEAR it_objbin.
*--Append Blank Lines
APPEND it_objbin. CLEAR it_objbin.
APPEND it_objbin. CLEAR it_objbin.
*User name
CLEAR text.
MOVE: 'User:' TO text,
sy-uname TO text+6.
it_objbin = text.
APPEND it_objbin. CLEAR it_objbin.
---appending heading to Internal table of Email
CLEAR: w_longtext, w_xblnr_1 , w_aubel_1, w_vemng_1,
w_matnr_1, w_harmdesc_1, w_hc_1, w_cooland1_1,
w_brgew_1, w_tknum_1, w_vbeln_1, w_vbeln1_1,
w_exidv_1, w_vhilm_1, w_pack_no_1,
w_brgew1_1, w_laeng_1, w_breit_1,
w_hoehe_1, w_vol_1, w_error.
w_xblnr_1 = 'Cust PO No.'.
w_aubel_1 = 'Sal Order'.
w_vemng_1 = 'Pack Qty'.
w_matnr_1 = 'Model no.'.
w_harmdesc_1 = 'Hrm Desc'.
w_hc_1 = 'Hrm Code'.
w_cooland1_1 = 'Counrty of Origin'.
w_brgew_1 = 'Net Wt.'.
w_tknum_1 = 'Shipment'.
w_vbeln_1 = 'Billing doc'.
w_vbeln1_1 = 'Delivery'.
w_exidv_1 = 'Pkg ID'.
w_vhilm_1 = 'Pkg Desc'.
w_pack_no_1 = 'Pkg No.'.
w_brgew1_1 = 'Gross Wt'.
w_laeng_1 = 'Length'.
w_breit_1 = 'Width'.
w_hoehe_1 = 'Height'.
w_vol_1 = 'Cubic Mtr'.
w_error = 'Error'.
CONCATENATE w_xblnr_1 w_aubel_1 w_vemng_1
w_matnr_1 w_harmdesc_1 w_hc_1 w_cooland1_1
w_brgew_1 w_tknum_1 w_vbeln_1 w_vbeln1_1
w_exidv_1 w_vhilm_1 w_pack_no_1
w_brgew1_1 w_laeng_1 w_breit_1
w_hoehe_1 w_vol_1 w_error
INTO w_longtext SEPARATED BY ','.
it_objbin = w_longtext.
APPEND it_objbin. CLEAR it_objbin.
*--Append the details to Internal table of Email
LOOP AT it_tab.
DO.
ASSIGN COMPONENT sy-index OF STRUCTURE it_tab TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
Look for Commas in the field value. If it exists, put quotes around
value so that the file opens correctly with all the columns aligned
in Excel.
SEARCH <field> FOR ',' IN CHARACTER MODE.
If search for commas was successful.
IF sy-subrc = 0.
CONCATENATE '"' <field> '"' INTO <field> IN CHARACTER MODE.
ENDIF.
IF sy-index = 1.
i_dload-dload = <field>.
SHIFT: i_dload-dload LEFT DELETING LEADING space.
ELSE.
Put Comma as a separator for values in IT_DLOAD internal table
SHIFT: i_dload-dload LEFT DELETING LEADING space.
CONCATENATE i_dload-dload <field> INTO i_dload-dload
SEPARATED BY ',' IN CHARACTER MODE.
ENDIF.
ENDDO.
it_objbin = i_dload-dload.
APPEND it_objbin. CLEAR it_objbin.
ENDLOOP.
flag = 0.
endif.
-Convert to correct format----
CALL FUNCTION 'SO_RAW_TO_RTF'
TABLES
objcont_old = it_objbin
objcont_new = it_objbin.
create the control table entry for the main email
DESCRIBE TABLE it_objtxt LINES tab_lines.
CLEAR it_objpack-transf_bin.
it_objpack-head_start = 1.
it_objpack-head_num = 0.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'RAW'.
APPEND it_objpack.
DESCRIBE TABLE it_objbin LINES tab_lines.
it_objpack-head_start = 1.
it_objpack-head_num = 0.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-transf_bin = c_x.
it_objpack-doc_type = 'CSV'.
it_objpack-obj_descr = w_filename. "'billing doc no.csv'.
it_objpack-obj_name = 'Billing Doc'.
it_objpack-doc_size = tab_lines * 255.
APPEND it_objpack.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
PUT_IN_OUTBOX = c_x
commit_work = c_x
TABLES
packing_list = it_objpack
object_header = it_objhead
contents_bin = it_objbin
contents_txt = it_objtxt
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
IF sy-subrc <> 0.
WRITE: / 'failure in sending mail'.
ELSE.
if flag = 0.
MESSAGE s999(pp) WITH text-007.
endif.
if flag = 1.
MESSAGE s999(pp) WITH text-006.
endif.
WRITE: / 'success in sending mail'.
ENDIF.
ENDFORM. " p_send_email -
Hi All,
I have a requirement of sending the data available in an internal table via email. I need to populate this content into excel sheet and send it as an attachment to recipients. I am using the following code for that.
REPORT z51515t_doc_att.
DATA: objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
DATA : BEGIN OF itab OCCURS 0,
pernr LIKE p0001-pernr,
name LIKE p0002-vorna,
END OF itab.
Creation of the document to be sent
File Name
doc_chng-obj_name = 'SENDFILE'.
Mail Subject
doc_chng-obj_descr = 'Delivered Mail'.
Mail Contents
objtxt = 'My Content 1 '.
APPEND objtxt.
objtxt = 'My Content2'.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
Creation of the entry for the document
CLEAR objpack-transf_bin. "Will get content from content_text
objpack-head_start = 1. "Reads given row number in object header
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
Prepare content for attachment
DO 3 TIMES.
itab-pernr = 182.
itab-name = 'Prasath'.
APPEND itab.
itab-pernr = 1000.
itab-name = 'Praveen'.
APPEND itab.
ENDDO.
Populate attachment content
LOOP AT itab.
CONCATENATE itab-pernr itab-name INTO objbin-line.
APPEND objbin.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
Creation of the entry for the compressed attachment
objpack-transf_bin = 'X'. "Will get content from content_bin
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'EXT'.
objpack-obj_name = 'WEBSITE'.
objpack-obj_descr = 'MyFile.XLS'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
target recipent
CLEAR reclist.
reclist-receiver = '[email protected]'.
reclist-express = 'X'.
reclist-rec_type = 'U'.
APPEND reclist.
copy recipents
CLEAR reclist.
reclist-receiver = '[email protected]'.
reclist-express = 'X'.
reclist-rec_type = 'U'.
reclist-copy = 'X'.
APPEND reclist.
Sending the document
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 = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
Now using this code i am able to send out the file but the data in the XL file is not aligned properly. When i open the attachment that i receive the contents of itab appear inside the same cell - A1 of the XL sheet. I want the data to be available in different rows and columns. How do i achieve this?
Thanks,
Prasath NSee the below program it was sending the file as attach in XLS format by column and rows are properly placed ... see the
<b>Code in my program :
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode</b>
REPORT ZEMAIL_ATTACH .
TABLES: ekko.
PARAMETERS: p_email TYPE somlreci1-receiver
DEFAULT '[email protected]'.
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
wa_ekpo TYPE t_ekpo.
TYPES: BEGIN OF t_charekpo,
ebeln(10) TYPE c,
ebelp(5) TYPE c,
aedat(8) TYPE c,
matnr(18) TYPE c,
END OF t_charekpo.
DATA: wa_charekpo TYPE t_charekpo.
DATA: it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
WITH HEADER LINE.
DATA: t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
w_cnt TYPE i,
w_sent_all(1) TYPE c,
w_doc_data LIKE sodocchgi1,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
*START_OF_SELECTION
START-OF-SELECTION.
* Retrieve sample data from table ekpo
PERFORM data_retrieval.
* Populate table with detaisl to be entered into .xls file
PERFORM build_xls_data_table.
*END-OF-SELECTION
END-OF-SELECTION.
* Populate message body text
perform populate_email_message_body.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_message
it_attach
using p_email
'Example .xls documnet attachment'
'XLS'
'filename'
changing gd_error
gd_reciever.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
PERFORM initiate_mail_execute_program.
*& Form DATA_RETRIEVAL
* Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
SELECT ebeln ebelp aedat matnr
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekpo.
ENDFORM. " DATA_RETRIEVAL
*& Form BUILD_XLS_DATA_TABLE
* Build data table for .xls document
FORM build_xls_data_table.
CONSTANTS: con_cret TYPE x VALUE '0D', "OK for non Unicode
con_tab TYPE x VALUE '09'. "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
*constants:
* con_tab type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
* con_cret type c value cl_abap_char_utilities=>CR_LF.
CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR'
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
LOOP AT it_ekpo INTO wa_charekpo.
CONCATENATE wa_charekpo-ebeln wa_charekpo-ebelp
wa_charekpo-aedat wa_charekpo-matnr
INTO it_attach SEPARATED BY con_tab.
CONCATENATE con_cret it_attach INTO it_attach.
APPEND it_attach.
ENDLOOP.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables pit_message
pit_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = pit_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
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.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
* Instructs mail send program for SAPCONNECT to send email.
FORM initiate_mail_execute_program.
WAIT UP TO 2 SECONDS.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDFORM. " INITIATE_MAIL_EXECUTE_PROGRAM
*& Form POPULATE_EMAIL_MESSAGE_BODY
* Populate message body text
form populate_email_message_body.
REFRESH it_message.
it_message = 'Please find attached a list test ekpo records'.
APPEND it_message.
endform. " POPULATE_EMAIL_MESSAGE_BODY
reward points if it is usefull ....
Girish -
Problem with attachment using SO_NEW_DOCUMENT_ATT_SEND_API1
Hi,
I'm using function module SO_NEW_DOCUMENT_ATT_SEND_API1 to send emails from SAP (to Outlook - but the problem can already be observed when checking the email attachment in transaction SOST) with attachments.
My attachment is a tab delimited file (so that I can open with MS Excel) with a line size of approx. 1600 characters. I mean, concatenating all fields of the output table into a 1600 character field, separated by tabstops (cl_abap_char_utilities=>horizontal_tab)
I am using function module SCMS_STRING_TO_FTEXT to convert the internal table that I want to send to the line size as accepted by function module SO_NEW_DOCUMENT_ATT_SEND_API1, tables parameter contents_bin. Due to function module SCMS_STRING_TO_FTEXT this happens line by line, using a string variable. I make sure to remove any exess blanks that appear in the process due to not completey filled character fields. And for all rows bar the first the string is prefixed with (cl_abap_char_utilities=>cr_lf). I believe that's required so that SAP knows to put the lines back together. So far so good.
When checking the email's attachment via SOST (and the same happens in Outlook) there are extra blanks in certain fields. Like:
Annual Base
92,928. 00
or
Email
First L ast
In debugging it appears that these excess spaces (sometimes 1, sometimes several) appear where the 1600 character data line is split into the 255 character pieces in 'contents_bin'. But then it happens quite randomly and cannot be observed in all data rows.
Is there a better way of splitting my internal table into 255 character chunks so that what is one field will never get split up into two rows. For the above example, the two fields would show like this in contents_bin
.... 92,928.
00
and
First_L
ast
Or where else lies the problem?
Thanks in advance!
PhilippRon,
Thank you for the suggestion. Just tried but issue remains exactly the same. The function module you have suggested builds the table in the same way.
But, after a few more rounds of debugging and scratching my head it occured to me that my problem is self inflicted. I was using the condense statement in an attempt to get rid of the trailing blanks at the end of a row causing the last column to be filled with lots of spaces at the end. But it wasn't working anyway and I have since inserted a dummy column at the end to take all those trailing blanks. What this condense statement did though was creating trailing blanks in some of those rows with 255 characters fixed length and those trailing blanks then showed up as additional blanks in some columns in the attachment that the emailing function module created by putting those lines back to it's original length of close to 1600 characters.
Problem solved!
Regards,
Philipp -
Multiple attachment using OLE2
Hi
How can i attached multiple document in a single mail. I am using OLE2 utility for sending mail.
Any help regards this will welcome
Thanks
VishalForms ver. 6.0.8.26.0 (Production)
Rgds
Vishal -
Send/Receive multiple attachments using SwA (no MTOM)
Hello all,
I would appreciate if someone can put me in the right direction about the following implementation:
- web service method able to receive multiple attachment using weblogic tools (wsdlc, jwsc) without MTOM.
I tried JAXRPC and JAXWS, starting from code and from wsdl, using bytearrayholder, DataHandler array ... without success.
Better solution for my own goal would be using JAXRPC and Array of attachments.
Actually I don't know what I can add again: I've done multiple tests and I cannot add all the used code/wsdl/build/... of course.
I'm using WLS 10.0 (p3)
I'm just a bit confused! So, I will thank if someone can suggest the right road and, in case, I'll post more details about the related test I've done.
Thanks,
PepeHello all,
I would appreciate if someone can put me in the right direction about the following implementation:
- web service method able to receive multiple attachment using weblogic tools (wsdlc, jwsc) without MTOM.
I tried JAXRPC and JAXWS, starting from code and from wsdl, using bytearrayholder, DataHandler array ... without success.
Better solution for my own goal would be using JAXRPC and Array of attachments.
Actually I don't know what I can add again: I've done multiple tests and I cannot add all the used code/wsdl/build/... of course.
I'm using WLS 10.0 (p3)
I'm just a bit confused! So, I will thank if someone can suggest the right road and, in case, I'll post more details about the related test I've done.
Thanks,
Pepe -
Send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1
Hi ABAPers,
I managed to send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
Let say I send it to my own email account.
But, when try to open the excel document, from lotus notes, there is warning message produced by the microsoft excel saying:
"The file is not in a recognizable format.
and so on....."
Anyway, when I click button 'OK', excel sheet will be opened and no information lost.
How can we code the abap program so that the message will not come each time I open the attachment from my lotus notes?
Or this is just the tab delimited issue?
Thank you.
Regards,
Edward.Hi Shan,
Thank you for replying.
I have the same as follows:
DESCRIBE TABLE lt_contents_hex LINES lv_lines.
lt_packing_list-transf_bin = 'X'.
lt_packing_list-head_start = 1.
lt_packing_list-head_num = 1.
lt_packing_list-body_start = 1.
lt_packing_list-body_num = lv_lines.
lt_packing_list-doc_type = 'XLS'.
lt_packing_list-obj_name = 'ATTACHMENT'.
lt_packing_list-obj_descr = 'Attachment'.
lt_packing_list-doc_size = lv_lines * 255.
APPEND lt_packing_list.
I'm using lt_contents_hex instead of lt_contents_bin.
Still the problem is there.
Is there any other way to calculate the doc size correctly?
Regards,
Edward. -
How to create list items with multiple attachment files using rest api javascript
In one of user form I am using javascript rest api to create a list item with multiple attachment files. So far I am able to create list item and once created uploading an attachment file. But this is two step process first create an item and then upload
a file.
It create an additional version of the item which is not desired. Also I am not able find a way to attach multiple files in a go. Following is the code I am using.
createitem.executeAsync({
url: "/_api/web/lists/GetByTitle('UserForm')/items(1)/AttachmentFiles/add(FileName='" + aFile.name + "')",
method: "POST",
contentType: "application/json;odata=verbose",
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
binaryStringRequestBody: true,
body: fileContent,
success: fnsuccess,
error: fnerror
So somehow I need to combine item attributes along with attachment files in body: param. I visited https://msdn.microsoft.com/en-us/library/office/dn531433.aspx#bk_ListItem but no success.
Appreciate any help.Thanks Mahesh for the reply and post you share it was useful.
But this does not solve the core of the issue. You are uploading attachments after creation of item and multiple files are being attached in loop. This is kind of iterative update to an existing item with attachments. This will end up creating multiple versions.
What I am trying to achieve is to create an item along with multiple attachments in a go. No item updates further to attach a file.
Please suggest how this can be done in one go. SharePoint does it when one creates an item with multiple attachment.
Thanks for your reply. -
I have an HP photosmart 2610 4 in1. How can I scan multiple items and put them in the same attachment using e-mail? Using my laptop.
Hi @needyrhelp,
Welcome to the HP Forums!
I see that you are wondering how to scan multiple items using your HP photosmart 2610 and for them to be able to be in one attachment in your e-mail. I am happy to look into this for you!
Please see the how to scan guide for the Operating System you are using. Here is the list of how to scan guides, Scan. Select your Operating System from the list, then select How to scan with HP software, then How to scan a multi-page original text document into a single file. You will need to scan each page one at a time, and add it to the same document. The how to scan guide will show you how. After done scanning to the file, then see the link for How to attach a scan to an email.
If you do not know the Operating System you are using, please visit this website. Whatsmyos.
Hope this information is helpful, and thank you for posting!
RnRMusicMan
I work on behalf of HP
Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
Click the “Kudos Thumbs Up" to say “Thanks” for helping! -
Since i have updated my iPhone 4 to iOS 5.0.1 i cannot attach multiple photos using the ' Message ' option in the ' Photos ' app.
i browse my photos and then select ' Message ' on a photo. i am then able to attach the first image to the message.
When i then select the Camera icon on the created message to add another image , either ' Choose existing ' or ' Take Photo or Video ' , it does nothing and takes you back to your existing message.
I am able to attach multiple images when accessing the iMessage app it is just from the Photos app it is occuring
is anyone else having the same issue ?You can submit the feedback to Apple here:
http://www.apple.com/feedback -
How to send multiple attachment in single mail
i am using FM SO_NEW_DOCUMENT_ATT_SEND_API1 for sending mail.
pls guide me how can i modify my code so that i can send multiple attachmentsHi Manish,
Check out the links below.
E-mail multiple PDF attachments
Send a Single Mail with Multiple Attachment
Hope it helps.
Regards,
Amit
*Always reward points for helpful answers
Message was edited by:
Amit Kumar -
Send smartform to multiple users using std. smartform interface
Hello All,
Below is the requirement : -
While doing an external send against the custom output type in transaction VF02, smartform is automatically send to the appropriate email address as pdf attachment. This email address can be sold to party/bill to party etc and it is controlled using configuration.
Now the prb is, using such configuration we can send email to single email id only. I need to send the email to multiple users using the standard smartform interface ONLY i.e by using the parameter MAIL_RECEPIENT in the std. smartform interface.
I have alredy evaluated the below workarounds for the above solution, but we need to implement the above functionality using standard smartform interface only.
1) Convert the smartform OTF data to PDF format data and then send the PDF attachment via email to multiple recipients using the standard FM SO_NEW_DOCUMENT_ATT_SEND_API1.
2) Loop at the recipients table and within the loop pass different recipient to the interface parameter MAIL_RECIPIENT of smartform. Hence in this case smartform will be called within the loop which can cause performance issues incase of multiple recipients. Also the mail will be sent individually to every recipient.
3) I have already checked by passing the distribution list the parameter MAIL_RECEIPIENT but it does not work.
Looking forward for your responses.
Regards,
R.DoshiHi
Check if SAP Note 1260015 - Sending mail to multiple recipients is useful for your requirements.
Regards
Eduardo -
Sending mail with multiple attachment
hi.
i want to send mail with multiple attachment.
i m succeed in sending multiple attachment but the second pdf is not open.
its given error like "This file is damaged and could not be open.
pls check my code. and
give the solution....
point should be assured...........
hope all u r understand my problem..
& tell me where is i m missing something.
REPORT YSDPASALE1_MAIL LINE-SIZE 110.
data : year_month(6) type c.
data : from_date like sy-datum,to_date like sy-datum.
INITIALIZATION.
year_month = sy-datum+0(6).
CONCATENATE year_month '01' into from_date.
to_date = sy-datum.
ranges : temp for mkpf-budat.
temp-low = from_date.
temp-high = to_date.
append temp to temp.
DATA: P_JOBCNT LIKE TBTCJOB-JOBCOUNT,
jobname like TBTCJOB-JOBNAME,
L_RELEASE(1) TYPE c.
CONSTANTS : l_c_device(4) VALUE 'LOCL'.
DATA : t type i value 0.
DATA : p_email1 like somlreci1-receiver,
p_sender LIKE somlreci1-receiver.
Data Declaration
DATA: gd_recsize TYPE i,gd_recsize1 TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att1 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att2 LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_desc1 TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des,
gd_mtitle LIKE sodocchgi1-obj_descr.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
DATA: BEGIN OF mailstr OCCURS 0,
p_email like somlreci1-receiver,
END OF mailstr.
DATA: mailtab like STANDARD TABLE OF mailstr WITH HEADER LINE.
DATA: ypp18tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis008tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ysd15tab like STANDARD TABLE OF mailstr WITH HEADER LINE,
ymis10tab like STANDARD TABLE OF mailstr WITH HEADER LINE.
SUBMIT YSDPASALE1 with bdt in temp
to sap-spool
with line-size = '255'
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' '
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf.
select yemail as p_email into CORRESPONDING FIELDS OF TABLE ymis008tab
from ymail
where ytcode = 'YMIS008'.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool & mail sending',
'request to be created.'.
ENDIF.
wait up to 3 seconds.
submit YSD_MONTHLY_SALES
USING SELECTION-SET 'MAIL'
to sap-spool
with KEEP_IN_SPOOL = 'X'
with IMMEDIATELY = ' ' "SPACE
WITHOUT SPOOL DYNPRO
AND RETURN
NEW-PAGE PRINT ON
DESTINATION l_c_device
IMMEDIATELY ' '
KEEP IN SPOOL 'X'
NEW LIST IDENTIFICATION 'X'
NO DIALOG.
new-page print off.
IF sy-batch EQ 'X'.
gd_attachment_desc1 = 'YMIS10'.
gd_mtitle = 'Monthly Sales Report'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
PERFORM convert_spool_to_pdf1.
loop at it_mess_att.
move it_mess_att1 to it_mess_att.
APPEND it_mess_att.
endloop.
APPEND LINES OF it_mess_att1 to it_mess_att.
free it_mess_att1.
it_mess_att[] = it_mess_att1[].
insert LINES OF it_mess_att1 into it_mess_att.
APPEND LINES OF it_mess_att2 to it_mess_att .
insert LINES OF it_mess_att1 into it_mess_att.
insert LINES OF it_mess_att2 into it_mess_att.
loop at ymis008tab into mailstr.
p_email1 = mailstr-p_email.
p_email1 = '[email protected]'.
PERFORM process_email.
endloop.
clear mailstr.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ELSE.
SKIP.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output 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.
ENDFORM.
FORM convert_spool_to_pdf1.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_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.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att1 = gd_buffer.
APPEND it_mess_att1.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
DESCRIBE TABLE it_mess_att1 LINES gd_recsize1.
CHECK gd_recsize > 0 or gd_recsize1 > 0.
PERFORM send_email." USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email." USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = gd_attachment_desc1 .
gd_attachment_desc = 'YPP18 - Daily Highlights'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Dear Sir,'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'kindly find the attached document'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Do not reply on this mail, It is generated from SAP'.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = ' '.
APPEND it_mess_bod.
it_mess_bod = 'Regards,'.
APPEND it_mess_bod.
it_mess_bod = 'Arpit Shah'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
it_mess_att1
using "p_email
gd_mtitle
'Testing mail generated from SAP'
'Daily Highlights Abstract Report - YPP18'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
it_attach1
using "p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1,w_doc_data1 like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data1-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
For 2nd Attachments
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach1 INDEX w_cnt.
w_doc_data-doc_size = w_doc_data1-doc_size +
( w_cnt - 1 ) * 255 + STRLEN( it_attach1 ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
APPEND LINES OF it_attach1 to t_attachment.
t_attachment[] = it_attach1[].
APPEND LINES OF it_attach1 to t_attachment.
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
DESCRIBE TABLE it_mess_att LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS008'."ld_attdescription.
t_packing_list-obj_name = 'YMIS008'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
clear t_packing_list.
for 2 attachments
data : a type i,b type i.
a = t_packing_list-body_num.
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = a + 1. "1
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
DESCRIBE TABLE it_attach1 LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
a = t_packing_list-body_num.
clear t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = a + 1.
t_packing_list-body_num = t_packing_list-body_num + 1.
DESCRIBE TABLE it_mess_att1 LINES t_packing_list-body_num.
t_packing_list-body_num = a + t_packing_list-body_num .
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = 'YMIS10'."ld_attdescription.
t_packing_list-obj_name = 'YMIS10'."ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
loop at ymis008tab into mailstr.
t_receivers-receiver = mailstr-p_email. "ld_email.
t_receivers-receiver = p_email1.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'. "X "Read Acknoledgement
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
endloop.
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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Rgds.
ArpitHi Arpit,
Take a look at the documentation of FM 'SO_DOCUMENT_SEND_API1' for parameter PACKING_LIST. I think you should set t_packing_list-head_num to a different value than 0 for the second attachment.
Regards,
John. -
Multiple attachment in sender mail adapter with PI 7.11
Hello all,
I've got a scenario MAIL -> PI -> MAIL.
In my sender adapter mail, i have two attachment.
From what i've saw on different thread, it wasn't possible to handle this case in standard with PI 7.0.
Is it possible now with PI 7.11 ? Or must i develop a specific module for that ?
Thank you.Hi Jean ,
I got the same issue too, the Scenario is MAIL ->FILE . Mail Sender Adapter picks up the 1 PDF attachment and saves in network folder successfully but not multiple attachments of a mail.
These are the setting in Module configuration I made:
1. The IMAPS was used in Mail Sender Adapter : imaps://10.192.101.16:993/Inbox
*IP address of the Mail Server was got from the Admin )
2. Ports : 143, 993 are opened for the Mail Server to access for XI SERver ( Raised an Ticket to open Ports of Mail server :NZTxxx.dknz.nzcorp.net)
3. As the attachment was only in PDF : Added swapbean in Module tab as below :
Process Sequesnce :
-Make sure: AF_Modules/PayloadSwapBean Modul key : TRANSFORM is added before sap.com/com.sap.aii.adapter.mail.app/XIMailAdapterBean
-And under Module Configuration select : TRANSFORM as Module Key and add >
swap.keyName Content-Disposition
swap.keyName Content-Description
swap.keyValue attachment;filename='MailAttachment-1.pdf"
swap.keyValue MailAttachment-1
-IF you get to know how to fetch multiple attachment , Please update.
Thanks,
Vara
Maybe you are looking for
-
Itunes crashed, now programs that run on startup crash
hi, I just installed itunes for my new ipod mini, and while going through my library (my music) i received an error message that advised that there may be a problem with my hardware. I managed to close itunes, and noticed that there were only 13 song
-
Essbase 11.1.2 and apache
Hi All 1. I m trying to install Hyperion 11.1.2. and would like to know if I have to install any webservers/ app servers as a pre requisite along with installing Oracle database? 2. will xpress edition 10 of oracle serve the purpose? Thanks in advanc
-
Hi All, I have created a new field in user form named telephone number,When ever I run AD target recon, the updated telephone number in AD is reflecting in Process form. I wrote a copy Adapter that copies process form value to usr form. This is worki
-
Hi, I am making a picture album with iPhoto 09 and when I pressed "Buy Book" it says "Your book seems to have frames on one or more pages that do not contain photos. You must either change the layout of those pages or place photos in those frames bef
-
How to delete connections for modules in OWB?
Hi all, When we create an Oracle Module in OWB, we can create and specify a connection for the module. But I don't know how to delete or modify those connections. Anyone can tell me a method. Thanks a lot.