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

Problem in sending Excel attachment on the SAI id.

Former Member
0 Kudos
136

Hi Experts.

i am using one function module to send one alv output in Excel format to sapid.

FORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.

CALL FUNCTION 'Z_MAIL_ITAB_AS_XLS_ATTACHMENT'

EXPORTING

I_MESSAGE_TITLE = SYST-TITLE

I_ATTACHMENT_TITLE = SYST-TITLE

I_STRUCTURE_NAME = 'ZAMT__ZBCAUTH0001'

I_INCLUDE_HEADER = 'X'

  • I_RECIPIENT_UNAME = P_UNAME

TABLES

T_MESSAGE = MESSAGE_TAB

T_DATA = I_TABLE

T_RECEIVERS = RECEIVERS_TAB

EXCEPTIONS

NO_DATA_TO_SEND = 01

UNABLE_TO_GET_NAMETAB = 02

UNABLE_TO_GET_DDTEXTS = 03

NO_HEADER_SUPPLIED = 04

MAIL_SENDING_FAILED = 05

OTHERS = 06.

IF SYST-SUBRC NE 0.

MESSAGE ID SYST-MSGID TYPE SYST-MSGTY NUMBER SYST-MSGNO

WITH SYST-MSGV1 SYST-MSGV2 SYST-MSGV3 SYST-MSGV4.

ENDIF.

ENDFORM.

now, my requirement is i had two internal table one for ITAB_FICO & ITAB_SD for FICO and SD module.AND BY CHECKING CONDITON I HAD TO SEND MAIL TO CORRESPONDING DIFFERENT PERSON.

I HAD DONE THE CODING AS GIVEN BELOW.

IF NOT itab_fico[] IS INITIAL.

RECEIVERS_TAB-RECEIVER = 'SAP_00021'.

RECEIVERS_TAB-REC_TYPE = 'B'.

RECEIVERS_TAB-EXPRESS = 'X'.

APPEND RECEIVERS_TAB.

PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.

endif.

IF NOT itab_sd[] IS INITIAL.

RECEIVERS_TAB-RECEIVER = 'SAP_00022'. <------- its my sap id

RECEIVERS_TAB-REC_TYPE = 'B'.

RECEIVERS_TAB-EXPRESS = 'X'.

APPEND RECEIVERS_TAB.

PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.

endif.

Now, what is happening is i am getting two mails,

one contains the attachement in Excel for ITAB_FICO. ( 3 ROWS)

SECOND mail contains two attachement one for ITAB_FICO ,second attachment contains the line items of ITAB_FICO + in the same excel the line items of ITAB_SD(2 ROWS).

So, for one time its working fine, but on sending mail second or third them its attaching the previous attachment also...... i tried to refresh everything but its not working....................

please help,,,,or if possible tell me some other SAP FM ...which can fulfil the requirements.

I will reward points for every suggestion.

thanks

3 REPLIES 3
Read only

former_member223537
Active Contributor
0 Kudos
106

Hi Saurabh,

IF NOT itab_fico[] IS INITIAL.

<b>REFRESH : RECEIVERS_TAB.

CLEAR : RECEIVERS_TAB.</b>

RECEIVERS_TAB-RECEIVER = 'SAP_00021'.

RECEIVERS_TAB-REC_TYPE = 'B'.

RECEIVERS_TAB-EXPRESS = 'X'.

APPEND RECEIVERS_TAB.

PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.

endif.

IF NOT itab_sd[] IS INITIAL.

<b>REFRESH : RECEIVERS_TAB.

CLEAR : RECEIVERS_TAB.</b>

RECEIVERS_TAB-RECEIVER = 'SAP_00022'. <------- its my sap id

RECEIVERS_TAB-REC_TYPE = 'B'.

RECEIVERS_TAB-EXPRESS = 'X'.

APPEND RECEIVERS_TAB.

PERFORM SEND_MAIL TABLES T_AMS RECEIVERS_TAB.

endif.

Best regards,

Prashant

Read only

Former Member
0 Kudos
106

Hi..

I am already refreshing the RECEIVERS, just forgot to mention.

Read only

0 Kudos
106

Hi,

go thru this thread,

regards,

madhu