Thursday, August 5, 2010

Send mail via ABAP functions Module to SAP mail inbox

REPORT ZEMAIL_SEND.
* 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.
OBJCONT-LINE = ‘text’. “Content of email that you want to mail
APPEND OBJCONT.

* 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 ‘Test Mail’ “Subject of mail
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.

Wednesday, July 21, 2010

Difference between user-exit & customer-exit


·         USER EXITS are FORMS and are called by SAP standard programs using PERFORM.

CUSTOMER EXITS are FUNCTIONS so they are called using CALL FUNCTION (or more exactly CALL CUSTOMER FUNCTION).

·         Inside the form (user exit) you can read and change almost any global data from host program.
Inside a function (customer exit) you can only access your import/export/changing/tables parameters.


·         User exits are more flexible because you have more information to use in your code but on the other hand, it is very easy to manipulate erroneously global data and lead the standard program to a dump or even to make database inconsistent. Customer exits are more restrictive but you are sure any change you can make to any parameters will never lead to inconsistency

·         User-exit doesn’t have any classification. In customer-exit we have function-module exit, screen exit and menu exit.

·         User exits are basically designed For SD module. Customer exits are available for M, SD, FI and HR. Basically designed for all modules.