Smartforms output as HTML in email
Hi,
I want to send the output of a smartform as html in email body.
I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
I did everything as per the blog.
However I am getting the email as:
sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
When I display the document using SOST, I get the output as
Address bar has this: C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
and window contains:
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
Regards,
Reema
Message was edited by:
Reema Shahbazkar
In case anyone needs to have a look at my code:
REPORT ZSMARTFORM_2_HTML_EMAIL.
get generated function module for the smartform
DATA: FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF_SAMPLE_HTML'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_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.
get smartform contetnt
set smartform output options
data:
control_parameters type SSFCTRLOP,
OUTPUT_OPTIONS TYPE SSFCOMPOP,
DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
JOB_OUTPUT_INFO TYPE SSFCRESCL,
JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
XSFPARAM_LINE TYPE SSFXSFP,
P_HTML TYPE TRFRESULT,
P_GRAPHICS TYPE TSF_XSF_GR,
WA_RETURN TYPE BAPIRET2.
CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
control_parameters-NO_DIALOG = 'X'.
*control_parameters-GETOTF = 'X'.
OUTPUT_OPTIONS-TDNEWID = SPACE.
OUTPUT_OPTIONS-TDIMMED = SPACE.
OUTPUT_OPTIONS-XSFCMODE = 'X'. "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
OUTPUT_OPTIONS-XSF = 'X'. "XSF OUTPUT ACTIVATED
OUTPUT_OPTIONS-XSFOUTMODE = 'A'. "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
CLEAR: OUTPUT_OPTIONS-XSFOUTDEV. "OUTPUT SPOOL DEVICE
OUTPUT_OPTIONS-XSFFORMAT = 'X'. "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
XSFPARAM_LINE-NAME = 'GRAPHICS'.
XSFPARAM_LINE-VALUE = 'EXTRACT'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
XSFPARAM_LINE-VALUE = C_GR_DIR.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'CONTENT-ID'.
XSFPARAM_LINE-VALUE = 'ENABLE'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = OUTPUT_OPTIONS
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
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.
SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
PROCEED TO SEND EMAIL
DATA: HTML_DATA TYPE TRFRESULT,
L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
HTML_XSTR TYPE XSTRING.
CLEAR: HTML_XSTR.
LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
ENDLOOP.
HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
SPECIAL CHARACTER CONVERSION
DATA: HTML_STR TYPE STRING,
HTML_LEN TYPE I.
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
INBUFF = HTML_XSTR
INBUFFLG = 0
INCODE = '4110' "utf-8
OUTBUFFLG = 0
OUTCODE = '0000'
CSUBST = 'X'
SUBSTC_HASH = ' '
SUBSTC_DOT = ' '
SUBSTC_SPACE = 'x'
SUBSTC = '00035'
IMPORTING
INUSED =
OUTBUFF = HTML_STR
OUTOVERFLOW =
OUTUSED = HTML_LEN
SUBSTED =
INPUT_ENDS_IN_CHAR =
ERRMSG =
EXCEPTIONS
INVALID_CODEPAGE = 1
INTERNAL_ERROR = 2
CANNOT_CONVERT = 3
FIELDS_BAD_TYPE = 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.
CHANGE ENCODING UTF-8 TO LATIN1
REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
HTML_LEN = STRLEN( HTML_STR ).
DATA: L_OFFSET TYPE I,
L_LENGTH TYPE I,
L_DIFF TYPE I,
LT_SOLI TYPE SOLI_TAB,
LS_SOLI TYPE SOLI.
L_OFFSET = 0.
L_LENGTH = 255.
WHILE L_OFFSET < HTML_LEN.
L_DIFF = HTML_LEN - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLI TO LT_SOLI.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
CREATE OBJECT LO_MIME_HELPER
EXPORTING
CODEPAGE = '1133'.
CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
EXPORTING
CONTENT = LT_SOLI
FILENAME =
DESCRIPTION =
HANDLE GRAPHICS
DATA: L_GRAPHIC TYPE SSF_XSF_GR,
GR_XSTR TYPE XSTRING,
L_GR_RAW TYPE BAPICONTEN,
L_CONTENT_ID TYPE STRING,
L_CONTENT_TYPE TYPE W3CONTTYPE,
L_OBJ_LEN TYPE SO_OBJ_LEN,
L_FILENAME TYPE STRING,
LT_SOLIX TYPE SOLIX_TAB,
LS_SOLIX TYPE SOLIX.
LOOP AT P_GRAPHICS INTO L_GRAPHIC.
CLEAR: GR_XSTR.
LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
ENDLOOP.
GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
L_OFFSET = 0.
L_LENGTH = 255.
CLEAR LT_SOLIX[].
WHILE L_OFFSET < L_GRAPHIC-LENGTH.
L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLIX TO LT_SOLIX.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
L_OBJ_LEN = L_GRAPHIC-LENGTH.
ADD IMAGES TO EMAIL
CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
EXPORTING
CONTENT = LT_SOLIX
FILENAME =
EXTENSION =
DESCRIPTION =
CONTENT_TYPE = L_CONTENT_TYPE
LENGTH = L_OBJ_LEN
CONTENT_ID = L_CONTENT_ID
ENDLOOP.
DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
P_SUBJECT TYPE SO_OBJ_DES,
LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
TRY.
CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
EXPORTING
I_SUBJECT = P_SUBJECT
I_LANGUAGE = SY-LANGU
I_IMPORTANCE = '5'
I_SENSITIVITY = 'F'
I_MULTIREL_SERVICE = LO_MIME_HELPER
RECEIVING
RESULT = LO_DOC_BCS
CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
CATCH CX_GBT_MIME INTO LV_GBT_MIME.
ENDTRY.
RECEIVERS
DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
RECEIVER TYPE SOMLRECI1,
L_MAIL_ADDRESS TYPE AD_SMTPADR,
LO_BCS TYPE REF TO CL_BCS,
LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
L_USERNAME TYPE UNAME,
SEND_PARTNER TYPE BU_PARTNER,
LI_SENDER TYPE REF TO IF_SENDER_BCS,
LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
LV_SENT_TO_ALL TYPE BOOLEAN.
CLEAR RECEIVER.
RECEIVER-RECEIVER = '[email protected]'.
RECEIVER-REC_TYPE = 'U'.
RECEIVER-COM_TYPE = 'INT'.
APPEND RECEIVER TO P_RECEIVERS.
L_USERNAME = SY-UNAME.
CLEAR RECEIVER.
LOOP AT P_RECEIVERS INTO RECEIVER.
L_MAIL_ADDRESS = RECEIVER-RECEIVER.
TRY.
CALL METHOD CL_BCS=>CREATE_PERSISTENT
RECEIVING
RESULT = LO_BCS
CALL METHOD LO_BCS->SET_DOCUMENT
EXPORTING
I_DOCUMENT = LO_DOC_BCS
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
CREATE SENDER
CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
TRY.
IF L_USERNAME NS '@'.
L_USERNAME = SEND_PARTNER.
TRANSLATE L_USERNAME TO UPPER CASE.
LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
ELSE.
DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
L_FROM_MAIL_ADDRESS = L_USERNAME.
LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
ENDIF.
CALL METHOD LO_BCS->SET_SENDER
EXPORTING
I_SENDER = LI_SENDER
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
create recepient
data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
TRY.
CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
EXPORTING
I_ADDRESS_STRING = L_MAIL_ADDRESS
I_ADDRESS_NAME =
I_INCL_SAPUSER =
RECEIVING
RESULT = LO_RECEPIENT
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
ENDTRY.
TRY.
CALL METHOD LO_BCS->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LO_RECEPIENT
I_EXPRESS =
I_COPY =
I_BLIND_COPY =
I_NO_FORWARD =
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
SEND EMAIL DOCUMENT
TRY.
CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
EXPORTING
I_REQUESTED_STATUS = 'N'
TRY.
CALL METHOD LO_BCS->SEND
EXPORTING
I_WITH_ERROR_SCREEN = SPACE
RECEIVING
RESULT = LV_SENT_TO_ALL
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
ENDTRY.
ENDLOOP.
COMMIT WORK.
Hi,
I want to send the output of a smartform as html in email body.
I found and used this bolg: :<a href="/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp HTML Email from SAP CRM/ERP</a>
I did everything as per the blog.
However I am getting the email as:
sf @media print {.xsfnoprint{ display : none ;}}/* Default css layout information for SAP Smart Forms (XSF Output) Last modified: 12.05.2003 /@media screen { body { background-color : #EFEFEF ; }}@media screen { .page { border-style : outset ; border-width : 2pt ; background-color : white ; }}/@media print { .page { overflow: hidden; }}// unification browser-dependent settings /table { border-spacing: 0pt; empty-cells: show;}tr { vertical-align: top; }td input img img.icon / End of default.css */.SYSTEM div#B.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : justify ; clear : both ;}.SYSTEM div#L.par{ font-family : "Courier New" ; font-size : 12pt ; font-weight : normal ; line-height : 4.23mm ; text-decoration : none ; text-align : left ; clear : both ;}.SYSTEM a.SYSTEM span#H.char{ font-weight : bold ;}.SYSTEM span#I.char{ font-style : italic ;}.SYSTEM span#U.char{ text-decoration : underline ;}#sfPAGE1-001.page@media screen {#MAIN.win{ overflow : auto ;}}@media print {#MAIN.win{ overflow : hidden ;}}#sfPAGE1-001.page #MAIN.win
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
I am using: Lotus notes client for email and my smartform contains only two text elements: one containing text Welcome and other containing text
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48">
When I display the document using SOST, I get the output as
Address bar has this: C:\Documents and Settings\EDC LTIL02\SapWorkDir\TESTHTMLEMAILFROMSMARTFORMOUTPUT_20070928154506.046_X.MHT
and window contains:
Welcome
<IMG src="https://www.sdn.sap.com/sd/img/logo_header.gif" border="0" aligh="left" width="559" height="48"> "
Regards,
Reema
Message was edited by:
Reema Shahbazkar
In case anyone needs to have a look at my code:
REPORT ZSMARTFORM_2_HTML_EMAIL.
get generated function module for the smartform
DATA: FM_NAME TYPE RS38L_FNAM.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSF_SAMPLE_HTML'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_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.
get smartform contetnt
set smartform output options
data:
control_parameters type SSFCTRLOP,
OUTPUT_OPTIONS TYPE SSFCOMPOP,
DOCUMENT_OUTPUT_INFO TYPE SSFCRESPD,
JOB_OUTPUT_INFO TYPE SSFCRESCL,
JOB_OUTPUT_OPTIONS TYPE SSFCRESOP,
XSFPARAM_LINE TYPE SSFXSFP,
P_HTML TYPE TRFRESULT,
P_GRAPHICS TYPE TSF_XSF_GR,
WA_RETURN TYPE BAPIRET2.
CONSTANTS: C_GR_DIR TYPE TDTEXT VALUE '/MYGRAPHICS'.
control_parameters-NO_DIALOG = 'X'.
*control_parameters-GETOTF = 'X'.
OUTPUT_OPTIONS-TDNEWID = SPACE.
OUTPUT_OPTIONS-TDIMMED = SPACE.
OUTPUT_OPTIONS-XSFCMODE = 'X'. "RUNTIME SETTINGS FROM SMARTFORM HEADER TO BE USED
OUTPUT_OPTIONS-XSF = 'X'. "XSF OUTPUT ACTIVATED
OUTPUT_OPTIONS-XSFOUTMODE = 'A'. "XSF OUTPUT STREAM PASSED DIRECTLY TO CALLING PROGRAM AS AN INTERNAL TABLE.
CLEAR: OUTPUT_OPTIONS-XSFOUTDEV. "OUTPUT SPOOL DEVICE
OUTPUT_OPTIONS-XSFFORMAT = 'X'. "ADDITIONALLLY TO XSF, HTML AND CSS LAYOUT INFORMATION IS ALSO PASSED TO CALLING PROGRAM
XSFPARAM_LINE-NAME = 'GRAPHICS'.
XSFPARAM_LINE-VALUE = 'EXTRACT'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'GRAPHICS-DIRECTORY'.
XSFPARAM_LINE-VALUE = C_GR_DIR.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
XSFPARAM_LINE-NAME = 'CONTENT-ID'.
XSFPARAM_LINE-VALUE = 'ENABLE'.
APPEND XSFPARAM_LINE TO OUTPUT_OPTIONS-XSFPARS.
CALL GENERATED FUNCTION MODULE TO GET FORM CONTENTS
CALL FUNCTION FM_NAME
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = CONTROL_PARAMETERS
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = OUTPUT_OPTIONS
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = JOB_OUTPUT_INFO
JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
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.
SEPARATE HTML GRAPHICAL N CSS LAYOUT CONTENT
P_HTML = JOB_OUTPUT_INFO-XMLOUTPUT-TRFRESULT.
P_GRAPHICS[] = JOB_OUTPUT_INFO-XMLOUTPUT-XSFGR[].
PROCEED TO SEND EMAIL
DATA: HTML_DATA TYPE TRFRESULT,
L_HTML_RAW LIKE LINE OF HTML_DATA-CONTENT,
HTML_XSTR TYPE XSTRING.
CLEAR: HTML_XSTR.
LOOP AT P_HTML-CONTENT INTO L_HTML_RAW.
CONCATENATE HTML_XSTR L_HTML_RAW INTO HTML_XSTR IN BYTE MODE.
ENDLOOP.
HTML_XSTR = HTML_XSTR(P_HTML-LENGTH).
SPECIAL CHARACTER CONVERSION
DATA: HTML_STR TYPE STRING,
HTML_LEN TYPE I.
CALL FUNCTION 'SCP_TRANSLATE_CHARS'
EXPORTING
INBUFF = HTML_XSTR
INBUFFLG = 0
INCODE = '4110' "utf-8
OUTBUFFLG = 0
OUTCODE = '0000'
CSUBST = 'X'
SUBSTC_HASH = ' '
SUBSTC_DOT = ' '
SUBSTC_SPACE = 'x'
SUBSTC = '00035'
IMPORTING
INUSED =
OUTBUFF = HTML_STR
OUTOVERFLOW =
OUTUSED = HTML_LEN
SUBSTED =
INPUT_ENDS_IN_CHAR =
ERRMSG =
EXCEPTIONS
INVALID_CODEPAGE = 1
INTERNAL_ERROR = 2
CANNOT_CONVERT = 3
FIELDS_BAD_TYPE = 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.
CHANGE ENCODING UTF-8 TO LATIN1
REPLACE ALL OCCURRENCES OF 'UTF-8' IN HTML_STR WITH 'iso-8859-1' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<IMG' IN HTML_STR WITH '<IMG' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '/>' IN HTML_STR WITH '/>' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<A>' IN HTML_STR WITH '' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '<' IN HTML_STR WITH '<' IGNORING CASE.
REPLACE ALL OCCURRENCES OF '>' IN HTML_STR WITH '>' IGNORING CASE.
HTML_LEN = STRLEN( HTML_STR ).
DATA: L_OFFSET TYPE I,
L_LENGTH TYPE I,
L_DIFF TYPE I,
LT_SOLI TYPE SOLI_TAB,
LS_SOLI TYPE SOLI.
L_OFFSET = 0.
L_LENGTH = 255.
WHILE L_OFFSET < HTML_LEN.
L_DIFF = HTML_LEN - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLI-LINE = HTML_STR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLI TO LT_SOLI.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
DATA: LO_MIME_HELPER TYPE REF TO CL_GBT_MULTIRELATED_SERVICE.
CREATE OBJECT LO_MIME_HELPER
EXPORTING
CODEPAGE = '1133'.
CALL METHOD LO_MIME_HELPER->SET_MAIN_HTML
EXPORTING
CONTENT = LT_SOLI
FILENAME =
DESCRIPTION =
HANDLE GRAPHICS
DATA: L_GRAPHIC TYPE SSF_XSF_GR,
GR_XSTR TYPE XSTRING,
L_GR_RAW TYPE BAPICONTEN,
L_CONTENT_ID TYPE STRING,
L_CONTENT_TYPE TYPE W3CONTTYPE,
L_OBJ_LEN TYPE SO_OBJ_LEN,
L_FILENAME TYPE STRING,
LT_SOLIX TYPE SOLIX_TAB,
LS_SOLIX TYPE SOLIX.
LOOP AT P_GRAPHICS INTO L_GRAPHIC.
CLEAR: GR_XSTR.
LOOP AT L_GRAPHIC-CONTENT INTO L_GR_RAW.
CONCATENATE GR_XSTR L_GR_RAW-LINE INTO GR_XSTR IN BYTE MODE.
ENDLOOP.
GR_XSTR = GR_XSTR(L_GRAPHIC-LENGTH).
L_OFFSET = 0.
L_LENGTH = 255.
CLEAR LT_SOLIX[].
WHILE L_OFFSET < L_GRAPHIC-LENGTH.
L_DIFF = L_GRAPHIC-LENGTH - L_OFFSET.
IF L_DIFF > L_LENGTH.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_LENGTH).
ELSE.
LS_SOLIX-LINE = GR_XSTR+L_OFFSET(L_DIFF).
ENDIF.
APPEND LS_SOLIX TO LT_SOLIX.
ADD L_LENGTH TO L_OFFSET.
ENDWHILE.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_FILENAME.
CONCATENATE C_GR_DIR L_GRAPHIC-GRAPHICS '.BMP' INTO L_CONTENT_ID.
L_CONTENT_TYPE = L_GRAPHIC-HTTPTYPE.
L_OBJ_LEN = L_GRAPHIC-LENGTH.
ADD IMAGES TO EMAIL
CALL METHOD LO_MIME_HELPER->ADD_BINARY_PART
EXPORTING
CONTENT = LT_SOLIX
FILENAME =
EXTENSION =
DESCRIPTION =
CONTENT_TYPE = L_CONTENT_TYPE
LENGTH = L_OBJ_LEN
CONTENT_ID = L_CONTENT_ID
ENDLOOP.
DATA: LO_DOC_BCS TYPE REF TO CL_DOCUMENT_BCS,
P_SUBJECT TYPE SO_OBJ_DES,
LV_GBT_MIME TYPE REF TO CX_GBT_MIME,
LV_BCOM_MIME TYPE REF TO CX_BCOM_MIME,
LV_DOCUMENT_BCS TYPE REF TO CX_DOCUMENT_BCS.
P_SUBJECT = 'TEST HTML EMAIL FROM SMARTFORM OUTPUT'.
TRY.
CALL METHOD CL_DOCUMENT_BCS=>CREATE_FROM_MULTIRELATED
EXPORTING
I_SUBJECT = P_SUBJECT
I_LANGUAGE = SY-LANGU
I_IMPORTANCE = '5'
I_SENSITIVITY = 'F'
I_MULTIREL_SERVICE = LO_MIME_HELPER
RECEIVING
RESULT = LO_DOC_BCS
CATCH CX_DOCUMENT_BCS INTO LV_DOCUMENT_BCS.
CATCH CX_BCOM_MIME INTO LV_BCOM_MIME.
CATCH CX_GBT_MIME INTO LV_GBT_MIME.
ENDTRY.
RECEIVERS
DATA: P_RECEIVERS TYPE TABLE OF SOMLRECI1,
RECEIVER TYPE SOMLRECI1,
L_MAIL_ADDRESS TYPE AD_SMTPADR,
LO_BCS TYPE REF TO CL_BCS,
LV_SEND_REQ_BCS TYPE REF TO CX_SEND_REQ_BCS,
L_USERNAME TYPE UNAME,
SEND_PARTNER TYPE BU_PARTNER,
LI_SENDER TYPE REF TO IF_SENDER_BCS,
LV_ADDRESS_BCS TYPE REF TO CX_ADDRESS_BCS,
LV_SENT_TO_ALL TYPE BOOLEAN.
CLEAR RECEIVER.
RECEIVER-RECEIVER = '[email protected]'.
RECEIVER-REC_TYPE = 'U'.
RECEIVER-COM_TYPE = 'INT'.
APPEND RECEIVER TO P_RECEIVERS.
L_USERNAME = SY-UNAME.
CLEAR RECEIVER.
LOOP AT P_RECEIVERS INTO RECEIVER.
L_MAIL_ADDRESS = RECEIVER-RECEIVER.
TRY.
CALL METHOD CL_BCS=>CREATE_PERSISTENT
RECEIVING
RESULT = LO_BCS
CALL METHOD LO_BCS->SET_DOCUMENT
EXPORTING
I_DOCUMENT = LO_DOC_BCS
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
CREATE SENDER
CLASS CL_CAM_ADDRESS_BCS DEFINITION LOAD.
TRY.
IF L_USERNAME NS '@'.
L_USERNAME = SEND_PARTNER.
TRANSLATE L_USERNAME TO UPPER CASE.
LI_SENDER ?= CL_SAPUSER_BCS=>CREATE( L_USERNAME ).
ELSE.
DATA: L_FROM_MAIL_ADDRESS TYPE AD_SMTPADR.
L_FROM_MAIL_ADDRESS = L_USERNAME.
LI_SENDER ?= CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS( I_ADDRESS_STRING = L_FROM_MAIL_ADDRESS ).
ENDIF.
CALL METHOD LO_BCS->SET_SENDER
EXPORTING
I_SENDER = LI_SENDER
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
create recepient
data: LO_RECEPIENT TYPE REF TO IF_RECIPIENT_BCS.
TRY.
CALL METHOD CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS
EXPORTING
I_ADDRESS_STRING = L_MAIL_ADDRESS
I_ADDRESS_NAME =
I_INCL_SAPUSER =
RECEIVING
RESULT = LO_RECEPIENT
CATCH CX_ADDRESS_BCS INTO LV_ADDRESS_BCS.
ENDTRY.
TRY.
CALL METHOD LO_BCS->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = LO_RECEPIENT
I_EXPRESS =
I_COPY =
I_BLIND_COPY =
I_NO_FORWARD =
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
SEND EMAIL DOCUMENT
TRY.
CALL METHOD LO_BCS->SEND_REQUEST->SET_REQUESTED_STATUS
EXPORTING
I_REQUESTED_STATUS = 'N'
TRY.
CALL METHOD LO_BCS->SEND
EXPORTING
I_WITH_ERROR_SCREEN = SPACE
RECEIVING
RESULT = LV_SENT_TO_ALL
CATCH CX_SEND_REQ_BCS INTO LV_SEND_REQ_BCS.
ENDTRY.
ENDTRY.
ENDLOOP.
COMMIT WORK.
Similar Messages
-
Dear all ,
I want to take smartform output in html format . the logos are not coming as well as the header template the records are coming in next line not side by side .my code is :
gs_output_options-xsfcmode = 'X'.
gs_output_options-xsf = 'X'.
gs_output_options-xsfoutmode = 'A'.
gs_output_options-xsfformat = 'X'.
xsfparam_line-name = 'GRAPHICS'.
xsfparam_line-value = 'EXTRACT'.
APPEND xsfparam_line TO gs_output_options-xsfpars.
xsfparam_line-name = 'GRAPHICS-DIRECTORY'.
xsfparam_line-value = c_gr_dir.
APPEND xsfparam_line TO gs_output_options-xsfpars.
xsfparam_line-name = 'CONTENT-ID'.
xsfparam_line-value = 'ENABLE'.
APPEND xsfparam_line TO gs_output_options-xsfpars.
CALL FUNCTION fm_name
EXPORTING
control_parameters = gs_ssfctrlop
output_options = gs_output_options
p_graphics[] = gs_job_output_info-xmloutput-xsfgr[].
p_html = gs_job_output_info-xmloutput-trfresult
CONCATENATE 'C:\TEST\TC1_' p_vbeln '.html' INTO p_file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = html_len
filename = p_file
filetype = 'BIN'"'ASC'
trunc_trailing_blanks = 'X'
TABLES
data_tab = p_html-content
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = p_fileThis question (logos and html smartform output) has been discussed several times related to email sending. Try searching the forum. You may find some relevant info in other posts. Have you tried reaching the url that's generated for the logo?
-
Hello,
I want to convert smartform output to html and send the output in an email body. I have followed the blog Sending HTML Email from SAP CRM/ERP and got the output in outlook but its not formatted correctly in other email clients. If any body else had same issues and was able to resolve, please suggest. Also I am trying to convert form spool output to html and send it but I am not able to use LIST_FROM_MEMORY Fm , its not returning the abap list table. So is there a way to convert form spool output to abap list?HI friend,
I am not having the exact solution for your requirement but i think this will help you a bit.
See this white paper in SND for sending mails in HTML format.
Link: [Sending mail with HTML attachment|http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/e009f97e-ee5d-2e10-31ba-9c9509e5925c?QuickLink=index&overridelayout=true]
I think this will help you. If you have any doubt in that white paper please revert back to me i will help you.
Thanks,
Sri Hari -
How to send smartform output in body of email?
Hi all ,
I have to send smartform output in body of email (not as an attachement in mail) .PLease help me in this regard.
Thanks,
Ananth S.Hi Ananth
See these threads.
[https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6889194]
[https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6861330]
[https://forums.sdn.sap.com/click.jspa?searchID=23497094&messageID=6855364]
Regards
Hareesh Menon -
Smartforms output in HTML format
Hi Experts,
I want to save my smartforms in HTML format.Is there any Standard programe is available for it.
Like as RSTXPDFT4 for converting output in PDF format.Hi,
Check this link.In that,I am converting the output of smartform to PDF and then attaching it through mail.
https://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap code samples/smartforms/smartform in abap.pdf -
Converting Smartforms output content into HTML File
Hi,
I have a requirement, Smartforms output contents needs be converted as HTML File and it should be sent as email.
I am able to get the Smartforms output in html format but the output is shown as binary format.
After the fm call the job_output_info parameter is holding the smartforms output content in
job_output_info-XMLOUTPUT[] (xsf content)
job_output_info-XMLOUTPUT-STSHEET[] (css content)
job_output_info-XMLOUTPUT-TRFRESULT[] (html content)
Help me out how to handle the job_output_info details to html format.
Code
DATA v_fm_name TYPE rs38l_fnam.
DATA v_tdsfname TYPE tdsfname VALUE 'ZVR39_SF'.
DATA output_options TYPE ssfcompop.
DATA job_output_info TYPE ssfcrescl.
DATA document_output_info TYPE ssfcrespd.
DATA job_output_options TYPE ssfcresop.
DATA w_control TYPE ssfctrlop.
*-Finding the Smartform Layout Name
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = v_tdsfname
IMPORTING
fm_name = v_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
*-Defining the output to HTML Format
*-Activating XSF Output
output_options-xdfcmode = 'X'.
output_options-xdf = space.
output_options-xsfcmode = 'X'.
output_options-xsf = 'X'.
output_options-xsfoutmode = 'A'. "
output_options-xsfoutdev = 'P863'.
output_options-xsfformat = 'X'.
*-Calling the Smartform Layout
CALL FUNCTION v_fm_name
EXPORTING
output_options = output_options
user_settings = 'X'
IMPORTING
document_output_info = document_output_info
job_output_info = job_output_info
job_output_options = job_output_options
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
GiriHi,
Check this link.In that,I am converting the output of smartform to PDF and then attaching it through mail.
https://sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap code samples/smartforms/smartform in abap.pdf -
How to send a SmartForm output as Email to external id?
I want the Smartform output to email to extrenal email-id.
I don't want the Smartform output as any kind of attachment, but the Smartform output needs to be shown on the main email body. Can anyone pls. help me out?First, thanks for your responses.
I haven't found the demo program 'BCS_EXAMPLE_6' in SAP 4.7. But then I got it in SAP 5.0 version. But this program only describes how to send Form output as PDF attachment with email. But this is well-known and I haven't asked for this. I want the Smartform output within the mail-body without attachment.
The weblog at "/people/pavan.bayyapu/blog/2005/08/30/sending-html-email-from-sap-crmerp seems a more logical one, though I have already tried it out. Here the html page creation and graphics load -- everything is going right. But this HTML page is being delivered as an Attachment within the email. The normal HTML Email is not coming. I think this technique wouldn't work with all mailing tools. Here in the weblog, Pavan has shown the example with Microsoft Outlook. But I have tested with Lotus Notes and Yahoo. And In both cases, the mail is coming with attached HTML file (in .mht format), but not as a notmal html mail without attachments. -
Smartform output to be send via Email
Hi Guys,
I have a custom report and output generated by Smartform, currently it is printing on printer.
My requirement is to sent this output to customer via Email.(email and perferred communication details are available from customer master)
We have a output management server which will receive this output and convert into PDF format and distribute this output to customer.
I would like to know what are the possible changes require on driver program.
Appriciate your help.
Regards
Pravin
Edited by: Pravin on Apr 16, 2008 9:23 PM
Edited by: Pravin on Apr 16, 2008 9:25 PMHi Pravin,
Check the following sample program. Smartform driver program. It helps you how to convert smartform output as PDF using function module CONVERT_OTF. Once it is converted mail can be sent through function module SO_NEW_DOCUMENT_ATT_SEND_API1.
Wherever u find MAI that should be mail.
REPORT zvenkat_smartform_via_mai.
*& Structures and Infotype Internal tables.
TABLES pernr.
INFOTYPES:
0000,
0001,
0002,
0006,
0022,
0023.
INCLUDE dbpnpmac.
*& Declaration part
* Types
TYPES:
BEGIN OF t_emp_info,
pernr TYPE pa0001-pernr,
ename TYPE pa0001-ename,
bukrs TYPE pa0001-bukrs,
persk TYPE pa0001-persk,
stell TYPE pa0001-stell,
gblnd TYPE pa0002-gblnd,
END OF t_emp_info,
BEGIN OF t_mard,
matnr TYPE mard-matnr,
werks TYPE mard-werks,
labst TYPE mard-labst,
meins TYPE mara-meins,
END OF t_mard.
* Work areas
DATA:
w_emp_info TYPE t_emp_info.
* Internal tables
DATA:
i_emp_info TYPE STANDARD TABLE OF t_emp_info,
i_mard TYPE STANDARD TABLE OF t_mard.
" Mai related declarations
"Variables
DATA :
g_sent_to_all TYPE sonv-flag,
g_tab_lines TYPE i.
"Types
TYPES:
t_document_data TYPE sodocchgi1,
t_packing_list TYPE sopcklsti1,
t_attachment TYPE solisti1,
t_body_msg TYPE solisti1,
t_receivers TYPE somlreci1,
t_pdf TYPE tline.
"Workareas
DATA :
w_document_data TYPE t_document_data,
w_packing_list TYPE t_packing_list,
w_attachment TYPE t_attachment,
w_body_msg TYPE t_body_msg,
w_receivers TYPE t_receivers,
w_pdf TYPE t_pdf.
"Internal Tables
DATA :
i_document_data TYPE STANDARD TABLE OF t_document_data,
i_packing_list TYPE STANDARD TABLE OF t_packing_list,
i_attachment TYPE STANDARD TABLE OF t_attachment,
i_body_msg TYPE STANDARD TABLE OF t_body_msg,
i_receivers TYPE STANDARD TABLE OF t_receivers,
i_pdf TYPE STANDARD TABLE OF t_pdf.
PARAMETERS:
p_mai_id(99) TYPE c.
*& Start-of-selection.
START-OF-SELECTION.
GET pernr.
PERFORM get_data.
PERFORM show_smartform.
*& End-of-selection.
END-OF-SELECTION.
*& Form get_data
FORM get_data .
rp-provide-from-last p0000 space pn-begda pn-endda.
rp-provide-from-last p0001 space pn-begda pn-endda.
rp-provide-from-last p0002 space pn-begda pn-endda.
MOVE-CORRESPONDING: p0000 TO w_emp_info,
p0001 TO w_emp_info,
p0002 TO w_emp_info.
SELECT matnr werks labst
FROM mard
INTO CORRESPONDING FIELDS OF TABLE i_mard.
ENDFORM. " get_data
*& Form show_smartform
FORM show_smartform .
DATA :
l_sform_name TYPE tdsfname,
l_fm_name TYPE rs38l_fnam.
DATA :
l_sf_control TYPE ssfctrlop,
l_sf_options TYPE ssfcompop.
DATA: i_otf LIKE itcoo OCCURS 100 WITH HEADER LINE.
* i_pdf LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: op_option TYPE ssfctrlop,
job_output TYPE ssfcrescl.
* op_option-getotf = 'X'.
l_sform_name = 'ZVENKAT_SMARTFORM'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = l_sform_name
IMPORTING
fm_name = l_fm_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.
ELSE.
CALL FUNCTION l_fm_name
EXPORTING
control_parameters = op_option
output_options = l_sf_options
w_emp_info = w_emp_info
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = job_output
TABLES
p0006 = p0006
p0022 = p0022
p0023 = p0023
i_mard = i_mard.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
TABLES
otf = job_output-otfdata
lines = i_pdf.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
PERFORM send_mai.
ENDIF.
ENDFORM. " show_smartform
*& Form send_mai
FORM send_mail .
"Subject of the mai.
w_document_data-obj_name = 'MAI_TO_HEAD'.
w_document_data-obj_descr = 'Regarding Mai Program by SAP ABAP'.
"Body of the mai
PERFORM build_body_of_mai
USING:space,
'Hi,',
'I am fine. How are you? How are you doing ? ',
'This program has been created to send simple mai',
'with Subject,Body with Address of the sender. ',
'Regards,',
'Venkat.O,',
'SAP HR Technical Consultant.'.
"Write Packing List for Body
DESCRIBE TABLE i_body_msg LINES g_tab_lines.
w_packing_list-head_start = 1.
w_packing_list-head_num = 0.
w_packing_list-body_start = 1.
w_packing_list-body_num = g_tab_lines.
w_packing_list-doc_type = 'RAW'.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Write Packing List for Attachment
w_packing_list-transf_bin = 'X'.
w_packing_list-head_start = 1.
w_packing_list-head_num = 1.
w_packing_list-body_start = 1.
DESCRIBE TABLE i_attachment LINES w_packing_list-body_num.
w_packing_list-doc_type = 'PDF'.
w_packing_list-obj_descr = 'PDF Attachment'.
w_packing_list-obj_name = 'PDF_ATTACHMENT'.
w_packing_list-doc_size = w_packing_list-body_num * 255.
APPEND w_packing_list TO i_packing_list.
CLEAR w_packing_list.
"Fill the document data and get size of attachment
w_document_data-obj_langu = sy-langu.
READ TABLE i_attachment INTO w_attachment INDEX g_tab_lines.
w_document_data-doc_size = ( g_tab_lines - 1 ) * 255 + STRLEN( w_attachment ).
"Receivers List.
w_receivers-rec_type = 'U'. "Internet address
w_receivers-receiver = p_mai_id. "here mai Id should be given
w_receivers-com_type = 'INT'.
w_receivers-notif_del = 'X'.
w_receivers-notif_ndel = 'X'.
APPEND w_receivers TO i_receivers .
CLEAR:w_receivers.
"Function module to send mai to Recipients
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_document_data
put_in_outbox = 'X'
commit_work = 'X'
IMPORTING
sent_to_all = g_sent_to_all
TABLES
packing_list = i_packing_list
contents_bin = i_attachment
contents_txt = i_body_msg
receivers = i_receivers
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.
IF sy-subrc = 0 .
MESSAGE i303(me) WITH 'Mai has been Successfully Sent.'.
ELSE.
WAIT UP TO 2 SECONDS.
"This program starts the SAPconnect send process.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ENDFORM. " send_mai
*& Form build_body_of_mai
* text
* -->L_MESSAGE text
FORM build_body_of_mai USING l_message.
w_body_msg = l_message.
APPEND w_body_msg TO i_body_msg.
CLEAR w_body_msg.
ENDFORM. " build_body_of_mai
I hope that it helps u .
Regards,
Venkat.O -
Urgent : Display logo in Smartform with XSF+ HTML as Output Format
Hi,
Through the Portal we are displaying ESS Salary Statement of a Employee for last 24 monthys in the iView using the Customized Smartform ZHR_ESS_PAYSLIP_TO_PDF which is copy of Standard Smartform HR_ESS_PAYSLIP_TO_PDF .
Requirement is that we have to change the Output Option to "XSF+HTML" and Display a logo at Top-Middle of the form.
But the problem is that Logo is only visible only when Output Option is "Standard Output". and not visible when Output Option is "XSF+HTML".
Please tell me how to display the Logo in the Smartform so that it is visible in "XSF+HTML" or "XSF" as Output Option.
Asnwers will be suitably rewarded.
Thanks,
Ajay JangidHi Ajay,
Following threads may help you
Smartforms to Xsf & Html format
/message/1484753#1484753 [original link is broken]
Regards,
Manoj -
To send smartform output in an email without attachment
Hi All,
How to send smartform output in an email without attachment?
Thanks & Regards,
Mamta Gupta.Try this,
DATA:
ls_control_param TYPE ssfctrlop, "Control paramters
ls_output_options TYPE ssfcompop. "Output options
DATA:
lv_ip_mailaddr TYPE so_name, "Address of a Mail Recipient
lv_ip_type_id TYPE so_escape, "Recipient type
ls_recipient_id TYPE swotobjid, "Structure for recvr obj ID
ls_sender_id TYPE swotobjid. "Structure for sender obj id
CONSTANTS:
lc_ip_type_id TYPE so_escape VALUE 'U', "For internet address.
lc_smartform TYPE tdsfname VALUE 'ZVSF_ASN_DELNOTE', "Smart form name
lc_mail TYPE tddevice VALUE 'MAIL'. "Mail device
Assign recipient
lv_ip_mailaddr = gv_smtp_addr. "CSAM email id
lv_ip_type_id = lc_ip_type_id. "External address
Create Mail title
CONCATENATE text-001
nast-objky
INTO ls_output_options-tdtitle.
Create recipient object
CALL FUNCTION 'CREATE_RECIPIENT_OBJ_PPF'
EXPORTING
ip_mailaddr = lv_ip_mailaddr
ip_type_id = lv_ip_type_id
IMPORTING
ep_recipient_id = ls_recipient_id
EXCEPTIONS
invalid_recipient = 1
OTHERS = 2.
IF sy-subrc 0.
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
Get sender object id.
CALL FUNCTION 'CREATE_SENDER_OBJECT_PPF'
EXPORTING
ip_sender = sy-uname
IMPORTING
ep_sender_id = ls_sender_id
EXCEPTIONS
invalid_sender = 1
OTHERS = 2.
IF sy-subrc 0.
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
Assign the smart form name
w_ssfname = lc_smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_ssfname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc 0.
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
For Print output:
IF nast-nacha = '1'. "Print output
ls_control_param-preview = 'X'.
ls_control_param-no_dialog = 'X'.
ENDIF.
For Email output.
IF nast-nacha = '2'. "Email
Output options
ls_output_options-tdteleland = gs_kna1-land1.
ls_output_options-tdtelenum = gs_kna1-telfx.
ls_output_options-tdfaxuser = sy-uname.
ls_output_options-BCS_COMMIT = 'X'.
ls_control_param-device = lc_mail.
ENDIF.
dynamically call Fm behind the Smart form
CALL FUNCTION lf_fm_name
EXPORTING
control_parameters = ls_control_param
mail_recipient = ls_recipient_id
mail_sender = ls_sender_id
output_options = ls_output_options
user_settings = ' '
TABLES
delivery = gt_delivery
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc 0.
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
Regards,
Joan -
Smartform output as Email.
Hi,
Can a smartform output be sent directly as a mail into SAP inbox with out converting it into .PDF format? Help needed regarding this.
Regards,
suresh.hi
it can be done. here's the code
report zhr_r_pdf_to_email message-id zmsg.
parameters: p_vbeln type vbak-vbeln default '35'.
data: it_items type table of vbap,
v_fm_name type rs38l_fnam,
v_tot_lines type i,
v_sy_tabix type i,
output_data type ssfcrescl. " To hold Output information
constants:
c_sep type c value '-', " Value -
c_x type c value 'X', " Value X
c_space type c value ' '. " Space
*****MAIL START
include .
data: g_mail_rec_obj type swotobjid,
g_mail_sen_obj type swotobjid,
g_mail_app_obj type swotobjid,
g_cont_par type ssfctrlop,
folder type swc_object,
begin of sofmfol_key,
foldertype like sofm-foltp,
folderyear like sofm-folyr,
foldernumber like sofm-folno,
type like sofm-doctp,
year like sofm-docyr,
number like sofm-docno,
forwarder like soub-usrnam,
end of sofmfol_key,
bor_key like swotobjid-objkey,
g_mail TYPE ppfdmailad VALUE '[email protected]',
g_mail type so_name value '[email protected]',
g_mail TYPE ppfdmailad VALUE '[email protected]' ,
g_mail TYPE ppfdmailad VALUE '[email protected]' ,
g_rectype type so_escape value 'U'. " 'B'.
data: job_output_info type ssfcrescl,
hotfdata like itcoo occurs 1 with header line,
htline like tline occurs 1 with header line,
x_objcont like soli occurs 1 with header line,
ld_packing_list like soxpl occurs 1 with header line,
x_object_hd_change like sood1 occurs 1 with header line,
x_objhead like soli occurs 1 with header line,
x_receivers like soos1 occurs 1 with header line,
format_pdf(10) value 'PDF',
doc_size(12) type c,
hltlines type i,
htabix like sy-tabix,
fle1(2) type p,
fle2(2) type p,
off1 type p,
hfeld(500) type c.
tables: soud.
*****MAIL END
select *
into table it_items
from vbap
where vbeln = p_vbeln.
if it_items[] is initial.
exit.
endif.
perform call_smartform.
*& Form call_smartform
text
--> p1 text
<-- p2 text
form call_smartform .
*DATA: lx_control_parameters TYPE SSFCTRLOP,
lx_OUTPUT_OPTIONS type SSFCOMPOP.
lx_OUTPUT_OPTIONS-TDIMMED = ' '.
lx_OUTPUT_OPTIONS-TDfinal = 'X'.
lx_OUTPUT_OPTIONS-TDDELETE = 'X'.
lx_CONTROL_PARAMETERS-NO_CLOSE = 'X'.
lx_CONTROL_PARAMETERS-NO_OPEN = ' '.
data: x_ssfcompop type ssfcompop,
x_ssfctrlop like ssfctrlop,
x_ssfcrescl type ssfcrescl.
**MAIL
g_cont_par-langu = sy-langu.
g_cont_par-no_dialog = 'X'.
g_cont_par-getotf = 'X'.
g_cont_par-device = 'MAIL'.
Get BOR-Objects for Recipient, Sender und Applikation
perform mail_recipient_object changing g_mail_rec_obj.
perform mail_sender_object changing g_mail_sen_obj.
perform mail_appl_object changing g_mail_app_obj.
**MAIL
*--Internal table is having more than 1 record
if v_tot_lines gt 1.
if v_sy_tabix = 1.
*--For first record of table
x_ssfctrlop-no_open = c_space.
x_ssfctrlop-no_close = c_x.
elseif v_sy_tabix = v_tot_lines.
*--For last record of table
x_ssfctrlop-no_open = c_x.
x_ssfctrlop-no_close = c_space.
else.
x_ssfctrlop-no_open = c_x.
x_ssfctrlop-no_close = c_x.
endif.
endif.
IF r_previ = c_x.
x_ssfctrlop-preview = c_x.
x_ssfctrlop-getotf = c_x.
ENDIF.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'YSSN_SMARTFORM'
VARIANT = ' '
DIRECT_CALL = ' '
importing
fm_name = v_fm_name
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
if sy-subrc <> 0.
message i000 with 'Smart form module name failure'.
exit.
endif.
CALL FUNCTION '/1BCDWB/SF00000199'
call function v_fm_name
exporting
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = g_cont_par
mail_appl_obj = g_mail_app_obj
mail_recipient = g_mail_rec_obj
mail_sender = g_mail_sen_obj
OUTPUT_OPTIONS = lx_OUTPUT_OPTIONS
USER_SETTINGS = 'X'
t_vbap = it_items
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = job_output_info
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
perform send_pdf_mail.
endform. " call_smartform
*& Form send_pdf_mail
text
--> p1 text
<-- p2 text
form send_pdf_mail .
data ld_binfile type xstring.
pdf_table type rcl_bag_tline,
data: ld_originator like soos1-recextnam.
convert form
loop at job_output_info-otfdata into hotfdata.
append hotfdata.
endloop.
call function 'CONVERT_OTF'
exporting
format = format_pdf
max_linewidth = 132
importing
bin_filesize = doc_size
bin_file = ld_binfile
tables
otf = output_data-otfdata
lines = htline
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
others = 4.
*-Itab 134 Zeichen nach 255 Zeichen überführen
describe table htline lines hltlines.
describe field htline length fle1 in character mode.
describe field x_objcont length fle2 in character mode.
loop at htline.
htabix = sy-tabix.
move htline to hfeld+off1.
if htabix = hltlines.
fle1 = strlen( htline ).
endif.
off1 = off1 + fle1.
if off1 ge fle2.
clear x_objcont.
x_objcont = hfeld(fle2).
append x_objcont.
shift hfeld by fle2 places.
off1 = off1 - fle2.
endif.
if htabix = hltlines.
if off1 gt 0.
clear x_objcont.
x_objcont = hfeld(off1).
append x_objcont.
endif.
endif.
endloop.
x_object_hd_change-objnam = 'EMAIL'.
x_object_hd_change-objdes = 'Smart Form'.
x_object_hd_change-objla = sy-langu.
x_object_hd_change-objsns = 'O'.
x_object_hd_change-objlen = doc_size.
x_object_hd_change-file_ext = 'TXT'.
ld_packing_list-transf_bin = 'X'.
ld_packing_list-head_start = 1.
ld_packing_list-head_num = 0.
ld_packing_list-body_start = 1.
describe table x_objcont lines ld_packing_list-body_num.
ld_packing_list-objtp = 'EXT'.
ld_packing_list-objdes = 'Smart Form'.
ld_packing_list-objla = sy-langu.
ld_packing_list-objlen = doc_size.
ld_packing_list-file_ext = 'PDF'.
append ld_packing_list.
x_receivers-recextnam = g_mail.
x_receivers-recesc = 'E'.
x_receivers-sndart = 'INT'.
append x_receivers.
ld_originator = '[email protected]'.
ld_originator = FSABE-USRNAM.
call function 'SO_OBJECT_SEND'
exporting
object_hd_change = x_object_hd_change
object_type = 'RAW'
originator_type = 'B' "Einfügen
originator = ld_originator "Einfügen
tables
objcont = ld_text
receivers = x_receivers
packing_list = ld_packing_list
att_cont = x_objcont
att_head = x_objhead
exceptions
active_user_not_exist = 1
communication_failure = 2
component_not_available = 3
folder_not_exist = 4
folder_no_authorization = 5
forwarder_not_exist = 6
note_not_exist = 7
object_not_exist = 8
object_not_sent = 9
object_no_authorization = 10
object_type_not_exist = 11
operation_no_authorization = 12
owner_not_exist = 13
parameter_error = 14
substitute_not_active = 15
substitute_not_defined = 16
system_failure = 17
too_much_receivers = 18
user_not_exist = 19
x_error = 20
others = 21.
endform. " send_pdf_mail
*& Form mail_sender_object
text
<--P_G_MAIL_SEN_OBJ text
form mail_sender_object changing p_mail_sen_obj.
call function 'CREATE_SENDER_OBJECT_PPF'
exporting
ip_sender = sy-uname
importing
ep_sender_id = p_mail_sen_obj
exceptions
invalid_sender = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " mail_sender_object
*& Form mail_appl_object
text
<--P_G_MAIL_APP_OBJ text
form mail_appl_object changing p_mail_app_obj.
SELECT * FROM soud WHERE sapnam LIKE sy-uname AND deleted = ' '.
ENDSELECT.
IF sy-subrc NE 0.
call function 'SO_USER_AUTOMATIC_INSERT'
exporting
sapname = sy-uname
exceptions
no_insert = 1
sap_name_exist = 2
x_error = 3
others = 4.
if sy-subrc ne 0.
clear soud.
else.
select * from soud where sapnam like sy-uname and deleted = ' '.
endselect.
endif.
ENDIF.
clear sofmfol_key.
sofmfol_key-type = 'FOL'.
sofmfol_key-year = soud-inbyr.
sofmfol_key-number = soud-inbno.
bor_key = sofmfol_key.
if not bor_key is initial.
swc_create_object folder 'SOFMFOL' bor_key.
if sy-subrc = 0.
swc_object_to_persistent folder p_mail_app_obj.
if sy-subrc ne 0.
clear p_mail_app_obj.
endif.
endif.
else.
clear p_mail_app_obj.
endif.
endform. " mail_appl_object
*& Form mail_recipient_object
text
<--P_G_MAIL_REC_OBJ text
form mail_recipient_object changing p_mail_rec_obj.
call function 'CREATE_RECIPIENT_OBJ_PPF'
exporting
IP_COUNTRY =
IP_FAXNO =
ip_mailaddr = g_mail
ip_type_id = g_rectype " 'U'
importing
ep_recipient_id = p_mail_rec_obj
EP_ADDRESS =
ET_RECIPIENT =
exceptions
invalid_recipient = 1
others = 2.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " mail_recipient_object
regards
Arun -
How to send smartform output through email
Hi,
I want to send smartform output through email.....
can u give me sample program to send it through email......
Regards,
Jenifer
MOderator Message: Basic and Frequently asked question. Please search before posting.
Edited by: kishan P on Nov 26, 2010 11:11 AMHi Jenifer,
There are many threads available on SDN.
Just have a look at this thread
<<link removed by moderator>>
Kindly search before you post.
Regard
Abhii
Moderator Message: You have been warned many times against point-hunting. Continuing ignoring of the Moderator warnings will lead to account deletion. Consider this your last warning
Edited by: kishan P on Nov 26, 2010 11:09 AM -
To send smartform output through email and fax
Hi,
I need to send smartform output through email if the email address is present else if the email address is present then it has to be sent through fax.If both the email address and fax are present,then it has to send an email.
Now the issue is I am able to send the email and I am getting the message as 'Output was successfully issued'.But the entry corresponding to this is not shown in SOST transaction.
Can anyone tell me what would be the reason for this?HI,
Try to look in transaction SCOT
Regards,
Egle -
Sending smartform output to external email id
here the issue is ,,'
in pa40..m
after changing the start date of pernr ...
if i click on save button i have to generate one smartform based on the pernr and bedga ..
after i have to send that smartform output to external email id dynamically ..
please help me in this...
Moderator message: please search for available information/documentation before asking, your posts are pain to read, use normal punctuation, capitalization, do not open multiple threads for the same issue.
[Asking Good Questions in the Forums to get Good Answers|/people/rob.burbank/blog/2010/05/12/asking-good-questions-in-the-forums-to-get-good-answers]
[Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
Edited by: Thomas Zloch on Nov 10, 2010 1:56 PMHi Swati,
Try to maintain an auto-forwarding email address for this user using transaction SO36 and check if that solves your problem.
Regards,
Jigar -
SAPFM06P - Can this program be used for triggering a Smartform Output??
Hi Experts!
I researched a lot and came to a conclusion that Program SAPFM06P can only be used trigger either a SAP SRIPT Output or a PDF FORM output. It cannot be used to trigger a SMARTFORM output directly as there is no code in it to trigger a SMARTFORM.
My understanding:
I will have to either create an Enhancement to the Program or a Zcopy of SAPFM06P where I need to write the logic in form routine ENTRY_NEU to call a SMARTFORM.
Please tell me if my understanding is correct and please guide me if there is any easier way to achieve the same functionality.
Thanks for help!
Greetings,
AmitHi,
U can Copy this standard Program to ZProgram and Insert the FM SSF_FUNCTIONMODULE_NAME and call ur smartform and assign the same combination to the Output type Given to u in NACE Transaction..
This is the Driver Program which I used for PO Smartform
[http://vjkvijaya.blogspot.com/2009/03/puchace-order-smartform-driver-program.html]
Regards,
Vijaya Lakshmi.T
Maybe you are looking for
-
A non-obsoleting multiversioning package management filesystem.
I found this in another topic (http://bbs.archlinux.org/viewtopic.php?id=56108), and found it very interesting, since I have conspired to do the same thing myself. The question that has always kept my attention is, "how to eliminate packages from bre
-
Best solutions for storing text, Word and pdf documents on iPad
I just switched from using a powerbook to an iPad + microkeyboard for my work computer (I'm freelance and need to bring my own device wherever I go), and I love the size and weight of it compared to a laptop. What I am glitching on is the fact that I
-
Can't get iphone to work due to zoom
Can I disable zoom? iTunes does not recognize my phone... it asked me to respond on my phone, but the phone isn't working due to the oversized cover photo Thanks for any help!
-
Material Groupwise authorization for purchase requisation creation
Gurus My client want to give authorization for creating purchase requisation - material groupwise. i.es for material group 1,2,3,4,5,purchase group 100 has the authority to create the PRs and for material group 6,7 & 9 it should be with purchase grou
-
Fix Untrusted Search Path Vulnrability in Office 2007 Power Point
We use Windows XP Pro SP3 on most our workstations and Win7 Pro SP1 on a few and Office 2007 SP3 on all workstations. We also use a third party software called LanGaurd to detect vulnerbilities on our workstations. And it is showing a vulnerability