on 08-20-2008 9:06 AM
Hi Gurus
Plz let me know how can we convert a smartform to PDF and send a email .
what are the possibilities of doing the same as Adobe forms and where can we do that
Pol
Try this example link, https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8cd6adbb-0301-0010-39ba-938c601d...
rgds,
Sairam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here You can find the sample of working code.
Just change come parameters in order to suit You.
*some data
*please check which You need there is some thing that is not *usefull
data lv_string type string.
data main_text type bcsy_text.
data binary_content type solix_tab.
data size type so_obj_len.
* event handler for data retrieval
data: l_devtype type rspoptype,
l_function_module_name type rs38l_fnam.
data: ls_output_options type ssfcompop,
ls_control_parameters type ssfctrlop.
data: ls_output_data type ssfcrescl.
* generated result: HTML with embedded CSS
data: ls_xmloutput type ssfxmlout,
lt_html_raw type tsfixml.
data: l_xstring type xstring, "needed for HTTP response
l_xlength type i,
l_html_xstring type xstring.
data: l_pdf_xstring type xstring,
lt_lines type table of tline,
ls_line type tline,
l_pdf_len type i.
data:
solix TYPE solix,
soli type soli.
DATA send_request TYPE REF TO cl_bcs.
DATA text TYPE bcsy_text.
DATA document TYPE REF TO cl_document_bcs.
DATA recipient TYPE REF TO if_recipient_bcs.
DATA sent_to_all TYPE os_boolean.
DATA pdf_content TYPE solix_tab.
DATA lp_pdf_size TYPE so_obj_len.
*here we make the smartform and convert it to pdf
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = sy-langu
* i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = l_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid type sy-msgty number sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_output_options-tdprinter = l_devtype.
CALL FUNCTION l_function_module_name
EXPORTING
* archive_index =
* archive_parameters =
control_parameters = ls_control_parameters
* mail_appl_obj = APPL_OBJECT_ID
* mail_recipient = RECIPIENT_ID
* mail_sender = SENDER_ID
output_options = ls_output_options
user_settings = space
iv_werks = i_werks
iv_datum = i_date
IMPORTING
* document_output_info =
job_output_info = ls_output_data
* job_output_options =
TABLES
im_matnr = application->IT_MATERIAL
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
IF sy-subrc NE 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'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
IMPORTING
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring " binary file
TABLES
otf = ls_output_data-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
others = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid type sy-msgty number sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*and here we mail it
send_request = cl_bcs=>create_persistent( ).
lp_pdf_size = XSTRLEN( l_pdf_xstring ).
pdf_content = cl_document_bcs=>xstring_to_solix( ip_xstring = l_pdf_xstring ).
document = cl_document_bcs=>create_document( i_type = 'PDF'
i_hex = pdf_content
i_length = lp_pdf_size
i_subject = 'Test Message' ).
send_request->set_document( document ).
recipient = cl_cam_address_bcs=>create_internet_address(
i_address_string = 'YOUR-EMAIL-HERE' ).
send_request->add_recipient( i_recipient = recipient ).
sent_to_all = send_request->send( i_with_error_screen = 'X' ).
COMMIT WORK.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.