how to send output of program via email?

Answer Posted / k.nagalakshmi

REPORT ZSEND .

TABLES: KNA1.

* data for send function
DATA DOC_DATA LIKE SODOCCHGI1.
DATA OBJECT_ID LIKE SOODK.
DATA OBJCONT LIKE SOLI OCCURS 10 WITH HEADER LINE.
DATA RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.

SELECT * FROM KNA1 WHERE ANRED LIKE 'C%'.
WRITE:/ KNA1-KUNNR, KNA1-ANRED.

* send data internal table
CONCATENATE KNA1-KUNNR KNA1-ANRED
INTO OBJCONT-LINE SEPARATED BY
SPACE.

APPEND OBJCONT.
ENDSELECT.

* insert receiver (sap name)
REFRESH RECEIVER.
CLEAR RECEIVER.
MOVE: SY-UNAME TO RECEIVER-RECEIVER,
'X' TO RECEIVER-EXPRESS,
'B' TO RECEIVER-REC_TYPE.
APPEND RECEIVER.

* insert mail description
WRITE 'Sending a mail through abap'
TO DOC_DATA-OBJ_DESCR.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = DOC_DATA
IMPORTING
NEW_OBJECT_ID = OBJECT_ID
TABLES
OBJECT_CONTENT = OBJCONT
RECEIVERS = RECEIVER
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.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is sap locking?

593


What are the major steps will you use for tuning?

589


How do you send files to the legacy systems from sap and vice versa? How does one know that the legacy files have come on to the sap server you are working on? : abap bdc

562


What are the modes in which any update tasks work?

623


How to read files and process BDC's automatically ?

1628






HOW TO TRANSFER VENDOR MASTER DATA FROM LEGACY SYSTEM TO SAP SYSTEM THRU LSMW (IN LSMW, USING DIRECT INPUT PROGRAM:RFBIKR00)

3284


what is the process of creating quotation using BAPIs.

1567


SAP query how to use end users?

1693


In order to upload purchase order details, how you handle multiple values for a single field?

563


what is the purpose of BAPI BAPI_CUSTMATINFO_GETLIST What is input and output of this BAPI.

2093


Work most on which module: name a few tables?

591


What are the function modules used in f4 help?

638


What are the sequences of event block?

620


What is the significance of the memory table ‘screen’?

599


Can any tell me ECC 5.0, ECC 6.0 Released year? and difference between them?

1972