Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Email for ITAB

Former Member
0 Kudos

Hi Guys,

This is Udjent.

I got one requirement .

that is sending the Itab data to mail.

how can i do that .

plz help onthis.

Thanks, rayeez

2 REPLIES 2

Former Member
0 Kudos

SumanPoddar
Active Participant
0 Kudos

This is a template for Sending Any ITAB as XLS attachment...

1. Data Declaration For Sending Mail

*******Code**********************************************************

*----Data for sending Mail

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.

*****Code***************************************************************

2. Sending Mail......[ For My prog it_rols[] was the ITAB ]

*****Code******************************************************************

check it_rols[] is not initial.

  • Creation of the document to be sent

  • File Name

doc_chng-obj_name = 'SENDFILE'.

  • Mail Subject

doc_chng-obj_descr = 'Materials below the safety stock level ... '.

  • Mail Contents

objtxt = 'Attachment below contain the details'.

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

CONSTANTS:

con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

CONCATENATE 'Mat Type' 'Mat Grp.' 'MAT NO' 'Mat desc' 'Stock' 'UOM'

'Safety Stk' 'Min Safety stk' 'Val Stk' 'Store Loc'

'Plant' 'Busi. Area'

INTO objbin SEPARATED BY con_tab.

CONCATENATE con_cret objbin INTO objbin.

APPEND objbin.

  • Making the attachment from internal table

LOOP AT it_rols INTO wa_rol.

l_mbw = wa_rol-mbwbest.

l_bas = wa_rol-basme.

l_eisb = wa_rol-eisbe.

l_eisl = wa_rol-eislo.

l_wbw = wa_rol-wbwbest.

CONCATENATE wa_rol-mtart

wa_rol-matkl

wa_rol-matnr

wa_rol-maktx

l_mbw

l_bas

l_eisb

l_eisl

l_wbw

wa_rol-lgort

wa_rol-werks

wa_rol-gsber

INTO objbin SEPARATED BY con_tab.

CONCATENATE con_cret objbin 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 = 'XLS'.

objpack-obj_name = 'WEBSITE'.

objpack-obj_descr = 'ORDERS.XLS'.

objpack-doc_size = tab_lines * 255.

APPEND objpack.

  • Completing the recipient list

  • target recipent

CLEAR reclist.

reclist-receiver = 'MMPURCHASE3'.

reclist-express = 'X'.

reclist-rec_type = 'B'.

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.

if sy-subrc eq 1.

.......

elseif .......

.....

endif.

*****Code******************************************************************

This was for sending into SAP Mail .... U can also send in any enternet mail address if SCOT is properly configured,talk with basis guy..then there will change in 'reclist' table [ then reclist-rec_type = 'A' ]......

I think it will help u.....................