2007 Jun 28 11:32 AM
Hi
actually i want to send a mail with the following message through SAP server. Which was populated in
it_message. and now i want to print the document number also along with this statement in the same message. when i was trying to send both the document number and the message the message is displaying fine but when i put an loop its not reading the data in the internal table
read table int_bseg .
loop at int_bseg.
it_message = int_bseg-belnr.
* it_message = 'Assignment Date is coming After 2 Days'.
append it_message.
endloop.
regards
Pavan
Hi
actually i want to send a mail with the following message through SAP server. Which was populated in
it_message. and now i want to print the document number also along with this statement in the same message. when i was trying to send both the document number and the message the message is displaying fine but when i put an loop its not reading the data in the internal table
read table int_bseg .
loop at int_bseg.
it_message = int_bseg-belnr.
* it_message = 'Assignment Date is coming After 2 Days'.
append it_message.
endloop.
regards
Pavan
2007 Jun 28 11:35 AM
Hi
Change your stmnt to:
loop at int_bseg.
it_message = int_bseg-belnr.
<b>
concatenate it_message 'Assignment Date is coming After 2 Days' into it_message separated by space.
</b>
append it_message.
clear it_message.
endloop.
2007 Jun 28 11:50 AM
Hi Rajsekhar
I had tried already like that but its of no use. When ever i put a loop over there its not going into the loop
Regards
Pavan
2007 Jun 28 11:58 AM
Hi
Let me get a clear picture.
Do you want a seperate message for each belnr?
Hey, i got it...now! You need to use some field of it_message <b>instead of it_message.</b>
eg: it_message-mesg
Hoping that int_bseg is a internal table with some records.
<b>It will be helpful if you can paste your code.</b> To suggest a solution.
Regards
Raj
Message was edited by:
Rajasekhar Dinavahi
2007 Jun 28 12:08 PM
Hi Raj
Here i'm posting you my entire code in which i want to send an mail to a particular user two days before. for this i have created this here everything is going fine.
*&---------------------------------------------------------------------*
*& Report ZTESTMAIL *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZMATURITY .
tables: bseg.
*parameters: p_email type somlreci1-receiver default
*'[email protected]'.
Data: p_email(25) type c value '[email protected]'.
data: it_message type standard table of solisti1 initial size 0
with header line.
data: it_message1 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: text(90).
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.
data: lv_date type sy-datum.
data: lv_formatdate(10) type c.
data: var1(4) type c,
var2(2) type c,
var3(2) type c.
data: begin of int_bseg occurs 0,
BELNR LIKE BSEG-BELNR,
ZUONR LIKE BSEG-ZUONR,
end of int_bseg.
data: begin of int_send occurs 0,
BELNR LIKE BSEG-BELNR,
ZUONR LIKE BSEG-ZUONR,
end of int_send.
data: 2days_out type sy-datum.
2days_out = sy-datum + 2.
lv_date = 2days_out.
var1 = lv_date+(4).
var2 = lv_date+4(2).
var3 = lv_date+6(2).
concatenate var3 var2 var1 into lv_formatdate separated by '.'.
select zuonr belnr from bseg into
corresponding fields of int_bseg
where bukrs = 'GSEG' and
ZUONR = lv_formatdate.
endselect.
*read int_bseg.
*if int_bseg-zuonr is not initial.
* loop at int_bseg.
*
* int_bseg = int_send-belnr.
* int_bseg = int_send-zuonr.
*
* endloop.
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
'Assignment Date after 2 days'
'XLS'
'filename'
' '
' '
' '
changing gd_error
gd_reciever.
* Instructs mail send program for SAPCONNECT to send email(rsconn01)
perform initiate_mail_execute_program.
*endif.
end-of-selection.
*&---------------------------------------------------------------------
*
*& 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.
* 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
object_header = t_object_header
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. "send_file_as_email_attachment
*&---------------------------------------------------------------------
*
*& Form INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------
*
* Instructs mail send program for SAPCONNECT to send email.
*----------------------------------------------------------------------
*
form initiate_mail_execute_program.
wait up to 2 seconds.
if gd_error eq 0.
submit rsconn01 with mode = 'INT'
with output = 'X'
and return.
endif.
endform. " INITIATE_MAIL_EXECUTE_PROGRAM
*&---------------------------------------------------------------------
*
*& Form POPULATE_EMAIL_MESSAGE_BODY
*&---------------------------------------------------------------------
*
* Populate message body text
*----------------------------------------------------------------------
*
form populate_email_message_body.
refresh it_message.
* refresh it_message1.
read table int_bseg .<u><b>at this particular instant when i put a loop int_bseg internal table it should check number of documents related to send a mail on that particular day
but whenever i put a loop over here that statement is not executed instead it was directly going to endperform. I want to send a mail with both that message and related document number </b></u>
* loop at int_bseg.
it_message1 = int_bseg-belnr.
* it_message = 'Assignment Date is coming After 2 Days'.
concatenate it_message1 'Assignment Date is coming After 2 Days' into
text separated by space.
append it_message1.
clear it_message1.
* endloop.
endform. " POPULATE_EMAIL_MESSAGE_BODYRegards
Pavan
Message was edited by:
Pavan praveen
2007 Jun 28 12:39 PM
If i'm not putting a loop condition there then it is fetching only last line item but i want to loop the condition for all documents having a due date on that particular day
Regards
Pavan
2007 Jun 28 12:52 PM
Hi,
it seems there is no data in internal table. chek it once and try again.
if data is not there then it will not loop. again u r giving read table itab stmt use INDEX 1 keyword with that, to read first line.
Jogdand M B
2007 Jun 28 1:03 PM
HI
there is data is internal table and the last line item of the data is also coming in my mail but i want all the document numbers to come in the msg
Regards
Pavan
2007 Jun 28 12:43 PM
Hi,
While assigning the value ur not assigning to the field in the internal table.
use the following
loop at int_bseg.
it_message-belnr = int_bseg-belnr.
it_message-message = 'Assignment Date is coming After 2 Days'.
append it_message.
endloop.
Rewrd if helpful.
Regards,
Umasankar.
2007 Jun 28 12:50 PM
Hi Uma sankar
here it_message is meant only for display of message so i havnt declared any table or any fields for this internal table. So any other alternative plz
Regards
Pavan
2008 Jan 15 4:27 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |