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: 

ALV - is there a way to automatically send the ALV via e-mail

Former Member
0 Kudos

Hi,

I have a requirement to automatically send the ALV to an e-mail address.

Is this possible to do by just using the ALV methods available ?

Cheers

Colin.

8 REPLIES 8

athavanraja
Active Contributor
0 Kudos

with methods from ALV class? NO.

what do you mean by automatically?

you can schedule to run it and email the same.

or have a button in the alv screen, upon clicking you can then send the ALV (you have to write code)

Regards

Raja

0 Kudos

Hi,

I will schedule the ALV to be produced daily and I wish to automatically e-mail when it is produced.

How do I do that ? Do I set it up on the batch job or within the program itself.

Thanks

Colin.

Former Member
0 Kudos

Hi Colin,

Check the weblog:

/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface

Check these link..

http://www.sap-img.com/abap/sending-email-with-attachment.htm

https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/789. [original link is broken] [original link is broken] [original link is broken] [original link is broken]

Have a look at below code:

REPORT ZSENDEXTERNAL.

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.

  • Creation of the document to be sent

  • File Name

DOC_CHNG-OBJ_NAME = 'SENDFILE'.

  • Mail Subject

DOC_CHNG-OBJ_DESCR = 'Send External Mail'.

  • Mail Contents

OBJTXT = 'Minimum bid : $250000'.

APPEND OBJTXT.

OBJTXT = 'A representation of the pictures up for auction'.

APPEND OBJTXT.

OBJTXT = 'was included as attachment.'.

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

  • (Assume that the data in OBJBIN is in BMP format)

*OBJBIN = ' O/ '. APPEND OBJBIN.

*OBJBIN = ' | '. APPEND OBJBIN.

*OBJBIN = ' / '. APPEND OBJBIN.

*DESCRIBE TABLE OBJBIN LINES TAB_LINES.

*OBJHEAD = 'PICTURE.BMP'.

*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 = 'BMP'.

*OBJPACK-OBJ_NAME = 'PICTURE'.

*OBJPACK-OBJ_DESCR = 'Representation of object 138'.

*OBJPACK-DOC_SIZE = TAB_LINES * 255.

*APPEND OBJPACK.

  • Completing the recipient list

RECLIST-RECEIVER = 'youremail@sap.com'.

RECLIST-REC_TYPE = 'U'.

APPEND RECLIST.

*RECLIST-RECEIVER = 'SAPUSERNAME'.

*RECLIST-REC_TYPE = 'P'.

*APPEND RECLIST.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

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

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 'The document was sent'.

ELSE.

WRITE 'The document could not be sent'.

ENDIF.

ENDLOOP.

WHEN 1.

WRITE: / 'No authorization for sending to the specified number',

'of recipients'.

WHEN 2.

WRITE: / 'Document could not be sent to any recipient'.

WHEN 4.

WRITE: / 'No send authorization'.

WHEN OTHERS.

WRITE: / 'Error occurred while sending'.

ENDCASE.

Reward points if this Helps.

Manish

Former Member
0 Kudos

Hi Colin,

did you ever find out how to do this ?

Regards

Colin

former_member194669
Active Contributor
0 Kudos

Hi,

If you are going to schedule this job via SM36 you can set a SAP Office recipient for the job output. (There is button for "Spool List recipient") May be If you have SCOT correctly configured then the mail send to external mail id also.

aRs

Former Member
0 Kudos

With in the alv-output list, there is an icon for sending the list as email, Check the ICON.

Regds,

Kaleem.

0 Kudos

In my case there is no user interaction as the job would be schedule to run in the background nightly, producing the ALV grid and then send the ALV grid as an email attachment so it can be opened in EXCEL.

For classical reporting you can code to use new-page print on so all the print command are sent to the spool, trigger new-page print off once all the write statements are complete and use the spool number from sy-spono to read back the spool and send via email.

Any ideas ?

Former Member
0 Kudos

No longer required