on 04-05-2007 7:57 AM
Hi,
I have created a smartform for a standard transaction in CRM. Gave its name at proper place in the Configuration. The process is working fine but the smartform is coming as a PDF attachment in the mail. I want to display the form as a normal mail, so the PDF attachment is not required to be opened.
Any suggestion would be really appreciated. Thanks.
Regards,
Faiq
Hi,
We have a Procidure to send the PDF file as an attachment, at the same time in that mail, we also sends the Body of the mesage, so in that body, append all the data from the internal table which you are converting to the PDF and send that entire message in the BODY of the mail
Regards
Sudheer
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
I not using the smartform in the report to fill the date to it. I am just giving the smartform name is the configuration for a certain transaction. So I cannot apply code to it to send the email directly (not PDF). So is there any setting in the configuration that I could change to send the smartform directly to email (not as PDF attachment).
Any suggestion will be really appreciated. Thanks.
Regards,
Faiq
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Faiq,
Check this code.
REPORT zptpfrm202p_pogr_pr_instr MESSAGE-ID zmm.
----
TABLES *
----
Database table made for getting information about PRINTPREVIEW and
PRINT command more than one times
TABLES: zgr_table.
TYPE-POOLS:syscr.
----
GLOBAL TYPE DECLARATION *
----
DATA: zdoc_output_info TYPE ssfcrespd, "SF:Return Document Inf.
zjob_output_info TYPE ssfcrescl, "SF:Return value at end of
form printing
i_control TYPE ssfctrlop ,
i_output_options TYPE ssfcompop,
zjob_output_opts TYPE ssfcresop. "SF:Return value at start
of form printing
*This internal table is used for storing Document Segment: Material
DATA: BEGIN OF i_mseg.
INCLUDE STRUCTURE mseg.
DATA: END OF i_mseg.
This internal table is used for storing Header: Material Document
DATA: BEGIN OF i_mkpf.
INCLUDE STRUCTURE mkpf.
DATA: END OF i_mkpf.
*Variables
DATA flag(1) TYPE c.
DATA: vfile TYPE string.
----
SELECTION-SCREEN *
----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
PARAMETERS:p_mblnr TYPE mkpf-mblnr OBLIGATORY MATCHCODE OBJECT zganesh,
p_mjahr TYPE mkpf-mjahr OBLIGATORY MATCHCODE OBJECT zganesh1,
p_zeile TYPE mseg-zeile OBLIGATORY MATCHCODE OBJECT zganesh2.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETER:r_disp RADIOBUTTON GROUP g1 USER-COMMAND u1 DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 15(10) text-002 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETERS: r_down RADIOBUTTON GROUP g1.
SELECTION-SCREEN:COMMENT 15(10) text-003.
*PARAMETERS: v_file LIKE rlgrap-filename .
*SELECTION-SCREEN:COMMENT 70(50) text-005.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETERS: r_print RADIOBUTTON GROUP g1 .
SELECTION-SCREEN:COMMENT 15(10) text-004.
SELECTION-SCREEN END OF LINE.
PARAMETERS: v_file LIKE rlgrap-filename MODIF ID g12.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_file.
DATA : wlv_field_name LIKE dynpread-fieldname,
wlv_file_name LIKE ibipparms-path.
wlv_field_name = v_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = wlv_field_name
IMPORTING
file_name = wlv_file_name.
IF sy-subrc EQ 0.
vfile = wlv_file_name.
v_file = wlv_file_name.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'V_FILE'.
IF r_disp EQ 'X' OR r_print EQ 'X'.
screen-input = 0.
ELSE.
screen-input = '1'.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
----
START-OF-SELECTION EVENT *
----
START-OF-SELECTION.
----
CALLING CONVERSION FUNCTION MODULE 'CONVERSION_EXIT_ALPHA_INPUT' *
----
*Conversion function module for appending 00 befor MBLNR FIELD
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_mblnr
IMPORTING
output = p_mblnr.
Call subroutine for fetching data from database
PERFORM get_data.
----
END-OF-SELECTION EVENT *
----
END-OF-SELECTION.
Call subroutine for calling and processing smartform
PERFORM call_smartform.
&----
*& Form get_data
&----
Subroutine for fetching data from database
----
FORM get_data .
Fetching data from MKPF table with using parameters MBLNR and MJAHR
SELECT SINGLE * FROM mkpf
INTO i_mkpf
WHERE mblnr = p_mblnr
AND mjahr = p_mjahr.
IF sy-subrc EQ 0.
Fetching data from MSEG with using parameters MBLNR,ZEILE and MJAHR
SELECT SINGLE * FROM mseg
INTO i_mseg
WHERE mblnr = i_mkpf-mblnr
AND mjahr = i_mkpf-mjahr
AND zeile = p_zeile.
IF sy-subrc NE 0.
CLEAR i_mseg.
ENDIF.
ELSE.
MESSAGE i000.
EXIT.
ENDIF.
ENDFORM. " get_data
&----
*& Form call_smartform
&----
Subroutine for calling smartform
----
FORM call_smartform .
Local template used in the processing output of smartform
TYPES: BEGIN OF lt_ztable,
mandt TYPE sy-mandt,
mblnr TYPE mseg-mblnr,
flag(1) TYPE c,
END OF lt_ztable.
CONSTANTS: c_x(1) TYPE c VALUE 'X'.
Workarea
DATA: lw_ztable TYPE lt_ztable.
*Variable used in the smartform
DATA: lv_form(30) TYPE c,
lv_fm_name(30) TYPE c.
lv_form = 'ZPTPFRM202L_POGR'.
*Calling function module SSF_FUNCTION_MODULE_NAME which gives new name
*to the function module that will generated by smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_form
IMPORTING
fm_name = lv_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.
*Calling function module that will be generated by smartform
IF r_disp = c_x.
i_output_options-tdimmed = space.
i_output_options-tdnewid = c_x.
i_output_options-tddest = 'LOCL'.
i_control-no_dialog = 'X'.
i_control-preview = 'X'.
ELSEIF r_print = c_x.
i_output_options-tdimmed = c_x.
i_output_options-tddest = 'LOCL'.
i_control-no_dialog = c_x.
ELSE.
i_output_options-tdimmed = space.
i_output_options-tdnewid = c_x.
i_output_options-tddest = 'LOCL'.
i_control-getotf = 'X'.
i_control-preview = space.
i_control-no_dialog = c_x.
flag = c_x.
ENDIF.
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = i_control
output_options = i_output_options
user_settings = space
zmkpf = i_mkpf
zmseg = i_mseg
IMPORTING
document_output_info = zdoc_output_info
job_output_info = zjob_output_info
job_output_options = zjob_output_opts
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.
Modify the database table if it found the print command
IF zjob_output_opts-tdpreview NE c_x.
lw_ztable-mandt = sy-mandt.
lw_ztable-mblnr = p_mblnr.
lw_ztable-flag = c_x.
MODIFY zgr_table FROM lw_ztable.
CLEAR lw_ztable.
ENDIF.
IF flag EQ c_x.
DATA: li_lines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: lv_file TYPE string,
lbin_fsiz TYPE i.
lv_file = v_file.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lbin_fsiz
TABLES
otf = zjob_output_info-otfdata
lines = li_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lbin_fsiz
filename = lv_file
filetype = 'BIN'
TABLES
data_tab = li_lines
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " call_smartform
Hope this resolves your query.
Reward all the helpful answers.
Regards
Hi Faiq,
Check this code and modify your program accordingly.
REPORT zptpfrm202p_pogr_pr_instr MESSAGE-ID zmm.
----
TABLES *
----
Database table made for getting information about PRINTPREVIEW and
PRINT command more than one times
TABLES: zgr_table.
TYPE-POOLS:syscr.
----
GLOBAL TYPE DECLARATION *
----
DATA: zdoc_output_info TYPE ssfcrespd, "SF:Return Document Inf.
zjob_output_info TYPE ssfcrescl, "SF:Return value at end of
form printing
i_control TYPE ssfctrlop ,
i_output_options TYPE ssfcompop,
zjob_output_opts TYPE ssfcresop. "SF:Return value at start
of form printing
*This internal table is used for storing Document Segment: Material
DATA: BEGIN OF i_mseg.
INCLUDE STRUCTURE mseg.
DATA: END OF i_mseg.
This internal table is used for storing Header: Material Document
DATA: BEGIN OF i_mkpf.
INCLUDE STRUCTURE mkpf.
DATA: END OF i_mkpf.
*Variables
DATA flag(1) TYPE c.
DATA: vfile TYPE string.
----
SELECTION-SCREEN *
----
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-000.
PARAMETERS:p_mblnr TYPE mkpf-mblnr OBLIGATORY MATCHCODE OBJECT zganesh,
p_mjahr TYPE mkpf-mjahr OBLIGATORY MATCHCODE OBJECT zganesh1,
p_zeile TYPE mseg-zeile OBLIGATORY MATCHCODE OBJECT zganesh2.
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETER:r_disp RADIOBUTTON GROUP g1 USER-COMMAND u1 DEFAULT 'X'.
SELECTION-SCREEN:COMMENT 15(10) text-002 .
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETERS: r_down RADIOBUTTON GROUP g1.
SELECTION-SCREEN:COMMENT 15(10) text-003.
*PARAMETERS: v_file LIKE rlgrap-filename .
*SELECTION-SCREEN:COMMENT 70(50) text-005.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 10.
PARAMETERS: r_print RADIOBUTTON GROUP g1 .
SELECTION-SCREEN:COMMENT 15(10) text-004.
SELECTION-SCREEN END OF LINE.
PARAMETERS: v_file LIKE rlgrap-filename MODIF ID g12.
SELECTION-SCREEN END OF BLOCK b2.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR v_file.
DATA : wlv_field_name LIKE dynpread-fieldname,
wlv_file_name LIKE ibipparms-path.
wlv_field_name = v_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = wlv_field_name
IMPORTING
file_name = wlv_file_name.
IF sy-subrc EQ 0.
vfile = wlv_file_name.
v_file = wlv_file_name.
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
IF screen-name = 'V_FILE'.
IF r_disp EQ 'X' OR r_print EQ 'X'.
screen-input = 0.
ELSE.
screen-input = '1'.
ENDIF.
MODIFY SCREEN.
ENDIF.
ENDLOOP.
----
START-OF-SELECTION EVENT *
----
START-OF-SELECTION.
----
CALLING CONVERSION FUNCTION MODULE 'CONVERSION_EXIT_ALPHA_INPUT' *
----
*Conversion function module for appending 00 befor MBLNR FIELD
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_mblnr
IMPORTING
output = p_mblnr.
Call subroutine for fetching data from database
PERFORM get_data.
----
END-OF-SELECTION EVENT *
----
END-OF-SELECTION.
Call subroutine for calling and processing smartform
PERFORM call_smartform.
&----
*& Form get_data
&----
Subroutine for fetching data from database
----
FORM get_data .
Fetching data from MKPF table with using parameters MBLNR and MJAHR
SELECT SINGLE * FROM mkpf
INTO i_mkpf
WHERE mblnr = p_mblnr
AND mjahr = p_mjahr.
IF sy-subrc EQ 0.
Fetching data from MSEG with using parameters MBLNR,ZEILE and MJAHR
SELECT SINGLE * FROM mseg
INTO i_mseg
WHERE mblnr = i_mkpf-mblnr
AND mjahr = i_mkpf-mjahr
AND zeile = p_zeile.
IF sy-subrc NE 0.
CLEAR i_mseg.
ENDIF.
ELSE.
MESSAGE i000.
EXIT.
ENDIF.
ENDFORM. " get_data
&----
*& Form call_smartform
&----
Subroutine for calling smartform
----
FORM call_smartform .
Local template used in the processing output of smartform
TYPES: BEGIN OF lt_ztable,
mandt TYPE sy-mandt,
mblnr TYPE mseg-mblnr,
flag(1) TYPE c,
END OF lt_ztable.
CONSTANTS: c_x(1) TYPE c VALUE 'X'.
Workarea
DATA: lw_ztable TYPE lt_ztable.
*Variable used in the smartform
DATA: lv_form(30) TYPE c,
lv_fm_name(30) TYPE c.
lv_form = 'ZPTPFRM202L_POGR'.
*Calling function module SSF_FUNCTION_MODULE_NAME which gives new name
*to the function module that will generated by smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_form
IMPORTING
fm_name = lv_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.
*Calling function module that will be generated by smartform
IF r_disp = c_x.
i_output_options-tdimmed = space.
i_output_options-tdnewid = c_x.
i_output_options-tddest = 'LOCL'.
i_control-no_dialog = 'X'.
i_control-preview = 'X'.
ELSEIF r_print = c_x.
i_output_options-tdimmed = c_x.
i_output_options-tddest = 'LOCL'.
i_control-no_dialog = c_x.
ELSE.
i_output_options-tdimmed = space.
i_output_options-tdnewid = c_x.
i_output_options-tddest = 'LOCL'.
i_control-getotf = 'X'.
i_control-preview = space.
i_control-no_dialog = c_x.
flag = c_x.
ENDIF.
CALL FUNCTION lv_fm_name
EXPORTING
control_parameters = i_control
output_options = i_output_options
user_settings = space
zmkpf = i_mkpf
zmseg = i_mseg
IMPORTING
document_output_info = zdoc_output_info
job_output_info = zjob_output_info
job_output_options = zjob_output_opts
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.
Modify the database table if it found the print command
IF zjob_output_opts-tdpreview NE c_x.
lw_ztable-mandt = sy-mandt.
lw_ztable-mblnr = p_mblnr.
lw_ztable-flag = c_x.
MODIFY zgr_table FROM lw_ztable.
CLEAR lw_ztable.
ENDIF.
IF flag EQ c_x.
DATA: li_lines LIKE tline OCCURS 100 WITH HEADER LINE.
DATA: lv_file TYPE string,
lbin_fsiz TYPE i.
lv_file = v_file.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lbin_fsiz
TABLES
otf = zjob_output_info-otfdata
lines = li_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 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.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lbin_fsiz
filename = lv_file
filetype = 'BIN'
TABLES
data_tab = li_lines
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. " call_smartform
Hope this resolves your query.
Reward all the helpful answers.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
you would be getting all the data in OTF format of the smartform .
Then you can convert it into RAW data .
SX_OBJECT_CONVERT_OTF_RAW
Then you can use simple mail sending Function module to send the mail .
Regards
Saurabh garg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.