2008 Oct 16 11:31 AM
Hi all,
I have a requirement to add a line saying "This is an automated email. Please do not reply to this email" in the mail body of the return authorization programs sending mails in CRM. In this they are using Actions. And they are not using FM's like 'SO_NEW_DOCUMENT_ATT_SEND_API1' or "SO_OBJECT_SEND" in the corresponding method.
Can u please tell how to add this line and where should i add this????
Helpful answer will be awarded.
Thanks,
Jayshree.
2008 Oct 16 11:36 AM
This function module i have used to send Smartform to PDF and mail.
Please change according to your requirement.
FUNCTION ZECC_SEND_HR_APPROVAL_MAIL.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(PERNR) TYPE PERSNO OPTIONAL
*" VALUE(REQUEST) TYPE ZREQUEST_ID OPTIONAL
*" VALUE(HRMAILID) TYPE SO_RECNAME OPTIONAL
*" VALUE(L1MAILID) TYPE SO_RECNAME OPTIONAL
*" VALUE(EMPMAILID) TYPE SO_RECNAME OPTIONAL
*"----
INTERNAL TABLE DECLARATIONS
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
OBJECTS TO SEND MAIL.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
WORK AREA DECLARATIONS
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING,"To convert from 132 to 255
VARIABLES DECLARATIONS
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZECC_RESIGN_ACCEPTANCE_LETTER'
IMPORTING
FM_NAME = V_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_CTRLOP-LANGU = SY-LANGU.
W_CTRLOP-NO_OPEN = 'X'.
W_CTRLOP-NO_CLOSE = 'X'.
*
W_COMPOP-TDGROUP = 'X'.
W_COMPOP-TDNOPRINT = 'X'.
W_COMPOP-TDNOPREV = 'X'.
W_COMPOP-TDPRINTER = 'PDF1'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
PERNR = PERNR
REQUEST = REQUEST
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
FEHLERHANDLING
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
*ATTACHMENT
REFRESH:
I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
*CREATE MESSAGE BODY
*TITLE AND DESCRIPTION
I_OBJTXT = 'Acceptance should be handed over to Ex-Employee only after the submission of the Company Property and necessary documents.'.
APPEND I_OBJTXT.
I_OBJTXT = 'Please find the attached acceptance letter.'.
APPEND I_OBJTXT.
I_OBJTXT = 'This is an auto generated mail so please dont reply this mail'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'Resignation Acceptance'.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'Acceptance of Resignation'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
*MAIN TEXT
WA_DOC_CHNG-DOC_SIZE = ( V_LINES_TXT - 1 ) * 255 + STRLEN( I_OBJTXT ).
*.
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
*ATTACHMENT
*(PDF-ATTACHMENT)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
*LANGE DES ATTACHMENT ERMITTELN
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'Resignation Acceptance'.
I_OBJPACK-OBJ_DESCR = 'Acceptance Letter'.
APPEND I_OBJPACK.
IF HRMAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = HRMAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
IF L1MAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = L1MAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
IF EMPMAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = EMPMAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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.
ENDFUNCTION.
2008 Oct 16 11:36 AM
This function module i have used to send Smartform to PDF and mail.
Please change according to your requirement.
FUNCTION ZECC_SEND_HR_APPROVAL_MAIL.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(PERNR) TYPE PERSNO OPTIONAL
*" VALUE(REQUEST) TYPE ZREQUEST_ID OPTIONAL
*" VALUE(HRMAILID) TYPE SO_RECNAME OPTIONAL
*" VALUE(L1MAILID) TYPE SO_RECNAME OPTIONAL
*" VALUE(EMPMAILID) TYPE SO_RECNAME OPTIONAL
*"----
INTERNAL TABLE DECLARATIONS
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
OBJECTS TO SEND MAIL.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
WORK AREA DECLARATIONS
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING,"To convert from 132 to 255
VARIABLES DECLARATIONS
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZECC_RESIGN_ACCEPTANCE_LETTER'
IMPORTING
FM_NAME = V_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_CTRLOP-LANGU = SY-LANGU.
W_CTRLOP-NO_OPEN = 'X'.
W_CTRLOP-NO_CLOSE = 'X'.
*
W_COMPOP-TDGROUP = 'X'.
W_COMPOP-TDNOPRINT = 'X'.
W_COMPOP-TDNOPREV = 'X'.
W_COMPOP-TDPRINTER = 'PDF1'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
PERNR = PERNR
REQUEST = REQUEST
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
FEHLERHANDLING
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
*ATTACHMENT
REFRESH:
I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
*CREATE MESSAGE BODY
*TITLE AND DESCRIPTION
I_OBJTXT = 'Acceptance should be handed over to Ex-Employee only after the submission of the Company Property and necessary documents.'.
APPEND I_OBJTXT.
I_OBJTXT = 'Please find the attached acceptance letter.'.
APPEND I_OBJTXT.
I_OBJTXT = 'This is an auto generated mail so please dont reply this mail'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'Resignation Acceptance'.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'Acceptance of Resignation'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
*MAIN TEXT
WA_DOC_CHNG-DOC_SIZE = ( V_LINES_TXT - 1 ) * 255 + STRLEN( I_OBJTXT ).
*.
CLEAR I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
*ATTACHMENT
*(PDF-ATTACHMENT)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
*LANGE DES ATTACHMENT ERMITTELN
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'Resignation Acceptance'.
I_OBJPACK-OBJ_DESCR = 'Acceptance Letter'.
APPEND I_OBJPACK.
IF HRMAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = HRMAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
IF L1MAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = L1MAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
IF EMPMAILID IS NOT INITIAL.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = EMPMAILID.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_RECLIST.
ENDIF.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
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.
ENDFUNCTION.
2008 Oct 16 11:58 AM
Hi Naresh,
Thanks for your reply. but here also finally they are passing that text to FM SO_NEW_DOCUMENT_ATT_SEND_API1' . But in my case they are not using this FM.and thats why i m unable to find exact place where i can add this line or pass this line to the appropriate parameter.
Can u please help me in this?
Thanks,
Jayshree.