Sending ALV output to the SAP Inbox.
Hi
I'm using SAP report <b>sendlist_bcs</b> for sending report output to the SAP inbox but attachment is not getting delivered.
Can anybody help to resolve the issue...
My report is:
*& Report ZTTEST_SAGAR
REPORT ZTTEST_SAGAR.
*& Report SENDLIST_BCS
*& Sample report from note 190669 for sending lists via SAPconnect
*& using the BCS interface
*& Note:
*& 1. Set a commit work statement after the sending
*& 2. Give binary data of type x not type c to send module, i.e.
*& use structure solix instead of soli and give it to tables
*& parameter contents_hex instead of contents_bin
*& Do this by filling contents_hex directly from the module
*& table_compress. In case of reading the data from spool, convert
*& to solix using so_solitab_to_solixtab
*& 3. Don't calculate document size. It is done internally
*report sendlist_bcs no standard page heading message-id so.
selection-screen begin of block mode with frame title text-001.
parameters: submit radiobutton group mode default 'X'.
parameters: write radiobutton group mode .
parameters: spool radiobutton group mode.
selection-screen end of block mode.
global data
data g_list_content type solix_tab.
data g_text_content type soli_tab.
data sysid(10) TYPE C.
*---- start-of-selection -
start-of-selection.
perform create_text_content changing g_text_content.
perform create_list_content changing g_list_content.
perform send using g_text_content
g_list_content.
a commit work has to be set somewhere after the sending!
commit work.
Form routines *
*& Form create_list_content
form create_list_content changing list_content type solix_tab.
1st possibility - use "submit <report> exporting list to memory"
if submit = 'X'.
perform use_submit changing list_content.
endif.
2nd possibility - create a new list within this report.
if write = 'X'.
perform write_a_list changing list_content.
endif.
3rd possibility - get list from spool
if spool = 'X'.
perform get_list_from_spool changing list_content.
endif.
endform. "create_list_content
*& Form create_text_content
form create_text_content changing text_content type soli_tab.
append 'This is the first line' to text_content. "#EC NOTEXT
append 'This is the second line' to text_content. "#EC NOTEXT
convert the content from RAW to TXT
call function 'SO_RAW_TO_RTF'
tables
objcont_old = text_content
objcont_new = text_content
exceptions
others = 0.
endform. "create_text_content
*& Form SEND
form send using text_content type soli_tab
list_content type solix_tab.
data send_request type ref to cl_bcs.
data text type bcsy_text.
data document type ref to cl_document_bcs.
data recipient type ref to if_recipient_bcs.
data bcs_exception type ref to cx_bcs.
data sent_to_all type os_boolean.
try.
create the send request
send_request = cl_bcs=>create_persistent( ).
create the document with attachments
main document
append 'Hi,' to text.
append 'attached you will find the list.' to text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_subject = 'ABAPlist' ).
add text attachment to document
document->add_attachment( i_attachment_type = 'TXT'
i_attachment_subject = text-002
i_att_content_text = text_content ).
add list attachment to document
document->add_attachment( i_attachment_type = 'ALI'
i_attachment_subject = text-003
i_att_content_hex = list_content ).
add document to send request
send_request->set_document( document ).
sysid = sy-sysid.
data : uname type ad_uname.
uname = 'USTZZSKAZI'.
create recipient and add to send request
recipient = cl_cam_address_bcs=>CREATE_RML_ADDRESS( i_syst = sysid
i_client = sy-mandt
i_username = uname ).
send_request->add_recipient( i_recipient = recipient ).
send
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
if sent_to_all = 'X'.
message s022.
endif.
catch cx_bcs into bcs_exception.
message e865 with bcs_exception->error_type.
endtry.
endform. "send
*& Form USE_SUBMIT
form use_submit changing contents_hex type solix_tab.
data listobject type table of abaplist.
get the list object by calling the list in another report
F1 on submit gives more information
submit balvsd03 exporting list to memory and return.
import the list from memory and store it in table listobject
call function 'LIST_FROM_MEMORY'
tables
listobject = listobject
exceptions
not_found = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'LIST_FROM_MEMORY'.
endif.
free memory
call function 'LIST_FREE_MEMORY'
tables
listobject = listobject
exceptions
others = 1.
if sy-subrc <> 0.
message e105 with 'LIST_FREE_MEMORY'.
endif.
it's always necessary to compress the table.
SAPconnect will decompress it
call function 'TABLE_COMPRESS' "#EC *
tables
in = listobject
out = contents_hex
exceptions
compress_error = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'TABLE_COMPRESS'.
endif.
endform. " USE_SUBMIT
*& Form WRITE_A_LIST
form write_a_list changing contents_hex type solix_tab.
data listobject type table of abaplist.
perform write_list.
Save the list and store table listobject
call function 'SAVE_LIST'
exporting
list_index = sy-lsind
tables
listobject = listobject
exceptions
list_index_invalid = 1.
if sy-subrc = 1.
message e105 with 'SAVE_LIST'.
endif.
It's always necessary to compress the table
SAPconnect will decompress it
call function 'TABLE_COMPRESS' "#EC *
tables
in = listobject
out = contents_hex
exceptions
compress_error = 1
others = 2.
if sy-subrc <> 0.
message e105 with 'TABLE_COMPRESS'.
endif.
endform. " WRITE_A_LIST
*& Form GET_LIST_FROM_SPOOL
form get_list_from_spool changing contents_hex type solix_tab.
data spool_number type rspoid.
data contents_bin type soli_tab.
data print_parameters type pri_params.
data valid type c.
write a list into spool
call function 'GET_PRINT_PARAMETERS'
importing
out_parameters = print_parameters
valid = valid
exceptions
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
others = 4.
if sy-subrc <> 0.
message e105 with 'GET_PRINT_PARAMETERS'.
elseif valid is initial.
return.
endif.
new-page print on parameters print_parameters no dialog.
perform write_list.
new-page print off.
spool_number = sy-spono.
you can also send OTF documents from spool with this function
module. The importing parameter real_type gives you the doc type
that you have to give to the send interface. The parameter is not
used here
call function 'RSPO_RETURN_SPOOLJOB'
exporting
rqident = spool_number
tables
buffer = contents_bin
exceptions
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
others = 8.
if sy-subrc <> 0.
message e105 with 'RSPO_RETURN_SPOOLJOB'.
endif.
convert to hex table
call function 'SO_SOLITAB_TO_SOLIXTAB'
exporting
ip_solitab = contents_bin
importing
ep_solixtab = contents_hex.
endform. " GET_LIST_FROM_SPOOL
*& Form WRITE_LIST
form write_list.
data lt_scarr type table of scarr.
data carr type scarr.
select * from scarr into table lt_scarr.
format color = 1.
uline at /1(46).
write: / sy-vline,
'CARRID', 10 sy-vline,
'CARRNAME', 35 sy-vline,
'CURRCODE', 46 sy-vline.
format color = 2.
uline at /1(46).
loop at lt_scarr into carr.
write: / sy-vline,
carr-carrid, 10 sy-vline,
carr-carrname, 35 sy-vline,
carr-currcode, 46 sy-vline.
endloop.
uline at /1(46).
new-line.
endform. " WRITE_LIST
Thanks,
sagar
hi Sagar
'SO_NEW_DOCUMENT_ATT_SEND_API1' function module for that.
Example::::
Data Declaration
data pdf like tline occurs 0.
data : objbin like solisti1 occurs 0 with header line.
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 type table of SOMLRECI1 with header line.
Data: listobject like abaplist occurs 1 with header line.
data : objhex2 like objhex occurs 0 with header line.
Data: tab_lines type i,
doc_size type i,
att_type like SOODK-OBJTP.
data: ls_drao like drao occurs 0,
i_data like drao-orblk occurs 0,
ls_doc_file like dms_doc_file,
ls_draw like draw.
data: begin of i_data occurs 0,
orbkl like drao-orbkl,
orblk like drao-orblk,
end of i_data.
data: w_data like i_data,
w_data2 type drao-orbkl,
wa_drao type drao.
DATA: t_error(1) type c.
DATA: t_return like BAPIRET2.
*ls_draw-mandt = '200'.
ls_draw-dokar = 'GPO'.
ls_draw-doknr = 'Z10'.
ls_draw-dokvr = '00'.
ls_draw-doktl = '000'.
ls_draw-dttrg = 'SAP-SYSTEM'.
ls_draw-dAPPL = 'DOC'.
ls_doc_file-fileno = '1'.
ls_doc_file-dttrg = 'SAP-SYSTEM'.
*Debug the cv03n transaction to see how the FMs are used
CALL FUNCTION 'CV120_DOC_CHECKOUT_TO_TABLE'
EXPORTING
PS_COUT_DEF =
ps_doc_file = ls_doc_file
ps_draw = LS_DRAW
tables
PT_DRAZ =
ptx_content = ls_drao
PTX_DRAOZ =
EXCEPTIONS
ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at ls_drao into wa_drao.
move: wa_drao-orblk to w_data-orblk.
append w_data to i_data.
endloop.
OBJPACK-HEAD_START = 1.
DESCRIBE TABLE i_data LINES TAB_LINES.
CALL FUNCTION 'ZOUTPUT_X_TABLESIZE_CHG'
EXPORTING
IV_APPEND = ' '
IV_BYTE_MODE = 'X'
IV_STRING =
IV_XSTRING =
IMPORTING
EV_SIZE =
EV_LINES =
EV_STRING =
EV_XSTRING =
TABLES
IT_DATA = i_data
ET_DATA = objhex
EXCEPTIONS
NOENTRIES = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
loop at objhex.
move-corresponding objhex to objhex2.
append objhex2.
endloop.
docdata-obj_name = 'TEST_ALI'.
docdata-obj_descr = 'Test including ALI/HTML Attachment'.
Main Text
objtxt = 'Test Document.'.
append objtxt.
objtxt = 'You will find an ALI/HTML attachment '.
append objtxt.
objtxt = 'Have a nice day.'.
append objtxt.
Write Packing List (Main)
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.
Create Message Attachment
Write Packing List (Attachment)
att_type = 'PDF'.
describe table objhex lines tab_lines.
read table objhex index tab_lines.
objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
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 = 'ATTACHMENT1'.
objpack-obj_descr = 'Attached Document1'.
append objpack.
Second attachment
loop at objhex.
move-corresponding objhex to objhex2.
append objhex2.
endloop.
*att_type = 'DOC'.
*describe table objhex lines tab_lines.
*read table objhex index tab_lines.
*objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
*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 = 'ATTACHMENT2'.
*objpack-obj_descr = 'Attached Document2'.
*append objpack.
Third attachment
*loop at objhex.
move-corresponding objhex to objhex2.
append objhex2.
*endloop.
*att_type = 'PDF'.
*describe table objhex lines tab_lines.
*read table objhex index tab_lines.
*objpack-doc_size = ( tab_lines ) * 255 ."+ strlen( i_data ).
*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 = 'ATTACHMENT3'.
*objpack-obj_descr = 'Attached Document3'.
*append objpack.
Create receiver list
data: reclist1 type sadrfd .
reclist1-rec_fax = '650-467-2890'.
reclist1-REC_STATE = 'US'.
append reclist1.
*read table reclist1 index 1.
move reclist1(30) to reclist-receiver(30).
move reclist1346(3) to reclist-receiver346(3).
*reclist-receiver = reclist1."'US16503457900'.
*move reclist1-rec_fax to reclist-receiver.
*reclist-receiver = 'US16502796630'. "'+1 (16502796999)'.
reclist-REC_type = 'F'.
*reclist-country = 'US'.
*reclist-COM_TYPE = 'TELFAX'.
*reclist-fax = 'US1650-279-6630'.
append reclist.
*reclist-receiver = sy-uname. "<-- change internal user
*reclist-rec_type = 'B'.
*append reclist.
Send Message
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.
**Please reward suitable points***
With Regards
Navin Khedikar
Similar Messages
-
Send ALV output to SAP user unbox..
Hi Friends..
I want to send the ALV output to the SAP users inbox.
So plz anyone give the sample code for that..
With regards
GowrishankarHi
Check this sample report
*& Report ZTESTMAIL *
REPORT ZTESTMAIL .
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.
t_object_header = 'Text.xls'. append t_object_header.
*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
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.
*& 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
*PARAMETERS: psubject(40) type c default 'Testing',
*p_email(40) type c default '[email protected]'. "use ur email id
*data: it_packing_list like sopcklsti1 occurs 0 with header line,
*it_contents like solisti1 occurs 0 with header line,
*it_receivers like somlreci1 occurs 0 with header line,
*it_attachment like solisti1 occurs 0 with header line,
*gd_cnt type i,
*gd_sent_all(1) type c,
*gd_doc_data like sodocchgi1,
*gd_error type sy-subrc.
*data: it_message type standard table of SOLISTI1 initial size 0
*with header line.
**START-OF-SELECTION.
*START-OF-SELECTION.
*Perform populate_message_table.
**Send email message, although is not sent from SAP until mail send
**program has been executed(rsconn01)
*PERFORM send_email_message.
**Instructs mail send program for SAPCONNECT to send email(rsconn01)
*perform initiate_mail_execute_program.
**& Form POPULATE_MESSAGE_TABLE
** Adds text to email text table
*form populate_message_table.
*Append 'Line1' to it_message.
*Append 'Line2' to it_message.
*Append 'Line3' to it_message.
*Append 'Test- 1' to it_message.
*endform. " POPULATE_MESSAGE_TABLE
**& Form SEND_EMAIL_MESSAGE
** Send email message
*form send_email_message.
** Fill the document data.
*gd_doc_data-doc_size = 1.
** DATA: TAB_LINES LIKE sy-tabix.
** DESCRIBE TABLE it_message LINES TAB_LINES.
** READ TABLE it_message INDEX TAB_LINES.
** gd_doc_data-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( it_message )
** Populate the subject/generic message attributes
*gd_doc_data-obj_langu = sy-langu.
*gd_doc_data-obj_name = 'SAPRPT'.
*gd_doc_data-obj_descr = psubject.
*gd_doc_data-sensitivty = 'F'.
** Describe the body of the message
** Information about structure of data tables
*clear it_packing_list.
*refresh it_packing_list.
*it_packing_list-transf_bin = space.
*it_packing_list-head_start = 1.
*it_packing_list-head_num = 0.
*it_packing_list-body_start = 1.
*describe table it_message lines it_packing_list-body_num.
*it_packing_list-doc_type = 'RAW'.
*append it_packing_list.
** Add the recipients email address
*clear it_receivers.
*refresh it_receivers.
*it_receivers-receiver = p_email.
*it_receivers-rec_type = 'U'.
** it_receivers-com_type = 'INT'.
** it_receivers-notif_del = 'X'.
** it_receivers-notif_ndel = 'X'.
*append it_receivers.
** Call the FM to post the message to SAPMAIL
*call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'
*exporting
*document_data = gd_doc_data
*put_in_outbox = 'X'
*importing
*sent_to_all = gd_sent_all
*tables
*packing_list = it_packing_list
*contents_txt = it_message
*receivers = it_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.
** Store function module return code
*gd_error = sy-subrc.
** Get it_receivers return code
*loop at it_receivers.
*endloop.
*endform. " SEND_EMAIL_MESSAGE
**& 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
Check this link
ALV Output in PDF format
Re: Send ALV Grid output as PDF attachment to external mail id?
Reward all helpfull answers
Regards
Pavan
Message was edited by:
Pavan praveen -
How to send ALV output data into Excel sheet format via Mail to the user?
Hi friends,
I have a doubt ie,
How to send ALV output data into Excel sheet format via Mail to the user?
regards
MoosaHi,
Provide the output internal table to the objbin in the below FM
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = i_docdata
put_in_outbox = c_x
TABLES
packing_list = i_objpack
object_header = i_objhead
contents_bin = i_objbin
contents_txt = i_objtxt
receivers = i_reclist
and specify the document type
i_objpack-doc_type = 'XLS'.
and try.
Regards,
Nandha -
SAP Inbox: Send Transaction code link to the SAP Inbox
Hi,
I have a requirement, which is as follows.
I need mail to be sent to the SAP Inbox every morning.
In the body, there should be a link. When the user double-click's on the link, a transaction code should be executed in the background, thus bringing the user to the screen showing a report.
Is this possible and if so, how can it be done?
All help will be rewarded and greatly appreciated.
Thank You,
JohnWhat he want to Say is that this request can easily be done with the help of a workflow, so you need to consult your workflow consultant.
Check this link to know more -
http://web.mit.edu/sapr3/docs/webdocs/purchpay/ppAPRnotify.html#inbox
For without workflow check this -
workflow sending notification to sap inbox.
Regards,
Amit -
How to put the alv output into the spool request?
Hi guys,
How to put the alv output into the spool request?
Thanks!Hi
Sending an ALV List screen output to SPOOL
Convert ALV list to PDF and send mails to respective persons
Regards
Pavan -
Execute workitem outside the SAP Inbox.
Hi Friends,
Please answer my querries if you can -
When any work item comes to the SAP Inbox, usually the requirement revolves around 2 things -
(1) How to send notification of the Workitem to the agent once work item appears in his inbox.
But my question is can i send notification to external mail id like YAHOO, GMAIL,REDIFFMAIL etc. by maintaining the agent's mailid in SU01 and scheduling the RSWUWFML2 report ?
(2) How to execute the work item in outlook
We can send the sap link for the work item to the outlook and when the user clicks on the link it is directed to sap inbox and then he can take the action.
But My question is How the agent can take decision in the oulook itself ? I mean just like sap inbox he can approve and reject in outlook itself. The agent doesnot have to go to the SAP business workplace for this purpose.
(3) How the point2 functionality can be achieved for external mail (GMAIL, YAHOO etc.) as well
Regards,
DebiHi Rick,
Thanks a lot.
You mean to say -
(1) Just like RSWUWFML2 we can also send notification to outlook and any other email (like GMAIL etc.) throgh Extended notification. Right ?
(2) Outlook supports the button (approve/reject), so we can integrate that with the SAP Inbox using Duet (as suggested in my previous forum). That means, the agent will take an action from outlook itself and the same will be communicated to SAP. Right? If yes, then please mention the procedure how to integate the outlook with SAP.
(3) Since GMAIL etc. does not support this button(approve/reject), so we just cant do anything for the requirement -> Agent will take an action (approve / reject) in GMAIL and the same will be communicated to sap InBox.
My requirement is that my client wants to take action from external mail id. Is this possible ? If not then atleast can we do the same in outlook.
Regards,
Debi -
How To Send ALV Output By Email.
Hi !
I wanted to ask how to send ALV output of report by email.
I know that i have to use the fms :
1. 'WWW_HTML_FROM_LISTOBJECT' - in order to convert the table to HTML.
2. 'SO_NEW_DOCUMENT_ATT_SEND_API1' - in order to send the HTML file.
My problem is how to convert the ALV screen output to the apropriate table parameter of the function 'WWW_HTML_FROM_LISTOBJECT' to listobject type ?
thanks
mosheHi look at the following program.
*& Report ZSM17_EMAIL1
REPORT zsm17_email.
tables : mara.
data: begin of it_mara occurs 0,
matnr like mara-matnr,
ernam like mara-ernam,
mtart like mara-mtart,
matkl like mara-matkl,
end of it_mara.
data: begin of it_final occurs 0,
v_string(255),
end of it_final.
*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,
reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: objpack LIKE sopcklsti1 OCCURS 0 with header line,
objhead LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE.
data: wa_objbin like line of objbin.
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix.
select-options s_matnr for mara-matnr.
*--- Selecting data from mara
select matnr
ernam
mtart
matkl
into table it_mara
from mara
where matnr in s_matnr.
if sy-subrc ne 0.
write:/ 'no data found'.
exit.
else.
loop at it_mara.
concatenate it_mara-matnr
it_mara-ernam
it_mara-mtart
it_mara-matkl
into it_final-v_string separated by '~'.
append it_final.
clear it_final.
endloop.
endif.
Creating the document to be sent
doc_chng-obj_name = 'TEST'. "name of the document
title of document or subject
doc_chng-obj_descr = 'Test Email program'.
body of the mail
objtxt = 'A test report'.
APPEND objtxt.
objtxt = 'is enclosed as an attachment.'.
APPEND objtxt.
*clear objtxt.
DESCRIBE TABLE objtxt LINES tab_lines.
Size of SAPoffice Document (for API1)
doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
Creating the entry for the compressed attachment
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'RAW'.
*objpack-obj_name = 'ATTACHMENT'.
*objpack-obj_descr = 'Test Email Program'.
*objpack-doc_size = tab_lines * 255.
APPEND objpack..
*--- Populating the records in the attachment
data: w_str(255) TYPE c.
loop at it_final into wa_objbin.
append wa_objbin to objbin.
append objbin.
clear wa_objbin.
endloop.
DESCRIBE TABLE objbin LINES tab_lines.
tab_lines = tab_lines + 1.
objhead = 'test_report.txt'.
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 = 'txt'.
objpack-obj_name = 'txt'.
objpack-obj_descr = 'Test Email Program'.
objpack-doc_size = tab_lines * 255.
APPEND objpack..
*write:/ 'object text', objtxt.
Entering names in the distribution list
reclist-receiver = '[email protected]'.
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 = '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.
CASE sy-subrc.
WHEN 0.
WRITE: / 'Result of the send process:'.
LOOP AT reclist.
WRITE: reclist-receiver(48), ':'.
IF reclist-retrn_code = 0.
WRITE 'sent successfully'.
ELSE.
WRITE 'not sent'.
ENDIF.
ENDLOOP.
loop at objbin.
write: objbin-line.
endloop.
WHEN 1.
WRITE: / 'no authorization to send to the specified number of' .
"'recipients!'.
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. -
Is the SAP Inbox and the universal worklist on the portal linked ?
Hi,
I am using the FM SO_DOCUMENT_SEND_API1 to send emails to SAP inbox. This successfully sends emails. My question is whether these mails that I send to the SAP inbox will be seen at the universal worklist on the portal also.
Thanks,
MukulIf Universal Worklist is connected with your SAP inbox, then yes, you can see the work items in universal worklist also.
For more Details, Check out this:
http://www.sap-hefte.de/download/dateien/1461/146_leseprobe.pdf -
What are the SAP inbox tables.
Hi Team
i want to know what are the SAP inbox tables.
if i have click on SAP inbox for perticular user, retrived 37000 entries and give short dump "Time Out" . i want to know from which table retrived the records and display into the SAP inbox(SBWP).
Thanks in advance.
Puneet.Look at SAPoffice tables and Business Workplace tables : SOOD, SOOS, SOC3, SOFFCONT1, BCST_SR, BCST_CAM
Regards,
Raymond -
Is there any way to make work item invisible in the SAP inbox?
Is there any way to make work item invisible in the SAP inbox?
If yes , How?
How can we delete a work item without using SAPLSINWP program?Is it possible???Thanks suresh, But I was a looking for a solution where as soon as the work item is created should be made invisible in the SAP inbox, is there any way for this or any other alternative?
-
FM to access the SAP inbox calender
Hi All,
Can anyone tell me the FM in CRM to access the SAP Inbox calender details?I think CRM forum would be right place to post this question since it is related to cRM.
-
Send ALV output as attachment (exceeding 255 columns) to Inbox or email
Hello,
My requirement is to send the ALV output as attachment (csv or xls) to either Office Inbox or external email. The trick is the ALV output is way more than the 255 columns (about 2000).
I have read a number of threads on this matter. It seems that it is either SO_NEW_DOCUMENT_ATT_SEND_API1 or class BCS (cl_document_bcs=>create_document) but both has restriction on the line size (max 255 chars) (please correct me if I am wrong).
Could anyone suggest other approaches? Your input is much appreciated.
Regards
CalvinHi,
Comapare with your code,
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.
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.
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. -
ALV: Send ALV output as mail - background processing
Hi all,
I'm a newbie in SDC and try to implement the following functionality (Version 4.0B):
A ABAP report (to be scheduled as e.g. a daily job run) with ALV output should send an automated email containing the ALV informations to a receiver specified in the selection criterias.
I already have the following pieces:
1) The report with ALV output (running online and clicking on List/send/office works perfectly, the alv-output is attached to the mail). The report runs also in background and generates a spool.
2) A subroutine wich sends a email (input has to be in an itab)
Now I try to put them together.
Question: How can I automate the send process?
I did a little bit of debugging, but got lost in the SAP Office functions.
Any help appreciated!
ThomasHi Michael,
thank you again a helpfull reply. To solve the issue I ended up writing a second little report.
Here is a short description of my solution just in case anybody else is also interested in.
I set up a Job with two steps.
Step 1 is the ABAP that creates e.g. a ALV output (anything that goes to spool).
Step 2 is a little ABAP that does nothing else than reading the output of step 1 (Spool) and send it as SAP Office Document. (To be a little more flexible I added some selection criterias for step 2 like Jobstep number, receiver, sendmode, ...).
It works fine online (by keying in the spool number manually) and in batch mode (by determining the spool number based on the job number). I think this solution is flexible and lightwight.
Kind regards,
Thomas
Message was edited by: Thomas Hager
Message was edited by: Thomas Hager -
How to generate a mail into the SAP Inbox
Hi everyone,
I have an MM Workflow that is starting correctly and a mail is supposed to be generated in the user Inbox in SAP after the completion of a material enhancement but it does not. The Workflow was copied from another system and it was working fine.
I tried to see any event (step) that is sending a mail in the Workflow and I found only 1 but it seem correctly configured from what I can see. I am not even sure this is the right event that I am looking at.
Does anyone have an idea of what I should look for and how I could manage to see why no mail is generated?
I am still a beginner in Workflow so try to give me as much detail as possible.
Thank you in advance for your answers.
Best regards,
SylvainHi Sylvain,
The issue could be at many places.
Check the workflow step that needs to send the mail to the desired user.
Check if the agent who needs to recieve the mail is pesent in the current system. If the user is not hard-coded, check how the user is getting fetched in the step. If it is through rules, etc you need to debug the same.
Also check the authorizations of the user in SU01. Check the agent assignment for the task as well.
You can find much information in the workflow log to start with the debugging.
Hope this helps!
Regards,
Saumya -
Mail sending - how to restrict from SAP inbox,
I am passing my internal table gt_message in the below FM code .
It is working fine.
1). HOWEVER I AM GETTING MAIL TO MY SAP INBOX.
*My functional consultant don't want this.*
How can I send only to mail id with out saving SAP mail.
2).
I am not able to send mails to other mails ids other than our outlook. We need to send mail to our customer.
How to do this . Please help / or just below coding is sufficient to send mail to external mailis like our customers ?
FORM send_email_message.
wa_doc_data-doc_size = 1.
wa_doc_data-obj_langu = sy-langu.
wa_doc_data-obj_name = 'SAPRPT'.
wa_doc_data-obj_descr = text-017. " 'Results of EDI 869 and 870'. " psubject.
wa_doc_data-sensitivty = 'F'.
CLEAR wa_packing_list.
REFRESH gt_packing_list.
wa_packing_list-transf_bin = space.
wa_packing_list-head_start = 1.
wa_packing_list-head_num = 0.
wa_packing_list-body_start = 1.
DESCRIBE TABLE gt_message LINES wa_packing_list-body_num.
wa_packing_list-doc_type = 'RAW'.
APPEND wa_packing_list TO gt_packing_list.
wa_receivers-receiver = 'mahesh.bagel at the rate cadi.com'.
wa_receivers-rec_type = 'U'.
wa_receivers-express = ' '.
wa_receivers-com_type = 'INT'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers TO gt_receivers.
CLEAR wa_receivers.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = 'X'
IMPORTING
sent_to_all = v_sent_all
TABLES
packing_list = gt_packing_list
contents_txt = gt_message
receivers = gt_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.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
v_error = sy-subrc.
LOOP AT gt_receivers INTO wa_receivers.
ENDLOOP.
ENDFORM. " SEND_EMAIL_MESSAGE
Edited by: Sam Kumar on Oct 9, 2008 9:40 PMIn your call don't pass put_in_outbox = 'X'.
Don't pass the Transmission Medium in the Receiver
Like:
wa_receivers-receiver = 'mahesh.bagel at the rate cadi.com'.
wa_receivers-rec_type = 'U'.
wa_receivers-notif_del = 'X'.
wa_receivers-notif_ndel = 'X'.
APPEND wa_receivers TO gt_receivers.
CLEAR wa_receivers.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = space " <<
IMPORTING
sent_to_all = v_sent_all
TABLES
packing_list = gt_packing_list
contents_txt = gt_message
receivers = gt_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.
IF sy-subrc EQ 0.
COMMIT WORK.
ENDIF.
Regards,
Naimesh Patel
Edited by: Naimesh Patel on Oct 9, 2008 4:54 PM
Maybe you are looking for
-
When i try to update my itunes an error message tells me 'the path cannot be found' and 'you dont have access to this location' any help?
-
Field Dominance inconsistent after Advanced Pulldown capture
Following up on my immediately previous post (regarding the interview footage I captured from my dvx 100A using advanced pulldown setting in FCP5) I notice that, according to my FCP5 browser, some of my captured 23.xx clips show a Field Dominance of
-
Customizing af:query component?
Hello friends, Is it possible to customize af:query component. For example i need to move "search", "reset","save" buttons to the toolbar of the component and change the background of the toolbar. Also i have a request to hide that "+/-" thing which
-
Commercial Invoice Number in MIGO (GRN) Document - Link
Hi All, I wish to understand - what/where/how is SAP establishing the link between the Custom/Commercial Invoice posted via MIRO to Goods Receipts (MIGO). I am also interested to know whether this link is at all updated in SAP somewhere?? This should
-
ok hi! Im new here, and I need some help. I am currently building an amplifier out of the parts of an old creative SBS 4.1 . I have found the datasheet for the philips TDA a85j ic, and have dowloaded a schematic for it so I can build an amp with it.