Application Development and Automation 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: 
Read only

Email excel attachment

Former Member
0 Likes
494

I am sending an email with an excel attachment using fm SO_NEW_DOCUMENT_ATT_SEND_API1. All is well except that the first column of the excel document displys a load of blank spaces in front of the data item. Is there any way of cutting out the blank spaces?

Code is as follows:

  • Populate the email header

CONCATENATE text-m09 l_pltxt INTO docdata-obj_descr.

docdata-obj_name = text-m11.

  • Populate the body of the mail

MOVE text-m10 TO objtxt.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

  • Size of the document in bytes. The calculation is

  • Length of last line + number of remaining lines * 255

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 = 'RAW'.

APPEND objpack.

  • Get end of line character

l_eol = cl_abap_char_utilities=>newline.

  • Set up attachment

  • Column headers

CONCATENATE 'Requested by'

'Serial Number'

'Part Number'

'Inst.or Dism.'

'Mvmnt.To(Sup.Equip.)'

'Mvmnt.To(Func.Loc.)'

'Mvmnt.Date'

'Posn'

'Start Date'

l_eol

INTO objbin SEPARATED BY ','.

APPEND objbin.

CLEAR objbin.

  • Lines

LOOP AT it_equipment.

CONCATENATE sy-uname

it_equipment-sernr

zdbmatl-matnr

it_equipment-iord

it_equipment-equnr

it_equipment-tplnr

it_equipment-move_date

it_equipment-pors

it_equipment-start_date

l_eol

INTO objbin SEPARATED BY ','.

APPEND objbin.

CLEAR objbin.

ENDLOOP.

att_type = 'CSV'.

DESCRIBE TABLE objbin LINES tab_lines.

READ TABLE objbin INDEX tab_lines.

  • Size of the document in bytes.The calculation is

  • Length of last line + number of remaining lines * 255

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'.

CONCATENATE text-m09

l_pltxt

INTO objpack-obj_descr SEPARATED BY space.

APPEND objpack.

CLEAR objpack.

reclist-receiver = 'test@test.co.uk'.

reclist-rec_type = 'U'.

APPEND reclist.

  • Send mail

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = '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

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

COMMIT WORK.

3 REPLIES 3
Read only

Former Member
0 Likes
412

Hi

Please see the link below

It will definately satisfy your requirement.

<b>Mark if helpful</b>

Regards

Tushar

Message was edited by:

Tushar Mundlik

Read only

0 Likes
412

Tushar,

I think the link may be the wrong one.

Read only

Former Member