Sending Chinese email uisng FM SO_NEW_DOCUMENT_ATT_SEND_API1
Hi Experts,
I attempt to send chinese language character using chinese logon using the above function module in 4.6C hotpack 50.
The chinese character are in the content_txt table of the FM and for the rest of the table for this function module, I had set the language to sy-langu where ever possible.
But when the email is received, it's still not display in chinese language.
Anybody can advice?
Thanks.
Hey Darren,
This sound interesting. I didn't do this.
Anyway.. I am just sending a normal mail out and not touching or retrieving anything via NAST table. Is this statement still required? Where should I put this statement?
Just more details, my program is suppose to upload a text field, break it into multiple emails to send to supplier based on the PIR for the material number. There's not retrieval via NAST nor anything related to PO.
Thanks.
Similar Messages
-
Regarding Sending an email by using SO_NEW_DOCUMENT_ATT_SEND_API1
Hi Experts,
I have tow internal tables like ...ITAB1 AND ITAB2.
Is it possible to send an email with these two internal tables as attachments..like Attachment1...Itab1 and Attachment2...Itab2..
Is it possible by using the FM SO_NEW_DOCUMENT_ATT_SEND_API1??
Rgds,
Sruthi.Hi Shruthi,
You can use FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send internal tables as attachment in mail.
Plz check this link:
https://wiki.sdn.sap.com/wiki/display/ABAP/Tosend2inttablesdataastwoattachmentstomailidoutsidesapsystem
It will guide you in solving your problem.
Thanks & regards,
Sarita Singh -
Hi,
I am using the FM "SO_NEW_DOCUMENT_ATT_SEND_API1" to send an E-Mail. I have to use the sender's E-Mail address as a general one ( Not to the SAP login user's id ). How to do this.
Please advice.
Thanks in advance.Hai Sabari
Check the following Code
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 L_NUM(3).
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 = 'Object text'.
APPEND OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
Creation of the document attachment
LOOP AT ITAB_DATA.
CONCATENATE ITAB_DATA-PRODUCTOR
ITAB_DATA-VBELN
ITAB_DATA-POSNR
ITAB_DATA-MATNR INTO OBJBIN.
APPEND OBJBIN.
ENDLOOP.
DESCRIBE TABLE OBJBIN LINES TAB_LINES.
OBJHEAD = 'ORDERS'.
APPEND OBJHEAD.
Creation of the entry for the compressed attachment
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'TXT'.
OBJPACK-OBJ_NAME = 'WEBSITE'.
OBJPACK-OBJ_DESCR = 'ORDERS.TXT'.
OBJPACK-DOC_SIZE = TAB_LINES * 255.
APPEND OBJPACK.
Completing the recipient list
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
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.
Thanks & regards
Sreenivasulu P -
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. -
Experts:
I am working on sending Excel as an email attachment thro the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'
I am able to send mail successfully but I face the following two issues while opening the attachment.
1. While opening it says 'un recognized format' , on pressing 'OK' it opens the excel file.
2. The column heading (first row) which should be in Korean character is displayed in junk char. I tried to
specify the unicode (Code Page = '8500') but does not know how to do it.
I am reading the column header text from standard text.
Please let me know what mistake I have commited in my code and where I should specify the unicode transformation. I refered many samples but could not make it.
Please let me know the error.
The code is as follows.
FORM sendemail_barcodedata.
TYPE-POOLS: truxs.
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: objbin1 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: l_sent_to_all TYPE sonv-flag.
* Creating the document to be sent
* File Name
doc_chng-obj_name = 'BCODEINFO'.
* Mail Subject
doc_chng-obj_descr = 'Delivery Barcode Information'.
* Mail Content
objtxt = 'Hi:'.
APPEND objtxt.
objtxt = 'Find attached, Delivery Barcode Information'.
APPEND objtxt.
CONCATENATE 'Attachment : <<' w_fname1 '>>' INTO objtxt.
APPEND objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
doc_chng-obj_langu = sy-langu.
doc_chng-sensitivty = 'F'.
* Creating the entry for the compressed document
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
APPEND objpack.
* Creating the document attachment
* Get column names for Barcode Data
CLEAR objbin.
CONCATENATE text-h23
text-h24
text-h25
text-h26
text-h27
INTO objbin SEPARATED BY con_tab .
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
LOOP AT it_excel2 INTO wa_excel2.
CONCATENATE wa_excel2-zz_date
wa_excel2-zz_delivery
wa_excel2-zz_barcode
wa_excel2-blank1
wa_excel2-blank2
INTO objbin SEPARATED BY con_tab.
CONCATENATE objbin con_cret INTO objbin.
APPEND objbin.
CLEAR objbin.
ENDLOOP.
DESCRIBE TABLE objbin LINES tab_lines.
objhead = w_fname1.
APPEND objhead.
* Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 1.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'XLS'.
objpack-obj_name = 'Barcode Information'.
objpack-obj_descr = 'Barcode Information'.
objpack-doc_size = tab_lines * 255.
APPEND objpack.
* Entering names in the distribution list
reclist-receiver = p_email.
reclist-rec_type = 'U'.
APPEND reclist.
* Sending the document
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = ' '
commit_work = 'X'
IMPORTING
sent_to_all = l_sent_to_all
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
receivers = reclist
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.
CASE sy-subrc.
WHEN 0.
MESSAGE i000(z65f_msgclass) WITH text-211.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of'.
WHEN 2.
WRITE: / 'document could not be sent to any of the recipients!'.
WHEN 4.
WRITE: / 'no authorization to send !'.
WHEN OTHERS.
WRITE: / 'error occurred during sending !'.
ENDCASE.
ENDFORM.
Thanks in advance.
Regards
VijaiHi:
Can any one provide me a solution for this?
regards
vijai -
Issue in sending the email with XL attachment in ECC version
Hi,
I have an issue with sending the email with XL attachment. My program is sending a mail to the receiver with XLS as attachment. Recently we have migrated from 4.6B to ECC version. Same code was worked in 4.6B.But it is not working in ECC version.When i try to open the attachment, i get a Dialog Box with the following message
"The file is not in a recognizable format.
1. if you know the file is from another program whih is incompatible with Microsoft excel,click cancel,then open this file in its original application
2.If you suspect the file is damaged, click help for more information about solving theproblem.
3.if you still want to see what text is contained in the file, click OK.Then click the text import wizard. "
when i click OK, the excel sheet is opening with all required data.
Can anyone kindly tell me why this is happening.
I am also attaching part of the coding related to this requirement.
*& Form BUILD_XLS_DATA_TABLE
text
--> p1 text
<-- p2 text
FORM build_xls_data_table.
DATA: w_total(13),
w_clabs(13),
w_cinsm(13),
w_ceinm(13),
w_cretm(13),
w_cspem(13),
w_cumlm(13),
w_exp_date(8),
w_v_totalp(13),
w_min_rem(8),
w_ersda(10),
w_hsdat(10),
w_vfdat(10),
w_ship_date(10),
w_plnmg(13),
w_mhdrz(4).
CLEAR: w_total, w_clabs, w_cinsm, w_ceinm, w_cspem, w_exp_date,
w_v_totalp, w_min_rem, w_ersda, w_hsdat, w_vfdat, w_ship_date,
w_plnmg, w_mhdrz.
w_total = it_batch1-total.
w_clabs = it_batch1-clabs.
w_cinsm = it_batch1-cinsm.
w_ceinm = it_batch1-ceinm.
w_cspem = it_batch1-cspem.
w_cumlm = it_batch1-cumlm.
w_cretm = it_batch1-cretm.
w_exp_date = it_batch1-exp_date.
w_v_totalp = it_batch1-v_totalp.
w_min_rem = it_batch1-min_rem.
w_plnmg = it_batch1-plnmg.
w_mhdrz = it_batch1-mhdrz.
CONCATENATE it_batch1-ersda6(2) it_batch1-ersda4(2)
it_batch1-ersda+0(4) INTO w_ersda SEPARATED BY '.'.
CONCATENATE it_batch1-hsdat6(2) it_batch1-hsdat4(2)
it_batch1-hsdat+0(4) INTO w_hsdat SEPARATED BY '.'.
CONCATENATE it_batch1-vfdat6(2) it_batch1-vfdat4(2)
it_batch1-vfdat+0(4) INTO w_vfdat SEPARATED BY '.'.
CONCATENATE it_batch1-ship_date6(2) it_batch1-ship_date4(2)
it_batch1-ship_date+0(4) INTO w_ship_date SEPARATED BY '.'
CONCATENATE
it_batch1-werks it_batch1-mtart it_batch1-matnr it_batch1-maktg
it_batch1-prdha it_batch1-prctr it_batch1-ktext it_batch1-dispo
it_batch1-charg it_batch1-lgort it_batch1-herkl w_clabs
w_cinsm w_ceinm w_cretm w_cspem
w_cumlm w_total it_batch1-meins it_batch1-v_spr_unit
w_v_totalp it_batch1-waers w_plnmg it_batch1-meins
w_ersda w_hsdat w_vfdat w_exp_date
w_ship_date w_mhdrz w_min_rem it_batch1-zlifer
it_batch1-doknr it_batch1-dokar it_batch1-doktl it_batch1-dokvr
INTO L_STRING SEPARATED BY CON_TAB.
INTO l_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
WHILE l_string <> space.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING
length = 255
text = l_string
as_character = 'X'
IMPORTING
line = it_attach
rest = l_string.
IF l_string = space.
CONCATENATE IT_ATTACH CON_CRET INTO IT_ATTACH.
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ELSE.
APPEND it_attach.
CLEAR it_attach.
ENDIF.
ENDWHILE.
move l_string to it_attach .
CONCATENATE it_attach cl_abap_char_utilities=>cr_lf INTO it_attach.
APPEND it_attach.
CLEAR it_attach.
ENDFORM. " BUILD_XLS_DATA_TABLE
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
text
--> p1 text
<-- p2 text
FORM send_file_as_email_attachment.
DATA:w_length TYPE i.
DATA: 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,
t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE.
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 = text-034 .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
DESCRIBE TABLE it_attach LINES w_cnt.
DESCRIBE TABLE it_message LINES w_cnt.
READ TABLE it_message INDEX w_cnt.
w_length = STRLEN( it_attach ).
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_message ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = text-034.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_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.
***Start of changes by 501507008 on 29.01.2009
t_packing_list-obj_descr = 'MAIL BODY'.
***End of changes by 501507008 on 29.01.2009
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 = 'XLS'.
t_packing_list-obj_descr = text-034.
t_packing_list-obj_name = 'filename'.
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 it_adr6.
t_receivers-receiver = it_adr6-smtp_addr.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
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 = ' '
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.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
commit_work = ' '
IMPORTING
sent_to_all =
new_object_id =
tables
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_receivers
contents_hex =
object_para =
object_parb =
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.
ENDIF.
ENDFORM. " SEND_FILE_AS_EMAIL_ATTACHMENTHi,
could you tell me which opeion should i select in SCOT under INT node. I have tried with diffrent options. but no luck.
SAPscript/Smart Forms - No Conversion
ABAP List - No Conversion
Business Object/Link - No Conversion
RAW Text - No Conversion -
Convert spool to PDF and send as email attachment
When i try to convert SAP spool to PDF and send it as email attachment, size of PDF document becomes large as compared to size of the PDF cocument i download using the same spool.
I am using following FMs.
CONVERT_ABAPSPOOLJOB_2_PDF to convert spool to PDF
and
SO_NEW_DOCUMENT_ATT_SEND_API1 to send email with attchment.
some times size of attchment exceeds 2MB and email results in error in SAP connect (SOST).
Any idea on how to compress the PDF attchment??
ThanksHi Venkat,
Can you plesae assist me.
I have a requirement to convert spool to pdf
send an email to users
issue is that attachement is big cant go through
I have used compress, but when I open the pdf file error that file was not correclty decoded
please assist, anyone -
Need to send HTML email from Workflow : problem with sender
Hi all,
i need to send HTML email from my Workflow. I did it but i have a problem with the sender. The sender of email is always the agent responsible of workitem, and i don't want the receiver can answer to sender. So i need to put a false email address like nosender.at.mycustomer.com.
Possible to do that ?
Thanks for your help.
CheersHi rick
How to change the wf-batch to some other name as you mention in previous reply. Can you give some details of that. If i use the function module SO_NEW_DOCUMENT_ATT_SEND_API1 how to change the wf-batch name and if i use send mail step in my workflow how to change wf-batch name.
Regards
vijay -
How to Send an Email in HTML Format
I'm trying to send an email to Outlook in HTML format but it's not working. As I have limited knowledge of HTML, can anyone please show me how to do this?
Your help is highly appreciated.Hello,
You can use function WWW_LIST_TO_HTML to convert list into HTML format. Then use function SO_NEW_DOCUMENT_ATT_SEND_API1 to send it as attachment.
Thanks,
Venu -
How can I to send an email with a longer than 50 characters subject?
I'm trying to send an email through an abap program ( report ), but when the email arrives to the SOST transaction the subject is cut to 50 characters. How can I send an email with a longer than 50 characters subject?
check this below code and do changes in ur report
FORM SEND_MAIL_SUPPORT TABLES P_EM_BODY
USING P_TITLE.
*_ Start of the code to send an email notification
DATA : ATTACH_REC TYPE I.
DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,
OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,
DOC_CHNG LIKE SODOCCHGI1,
TAB_LINES LIKE SY-TABIX.
Creation of the document to be sent
DOC_CHNG-OBJ_NAME = 'Mat Attach'(010).
DOC_CHNG-OBJ_DESCR = P_TITLE.
APPEND LINES OF P_EM_BODY TO OBJTXT.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
*Creation of the entry for the compressed document
CLEAR OBJPACK-TRANSF_BIN.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 0.
OBJPACK-BODY_START = 1.
OBJPACK-BODY_NUM = TAB_LINES.
OBJPACK-DOC_TYPE = 'RAW'.
APPEND OBJPACK.
DESCRIBE TABLE IT_ERROR LINES ATTACH_REC.
IF ATTACH_REC GE '1'.
*Start of email attachement of internal table conversition
APPEND LINES OF IT_ERROR TO OBJBIN.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
CONCATENATE 'CCode.' 'A/CDocNum.' ' FYear.' 'DType.' 'PDate.' ' RefField.' INTO
V_TEXT SEPARATED BY ' '.
APPEND V_TEXT TO OBJBIN.
CLEAR V_TEXT.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
LOOP AT IT_ERROR.
CONCATENATE IT_ERROR-BUKRS IT_ERROR-BELNR IT_ERROR-GJAHR IT_ERROR-BLART
IT_ERROR-BUDAT IT_ERROR-STATUS INTO V_TEXT SEPARATED BY ' '.
APPEND V_TEXT TO OBJBIN.
CLEAR V_TEXT.
ENDLOOP.
WRITE: '----
' TO OBJBIN.
APPEND OBJBIN.
CLEAR OBJBIN.
DESCRIBE TABLE OBJBIN LINES OBJPACK-BODY_NUM.
OBJPACK-TRANSF_BIN = 'X'.
OBJPACK-HEAD_START = 1.
OBJPACK-HEAD_NUM = 1.
OBJPACK-BODY_START = 1.
OBJPACK-DOC_SIZE = OBJPACK-BODY_NUM * 255.
OBJPACK-DOC_TYPE = 'RAW'.
OBJPACK-OBJ_DESCR = 'List of Error Documents'(012). " Description
APPEND OBJPACK. CLEAR OBJPACK.
ENDIF.
RECLIST-RECEIVER = S_EMAIL-LOW.
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.
*CHECK SY-SUBRC = 0.
ENDFORM. " SEND_MAIL_SUPPORT -
How to send the email to different email addresses from Workflow
Hello,
i an not getting that how to send the email from Workflow in SAP.
plz give the steps to do that.
i have done lots of time but system is not sending the email to different email address.Hi,
lot of configuration is invloved in sending
mail to external email id. check BASIS to
configure for external mails ans also check
debug FM and see which conditions exceptions
(Document not sendis raised)
also check below code
CLEAR: DOC_CHNG, OBJTXT, OBJBIN, OBJPACK, OBJHEAD, RECLIST,
RECIPIENT_INT, DOC_SIZE,TAB_LINES.
REFRESH: OBJTXT, OBJBIN, OBJPACK, OBJHEAD, RECLIST.
OBJBIN[] = CONTENT_OUT[].
Populate e-mail title
DOC_CHNG-OBJ_NAME = 'MAIL'.
CONCATENATE 'EETS for Contract #'(245)
OIA01_TAB-EXGNUM
INTO DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.
DESCRIBE TABLE OBJTXT LINES TAB_LINES.
READ TABLE OBJTXT INDEX TAB_LINES.
DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).
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.
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 PDF
OBJPACK-DOC_TYPE = 'PDF'.
OBJPACK-OBJ_NAME = 'Attachment'(239).
CONCATENATE 'EETS_' OIA01_TAB-EXGNUM '_'
IT_ZMMTACCUID-ACCTUSRID
'_' SY-DATUM '_' SY-UZEIT '.PDF'
INTO OBJPACK-OBJ_DESCR.
READ TABLE OBJBIN INDEX TAB_LINES.
DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJBIN ).
OBJPACK-DOC_SIZE = DOC_SIZE.
APPEND OBJPACK.
Get e-mail address
CLEAR IT_ADDRESS.
READ TABLE IT_ADDRESS WITH KEY ACCTID = IT_ZMMTACCUID-ACCTUSRID
BINARY SEARCH.
IF SY-SUBRC = 0.
RECIPIENT_INT-ADDRESS = IT_ADDRESS-SMTP_ADR.
ENDIF.
*Send email to external mail address
RECLIST-RECEIVER = RECIPIENT_INT.
RECLIST-REC_TYPE = 'U'.
APPEND RECLIST.
CLEAR RECLIST.
*Send email to SAP Office mail address
RECLIST-RECEIVER = IT_ZMMTACCUID-ACCTUSRID.
RECLIST-REC_TYPE = 'B'.
APPEND RECLIST.
CLEAR RECLIST.
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'
importing
sent_to_all = sent_to_all
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.
also check
https:/Re: mail sending problem
Regards
amole -
FM to send an email with a PDF attachment
Hello All,
Please suggest me some FMs to send an email along with PDF attachment.
Thanks,DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
i_tline TYPE TABLE OF tline WITH HEADER LINE,
i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,
i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
* Objects to send mail.
i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
**************Work Area declarations***********************
w_objhead TYPE soli_tab,
w_ctrlop TYPE ssfctrlop,
w_compop TYPE ssfcompop,
w_return TYPE ssfcrescl,
w_doc_chng TYPE sodocchgi1,
w_data TYPE sodocchgi1,
w_buffer TYPE string."To convert from 132 to 255
data: v_len_in TYPE sood-objlen,
v_len_out TYPE sood-objlen,
v_len_outn TYPE i,
v_lines_txt TYPE i,
v_lines_bin TYPE i.
start-of-selection.
w_ctrlop-getotf = gv_abaptrue.
w_ctrlop-no_dialog = gv_abaptrue.
w_compop-tdnoprev = gv_abaptrue.
PERFORM call_smartform.
PERFORM convert_to_otf_format.
PERFORM pdf_formatting.
PERFORM build_mail_format.
PERFORM send_mail.
form call_smartform.
DATA:fm_name TYPE rs38l_fnam.
DATA:formname TYPE tdsfname VALUE 'ZSD_CRM_PROFORMA_INVOICE_001'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = formname
IMPORTING
fm_name = fm_name.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION fm_name
EXPORTING
control_parameters = w_ctrlop
output_options = w_compop
user_settings = ' '
v_vbeln = v_vbeln
v_erdat = gv_dat
wa_custaddr = gw_zcustaddr
v_stceg = gw_kna1-stceg
v_total = gv_total
vbak = vbak
v_lifnr = gw_kna1-lifnr
vbrp = vbrp
v_head = gv_heading
v_taxtext = gv_text
v_tax = gv_tax
v_gtotal = gv_gtot
IMPORTING
job_output_info = w_return
TABLES
it_det = gt_items
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
endform.
form convert_to_otf_format.
i_otf[] = w_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf
lines = i_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 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.
endform.
form pdf_formatting.
* Convert PDF from 132 to 255.
LOOP AT i_tline.
* Replacing space by ~
TRANSLATE i_tline USING ' ~'.
CONCATENATE w_buffer i_tline INTO w_buffer.
ENDLOOP.
* Replacing ~ by space
TRANSLATE w_buffer USING '~ '.
DO.
i_record = w_buffer.
* Appending 255 characters as a record
APPEND i_record.
SHIFT w_buffer LEFT BY 255 PLACES.
IF w_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
endform.
FORM build_mail_format .
DATA:lv_dash(1) TYPE c VALUE '-'.
DATA:lv_xtn(4) TYPE c VALUE '.pdf'.
CONSTANTS:lv_esacpe TYPE so_escape VALUE 'U'.
CONSTANTS:lv_so_obj_tp TYPE so_obj_tp VALUE 'PDF'.
CONSTANTS:lv_so_obj_tp1 TYPE so_obj_tp VALUE 'RAW'.
CONSTANTS:lv_so_obj_sns TYPE so_obj_sns VALUE 'F'.
* Get Email ID's
SELECT * INTO TABLE gt_address[] FROM adr6
WHERE addrnumber = gw_kna1-adrnr.
REFRESH:i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR w_objhead.
* Object with PDF.
i_objbin[] = i_record[].
DESCRIBE TABLE i_objbin[] LINES v_lines_bin.
* Object with main text of the mail.
i_objtxt = text-002.
APPEND i_objtxt.
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
* Document information.
w_doc_chng-obj_name = text-005.
w_doc_chng-expiry_dat = sy-datum + 10.
IF gw_flg = 'T'.
w_doc_chng-obj_descr = text-003.
ELSE.
w_doc_chng-obj_descr = text-004.
ENDIF.
CONCATENATE w_doc_chng-obj_descr lv_dash v_vbeln INTO w_doc_chng-obj_descr.
w_doc_chng-sensitivty = lv_so_obj_sns. "Functional object
w_doc_chng-doc_size = v_lines_txt * 255.
* Pack to main body as RAW.
* Obj. to be transported not in binary form
CLEAR i_objpack-transf_bin.
* Start line of object header in transport packet
i_objpack-head_start = 1.
* Number of lines of an object header in object packet
i_objpack-head_num = 0.
* Start line of object contents in an object packet
i_objpack-body_start = 1.
* Number of lines of the object contents in an object packet
i_objpack-body_num = v_lines_txt.
* Code for document class
i_objpack-doc_type = lv_so_obj_tp1.
APPEND i_objpack.
* Packing as PDF.
i_objpack-transf_bin = gv_abaptrue.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = lv_so_obj_tp.
i_objpack-obj_name = text-005.
CONCATENATE w_doc_chng-obj_descr lv_xtn INTO i_objpack-obj_descr.
i_objpack-doc_size = v_lines_bin * 255.
APPEND i_objpack.
* Document information.
CLEAR i_reclist.
* e-mail receivers.
LOOP AT gt_address INTO gw_adr6.
i_reclist-receiver = gw_adr6-smtp_addr.
i_reclist-express = gv_abaptrue.
i_reclist-rec_type = lv_esacpe. "Internet address
APPEND i_reclist.
ENDLOOP.
endform.
FORM send_mail .
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_chng
put_in_outbox = ' '
TABLES
packing_list = i_objpack[]
object_header = w_objhead[]
contents_bin = i_objbin[]
contents_txt = i_objtxt[]
receivers = i_reclist[]
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
COMMIT WORK.
ENDFORM.
hi this is a program for sending smartform as pdf attachment.
make the necessary modifications in the OTF part and use it
Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM
Edited by: Keshu Thekkillam on Jul 10, 2009 7:17 PM -
Sending outbound email with paragraphs 255 characters
G'day all,
My problem at the moment is getting an outbound email with a body that includes continuous paragraphs greater than 255 characters. I want to be able to send an email where there is no emposed limit on a continuous paragraph.
Please note I am not interested in attachements with lengths greater than 255, it's the email body that concerns me. Simple email text ******
I've been working with inbound and outbound mails and making heavy use of Thomas Jung's blogs on the same -- Thanks so much to Thomas for these really helpful blogs, and all his posts!! --
/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
/people/thomas.jung3/blog/2004/09/09/receiving-e-mail-and-processing-it-with-abap--version-610-and-higher
On this basis I'm creating a document using class CL_DOCUMENT_BCS and passing it a table based on SOLI_TAB in which includes the email body with CL_ABAP_CHAR_UTILITIES=>CR_LF where required between paragraphs. I've been trying to use type 'RAW' as I want to keep the mails as low-tech as possible (no idea what email clients the recipients will be running).
I then pass the document to an instance of CL_SEND_REQUEST_BCS (via SETU_DOCUMENT) to send.
When the email is sent it includes an unwanted line break every 255 characters so it's not possible to have a continuous paragraph longer than 255 (the length of SOLI-LINE).
I did find a post from Thomas Jung stating that SOLI didn't impose a line break for each line (I can't find it again now due to SDN's poor search performance) but I believe this may have only been for attachments and not the mail body.
If HTM type is the only solution, I'm interested to hear about it, but I'd also like advice on how to best generate the correct HTML tags. I can include <BR> instead of CL_ABAP_CHAR_UTILITIES=>CR_LF but I'm not sure if this will be acceptable to all mail clients.
Many thanks (and points) for any help!
Mark
In response to initial response, I've edited the question.
Message was edited by:
Mark PycHello Mark,
Check this report.
* Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
* FORM
FORM ml_customize USING objname objdesc.
*----------- Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
*--------- Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
* FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
* FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
* FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
*--------- Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
* Header Data
* Already Done Thru FM
* Main Text
* Already Done Thru FM
* Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
* Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
* Receiver List
* Already done thru fm
ENDFORM. "ml_prepare
* FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
* CONTENTS_HEX = objhex
* OBJECT_PARA =
* object_parb =
receivers = reclist
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 ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
* FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
*-------------- Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
*------------- Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
* FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
*-------- Data
DATA : pos TYPE i.
DATA : len TYPE i.
*------------ Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
*------------- CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
* DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
* SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
* FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
EXTENSION = extension
NAME = name
* NAME_WITH_EXT =
* PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
Regards,
VAsanth -
Issue in sending a mail using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1'
HI Abappers,
I have contents of the attachmnet to be sent in an internal table. when i pass this table to the FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' , the text attachment shows a slant format. i mean all the contents of the attachment shift to right and has no proper alignment.
What can be done.? pLease help...Hi,
You must have skipped some data declaration part which causes this.
Please refer to the below mentioned code for reference:
REPORT zrat NO STANDARD PAGE HEADING.
*DATA DECLARATION
DATA : BEGIN OF wa_ccode,
bukrs TYPE t001-bukrs,
END OF wa_ccode.
DATA : itab_ccode LIKE TABLE OF wa_ccode.
DATA : BEGIN OF wa_emp,
pernr TYPE pa0001-pernr,
sachp TYPE pa0001-sachp,
sname TYPE pa0001-sname,
END OF wa_emp.
DATA : itab_emp LIKE TABLE OF wa_emp.
DATA : BEGIN OF wa_bdate,
nachn LIKE pa0002-nachn,
vorna LIKE pa0002-vorna,
pernr TYPE pa0002-pernr,
gbdat TYPE pa0002-gbdat,
END OF wa_bdate.
DATA : itab_bdate LIKE TABLE OF wa_bdate.
DATA : new_date LIKE sy-datum.
DATA : diff TYPE i.
DATA : years LIKE p0347-scryy,
months LIKE p0347-scrmm,
days LIKE p0347-scrdd.
DATA : sup_code LIKE pa0001-sachp,
itab_usrid LIKE t526-usrid,
sup_pernr LIKE pa0105-pernr.
DATA : BEGIN OF wa_email,
usrid_long LIKE pa0105-usrid_long,
END OF wa_email.
DATA : sup_email LIKE TABLE OF wa_email.
DATA : gwa_document_data LIKE sodocchgi1,
gc_name TYPE so_obj_nam VALUE 'RETIREMENT',
gc_senst TYPE so_obj_sns VALUE 'P',
gc_size TYPE so_doc_siz VALUE '510',
gi_obj_cnt LIKE TABLE OF solisti1 WITH HEADER LINE,
gi_recievers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
gwa_obj_cnt LIKE LINE OF gi_obj_cnt.
DATA : smtp_addr LIKE adr6-smtp_addr.
DATA : wa_date LIKE sy-datum,
entries LIKE sy-tabix,
name(15),
line1(18) TYPE c,
line2(20) TYPE c,
line3(20) TYPE c,
line4(23) TYPE c,
line5(10) TYPE c,
line6(45) type c,
date(2) TYPE c,
month(2) TYPE c,
year(4) TYPE c.
*START OF SELECTION
SELECT bukrs
FROM t001
INTO TABLE itab_ccode
WHERE land1 EQ 'GB'.
SORT itab_ccode.
DELETE ADJACENT DUPLICATES FROM itab_ccode.
SELECT pernr sachp sname
FROM pa0001
INTO TABLE itab_emp
FOR ALL ENTRIES IN itab_ccode
WHERE bukrs EQ itab_ccode-bukrs AND begda LE sy-datum AND
endda GE sy-datum and persg eq '1'.
SELECT nachn vorna pernr gbdat
FROM pa0002
INTO TABLE itab_bdate
FOR ALL ENTRIES IN itab_emp
WHERE pernr EQ itab_emp-pernr.
*TO CHECK EMPLOYEES WHOSE AGE IS NEAR 75 YEARS.
LOOP AT itab_bdate INTO wa_bdate.
new_date = wa_bdate-gbdat.
*TO CALCULATE THE AGE TILL DATE
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
EXPORTING
date1 = sy-datum
date2 = new_date
output_format = '05'
IMPORTING
years = years
months = months
days = days
IF sy-subrc <> 0.
ENDIF.
IF years EQ 64 AND months EQ 4.
IF days GE 23 AND days LE 31.
*FETCH THE DATA IF THE AGE IS NEARING 75 YEARS
SELECT SINGLE sachp FROM pa0001 INTO sup_code WHERE pernr EQ
wa_bdate-pernr AND begda LE sy-datum AND endda GE sy-datum.
SELECT SINGLE usrid FROM t526 INTO itab_usrid WHERE sachx EQ
sup_code.
SELECT SINGLE pernr FROM pa0105 INTO sup_pernr WHERE usrid EQ
itab_usrid AND subty EQ '0001'.
clear sup_email[].
SELECT usrid_long FROM pa0105 INTO TABLE sup_email WHERE pernr EQ
sup_pernr AND subty EQ '0010'.
*EMAIL ADDRESS OF THE SUPERVISOR TO BE NOTIFIED
CLEAR gi_obj_cnt.
CLEAR gi_recievers.
CLEAR gwa_document_data.
Loop at sup_email into wa_email.
write sy-uline+0(5).
write sy-uline+10(5).
write sy-uline+20(5).
write sy-uline+30(5).
write sy-uline+40(5).
write sy-uline+50(5).
write sy-uline+60(5).
write sy-uline+70(5).
smtp_addr = wa_email-usrid_long.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
Endloop.
smtp_addr = '[email protected]'.
gi_recievers-receiver = smtp_addr.
gi_recievers-rec_type = 'U'.
gi_recievers-com_type = 'INT'.
APPEND gi_recievers.
gwa_document_data-obj_name = gc_name.
gwa_document_data-obj_descr = 'RETIRE'.
gwa_document_data-sensitivty = gc_senst.
gwa_document_data-obj_langu = sy-langu.
*CONTENT OF THE EMAIL TO BE SENT
line1 = 'Please note that '.
line2 = wa_bdate-vorna.
line3 = wa_bdate-nachn.
line4 = ' will be 65 years on '.
line50(4) = wa_bdate-gbdat4(4).
date = line5+2(2).
month = line5+0(2).
year = wa_bdate-gbdat+0(4) + 65.
CONCATENATE date month year INTO line5 SEPARATED BY '.'.
line6 = '.Please complete the Retirement Procedure.'.
CONCATENATE line1 line2 line3 line4 line5 line6 INTO gwa_obj_cnt
SEPARATED BY space.
APPEND gwa_obj_cnt TO gi_obj_cnt.
CLEAR gwa_obj_cnt.
DESCRIBE TABLE gi_obj_cnt LINES entries.
READ TABLE gi_obj_cnt INDEX entries.
gwa_document_data-doc_size = ( entries - 1 ) * 255 + STRLEN( gi_obj_cnt
*FUNCTION MODULE TO SEND THE EMAIL TO THE CONCERNED PERSONS
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = gwa_document_data
document_type = 'RAW'
commit_work = 'X'
TABLES
object_content = gi_obj_cnt
receivers = gi_recievers
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
*MESSAGE TO BE DISPLAYED AFTER THE EXECUTION
endif.
CASE sy-subrc.
WHEN 0.
LOOP AT gi_recievers.
IF gi_recievers-receiver = space.
name = gi_recievers-rec_id.
ELSE.
name = gi_recievers-receiver.
ENDIF.
IF gi_recievers-retrn_code = 0.
WRITE: / name, ': succesfully sent'.
ELSE.
WRITE: / name, ': error occured'.
ENDIF.
ENDLOOP.
WHEN 1.
WRITE: / 'Too many receivers specified !'.
WHEN 2.
WRITE: / 'No receiver got the document !'.
WHEN 4.
WRITE: / 'Missing send authority !'.
WHEN OTHERS.
WRITE: / 'Unexpected error occurred !'.
ENDCASE.
ENDIF.
ENDIF.
ENDLOOP.
In case you have any further clarifications,do let me know.
Regards,
Puneet Jhari. -
Error 829 in SOST tcode while sending an email attachment ??
Hi..
I am using the function module "SO_NEW_DOCUMENT_ATT_SEND_API1" to send an email attachment.
The program is getting executed successfully but when i see in SOST transaction, i am getting an error message.
Error number is 829 and it says " Internal error: SO_OBJECT_MIME_GET Exception: 2 "...
How do i resolve this error ....??Hi,
Please check this links will help you.
Error in SOST transaction for Mail Triggered from SAP
Re: need help in implementing a note
Maybe you are looking for
-
How to check if a socket is still alive and not closed by the server?
If I create a socket connection in Java, then is there any way to test whether that socket conecction is alive at any point of time. You may assume that the socket connection is never closed from my side ie. the client's end, however it may be closed
-
Upgraded to Windows Vista computer and now my ipod won't show videos/pics
I recently bought a new computer. Around the same time my ipod broke and I got a brand new one. Everything works on it except the videos and I can't sync any pics. The videos will show up in my recently added list, with the little tv pic but if click
-
Convert 2320 MFP printer from 220v to 110v
I have some HP2320 mfp printers that were mistakenly ordered to operate on 220 volts. How can I convert them to operate on 110 volts? Is it only the power supply that must be changed to accomplish this? If so, I have some defective 2320s that I could
-
I didn't notice this before, but I have 2 site collections, one shows this when I go to Site Settings: $Resources:ReportServerResources,ReportServerSiteSettingsGroupTitle; $Resources:ReportServerResources,ScheduleList; $Resources:ReportServerResource
-
Material Determination when creating Sales Order referencing Contract
Hi Experts, Is ther any way to force material determination when creating a sales order with reference to a contract? When I create a sales order from scratch, the material determinations works fine, but when the sales order is created referencing a