Error send a smartform PDF by Email to Vendor
Hi Expert,
Please help me.........................
I want to send a PO (Smartform) as Email to Vendor.
In SAPScript the PO send by Email is working fine, but in Smartforms it is not working.
Normally, I will use via Smartforms the Program = YBAA_FM06P, FORM routine = ENTRY_NEU, PDF/Smartform Form = ZYBAA_MMPO1.
A communication strategy has communication type as INT has been defined.
This communication strategy has been set as default in the output type ZNEU. The transmission medium has been set to 5 (External Send) and the partner function as VN (Vendor).
The e-mail address of the vendor has also been maintained.
In transaction MN04, i have also made an entry for output type ZNEU and set the document type as NB.
But message output do not create.
How to send a smartform PDF by Email to vendor?
Thanks,
Hi,
I can convert the PO output in to PDF from SOST I can sent it to external vendor using the Mail triggering configuration settings but meassage output do not create.
Please tell me how can I do.
Thank,
Similar Messages
-
Problem in sending the smartform as an email in a country specific language
Hi,
I am facing a problem in sending a smartform as a email for all other Languages except english and another problem is its sending the email but the output status is still in RED in the messages tab.
the program is working fine for english.
Please do find the below code using which i would be sending the smartform as an email for a PO along with the line item attachments.
Please help.
Arun.
Determine smartform function module for purchase document
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
error handling
ent_retco = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(/smb40/ssfcomposer) WITH tnapr-sform.
ENDIF.
PERFORM protocol_update_i.
ENDIF.
*Start of changes <Arun K Singarapu> C082493 <04/28/2008>
*for print preview
IF sy-ucomm = 'PREVOUTPUT' OR sy-ucomm = 'VIEW'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
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.
EXIT.
ELSE.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
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.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.
get the attachments of the PO for each line item
SELECT ebeln
ebelp
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln = l_doc-xekko-ebeln.
concatenate PO and the Line Item Numebr to get the Object key
LOOP AT it_ekpo INTO wa_ekpo.
CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO wa_temp-objky.
APPEND wa_temp TO it_temp.
CLEAR: wa_temp,wa_ekpo.
ENDLOOP.
*Get data from table DRAD
IF it_temp[] IS NOT INITIAL.
SELECT dokar
doknr
dokvr
doktl
objky
FROM drad
client specified
INTO TABLE it_drad
FOR ALL ENTRIES IN it_temp
WHERE mandt = sy-mandt
AND objky = it_temp-objky.
ENDIF.
IF NOT it_drad IS INITIAL.
SELECT * FROM dms_doc2loio
INTO TABLE it_dms_doc2loio
FOR ALL ENTRIES IN it_drad
WHERE dokar = 'SRM'
AND doknr = it_drad-doknr
AND dokvr = it_drad-dokvr
AND doktl = it_drad-doktl.
ENDIF.
Get the Physical object class and Object ID of the attachment
IF NOT it_dms_doc2loio IS INITIAL.
SELECT * FROM dms_ph_cd1
INTO TABLE it_dms_ph_cd1
FOR ALL ENTRIES IN it_dms_doc2loio
WHERE loio_id = it_dms_doc2loio-lo_objid.
ENDIF.
Get the file from the DMS server using the below function module.
LOOP AT it_dms_ph_cd1 INTO wa_dms_ph_cd1.
wa_object_id-class = wa_dms_ph_cd1-ph_class.
wa_object_id-objid = wa_dms_ph_cd1-phio_id.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
TABLES
file_access_info = it_file_access_info
file_content_binary = it_sdokcntbin
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_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.
READ TABLE it_file_access_info INTO wa_file_access_info INDEX 1.
IF wa_file_access_info-mimetype = 'application/msword'.
l_doc_type = 'DOC'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for PDF document
ELSEIF wa_file_access_info-mimetype = 'application/pdf'.
l_doc_type = 'PDF'.
file_size = wa_file_access_info-file_size.
Convert the 1022 binary data to xstring
CLEAR a_xstring.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = file_size
IMPORTING
buffer = a_xstring
TABLES
binary_tab = it_sdokcntbin
EXCEPTIONS
failed = 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.
DATA: w_output_length TYPE i.
Convert Xstring to 255 RAW
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = a_xstring
IMPORTING
output_length = w_output_length
TABLES
binary_tab = lt_content_bin.
len = w_output_length.
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_content_bin
type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for Excel Document
ELSEIF wa_file_access_info-mimetype = 'application/msexcel'.
l_doc_type = 'XLS'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for text doxument
ELSEIF wa_file_access_info-mimetype = 'plain/text'.
l_doc_type = 'TXT'.
file_size = wa_file_access_info-file_size.
Get the file name
l_filename = wa_file_access_info-file_name.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = file_size
TABLES
binary_tab = it_sdokcntbin
text_tab = file_data
EXCEPTIONS
failed = 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.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = l_doc_type
i_subject = l_filename
i_text = file_data
RECEIVING
result = bcs_doc1.
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
ENDIF.
CLEAR:it_file_access_info,it_sdokcntbin.
CLEAR:wa_object_id,wa_file_access_info,file_size.
ENDLOOP.
CALL METHOD send_request->set_document( l_email_object ).
*Get the address number for the vendor
SELECT SINGLE adrnr
FROM lfa1
INTO l_adrnr
WHERE lifnr = l_doc-xekko-lifnr.
MOVE l_adrnr TO l_addrno.
Get the Email Address for the vendor using address number
CALL FUNCTION 'ADDR_GET_REMOTE'
EXPORTING
addrnumber = l_addrno
TABLES
adsmtp = it_adsmtp
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flg_nouse = 'X'.
IF sy-subrc = 0.
LOOP AT it_adsmtp INTO wa_adsmtp WHERE flg_nouse = 'X'.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
ELSE.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flgdefault = 'X'.
IF sy-subrc = 0.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDIF.
ENDIF.
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_sent_to_all ).
CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.
ENDTRY.
ENDIF.Hi,
I am facing a problem in sending a smartform as a email for all other Languages except english and another problem is its sending the email but the output status is still in RED in the messages tab.
the program is working fine for english.
Please do find the below code using which i would be sending the smartform as an email for a PO along with the line item attachments.
Please help.
Arun.
Determine smartform function module for purchase document
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
error handling
ent_retco = sy-subrc.
IF sy-subrc = 1.
MESSAGE e001(/smb40/ssfcomposer).
ENDIF.
IF sy-subrc = 2.
MESSAGE e002(/smb40/ssfcomposer) WITH tnapr-sform.
ENDIF.
PERFORM protocol_update_i.
ENDIF.
*Start of changes <Arun K Singarapu> C082493 <04/28/2008>
*for print preview
IF sy-ucomm = 'PREVOUTPUT' OR sy-ucomm = 'VIEW'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
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.
EXIT.
ELSE.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
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.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.
get the attachments of the PO for each line item
SELECT ebeln
ebelp
FROM ekpo
INTO TABLE it_ekpo
WHERE ebeln = l_doc-xekko-ebeln.
concatenate PO and the Line Item Numebr to get the Object key
LOOP AT it_ekpo INTO wa_ekpo.
CONCATENATE wa_ekpo-ebeln wa_ekpo-ebelp INTO wa_temp-objky.
APPEND wa_temp TO it_temp.
CLEAR: wa_temp,wa_ekpo.
ENDLOOP.
*Get data from table DRAD
IF it_temp[] IS NOT INITIAL.
SELECT dokar
doknr
dokvr
doktl
objky
FROM drad
client specified
INTO TABLE it_drad
FOR ALL ENTRIES IN it_temp
WHERE mandt = sy-mandt
AND objky = it_temp-objky.
ENDIF.
IF NOT it_drad IS INITIAL.
SELECT * FROM dms_doc2loio
INTO TABLE it_dms_doc2loio
FOR ALL ENTRIES IN it_drad
WHERE dokar = 'SRM'
AND doknr = it_drad-doknr
AND dokvr = it_drad-dokvr
AND doktl = it_drad-doktl.
ENDIF.
Get the Physical object class and Object ID of the attachment
IF NOT it_dms_doc2loio IS INITIAL.
SELECT * FROM dms_ph_cd1
INTO TABLE it_dms_ph_cd1
FOR ALL ENTRIES IN it_dms_doc2loio
WHERE loio_id = it_dms_doc2loio-lo_objid.
ENDIF.
Get the file from the DMS server using the below function module.
LOOP AT it_dms_ph_cd1 INTO wa_dms_ph_cd1.
wa_object_id-class = wa_dms_ph_cd1-ph_class.
wa_object_id-objid = wa_dms_ph_cd1-phio_id.
CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'
EXPORTING
object_id = wa_object_id
client = sy-mandt
TABLES
file_access_info = it_file_access_info
file_content_binary = it_sdokcntbin
EXCEPTIONS
not_existing = 1
not_authorized = 2
no_content = 3
bad_storage_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.
READ TABLE it_file_access_info INTO wa_file_access_info INDEX 1.
IF wa_file_access_info-mimetype = 'application/msword'.
l_doc_type = 'DOC'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for PDF document
ELSEIF wa_file_access_info-mimetype = 'application/pdf'.
l_doc_type = 'PDF'.
file_size = wa_file_access_info-file_size.
Convert the 1022 binary data to xstring
CLEAR a_xstring.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = file_size
IMPORTING
buffer = a_xstring
TABLES
binary_tab = it_sdokcntbin
EXCEPTIONS
failed = 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.
DATA: w_output_length TYPE i.
Convert Xstring to 255 RAW
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = a_xstring
IMPORTING
output_length = w_output_length
TABLES
binary_tab = lt_content_bin.
len = w_output_length.
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_content_bin
type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for Excel Document
ELSEIF wa_file_access_info-mimetype = 'application/msexcel'.
l_doc_type = 'XLS'.
CLEAR: a_xstring,len.
LOOP AT it_sdokcntbin INTO wa_sdokcntbin.
CONCATENATE a_xstring wa_sdokcntbin-line
INTO a_xstring IN BYTE MODE.
ENDLOOP.
len = XSTRLEN( a_xstring ).
transform to solix tab - adding additional attachments
REFRESH lt_solix.
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = a_xstring ).
CLEAR l_filename.
Get the file name
l_filename = wa_file_access_info-file_name.
bcs_doc1 = cl_document_bcs=>create_document(
i_type = l_doc_type
i_subject = l_filename
i_length = len
i_language = sy-langu
i_hex = lt_solix
*Type casting
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
for text doxument
ELSEIF wa_file_access_info-mimetype = 'plain/text'.
l_doc_type = 'TXT'.
file_size = wa_file_access_info-file_size.
Get the file name
l_filename = wa_file_access_info-file_name.
CALL FUNCTION 'SCMS_BINARY_TO_TEXT'
EXPORTING
input_length = file_size
TABLES
binary_tab = it_sdokcntbin
text_tab = file_data
EXCEPTIONS
failed = 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.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = l_doc_type
i_subject = l_filename
i_text = file_data
RECEIVING
result = bcs_doc1.
obj_file ?= bcs_doc1.
Add Attachment as a document to the email object
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_file.
ENDIF.
CLEAR:it_file_access_info,it_sdokcntbin.
CLEAR:wa_object_id,wa_file_access_info,file_size.
ENDLOOP.
CALL METHOD send_request->set_document( l_email_object ).
*Get the address number for the vendor
SELECT SINGLE adrnr
FROM lfa1
INTO l_adrnr
WHERE lifnr = l_doc-xekko-lifnr.
MOVE l_adrnr TO l_addrno.
Get the Email Address for the vendor using address number
CALL FUNCTION 'ADDR_GET_REMOTE'
EXPORTING
addrnumber = l_addrno
TABLES
adsmtp = it_adsmtp
EXCEPTIONS
parameter_error = 1
address_not_exist = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
sender = cl_sapuser_bcs=>create( sy-uname ).
CALL METHOD send_request->set_sender
EXPORTING
i_sender = sender.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flg_nouse = 'X'.
IF sy-subrc = 0.
LOOP AT it_adsmtp INTO wa_adsmtp WHERE flg_nouse = 'X'.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDLOOP.
ELSE.
READ TABLE it_adsmtp INTO wa_adsmtp WITH KEY flgdefault = 'X'.
IF sy-subrc = 0.
CALL METHOD cl_cam_address_bcs=>create_internet_address
EXPORTING
i_address_string = wa_adsmtp-smtp_addr
RECEIVING
result = recipient.
CALL METHOD send_request->add_recipient
EXPORTING
i_recipient = recipient
i_express = 'X'.
ENDIF.
ENDIF.
CALL METHOD send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = l_sent_to_all ).
CATCH cx_bcs INTO bcs_exception.
WRITE: 'Fehler aufgetreten.'(001).
WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
EXIT.
ENDTRY.
ENDIF. -
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. -
Sending Invoice as PDF in email
Hello,
I have a requirement where I have to send Proforma Invoice as PDF in email.
Now, the Proforma Invoice is already using output type to Print and when I see the routines in Tcode NACE
It uses RVADAUS1 Program where it calls RV_EXPORT_DOCUMENT_PRINT function module to generate the Print document.
This works fine.
So, I created a new output type, copied the RVADAUS1 to ZRVADAUS1 and modified the code where I am capturing the Spool generated through the original code and pass it to CONVERT_ABAPSPOOLJOB_2_PDF to convert it to PDF and then send it as an email.
Now, the problem I am facing is that, I am not able to generate a Spool when I am using the medium ( '5' External Send ). So the further code of capturing Spool and convert to PDF and send as email fails.
Any guidance is appreciated.
Regards,
DNPHi Sudhanshu,
Just before calling the function module RV_EXPORT_DOCUMENT_PRINT.
I forced TNAPR-NACHA = '1'. and NAST-NACHA = '1'.
which means I forced Transmission medium as 1(Print) instead of 5(External Send)
This created a SPOOL.
Regards,
DNP
Edited by: DNP on Aug 14, 2009 11:45 AM -
How to send a SMARTFORM as an email ?
Hello,
How can we send a smart form as an email?
Please explain with an exmaple.
ANy proper explonation will be appreciated...
Have a great day!
Thanks & Regards,
Krishna ChaitanyaHi Krishna,
When you pass the values to the Smartform by using the Function Module name of the Smartform, it will return you thr OTF format of the Smartform in the Importing Parameter 'job_output_info'. The following code will help you regarding the mail sending part:
If you still need help, Please let me know.If helpfull reward me points.*
TYPES: BEGIN OF tp_lips,
vbeln LIKE lips-vbeln,
posnr LIKE lips-posnr,
matnr LIKE lips-matnr,
lfimg LIKE lips-lfimg,
vgbel LIKE lips-vgbel,
vgpos LIKE lips-vgpos,
uecha LIKE lips-uecha,
END OF tp_lips,
BEGIN OF tp_vbap,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
matnr LIKE vbap-matnr,
kbmeng LIKE vbap-kbmeng,
werks LIKE vbap-werks,
END OF tp_vbap,
BEGIN OF tp_lips_tmp ,
uecha LIKE lips-uecha,
vbeln LIKE lips-vbeln,
posnr LIKE lips-posnr,
matnr LIKE lips-matnr,
lfimg LIKE lips-lfimg,
vgbel LIKE lips-vgbel,
vgpos LIKE lips-vgpos,
END OF tp_lips_tmp,
BEGIN OF tp_lips_split ,
uecha LIKE lips-uecha,
vbeln LIKE lips-vbeln,
posnr LIKE lips-posnr,
matnr LIKE lips-matnr,
lfimg LIKE lips-lfimg,
vgbel LIKE lips-vgbel,
vgpos LIKE lips-vgpos,
END OF tp_lips_split.
CONSTANTS : c_5(1) TYPE c VALUE '5',
c_otf(3) TYPE c VALUE 'OTF',
c_printer(7) TYPE c VALUE 'PRINTER',
c_x(1) TYPE c VALUE 'X',
c_pdf(3) TYPE c VALUE 'PDF',
c_o(1) TYPE c VALUE 'O',
c_mail(5) TYPE c VALUE 'EMAIL' ,
c_e TYPE so_escape VALUE 'E',
c_int TYPE tddevice VALUE 'INT' ,
c_ext(3) TYPE c VALUE 'EXT',
c_raw(3) TYPE c VALUE 'RAW',
c_b LIKE soos1-recesc VALUE 'B'.
DATA: ls_print_data_to_read TYPE ledlv_print_data_to_read.
DATA: ls_dlv_delnote TYPE ledlv_delnote.
DATA: lf_fm_name TYPE rs38l_fnam.
DATA: ls_control_param TYPE ssfctrlop.
DATA: ls_composer_param TYPE ssfcompop.
DATA: ls_recipient TYPE swotobjid.
DATA: ls_sender TYPE swotobjid.
DATA: lf_formname TYPE tdsfname.
DATA: ls_addr_key LIKE addr_key.
DATA: l_w_object_hd_change TYPE sood1,
l_w_header LIKE sood1-objdes.
*--Binary Data
DATA: BEGIN OF l_t_solix OCCURS 0.
INCLUDE STRUCTURE solix.
DATA: END OF l_t_solix.
*--Content to be mailed
DATA: BEGIN OF l_t_objcont OCCURS 0.
INCLUDE STRUCTURE soli.
DATA: END OF l_t_objcont.
*--PDF Data
DATA: BEGIN OF l_t_htline OCCURS 10.
INCLUDE STRUCTURE tline.
DATA: END OF l_t_htline.
DATA: BEGIN OF l_t_object_hd_change.
INCLUDE STRUCTURE sood1.
DATA: END OF l_t_object_hd_change.
*-- Recipient table with send attributes
DATA: BEGIN OF l_t_receivers OCCURS 0.
INCLUDE STRUCTURE soos1.
DATA: END OF l_t_receivers.
DATA: BEGIN OF l_t_objhead OCCURS 0.
INCLUDE STRUCTURE soli.
DATA: END OF l_t_objhead.
DATA: l_t_lips TYPE tp_lips OCCURS 0 WITH HEADER LINE,
l_t_vbap TYPE tp_vbap OCCURS 0 WITH HEADER LINE,
l_t_lips_tmp TYPE tp_lips_tmp OCCURS 0 WITH HEADER LINE,
l_t_lips_split TYPE tp_lips_split OCCURS 0 WITH HEADER LINE.
DATA : l_v_document_number TYPE likp-vbeln,
l_t_ssfcrespd TYPE ssfcrespd,
l_t_ssfcrescl TYPE ssfcrescl,
l_t_ssfcresop TYPE ssfcresop,
l_v_adrnr TYPE kna1-adrnr,
l_v_ls_address TYPE szadr_addr1_complete,
w_ls_adsmtpline TYPE szadr_adsmtp_line,
l_v_mail LIKE adr6-smtp_addr,
l_t_otf LIKE itcoo OCCURS 0,
l_v_hformat(10) TYPE c,
l_v_ld_binfile TYPE xstring,
l_v_doc_size TYPE i,
l_v_i TYPE i,
l_v_n TYPE i,
l_v_hkora(50) TYPE c,
w_soli TYPE soli,
w_solix TYPE solix,
l_v_var1(46) TYPE c ,
l_v_linecount TYPE p,
l_v_sent_to_all LIKE sonv-flag,
l_v_document_type LIKE soodk-objtp,
l_v_horiginator LIKE soos1-recextnam ,
l_w_lips TYPE tp_lips,
l_w_vbap TYPE tp_vbap,
l_v_avl_date TYPE erdat,
l_f_oos_status TYPE flag,
l_lfimg LIKE lips-lfimg.
l_v_document_number = nast-objky.
*--To get the smartform name
lf_formname = tnapr-sform.
*-- Determine print data
PERFORM set_print_data_to_read USING lf_formname
CHANGING ls_print_data_to_read
cf_retcode.
IF cf_retcode = 0.
*--select print data
PERFORM get_data USING ls_print_data_to_read
CHANGING ls_addr_key
ls_dlv_delnote
cf_retcode.
ENDIF.
*-- Begin of Insertion AG2K946177 Scan - Avail date
CLEAR: l_t_lips,
l_t_vbap.
*-- Get the items from the delivery table
SELECT vbeln posnr matnr lfimg vgbel vgpos uecha FROM lips INTO TABLE l_t_lips
WHERE vbeln = nast-objky.
IF sy-subrc = 0.
IF NOT l_t_lips[] IS INITIAL.
*-- Get the items from the order table
SELECT vbeln posnr matnr kbmeng werks FROM vbap INTO TABLE l_t_vbap
FOR ALL ENTRIES IN l_t_lips
WHERE vbeln = l_t_lips-vgbel AND
posnr = l_t_lips-vgpos.
IF sy-subrc = 0.
LOOP AT l_t_lips.
MOVE l_t_lips-vbeln TO l_t_lips_tmp-vbeln.
MOVE l_t_lips-posnr TO l_t_lips_tmp-posnr.
MOVE l_t_lips-matnr TO l_t_lips_tmp-matnr.
MOVE l_t_lips-lfimg TO l_t_lips_tmp-lfimg.
MOVE l_t_lips-vgbel TO l_t_lips_tmp-vgbel.
MOVE l_t_lips-vgpos TO l_t_lips_tmp-vgpos.
MOVE l_t_lips-uecha TO l_t_lips_tmp-uecha.
APPEND l_t_lips_tmp.
CLEAR l_t_lips_tmp.
ENDLOOP.
LOOP AT l_t_lips INTO l_w_lips where uecha is INITIAL.
CLEAR: l_lfimg.
LOOP AT l_t_lips_tmp WHERE uecha = l_w_lips-posnr.
MOVE l_t_lips_tmp-vbeln TO l_t_lips_split-vbeln.
MOVE l_t_lips_tmp-uecha TO l_t_lips_split-uecha.
MOVE l_t_lips_tmp-posnr TO l_t_lips_split-posnr.
MOVE l_t_lips_tmp-matnr TO l_t_lips_split-matnr.
MOVE l_t_lips_tmp-vgbel TO l_t_lips_split-vgbel.
MOVE l_t_lips_tmp-vgpos TO l_t_lips_split-vgpos.
l_lfimg = l_lfimg + l_t_lips_tmp-lfimg.
AT END OF uecha.
l_t_lips_split-lfimg = l_lfimg.
APPEND l_t_lips_split.
CLEAR l_t_lips_split.
ENDAT.
ENDLOOP.
READ TABLE l_t_lips_split WITH KEY uecha = l_w_lips-posnr.
IF sy-subrc = 0 .
READ TABLE l_t_vbap INTO l_w_vbap WITH KEY vbeln = l_w_lips-vgbel
posnr = l_w_lips-vgpos.
IF sy-subrc = 0.
IF l_t_lips_split-lfimg LT l_w_vbap-kbmeng.
SELECT SINGLE avl_dat FROM /mars/ou_avl_dat INTO l_v_avl_date
WHERE werks = l_w_vbap-werks AND
matnr = l_w_vbap-matnr.
IF sy-subrc = 0.
IF l_v_avl_date IS INITIAL OR l_v_avl_date < sy-datum.
l_f_oos_status = c_x.
t_objcont-line = l_w_vbap-matnr.
APPEND t_objcont.
CLEAR t_objcont.
ENDIF.
ELSE.
l_f_oos_status = c_x.
t_objcont-line = l_w_vbap-matnr.
APPEND t_objcont.
CLEAR t_objcont.
ENDIF.
ENDIF.
ENDIF.
ELSE.
READ TABLE l_t_vbap INTO l_w_vbap WITH KEY vbeln = l_w_lips-vgbel
posnr = l_w_lips-vgpos.
IF sy-subrc = 0.
IF l_t_lips-lfimg LT l_w_vbap-kbmeng.
SELECT SINGLE avl_dat FROM /mars/ou_avl_dat INTO l_v_avl_date
WHERE werks = l_w_vbap-werks AND
matnr = l_w_vbap-matnr.
IF sy-subrc = 0.
IF l_v_avl_date IS INITIAL OR l_v_avl_date < sy-datum.
l_f_oos_status = c_x.
t_objcont-line = l_w_vbap-matnr.
APPEND t_objcont.
CLEAR t_objcont.
ENDIF.
ELSE.
l_f_oos_status = c_x.
t_objcont-line = l_w_vbap-matnr.
APPEND t_objcont.
CLEAR t_objcont.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDIF.
IF l_f_oos_status NE c_x.
*-- End of Insertion AG2K946177 Scan - Avail date
*-- Begin of Insertion AG2K942430 Delivery Note
IF cf_retcode = 0.
IF nast-nacha NE c_5.
*-- End of Insertion AG2K942430 Delivery Note
PERFORM set_print_param USING ls_addr_key
CHANGING ls_control_param
ls_composer_param
ls_recipient
ls_sender
cf_retcode.
ls_control_param-no_dialog = space .
*-- Begin of Insertion AG2K942430 Delivery Note
ELSEIF nast-nacha EQ c_5.
SELECT SINGLE adrnr FROM kna1 INTO l_v_adrnr WHERE kunnr = nast-parnr.
IF sy-subrc = 0.
CLEAR l_v_ls_address.
-- To get the address Details
CALL FUNCTION 'ADDR_GET_COMPLETE'
EXPORTING
addrnumber = l_v_adrnr
IMPORTING
addr1_complete = l_v_ls_address
EXCEPTIONS
OTHERS = 5.
IF sy-subrc = 0.
LOOP AT l_v_ls_address-adsmtp_tab INTO w_ls_adsmtpline
WHERE date_from <= sy-datlo.
IF ( NOT w_ls_adsmtpline-adsmtp-smtp_addr IS INITIAL ).
*--Email Address
l_v_mail = w_ls_adsmtpline-adsmtp-smtp_addr.
ENDIF.
ENDLOOP.
ENDIF.
*--To fill the control paramters for Email
IF NOT l_v_mail IS INITIAL AND nast-nacha EQ c_5.
ls_control_param-device = c_printer.
ls_control_param-no_dialog = c_x.
ls_control_param-langu = sy-langu.
ls_control_param-preview = space.
ls_control_param-getotf = c_x.
*--Setting LS_COMPOSER_PARAM values
ls_composer_param-tddest = nast-ldest.
ls_composer_param-tdimmed = space.
ls_composer_param-tdnoprev = c_x.
ls_composer_param-faxformat = c_otf.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
*-- End of Insertion AG2K942430 Delivery Note
IF cf_retcode = 0.
*-- Determine smartform function module for delivery note
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lf_formname
IMPORTING
fm_name = lf_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
*-- Error handling
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
ENDIF.
IF cf_retcode = 0.
*-- Call smartform delivery note
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = space
is_dlv_delnote = ls_dlv_delnote
is_nast = nast
*-- Begin of Insertion AG2K942430 Delivery Note
IMPORTING
document_output_info = l_t_ssfcrespd
job_output_info = l_t_ssfcrescl
job_output_options = l_t_ssfcresop
*-- End of Insertion AG2K942430 Delivery Note
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
*-- Error handling
cf_retcode = sy-subrc.
PERFORM protocol_update.
*-- Get SmartForm protocol and store it in the NAST protocoll
PERFORM add_smfrm_prot.
ENDIF.
ENDIF.
*-- Begin of Insertion AG2K942430 Delivery Note
IF nast-nacha EQ c_5.
IF NOT l_t_ssfcrescl-otfdata[] IS INITIAL .
MOVE l_t_ssfcrescl-otfdata[] TO l_t_otf[].
ENDIF.
IF NOT l_t_otf[] IS INITIAL.
IF l_v_hformat IS INITIAL.
l_v_hformat = c_pdf.
ENDIF.
CLEAR l_t_htline.
REFRESH l_t_htline.
*-- Convert OTF Data to PDF Data
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = l_v_hformat
IMPORTING
bin_filesize = l_v_doc_size
bin_file = l_v_ld_binfile
TABLES
otf = l_t_otf
lines = l_t_htline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc = 0.
CLEAR l_t_solix.
REFRESH l_t_solix.
CLEAR l_t_objcont.
REFRESH l_t_objcont.
l_v_i = 0.
l_v_n = XSTRLEN( l_v_ld_binfile ).
WHILE l_v_i < l_v_n.
l_t_solix-line = l_v_ld_binfile+l_v_i.
APPEND l_t_solix.
CLEAR l_t_solix.
l_v_i = l_v_i + 255.
ENDWHILE.
FIELD-SYMBOLS: <ptr_hex> TYPE solix.
LOOP AT l_t_solix INTO w_solix.
CLEAR w_soli.
ASSIGN w_soli TO <ptr_hex> CASTING.
MOVE w_solix TO <ptr_hex>.
APPEND w_soli TO l_t_objcont.
ENDLOOP.
IF l_v_hformat = c_pdf.
*--Do nothing
ELSE.
CLEAR l_t_objcont.
REFRESH l_t_objcont.
LOOP AT l_t_htline.
l_t_objcont = l_t_htline.
APPEND l_t_objcont.
CLEAR l_t_htline.
ENDLOOP.
ENDIF.
ENDIF.
*--To Suppress zero's
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = l_v_document_number
IMPORTING
output = l_v_document_number.
CONCATENATE text-001 l_v_document_number INTO l_v_var1 SEPARATED BY space.
l_v_hkora = l_v_var1.
CLEAR l_t_object_hd_change.
l_t_object_hd_change-objnam = c_mail.
l_t_object_hd_change-objdes = l_v_hkora.
l_t_object_hd_change-objla = sy-langu.
l_t_object_hd_change-objsns = c_o.
l_t_object_hd_change-objlen = l_v_doc_size .
IF l_v_hformat = c_pdf.
l_t_object_hd_change-file_ext = c_pdf.
ENDIF.
CLEAR l_t_receivers.
REFRESH l_t_receivers.
l_t_receivers-recextnam = l_v_mail.
l_t_receivers-recesc = c_e.
l_t_receivers-sndart = c_int.
APPEND l_t_receivers.
CLEAR l_t_receivers.
DESCRIBE TABLE l_t_objcont LINES l_v_linecount.
CLEAR l_t_objhead.
REFRESH l_t_objhead.
IF l_v_hformat = c_pdf.
l_v_document_type = c_ext.
ELSE.
l_v_document_type = c_raw.
l_t_objhead = l_v_linecount.
APPEND l_t_objhead.
CLEAR l_t_objhead.
ENDIF.
l_v_horiginator = sy-uname.
*--Sending the PDF data as Email attachment
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = l_t_object_hd_change
object_type = l_v_document_type
originator = l_v_horiginator
originator_type = c_b
IMPORTING
sent_to_all = l_v_sent_to_all
TABLES
objcont = l_t_objcont
objhead = l_t_objhead
receivers = l_t_receivers
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
originator_not_exist = 20
x_error = 21
OTHERS = 22.
IF sy-subrc = 0.
COMMIT WORK AND WAIT.
ENDIF.
ENDIF.
ENDIF.
*-- End of Insertion AG2K942430 Delivery Note
*-- Begin of Insertion AG2K946177 Scan - Avail date
ELSE.
*-- Get the details for sending the email
PERFORM get_details TABLES t_objparb
t_receivers
CHANGING v_obj_type
v_owner
v_sender
w_object_hd_change.
*-- Sending Email
PERFORM send_email.
ENDIF.
*-- End of Insertion AG2K946177 Scan - Avail date
ENDFORM. "PROCESSING
*-- Begin of Insertion AG2K946177 Scan - Avail date
*& Form get_details
Get details for Sending Email
-->P_T_OBJPARB Parameter for Dialog Modules
-->P_T_RECEIVERS recipient with attributes
<--P_V_OBJ_TYPE Code for document class
<--P_V_OWNER Owner
<--P_V_SENDER Sender
<--P_W_OBJECT_HD_CHANGE object definition, change attributes
FORM get_details TABLES p_t_objparb STRUCTURE t_objparb
p_t_receivers STRUCTURE t_receivers
CHANGING p_v_obj_type
p_v_owner
p_v_sender
p_w_object_hd_change.
CONSTANTS: c_colon(1) TYPE c VALUE ':'.
DATA:
*-- To Get the Entry from ZZOURULE
BEGIN OF l_w_zzourule,
zzvalue1_1 LIKE zzourule-zzvalue1_1,
zzvalue2_1 LIKE zzourule-zzvalue2_1,
zzvalue3_1 LIKE zzourule-zzvalue3_1,
END OF l_w_zzourule,
*-- To get the entry from sofd
BEGIN OF l_w_sofd,
foltp LIKE sofd-foltp,
folyr LIKE sofd-folyr,
folno LIKE sofd-folno,
END OF l_w_sofd,
*-- To get the entry from sofm
BEGIN OF l_w_sofm,
foltp LIKE sofm-foltp,
folyr LIKE sofm-folyr,
folno LIKE sofm-folno,
doctp LIKE sofm-doctp,
docyr LIKE sofm-docyr,
docno LIKE sofm-docno,
END OF l_w_sofm,
BEGIN OF l_w_swotobjid,
logsys LIKE swotobjid-logsys,
objtype LIKE swotobjid-objtype,
objkey LIKE swotobjid-objkey,
END OF l_w_swotobjid.
DATA: l_w_header LIKE sood1-objdes.
*-- Fill exporting parameters of FM SO_OBJECT_SEND
CONCATENATE text-004 nast-objky c_colon text-002 INTO l_w_header SEPARATED BY space.
l_w_header = text-002.
w_object_hd_change-objla = sy-langu.
w_object_hd_change-objnam = c_notify.
w_object_hd_change-objdes = l_w_header.
v_obj_type = c_raw.
v_owner = sy-uname.
v_sender = sy-uname.
t_objparb-name = c_wi_id.
APPEND t_objparb.
CLEAR t_objparb.
t_objparb-name = text-003.
t_objparb-value = sy-datum.
APPEND t_objparb.
CLEAR t_objparb.
*-- Get the folder Name from the ZZOURULE table
SELECT zzvalue1_1 zzvalue2_1 zzvalue3_1
FROM zzourule INTO l_w_zzourule UP TO 1 ROWS
WHERE zzprog = sy-repid AND
zzdata = c_oos.
ENDSELECT.
IF sy-subrc = 0.
SELECT foltp folyr folno
FROM sofd INTO l_w_sofd UP TO 1 ROWS
WHERE objnam = l_w_zzourule-zzvalue1_1 AND
folrg = c_q.
ENDSELECT.
IF sy-subrc = 0.
SELECT foltp folyr folno doctp docyr docno
FROM sofm INTO l_w_sofm UP TO 1 ROWS
WHERE doctp = l_w_sofd-foltp AND
docyr = l_w_sofd-folyr AND
docno = l_w_sofd-folno.
ENDSELECT.
IF sy-subrc = 0.
CLEAR t_receivers.
MOVE l_w_zzourule-zzvalue1_1 TO t_receivers-recnam.
*-- C means Shared distribution List
MOVE c_c TO t_receivers-recesc.
APPEND t_receivers.
CLEAR t_receivers.
l_w_swotobjid-logsys = l_w_zzourule-zzvalue2_1.
l_w_swotobjid-objtype = l_w_zzourule-zzvalue3_1.
CONCATENATE l_w_sofm-foltp
l_w_sofm-folyr
l_w_sofm-folno
l_w_sofm-doctp
l_w_sofm-docyr
l_w_sofm-docno INTO l_w_swotobjid-objkey.
t_receivers-recextnam = l_w_swotobjid.
*-- J means external Object
MOVE c_j TO t_receivers-recesc.
APPEND t_receivers.
CLEAR t_receivers.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " get_details
*& Form send_email
Sending Email
FORM send_email .
*-- Email send to the receipent maintained in the shared folder
CALL FUNCTION 'SO_OBJECT_SEND'
EXPORTING
object_hd_change = w_object_hd_change
object_type = v_obj_type
owner = v_owner
sender = v_sender
IMPORTING
object_id_new = w_object_id_new
sent_to_all = v_sent_to_all
TABLES
objcont = t_objcont
objhead = t_objhead
objparb = t_objparb
receivers = t_receivers
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_email
*-- End of Insertion AG2K946177 Scan - Avail date -
How to add body text when sending output as PDF in email?
Hello,
We are using standard SAP to send SD output as PDF in an email (in output type we choose medium 5, email address is taken from customer master. In transaction SCOT is indicated that SAPscript/smartforms are converted to PDF. When the output is generated, we run rsconn01 to trigger the actual sending of the email).
Via form TEXT_SYMBOL_REPLACE we can modify the subject of the email that is send to include e.g. the order number. HOWEVER, in the body of the email that is send, we now only have the PDF, but we also would like to add a standard text in the body of the email. Does anyone know how to do this?
Thanks,
AlexHi,
Please refer to the following program and see if it helps you.
REPORT ZSAMPL_001 .
INCLUDE ZINCLUDE_01.
DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
*file_open_error = 1
*file_read_error = 2
*no_batch = 3
*gui_refuse_filetransfer = 4
*invalid_type = 5
*no_authority = 6
*unknown_error = 7
*bad_data_format = 8
*header_not_allowed = 9
*separator_not_allowed = 10
*header_too_long = 11
*unknown_dp_error = 12
*access_denied = 13
*dp_out_of_memory = 14
*disk_full = 15
*dp_timeout = 16
*OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
CHECK_DOS_FORMAT =
IMPORTING
DRIVE =
EXTENSION = extension
NAME = name
NAME_WITH_EXT =
PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
***INCLUDE ZINCLUDE_01 .
10.08.2005 Amit M - Created
Include For Mail (First Req F16)
Modification Log
Data
tables crmrfcpar.
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
data v_rfcdest LIKE crmrfcpar-rfcdest.
FORM
FORM ml_customize USING objname objdesc.
Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
IMPORTING
COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
Header Data
Already Done Thru FM
Main Text
Already Done Thru FM
Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
Receiver List
Already done thru fm
ENDFORM. "ml_prepare
FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
IMPORTING
SENT_TO_ALL =
NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
CONTENTS_HEX = objhex
OBJECT_PARA =
object_parb =
receivers = 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
IF sy-subrc <> 0.
MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
Data
DATA : pos TYPE i.
DATA : len TYPE i.
Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
FORM
FORM ml_saveforbp USING jobname jobcount.
Data
*data : yhead like yhrt_bp_head.
*DATA : ydocdata LIKE yhrt_bp_docdata,
*yobjtxt LIKE yhrt_bp_objtxt OCCURS 0 WITH HEADER LINE,
*yreclist LIKE yhrt_bp_reclist OCCURS 0 WITH HEADER LINE.
*DATA : seqnr TYPE i.
Head
*yhead-jobname = jobname.
*yhead-jobcount = jobcount..
*MODIFY yhrt_bp_head FROM yhead.
Doc Data
*ydocdata-jobname = jobname.
*ydocdata-jobcount = jobcount.
*MOVE-CORRESPONDING docdata TO ydocdata.
*MODIFY yhrt_bp_docdata FROM ydocdata.
Objtxt
*seqnr = 0.
*LOOP AT objtxt.
*seqnr = seqnr + 1.
*yobjtxt-jobname = jobname.
*yobjtxt-jobcount = jobcount.
*yobjtxt-seqnr = seqnr.
*MOVE-CORRESPONDING objtxt TO yobjtxt.
*MODIFY yhrt_bp_objtxt FROM yobjtxt.
*ENDLOOP.
RecList
*seqnr = 0.
*LOOP AT reclist.
*seqnr = seqnr + 1.
*yreclist-jobname = jobname.
*yreclist-jobcount = jobcount.
*yreclist-seqnr = seqnr.
*MOVE-CORRESPONDING reclist TO yreclist.
*MODIFY yhrt_bp_reclist FROM yreclist.
*ENDLOOP.
ENDFORM. "ml_saveforbp
FORM
FORM ml_fetchfrombp USING jobname jobcount.
*CLEAR docdata.
*REFRESH objtxt.
*REFRESH reclist.
*SELECT SINGLE * FROM yhrt_bp_docdata
*INTO corresponding fields of docdata
*WHERE jobname = jobname
*AND jobcount = jobcount.
*SELECT * FROM yhrt_bp_objtxt
*INTO corresponding fields of TABLE objtxt
*WHERE jobname = jobname
*AND jobcount = jobcount
*ORDER BY seqnr.
*SELECT * FROM yhrt_bp_reclist
*INTO corresponding fields of TABLE reclist
*WHERE jobname = jobname
*AND jobcount = jobcount
*ORDER BY seqnr.
ENDFORM. "ml_fetchfrombp
Hope this helps.
Please reward some points if it helps.
Regards,
Amit Mishra -
Sending SAPSCRIPT in PDF through email
Hi everybody,
I'm trying to send via email a sapscript. I red more posts regarding this issue but nothing seems to run correctly.
Some posts refers to a sample program ZRICH_0003.
I've just copied the code and replaced the form's name with one of mine and run it.
The function SO_NEW_DOCUMENT_ATT_SEND_API1 return with error code 2 (document not sent). I really don't know why. I've just run it in two different SAP (4.7 and 5.0)
Both didn't work. Both systems are UNIX. Must I do something in customizing or some RFC definition?
Is there anybody that have a simple program that uses this function?
Thanks in advance
Fabrizioi have tried the same thing. first generating spool & then convering sppol to PDF.
REPORT ZPO_PDF NO STANDARD PAGE HEADING
LINE-SIZE 254.
converts list to PDF - send via mail as attachment
TABLES: adrp, "Persons (central address administration)
bhdgd, "Common data area batch heading routine
bsik, "Accounting: Secondary Index for Vendors
usr21. "Assign user name address key
General data definition
TYPE-POOLS: icon.
TYPE-POOLS: slis.
DATA: d_linsz LIKE sy-linsz.
Constants
CONSTANTS: c_yes(1) TYPE c VALUE 'X'.
Structures
DATA: e_variant TYPE disvariant.
Selection-screen
DATA: le_parameters LIKE pri_params.
DATA: l_valid(1) TYPE c.
DATA: lt_pdf TYPE TABLE OF tline WITH HEADER LINE.
DATA: l_spool_c LIKE tsp01_sp0r-rqid_char.
DATA: l_spool_i LIKE tsp01-rqident,
_RECEIVER LIKE bsik-xref3.
Get the SPOOL number
PARAMETERS:
spoolno LIKE TSP01-RQIDENT.
l_spool_i = spoolno.
DATA: NUMBYTES TYPE I,
ARC_IDX LIKE TOA_DARA,
pdfspoolid like tsp01-rqident,
jobname like tbtcjob-jobname,
jobcount like tbtcjob-jobcount,
is_otf.
DATA PDF LIKE TLINE OCCURS 100 WITH HEADER LINE.
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
SRC_SPOOLID = l_spool_i
NO_DIALOG = ' '
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = numbytes
PDF_SPOOLID = pdfspoolid
OTF_PAGECOUNT =
BTC_JOBNAME = jobname
BTC_JOBCOUNT = jobcount
TABLES
PDF = lt_pdf
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Build the mail
PERFORM build_mail
TABLES lt_pdf
USING _receiver.
FORM prepare_print_format USING parameters LIKE priparams.
DATA: BEGIN OF lt_report_source OCCURS 0,
line(72) TYPE c,
END OF lt_report_source.
DATA: l_string_linsz TYPE string.
DATA: l_tabix LIKE sy-tabix.
DATA: BEGIN OF lt_sentencia OCCURS 0,
line(72) TYPE c,
END OF lt_sentencia.
DATA: lt_tsp1d TYPE TABLE OF tsp1d WITH HEADER LINE.
READ REPORT sy-repid INTO lt_report_source.
CHECK sy-subrc = 0.
CLEAR: l_tabix.
WHILE NOT l_string_linsz CS '.'.
ADD 1 TO l_tabix.
READ TABLE lt_report_source
INDEX l_tabix.
TRANSLATE lt_report_source-line TO UPPER CASE.
IF l_string_linsz CS 'REPORT'
OR lt_report_source-line CS 'REPORT'.
CONCATENATE l_string_linsz
lt_report_source-line
INTO l_string_linsz
SEPARATED BY space.
CONDENSE l_string_linsz.
ENDIF.
ENDWHILE.
TRANSLATE l_string_linsz USING '. '.
CLEAR: lt_report_source.
REFRESH: lt_report_source.
FREE: lt_report_source.
SPLIT l_string_linsz AT space INTO TABLE lt_sentencia.
LOOP AT lt_sentencia
WHERE line CS 'LINE-SIZE'.
l_tabix = sy-tabix.
EXIT.
ENDLOOP.
ADD 1 TO l_tabix.
READ TABLE lt_sentencia
INDEX l_tabix.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE lt_tsp1d
FROM tsp1d
WHERE type = 'L'
AND outcolumns >= lt_sentencia-line.
SORT lt_tsp1d
BY outcolumns.
READ TABLE lt_tsp1d
INDEX 1.
parameters-linct = lttsp1d-outrows.
parameters-linsz = ltsentencia-line.
parameters-paart = lttsp1d-papart.
ENDFORM. " prepare_print_format
FORM build_mail TABLES tpdf STRUCTURE tline
USING _receiver TYPE c.
DATA: l_length_t_pdf TYPE i.
DATA: l_string TYPE xstring.
DATA: l_string_bck TYPE string.
DATA: l_length_string TYPE i.
DATA: l_length_objbin TYPE i.
DATA: l_max_tabix TYPE i.
DATA: l_dif TYPE i.
DATA: l_hex_null TYPE x VALUE '00'.
DATA: lt_objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: l_tab_lines LIKE sy-tabix.
DATA: le_doc_chng LIKE sodocchgi1.
DATA: lt_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: lt_objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE.
DATA: lt_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: lt_contents_bin LIKE solisti1 OCCURS 0 WITH HEADER LINE.
Mail text
(...here you should fill table lt_objtxt-line)
lt_objtxt-line = 'First line of text'.
append lt_objtxt.
lt_objtxt-line = 'Second line'.
append lt_objtxt.
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
le_doc_chng-doc_size = ( l_tab_lines - 1 ) * 255
+ STRLEN( lt_objtxt ).
le_doc_chng-obj_descr = 'PO in PDF By mail'.
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Attached file, in PDF-format
DESCRIBE FIELD tpdf LENGTH l_length_t_pdf.
CLEAR: l_string_bck,
l_string.
LOOP AT tpdf.
CONCATENATE l_string_bck tpdf INTO l_string_bck.
l_dif = l_length_t_pdf - STRLEN( tpdf ).
DO l_dif TIMES.
CONCATENATE l_string_bck l_hex_null INTO l_string_bck.
ENDDO.
CONCATENATE l_string tpdf INTO l_string.
ENDLOOP.
sy-subrc = 0.
WHILE sy-subrc = 0.
REPLACE l_hex_null WITH space INTO l_string_bck.
ENDWHILE.
l_length_string = strlen( l_string_bck ).
DESCRIBE FIELD lt_contents_bin LENGTH l_length_objbin.
l_max_tabix = ceil( l_length_string / l_length_objbin * '1.0' ).
DO l_max_tabix TIMES.
lt_contents_bin = l_string_bck.
APPEND lt_contents_bin.
IF sy-tabix <> l_max_tabix.
l_string_bck = l_string_bck+l_length_objbin.
ENDIF.
ENDDO.
DESCRIBE TABLE lt_contents_bin LINES l_tab_lines.
APPEND lt_objhead.
lt_objpack-transf_bin = c_yes.
lt_objpack-head_start = 1.
lt_objpack-head_num = 1.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'PDF'.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255.
LOOP AT lt_contents_bin.
ENDLOOP.
lt_objpack-doc_size = lt_objpack-doc_size + STRLEN( lt_contents_bin ).
APPEND lt_objpack.
lt_reclist-receiver = 'testmailgmail.com'.
lt_reclist-rec_type = 'U'.
APPEND lt_reclist.
Finally! we send the mail
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = le_doc_chng
put_in_outbox = c_yes
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_contents_bin
contents_hex =
contents_txt = lt_objtxt
receivers = lt_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.
ENDFORM. " build_mail -
To send Payment advice note as Email to vendor
Hi
I like to know how can we send the payment advice note created after F110 run to be send as email to the vendor?
your help would be appreciated a lot
regards
auroHi Arvind,
Check out the following link
Re: f110 payment advice
Assign points if useful
Regards
Genie -
Configuration to send the smartform through fax
Hi,
I have used CONVERT_OTF_AND_FAX and SO_OBJECT_SEND FM's to send the smartform through fax.After executing SO_OBJECT_SEND function module,I am getting sy-subrc alue as 9(OBJECT_NOT_SEND).I am able to send the document through fax.But when I click on display in SOST transaction it is just printing the output of the smartform.It is not coming in PDF format.
The code looks fine.I think there is some problem with confuration settings.Is there any configuration to be done to send the smartform output through fax?
Please reply.
Regards,
HemaHi,
Actually,my requirement is to send the smartform output through email with medium 'external send'.I have done some coding for that.it is working fine and I am able to send the smartform through email and open the attachment in PDF format.
But if the email id of the recipient is not present then the smartform output has to be sent through fax with the same medium 'external send'.
So I have done some coding to send the smartform through fax when the email id is not present.
I am able to send the output of smartform through fax.But when I clicked on display in SOST transaction,it is not coming in PDF format.It is coming in RAW format.
Is it possible to send the smartform output through fax with medium 'external send'?
Regards,
Hema -
Sending documents as attachments via email
Hi,
I have a selection screen with purchase order number as "select-options" and 2 radio buttons one for downloading and opening the SAP Script output to the local file and the other raido button would convert the SAP Script output into .pdf file and send that file as an attachment via e-mail to the receipent(only one).
I'm through with the first operation. Now need to know about the e-mailing procedure and the function module(s) to be used and their import, export, etc. parameters.
Thanks & Regards,
RajeshHi Rajesh,
You can use standard SAP program <b>RSTXPDFT4</b> to convert SAPSript spools request to PDF.
Also please check this link for sample code to sending an attachment (PDF) via email:
http://www.sapgenie.com/abap/code/abap31.htm
Hope this will help.
Regards,
Ferry Lianto -
Attach page content as pdf in email
Thanks for all who answer this thread.
I am using this syntax to send email from a web page....
<cfset subject = "Application Name">
<a
href="mailto:?subject=#urlEncodedFormat(e_subject)#">Email
page</a>
i know, how to create page content in pdf...
How can i attach page content pdf to this mail? is that
possible?.
OR
what is best way to send page content PDF as email.....
user want to type some info in body of email.....
thanksUse cfsavecontent to generate your page content.
Use cfdocument to create the pdf file
Use cfmail and cfmailparam to send it as an email
attachment. -
Error - While converting Smartform to PDF and send in Email
HI all,
I am getting error while opening the PDF file. i searched in SDN but I am not able to figure out what is the correct issues.
Please find the piece of code.
* Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = ls_jobout_info-otfdata[].
* Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
** max_linewidth = 134
max_linewidth = 132
IMPORTING
** bin_file = ts_file
bin_filesize = gv_bin_filesize
TABLES
otf = gt_otf
lines = gt_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
* Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
DATA:
* gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
CLEAR : gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab.
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin.
ENDIF.
* Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = l_title.
gs_objpack-obj_descr = w_output-tdtitle.
APPEND gs_objpack TO gt_objpack.
ENDIF.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = p_doc_chng
put_in_outbox = 'X'
sender_address = p_w_sender
sender_address_type = 'INT'
TABLES
packing_list = p_objpack
** object_header = p_objhead
contents_bin = p_objbin
** contents_txt = p_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = p_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
kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
thanksHI all,
I am getting error while opening the PDF file. i searched in SDN but I am not able to figure out what is the correct issues.
Please find the piece of code.
* Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = ls_jobout_info-otfdata[].
* Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
** max_linewidth = 134
max_linewidth = 132
IMPORTING
** bin_file = ts_file
bin_filesize = gv_bin_filesize
TABLES
otf = gt_otf
lines = gt_pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
* Passing the SAP Script text lines to SAPoffice: Single List with Column Length 255 table
DATA:
* gv_bin_filesize TYPE i, " Store the file size
gv_pos TYPE i,
gv_len TYPE i,
gv_tab_lines TYPE i.
CLEAR : gs_objbin, gs_pdf_tab.
LOOP AT gt_pdf_tab INTO gs_pdf_tab.
gv_pos = 255 - gv_len.
IF gv_pos > 134. "length of pdf_table
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_pdf_tab(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255. "length of out (contents_bin)
APPEND gs_objbin TO gt_objbin.
CLEAR: gs_objbin, gv_len.
IF gv_pos < 134.
gs_objbin = gs_pdf_tab+gv_pos.
gv_len = 134 - gv_pos.
ENDIF.
ENDIF.
ENDLOOP.
IF gv_len > 0.
APPEND gs_objbin TO gt_objbin.
ENDIF.
* Filling the details in SAPoffice: Description of Imported Object Components table
DESCRIBE TABLE gt_objbin LINES gv_tab_lines.
CLEAR gs_objbin.
READ TABLE gt_objbin INTO gs_objbin INDEX gv_tab_lines.
IF sy-subrc = 0.
gs_objpack-doc_size = ( gv_tab_lines - 1 ) * 255 + STRLEN( gs_objbin ).
gs_objpack-transf_bin = 'X'.
gs_objpack-head_start = 1.
gs_objpack-head_num = 0.
gs_objpack-body_start = 1.
gs_objpack-body_num = gv_tab_lines.
gs_objpack-doc_type = 'PDF'.
gs_objpack-obj_name = l_title.
gs_objpack-obj_descr = w_output-tdtitle.
APPEND gs_objpack TO gt_objpack.
ENDIF.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = p_doc_chng
put_in_outbox = 'X'
sender_address = p_w_sender
sender_address_type = 'INT'
TABLES
packing_list = p_objpack
** object_header = p_objhead
contents_bin = p_objbin
** contents_txt = p_objtxt
* CONTENTS_HEX =
* OBJECT_PARA =
* OBJECT_PARB =
receivers = p_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
kindly help...email is coming but when i tried to open the PDF file, error saying, " There is error opening a file. thie file is damages and cannot be opened'
thanks -
Send PDF as email attachment using Outlook 2011 ERROR
Every time I try to send a PDF as an email attachment, I get the following error:
"An error occurred while trying to create a mail document. Acrobat is unable to complete your request."
Prior to getting this error, every time I sent an email Adobe would open the default Mail program on the mac. I opened mail and changed the preference to use Outlook 2011 as the default mail program, but this did not correct the error.
Any ideas?
Thanks!AmbooS wrote:
This is a known issue with Mac Outlook 2011 which is an unsupported version for Acrobat X. This will be supported in the next release.
If adobe was smart it would be added in the update rather than in than in AcrobatXI And while at it they need to add support for SeaMonkey and Thunderbird as well. You've been ingnoring of Dissing Mozilla Products since OSX has been out. -
Error in opening smartform generated PDF attachments
Hi every one,
my smartforms generate multiple emails based on the widely used code as shown below.
The emails are successfully being sent to different locations, but the problem is the first PDF file is opening, but the others followed by it are not opening. It's giving an error ' File damaged and cannot be opened!'
Pls see the below code and help me out.
Points would be awarded.
Thanks to all in advance!!
Arnab
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_maiHi,
Check the code below
1.converting smartform to PDF
Summury: Converting the smartfrom to PDF is process of 3 simple steps.
Calling the Smart form, then it returns the OTF data in Return.
Converting the OTF data into required format using the Function Module CONVERT_OTF_2_PDF.
Download the File
*& Report ZTEST_NREDDY_PDF
REPORT ZTEST_NREDDY_PDF.
DATA: it_otf TYPE STANDARD TABLE OF itcoo,
it_docs TYPE STANDARD TABLE OF docs,
it_lines TYPE STANDARD TABLE OF tline,
st_job_output_info TYPE ssfcrescl,
st_document_output_info TYPE ssfcrespd,
st_job_output_options TYPE ssfcresop,
st_output_options TYPE ssfcompop,
st_control_parameters TYPE ssfctrlop,
v_len_in TYPE so_obj_len,
v_language TYPE sflangu VALUE 'E',
v_e_devtype TYPE rspoptype,
v_bin_filesize TYPE i,
v_name TYPE string,
v_path TYPE string,
v_fullpath TYPE string,
v_filter TYPE string,
v_uact TYPE i,
v_guiobj TYPE REF TO cl_gui_frontend_services,
v_filename TYPE string,
v_fm_name TYPE rs38l_fnam.
CONSTANTS c_formname TYPE tdsfname VALUE 'ZTEST'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
*st_output_options-tdprinter = 'locl'.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
.................GET SMARTFORM FUNCTION MODULE NAME.................
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
IMPORTING
fm_name = v_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.
...........................CALL SMARTFORM............................
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_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.
ELSE.
.........................CONVERT TO OTF TO PDF.......................
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = st_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 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 THE FILE NAME TO STORE....................
CONCATENATE 'smrt' '.pdf' INTO v_name.
CREATE OBJECT v_guiobj.
CALL METHOD v_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = v_name
file_filter = v_filter
CHANGING
filename = v_name
path = v_path
fullpath = v_fullpath
user_action = v_uact.
IF v_uact = v_guiobj->action_cancel.
EXIT.
ENDIF.
..................................DOWNLOAD AS FILE....................
MOVE v_fullpath TO v_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_bin_filesize
filename = v_filename
filetype = 'BIN'
TABLES
data_tab = it_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.
Regards,
Raj. -
Problem in sending the smartform as email for other language except english
Hi Experts,
I could not send the smartform as an attachment for other languages, but where as i could send it in english.
The program is working fine with print priview but not when sending the SF as an attachment
(in other languages except english).
Please do find the below code which i used to send the smartform as an attachment.
Please let me know if there is any mistake in the code.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_compop-tdnoprev = 'X'.
CALL FUNCTION lf_fm_name "'/1BCDWB/SF00000197'
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_compop
user_settings = 'X'
is_ekko = l_doc-xekko
is_pekko = l_doc-xpekko
is_nast = l_nast
iv_from_mem = l_from_memory
iv_druvo = iv_druvo
iv_xfz = iv_xfz
IMPORTING
job_output_info = wa_return
TABLES
it_ekpo = l_doc-xekpo[]
it_ekpa = l_doc-xekpa[]
it_pekpo = l_doc-xpekpo[]
it_eket = l_doc-xeket[]
it_tkomv = l_doc-xtkomv[]
it_ekkn = l_doc-xekkn[]
it_ekek = l_doc-xekek[]
it_komk = l_xkomk[]
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.
*Convert the data from OTF to PDF format
it_otf[] = wa_return-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = l_len_in
bin_file = lp_xcontent
TABLES
otf = it_otf
lines = it_tline
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
TRY.
---------- create persistent send request ----------------------
send_request = cl_bcs=>create_persistent( ).
len = XSTRLEN( lp_xcontent ).
transform to solix tab
lt_solix =
cl_document_bcs=>xstring_to_solix(
ip_xstring = lp_xcontent ).
Create Body to the E-mail.
APPEND Text-005 TO l_text.
Attachment Name
l_ponumber = text-004.
CONCATENATE l_ponumber l_doc-xekko-ebeln INTO l_ponumber.
Subject for the E-Mail.
l_subject = text-001.
CONCATENATE l_subject l_doc-xekko-ebeln INTO l_subject.
*create document E-Mail.
*TRY.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_language = nast-spras
i_importance =
i_sensitivity =
i_text = l_text
i_hex =
i_header =
i_sender =
receiving
RESULT = l_email_object
CATCH cx_document_bcs .
*ENDTRY.
CALL METHOD cl_document_bcs=>create_document
EXPORTING
i_type = 'RAW'
i_subject = l_subject
i_length = '13'
i_text = l_text
RECEIVING
result = l_email_object.
*Create PDF Document
bcs_doc = cl_document_bcs=>create_document(
i_type = 'PDF'
i_subject = l_ponumber
i_length = len
i_language = nast-spras
i_hex = lt_solix
*Type casting
obj_pdf_file ?= bcs_doc.
Add PDF document as an attachment
CALL METHOD l_email_object->add_document_as_attachment
EXPORTING
im_document = obj_pdf_file.hi,
i tried with ur problem.but i am able send mail in other languages also.actaullly i wrote a msg whether the mail has been sent or not.i got success message. i am placing my code here please go thorugh it,and do relavant modifications.
*& Report ZPPS_SMARTFORM_TO_PDF
REPORT ZPPS_SMARTFORM_TO_PDF.
PARAMETER: p_date LIKE sy-datum.
PARAMETER: p_rea TYPE char255.
DATA: t_otfdata TYPE ssfcrescl,
t_lines LIKE tline OCCURS 0 WITH HEADER LINE,
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
t_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
Objects to send mail.
DATA:T_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
T_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
T_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE.
DATA: w_filesize TYPE i,
w_bin_filesize TYPE i,
wa_ctrlop TYPE ssfctrlop,
wa_outopt TYPE ssfcompop,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
WA_OBJHEAD TYPE SOLI_TAB,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1.
DATA: form_name TYPE rs38l_fnam,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I,
nast-spras type sy-langu value 'DE'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZSR_DEMO1'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = 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.
wa_ctrlop-LANGU = nast-spras.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_outopt-tdnoprev = 'X'.
CALL FUNCTION form_name
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = wa_ctrlop
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = wa_outopt
USER_SETTINGS = 'X'
MYDATE = p_date
REASON = p_rea
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = t_otfdata
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.
t_otf[] = t_otfdata-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = w_bin_filesize
BIN_FILE =
TABLES
OTF = t_otf
LINES = t_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.
loop at t_lines.
TRANSLATE t_lines USING '~'.
CONCATENATE WA_BUFFER T_LINES INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
t_RECORD = WA_BUFFER.
APPEND t_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: T_RECLIST,
T_OBJTXT,
T_OBJBIN,
T_OBJPACK.
CLEAR WA_OBJHEAD.
T_OBJBIN[] = T_RECORD[].
Create Message Body Title and Description
T_OBJTXT = 'test with pdf-Attachment!'.
APPEND T_OBJTXT.
DESCRIBE TABLE T_OBJTXT LINES V_LINES_TXT.
READ TABLE T_OBJTXT INDEX V_LINES_TXT.
WA_DOC_CHNG-OBJ_NAME = 'smartform'.
WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.
WA_DOC_CHNG-OBJ_DESCR = 'smartform'.
WA_DOC_CHNG-SENSITIVTY = 'F'.
WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.
Main Text
CLEAR T_OBJPACK-TRANSF_BIN.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
T_OBJPACK-BODY_NUM = V_LINES_TXT.
T_OBJPACK-DOC_TYPE = 'RAW'.
APPEND T_OBJPACK.
Attachment (pdf-Attachment)
T_OBJPACK-TRANSF_BIN = 'X'.
T_OBJPACK-HEAD_START = 1.
T_OBJPACK-HEAD_NUM = 0.
T_OBJPACK-BODY_START = 1.
DESCRIBE TABLE T_OBJBIN LINES V_LINES_BIN.
READ TABLE T_OBJBIN INDEX V_LINES_BIN.
T_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
T_OBJPACK-BODY_NUM = V_LINES_BIN.
T_OBJPACK-DOC_TYPE = 'PDF'.
T_OBJPACK-OBJ_NAME = 'smart'.
T_OBJPACK-OBJ_DESCR = 'test'.
APPEND T_OBJPACK.
CLEAR T_RECLIST.
T_RECLIST-RECEIVER = 'MAIL-ID'.
T_RECLIST-REC_TYPE = 'U'.
APPEND T_RECLIST.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
DOCUMENT_DATA = WA_DOC_CHNG
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
TABLES
PACKING_LIST = T_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = T_OBJBIN
CONTENTS_TXT = T_OBJTXT
RECEIVERS = T_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.
IF SY-SUBRC <> 0.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF.
and i thought of one more soluyion u can write
wa_ctrlop-langu = T002-spras. i think it will also help for u.
revert back if any questions.
please reward me if helpful.
gupta.pullipudi
Maybe you are looking for
-
Can't open Adobe Reader for Mac
Hello there! I have installed Adobe Reader but I can't open the program. I have a mackbook pro with OS X version 10.8.3
-
How to impert standard text?
hi, can anybody tell me how to import standard text?
-
How to switch two languages in wireless keyboard in window 7 in imac?
I bought Imac in Canada and bought wireless keyboard which has Korean and English in Korea. Now I connect and use English Korean keyboard in OS X succesfully. But I can't use English Korean keyboard in window 7 in Bootcamp.. The English Korean keybo
-
Delete Stock transfer requisitions
Hi, 1. Is the programs /SAPAPO/RLCDELETE used to delete any transaction data or just the orphan orders? 2. Do we need to delete stock transfer requisitions before running deployment? 3. Is there a best practice to delete so many days STRs and run de
-
Updating the Message priorities in AQ after publishing ?
Hi, I would like to know updating the message priorities in AQ after publishing the messages to AQ through Oracle JMS is a good approach ?. Please post your comments on this. Regards, Murali.