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 Excel attachment with a BOLD row

Former Member
0 Kudos

hi!

My requirement is that data in an internal table should be sent as an attachment in an email. There are a few records in the internal table which needs to be in bold(i have the logic to figure out whichones). I am using the below FM .

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = wa_object_hd

object_type = 'RAW'

TABLES

objcont = i_text

receivers = i_recv

packing_list = i_packing_list

att_cont = i_att

Does any body have any idea how to bold a few records in the excel attachment?

I appreciate your suggestions.

Thanks,

manasa

Message was edited by:

manasa

2 REPLIES 2

Former Member
0 Kudos

Hi Manasa,

The Code below is for sending Excel attachment in email. Not sure for BOLD...

You can copy and paste the following codes and execute..

Hope this will help you..

TYPE-POOLS: truxs.

DATA t5 LIKE t005t OCCURS 0 WITH HEADER LINE.

START-OF-SELECTION.

SELECT * INTO TABLE t5

FROM t005t

WHERE spras = sy-langu.

DATA wa_data TYPE truxs_t_text_data.

CALL FUNCTION 'SAP_CONVERT_TO_TXT_FORMAT'

EXPORTING

i_line_header = 'X'

TABLES

i_tab_sap_data = t5

CHANGING

i_tab_converted_data = wa_data

EXCEPTIONS

conversion_failed = 1

OTHERS = 2.

DATA stmp(4096) TYPE c.

DATA itmp TYPE i.

LOOP AT wa_data INTO stmp.

itmp = STRLEN( stmp ).

stmp+itmp = cl_abap_char_utilities=>cr_lf.

MODIFY wa_data FROM stmp.

ENDLOOP.

PERFORM send_email.

&----


*& Form send_email

&----


FORM send_email .

DATA docs LIKE docs OCCURS 0 WITH HEADER LINE.

DATA excelsize TYPE i.

DATA excel LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA doc LIKE sodocchgi1.

DATA excelln TYPE i.

DATA int_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.

DATA int_objhead LIKE solisti1 OCCURS 2 WITH HEADER LINE.

DATA int_objtext LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA int_reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.

DATA bodyln LIKE sy-tabix.

DATA output_data TYPE ssfcrescl.

excel[] = wa_data[].

  • excel table sizes

DESCRIBE TABLE excel LINES excelln.

  • Body Email

int_objtext-line = 'Test Body'.

APPEND int_objtext.

DESCRIBE TABLE int_objtext LINES bodyln.

READ TABLE int_objtext INDEX bodyln.

CLEAR doc.

doc-doc_size = ( bodyln - 1 ) * 255 + STRLEN( int_objtext ).

doc-obj_name = ' '.

doc-sensitivty = 'P'.

doc-proc_syst = sy-sysid.

doc-proc_clint = sy-mandt.

CLEAR: int_objpack, int_objpack[].

int_objpack-transf_bin = ' '.

int_objpack-head_start = 1.

int_objpack-head_num = 0.

int_objpack-body_start = 1.

int_objpack-body_num = bodyln.

int_objpack-doc_type = 'RAW'.

int_objpack-obj_descr = 'Test'.

APPEND int_objpack.

CLEAR: int_objhead, int_objhead[].

int_objhead = 'Attachment'.

APPEND int_objhead.

int_objpack-transf_bin = 'X'.

int_objpack-head_start = 1.

int_objpack-head_num = 0.

int_objpack-body_start = 1.

int_objpack-body_num = excelln.

int_objpack-doc_size = excelsize.

int_objpack-doc_type = 'XLS'.

int_objpack-obj_name = 'excel'.

int_objpack-obj_descr = 'test.xls'. "File name

APPEND int_objpack.

  • Set Receiver

int_reclist-receiver = 'SAPUSER'.

int_reclist-rec_type = 'B'.

int_reclist-notif_del = 'X'.

int_reclist-notif_read = 'X'.

int_reclist-notif_ndel = 'X'.

int_reclist-express = 'X'.

APPEND int_reclist.

doc-obj_descr = 'Report in Excel'.

  • Sending Email

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = int_objpack

object_header = int_objhead

contents_bin = excel

contents_txt = int_objtext "Body

receivers = int_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.

ENDFORM. " send_email

Note:

- If you are using FM SAP_CONVERT_TO_TXT_FORMAT you will not be able to execute this program in the background.

- dont forget to change 'SAPUSER' to your SAP user ID

- you can check the email by using tcode 'SBWP'.

Reward points if this Helps.

Manish

0 Kudos

hi manish,

Thanks for the reply. I am able to send the excel file in the email. My doubt is <u><i>how to change a particular row to BOLD.</i></u>regards,

manasa