|
|
Sending Emails and SAP Mail Using ABAP - Email Example UNIX ABAP Code
A D V E R T I S E M E N T
|
S A P - R E S O U R C E S
Get Free SAP Resources:
Are you looking for:
- SAP Jobs
- Free SAP eBooks
- SAP Softwares
- SAP Tutorials
- ERP Implementation Examples
Search SAP Resources:
|
REPORT ZTUNIXMAIL.
*
DATA : TO_ADDRESS LIKE SY_LISEL,
FROM_ADDRESS LIKE SY-LISEL,
SUBJECT LIKE SY-LISEL,
ATTACHMENT_NAME LIKE SY_LISEL,
DATA_FILE_PATH LIKE SXPGCOLIST-PARAMETERS,
BODY_FILE_PATH LIKE SXPGCOLIST-PARAMETERS.
DATA : BEGIN OF INT_EMAIL_ATTACH OCCURS 0,
TXTLINE CHAR(255),
END OF INT_EMAIL_ATTACH.
DATA : BEGIN OF INT_EMAIL_BODY OCCURS 0,
TXTLINE CHAR(255),
END OF INT_EMAIL_BODY.
CLEAR : INT_EXEC_PROTOCOL,INT_EMAIL_ATTACH,INT_EMAIL_BODY.
REFRESH : INT_EXEC_PROTOCOL,INT_EMAIL_ATTACH,INT_EMAIL_BODY.
*
INT_EMAIL_ATTACH-TXTLINE = 'Put all attachment text in this table'.
APPEND INT_EMAIL_ATTACH. CLEAR INT_EMAIL_ATTACH.
INT_EMAIL_BODY-TXTLINE = 'Put all attachment text in this table'.
APPEND INT_EMAIL_BODY. CLEAR INT_EMAIL_BODY.
*
CONCATENATE TO_ADDRESS
FROM_ADDRESS
SUBJECT
BODY_FILE_PATH
DATA_FILE_PATH
ATTACHMENT_NAME
INTO V_PARAMETERS.
*
IF NOT INT_EMAIL_ATTACH[] IS INITIAL.
OPEN DATASET DATA_FILE_PATH FOR OUTPUT IN TEXT MODE.
LOOP AT INT_EMAIL_ATTACH.
TRANSFER INT_EMAIL_ATTACH-TXTLINE TO DATA_FILE_PATH.
ENDLOOP.
CLOSE DATASET DATA_FILE_PATH.
ENDIF.
*
IF NOT INT_EMAIL_BODY[] IS INITIAL.
OPEN DATASET BODY_FILE_PATH FOR OUTPUT IN TEXT MODE.
LOOP AT INT_EMAIL_BODY.
TRANSFER INT_EMAIL_BODY-TXTLINE TO BODY_FILE_PATH.
ENDLOOP.
CLOSE DATASET BODY_FILE_PATH.
ENDIF.
*
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
COMMANDNAME = 'Z_EMAIL' - Command calling unix script
PARAMETERS = V_PARAMETERS
* importing
* status = ''
TABLES
EXEC_PROTOCOL = INT_EXEC_PROTOCOL
EXCEPTIONS
NO_PERMISSION = 1
COMMAND_NOT_FOUND = 2
PARAMETERS_TOO_LONG = 3
SECURITY_RISK = 4
WRONG_CHECK_CALL_INTERFACE = 5
PROGRAM_START_ERROR = 6
PROGRAM_TERMINATION_ERROR = 7
X_ERROR = 8
PARAMETER_EXPECTED = 9
TOO_MANY_PARAMETERS = 10
ILLEGAL_COMMAND = 11
OTHERS = 12.
|
A D V E R T I S E M E N T
|
|
| |