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

Program for Prime numbers and Matrix plz explain me the procedural method with steps

2257


How is conversion of data types done between abap/4 & db layer?

638


What are conversion routines? : abap data dictionary

594


What is an Open Item in SAP? How will you find an Open Item in SAP?

628


Does the call transaction method allow multiple transactions to be processed by sap? : abap bdc

524






What is a view? : abap data dictionary

657


What does the insert statement in extract datasets do?

626


What are the events used in interactive reports?

617


How do you set up background jobs in sap? What are the steps?

538


Proxy Programming with ABAP - How to develop the Proxy identification through programming

1885


hi,i worked mostly in core abap.know iam assigned to XI utility project.can u experts let me know what r the basic things i need to learn to work in XI utility project.i already searched in forum.thanks in advance.

1562


What are the function module in bdc?

643


Difference between sy-tabix and sy-index? Where it is used? Can you check sy-subarc after perform?

591


What are different ABAP editors? What are the differences?

594


Explain what are the events used in interactive reports?

492