Problem in sending the Smartform Output as PDF through Mail
Dear All,
I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file, it is giving error that FILE IS DAMAGED. Below is the code:
REPORT Y_SEND_MAIL2.
TABLES: vbrk, vbrp.
TYPE-POOLS: abap.
DATA: it_vbrk TYPE TABLE OF vbrk WITH HEADER LINE.
DATA: i_formname TYPE tdsfname,
i_fm_name TYPE rs38l_fnam,
it_vbak TYPE TABLE OF vbak WITH HEADER LINE,
it_ekko TYPE TABLE OF ekko WITH HEADER LINE.
DATA: is_bil_invoice TYPE lbbil_invoice,
output_options TYPE ssfcompop,
control_parameters TYPE ssfctrlop,
e_devtype TYPE rspoptype,
job_output_info TYPE ssfcrescl,
bin_file TYPE xstring,
lines TYPE TABLE OF tline WITH HEADER LINE,
doctab_archive TYPE TABLE OF docs WITH HEADER LINE,
filelength TYPE i,
bin_filesize TYPE i,
docs TYPE TABLE OF docs WITH HEADER LINE.
*"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.
DATA: BEGIN OF line_bin,
data(1024) TYPE x,
END OF line_bin.
DATA: data_tab_bin LIKE STANDARD TABLE OF line_bin.
So please suggest a solution.
Regards,
Vishal
Continued:
SELECT-OPTIONS: s_vbeln FOR vbrk-vbeln,
s_fkdat FOR vbrk-fkdat OBLIGATORY DEFAULT sy-datum.
SELECT * FROM vbrk
INTO TABLE it_vbrk
WHERE fkdat IN s_fkdat
AND vbeln IN s_vbeln.
i_formname = 'Z_SD_JINDAL_INVOICE10'.
output_options-tddest = 'LP02'.
output_options-tdimmed = 'X'.
output_options-tdnewid = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = i_formname
IMPORTING
fm_name = i_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0. "checking subrc
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. "IF sy-subrc <> 0
READ TABLE it_vbrk INDEX 1.
IF sy-subrc = 0.
is_bil_invoice-hd_gen-bil_number = it_vbrk-vbeln.
ENDIF.
control_parameters-no_dialog = 'X'.
control_parameters-getotf = 'X'.
CALL FUNCTION i_fm_name "'/1BCDWB/SF00000097'
EXPORTING
control_parameters = control_parameters
output_options = output_options
user_settings = space
is_bil_invoice = is_bil_invoice
IMPORTING
job_output_info = job_output_info
TABLES
it_vbak = it_vbak
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.
*FORM convert_otf_2_pdf.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
* EXPORTING
* USE_OTF_MC_CMD = 'X'
* ARCHIVE_INDEX =
IMPORTING
bin_filesize = bin_filesize
TABLES
otf = job_output_info-otfdata[]
doctab_archive = docs[]
lines = 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.
*ENDFORM. "convert_otf_2_pdf
Similar Messages
-
Problem in sending the file as an attachment through mail
Hi,
I have developed a Zreport. The functionality is like on executing this report it should send an e-mail with an attachment of the data in the xcel format.
So, while execting this report in background mode in ECC 5.0, it is able to send the mail as an attachment but the file doesn't contain the data in it But, the same report while trying to execute in back ground mode in ECC 6.0, it is able to send the mail with the attachment and the file also has the data.
So, my question is like are there any patches that has to be installed in ECC 5.0 system to get this successfully done.
Thanks in advance for your answers.
RohithHello,
Are you using the standad sap function module or using OLE objects to generate excel?
First try creating the excel file in foreground and see if the data is being populated.
Kind Regards,
Niky. -
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. -
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 -
Convert the smartform output to PDF when giving print from vf31
Hi Gurus,
I am facing one problem.I developed the program to chnage smartform output to PDF file when giving invoice print from VF02/VF03.
The same functionality i want to appy when i am giving print for the invoice through VF31.
I put the break-point in the driver program.But it is not stopping there when i am giving print from VF31.
How can i do this one..
Please Help Me.
Thanks &Regards,
R.P.SastryWhich Program you are putting the Breakpoint?
-
How can we send the smartform output to mail.
Dear Friends,
My query is how can we send the smart form output to mail.
In my company,payslip are given to the employee in printed format.instead of that we need to send payslip in mail.how can i do..plz help me.
[email protected]The code below demonstrates how to retrieve a spool request and email it as a PDF document. Please note to process a spool request the program can be executed in background or foreground. Because of the additional functionality to allow this to work in both background and foreground it has made it a little more confusing soyou might want to start by looking at the background only program. Also see transaction SCOT for SAPConnect administration.
*& Report ZSPOOLTOPDF2 *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program can be run in background or online and a spool request *
*& will still be created *
REPORT zspooltopdf2.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX,
p_online no-display.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i,
w_spool_nr like sy-spono.
%_print LIKE pri_params.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
Write statement to represent report output. Spool request is created
if write statement is executed in background. This could also be an
ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
If p_online = 'X'.
Processing performed when program calls itself when run online
gd_spool_nr = sy-spono.
EXPORT gd_spool_nr TO MEMORY ID 'SPOOLTOPDF'.
EXIT.
endif.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
ELSE.
gd_spool_nr = sy-spono.
If executed online, it submits a program to perform the write statements
instructing it to create a spool request, this could be another program
which just performs the write statements and then exports sy-spono
to memory. But in this example it calls itself passing X to parameter
p_online, which takes it down an alternative procesing path.
submit ZSPOOLTOPDF2
with p_online = 'X'
to sap-spool
spool parameters %_print
archive parameters %_print
without spool dynpro
and return.
ENDIF.
Get spool id from program called above
IMPORT gd_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
FORM get_job_details *
FORM get_job_details.
Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 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
OTHERS = 12.
CHECK sy-subrc = 0.
Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
perform send_email using p_email2.
ENDFORM.
FORM send_email *
--> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
Fill the document data.
w_doc_data-doc_size = 1.
Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.
Populate zerror return code
ld_error = sy-subrc.
Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
Regards,
Shakti Barath -
Sending the smartform output to SPOOL
Hi,
How do I create a spool request with the smartform out put? I have passed the following parameters, but it still does not create a spool request.
data: W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP.
W_CTRLOP-LANGU = LS_CONTROL-LANGU.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
W_COMPOP-TDNOPRINT = 'X'.
W_COMPOP-TDDATASET = 'VENEVA'.
w_COMPOP-TDDEST = 'UK24'.
W_COMPOP-TDNEWID = 'X'.
W_COMPOP-XSFOUTMODE = 'S'.
Thank you,
Geethahi Geetha,
is there any specifice reason to passin this <b>W_COMPOP-XSFOUTMODE = 'S'</b>
pass these parameters only u will get the spool in <b>JOB_OUTPUT_INFO-SPOOLIDS</b>
W_CTRLOP-LANGU = LS_CONTROL-LANGU.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
W_COMPOP-TDDATASET = 'VENEVA'.
w_COMPOP-TDDEST = 'UK24'.
W_COMPOP-TDNEWID = 'X'.
Please Close this thread.. when u r problem is solved. Reward all Helpful answers
Regards
Naresh Reddy K -
Separate program to send a smartform converted into pdf, thru mail
Hi Folks,
I had created a smartform and converted it into a PDF format.
Now I want a separate program where in if i submit this program it should sent it throuogh mail.
Note:-<b>I want a separate program not the one where in you design a smartform,convert into pdf and then send thru mail all in one program</b>
Points will be given.
K.Kiran.hi kiran
the program is as follows
The user is provided with
a) file name
b) email address to send mail
and it sends ANY FILE (.xls,.pdf .xyz..)
Instantaneously !
4. Make two things first :
1. Include with the name : ZAMI_INCLFOR_MAIL
2. Report with the name : ZAM_TEMP147 (any name will do)
3. Activate both and execute (2)
4. After providing filename, email adress
5. Code for Include :
Data
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.
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
CODE FOR PROGRAM
5.
REPORT zam_temp147 .
INCLUDE zami_inclfor_mail.
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
regards,
navjot
reward if helpfull -
Smartform output as PDF via mail
hello,
Where can I mention the device name for my requirement as mentioned in the subject.
I found that system picks the default device in the user profile. How can I avoid that.
I want to give a particular destination device name.
Please help.
Thanks.Hello,
I solved it by setting COMPOSER_PARAMETERS-TDDEST to device of my interest and then USER_SETTINGS = SPACE.
Now system will not pick device from User Profile.
Thanks for old posts in SDN.
Solved. -
Sending smartform output as PDF attachment, Error opening PDF attachment
Hi Experts,
I am using the code form the following link to send a smartform output as PDF attachment. I can able to see the message, but can not open PDF document.
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/convertSmartformtoPDFformat&
The information should be on my smartform are some text, company logo and a barcode.
With all of these received error: "There was an error opening this document. The file is damaged and could not be repaired."
I tried different ways like only text, text with company logo, text with barcode. I got the following errors:
An unrecognized token 'Td0' was found
There was problem reading this document(16).
There was problem reading this document(111).
Does anyone have idea of these ? Your help is greatly appreciated.
Thank you,
Suryaplease see this code ... for sending the Email as PDF attach file,
*& Report ZSPOOLTOPDF *
*& Converts spool request into PDF document and emails it to *
*& recipicant. *
*& Execution *
*& This program must be run as a background job in-order for the write *
*& commands to create a Spool request rather than be displayed on *
*& screen *
REPORT zspooltopdf.
PARAMETER: p_email1 LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_sender LIKE somlreci1-receiver
DEFAULT '[email protected]',
p_delspl AS CHECKBOX.
*DATA DECLARATION
DATA: gd_recsize TYPE i.
* Spool IDs
TYPES: BEGIN OF t_tbtcp.
INCLUDE STRUCTURE tbtcp.
TYPES: END OF t_tbtcp.
DATA: it_tbtcp TYPE STANDARD TABLE OF t_tbtcp INITIAL SIZE 0,
wa_tbtcp TYPE t_tbtcp.
* Job Runtime Parameters
DATA: gd_eventid LIKE tbtcm-eventid,
gd_eventparm LIKE tbtcm-eventparm,
gd_external_program_active LIKE tbtcm-xpgactive,
gd_jobcount LIKE tbtcm-jobcount,
gd_jobname LIKE tbtcm-jobname,
gd_stepcount LIKE tbtcm-stepcount,
gd_error TYPE sy-subrc,
gd_reciever TYPE sy-subrc.
DATA: w_recsize TYPE i.
DATA: gd_subject LIKE sodocchgi1-obj_descr,
it_mess_bod LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_mess_att LIKE solisti1 OCCURS 0 WITH HEADER LINE,
gd_sender_type LIKE soextreci1-adr_typ,
gd_attachment_desc TYPE so_obj_nam,
gd_attachment_name TYPE so_obj_des.
* Spool to PDF conversions
DATA: gd_spool_nr LIKE tsp01-rqident,
gd_destination LIKE rlgrap-filename,
gd_bytecount LIKE tst01-dsize,
gd_buffer TYPE string.
* Binary store for PDF
DATA: BEGIN OF it_pdf_output OCCURS 0.
INCLUDE STRUCTURE tline.
DATA: END OF it_pdf_output.
CONSTANTS: c_dev LIKE sy-sysid VALUE 'DEV',
c_no(1) TYPE c VALUE ' ',
c_device(4) TYPE c VALUE 'LOCL'.
*START-OF-SELECTION.
START-OF-SELECTION.
* Write statement to represent report output. Spool request is created
* if write statement is executed in background. This could also be an
* ALV grid which would be converted to PDF without any extra effort
WRITE 'Hello World'.
new-page.
commit work.
new-page print off.
IF sy-batch EQ 'X'.
PERFORM get_job_details.
PERFORM obtain_spool_id.
*** Alternative way could be to submit another program and store spool
*** id into memory, will be stored in sy-spono.
*submit ZSPOOLTOPDF2
* to sap-spool
* spool parameters %_print
* archive parameters %_print
* without spool dynpro
* and return.
* Get spool id from program called above
* IMPORT w_spool_nr FROM MEMORY ID 'SPOOLTOPDF'.
PERFORM convert_spool_to_pdf.
PERFORM process_email.
if p_delspl EQ 'X'.
PERFORM delete_spool.
endif.
IF sy-sysid = c_dev.
wait up to 5 seconds.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
AND RETURN.
ENDIF.
ELSE.
SKIP.
WRITE:/ 'Program must be executed in background in-order for spool',
'request to be created.'.
ENDIF.
* FORM obtain_spool_id *
FORM obtain_spool_id.
CHECK NOT ( gd_jobname IS INITIAL ).
CHECK NOT ( gd_jobcount IS INITIAL ).
SELECT * FROM tbtcp
INTO TABLE it_tbtcp
WHERE jobname = gd_jobname
AND jobcount = gd_jobcount
AND stepcount = gd_stepcount
AND listident <> '0000000000'
ORDER BY jobname
jobcount
stepcount.
READ TABLE it_tbtcp INTO wa_tbtcp INDEX 1.
IF sy-subrc = 0.
message s004(zdd) with gd_spool_nr.
gd_spool_nr = wa_tbtcp-listident.
MESSAGE s004(zdd) WITH gd_spool_nr.
ELSE.
MESSAGE s005(zdd).
ENDIF.
ENDFORM.
* FORM get_job_details *
FORM get_job_details.
* Get current job details
CALL FUNCTION 'GET_JOB_RUNTIME_INFO'
IMPORTING
eventid = gd_eventid
eventparm = gd_eventparm
external_program_active = gd_external_program_active
jobcount = gd_jobcount
jobname = gd_jobname
stepcount = gd_stepcount
EXCEPTIONS
no_runtime_info = 1
OTHERS = 2.
ENDFORM.
* FORM convert_spool_to_pdf *
FORM convert_spool_to_pdf.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = gd_spool_nr
no_dialog = c_no
dst_device = c_device
IMPORTING
pdf_bytecount = gd_bytecount
TABLES
pdf = it_pdf_output
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 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
OTHERS = 12.
CHECK sy-subrc = 0.
* Transfer the 132-long strings to 255-long strings
LOOP AT it_pdf_output.
TRANSLATE it_pdf_output USING ' ~'.
CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.
ENDLOOP.
TRANSLATE gd_buffer USING '~ '.
DO.
it_mess_att = gd_buffer.
APPEND it_mess_att.
SHIFT gd_buffer LEFT BY 255 PLACES.
IF gd_buffer IS INITIAL.
EXIT.
ENDIF.
ENDDO.
ENDFORM.
* FORM process_email *
FORM process_email.
DESCRIBE TABLE it_mess_att LINES gd_recsize.
CHECK gd_recsize > 0.
PERFORM send_email USING p_email1.
* perform send_email using p_email2.
ENDFORM.
* FORM send_email *
* --> p_email *
FORM send_email USING p_email.
CHECK NOT ( p_email IS INITIAL ).
REFRESH it_mess_bod.
* Default subject matter
gd_subject = 'Subject'.
gd_attachment_desc = 'Attachname'.
* CONCATENATE 'attach_name' ' ' INTO gd_attachment_name.
it_mess_bod = 'Message Body text, line 1'.
APPEND it_mess_bod.
it_mess_bod = 'Message Body text, line 2...'.
APPEND it_mess_bod.
* If no sender specified - default blank
IF p_sender EQ space.
gd_sender_type = space.
ELSE.
gd_sender_type = 'INT'.
ENDIF.
* Send file by email as .xls speadsheet
PERFORM send_file_as_email_attachment
tables it_mess_bod
it_mess_att
using p_email
'Example .xls documnet attachment'
'PDF'
gd_attachment_name
gd_attachment_desc
p_sender
gd_sender_type
changing gd_error
gd_reciever.
ENDFORM.
* FORM delete_spool *
FORM delete_spool.
DATA: ld_spool_nr TYPE tsp01_sp0r-rqid_char.
ld_spool_nr = gd_spool_nr.
CHECK p_delspl <> c_no.
CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
EXPORTING
spoolid = ld_spool_nr.
ENDFORM.
*& Form SEND_FILE_AS_EMAIL_ATTACHMENT
* Send email
FORM send_file_as_email_attachment tables it_message
it_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: ld_error TYPE sy-subrc,
ld_reciever TYPE sy-subrc,
ld_mtitle LIKE sodocchgi1-obj_descr,
ld_email LIKE somlreci1-receiver,
ld_format TYPE so_obj_tp ,
ld_attdescription TYPE so_obj_nam ,
ld_attfilename TYPE so_obj_des ,
ld_sender_address LIKE soextreci1-receiver,
ld_sender_address_type LIKE soextreci1-adr_typ,
ld_receiver LIKE sy-subrc.
data: t_packing_list like sopcklsti1 occurs 0 with header line,
t_contents like solisti1 occurs 0 with header line,
t_receivers like somlreci1 occurs 0 with header line,
t_attachment like solisti1 occurs 0 with header line,
t_object_header like solisti1 occurs 0 with header line,
w_cnt type i,
w_sent_all(1) type c,
w_doc_data like sodocchgi1.
ld_email = p_email.
ld_mtitle = p_mtitle.
ld_format = p_format.
ld_attdescription = p_attdescription.
ld_attfilename = p_filename.
ld_sender_address = p_sender_address.
ld_sender_address_type = p_sender_addres_type.
* Fill the document data.
w_doc_data-doc_size = 1.
* Populate the subject/generic message attributes
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle .
w_doc_data-sensitivty = 'F'.
* Fill the document data and get size of attachment
CLEAR w_doc_data.
READ TABLE it_attach INDEX w_cnt.
w_doc_data-doc_size =
( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
w_doc_data-obj_langu = sy-langu.
w_doc_data-obj_name = 'SAPRPT'.
w_doc_data-obj_descr = ld_mtitle.
w_doc_data-sensitivty = 'F'.
CLEAR t_attachment.
REFRESH t_attachment.
t_attachment[] = it_attach[].
* Describe the body of the message
CLEAR t_packing_list.
REFRESH t_packing_list.
t_packing_list-transf_bin = space.
t_packing_list-head_start = 1.
t_packing_list-head_num = 0.
t_packing_list-body_start = 1.
DESCRIBE TABLE it_message LINES t_packing_list-body_num.
t_packing_list-doc_type = 'RAW'.
APPEND t_packing_list.
* Create attachment notification
t_packing_list-transf_bin = 'X'.
t_packing_list-head_start = 1.
t_packing_list-head_num = 1.
t_packing_list-body_start = 1.
DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
t_packing_list-doc_type = ld_format.
t_packing_list-obj_descr = ld_attdescription.
t_packing_list-obj_name = ld_attfilename.
t_packing_list-doc_size = t_packing_list-body_num * 255.
APPEND t_packing_list.
* Add the recipients email address
CLEAR t_receivers.
REFRESH t_receivers.
t_receivers-receiver = ld_email.
t_receivers-rec_type = 'U'.
t_receivers-com_type = 'INT'.
t_receivers-notif_del = 'X'.
t_receivers-notif_ndel = 'X'.
APPEND t_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = w_doc_data
put_in_outbox = 'X'
sender_address = ld_sender_address
sender_address_type = ld_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = w_sent_all
TABLES
packing_list = t_packing_list
contents_bin = t_attachment
contents_txt = it_message
receivers = t_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.
* Populate zerror return code
ld_error = sy-subrc.
* Populate zreceiver return code
LOOP AT t_receivers.
ld_receiver = t_receivers-retrn_code.
ENDLOOP.
ENDFORM.
reward points if it is usefull ....
Girish -
Smartform Output To PDF And Send It As External Mail
Dear All,
I am sending the Smartform Output as an attachment by converting it into PDF. But when I am recieve this attachment I am unable to open the PDF file,it is giving error that FILE IS DAMAGED
So please suggest a solution.
Regards,
BhaveshREPORT ZTEST_PDF_MAIL.
Internal Table declarations
PARAMETERS : p_ebeln TYPE ekko-ebeln DEFAULT '4500000003'.
DATA: I_OTF TYPE ITCOO OCCURS 0 WITH HEADER LINE,
I_TLINE TYPE TABLE OF TLINE WITH HEADER LINE,
I_RECEIVERS TYPE TABLE OF SOMLRECI1 WITH HEADER LINE,
I_RECORD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
Objects to send mail.
I_OBJPACK LIKE SOPCKLSTI1 OCCURS 0 WITH HEADER LINE,
I_OBJTXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE,
I_RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE,
Work Area declarations
WA_OBJHEAD TYPE SOLI_TAB,
W_CTRLOP TYPE SSFCTRLOP,
W_COMPOP TYPE SSFCOMPOP,
W_RETURN TYPE SSFCRESCL,
WA_DOC_CHNG TYPE SODOCCHGI1,
W_DATA TYPE SODOCCHGI1,
WA_BUFFER TYPE STRING, "To convert from 132 to 255
Variables declarations
V_FORM_NAME TYPE RS38L_FNAM,
V_LEN_IN LIKE SOOD-OBJLEN,
V_LEN_OUT LIKE SOOD-OBJLEN,
V_LEN_OUTN TYPE I,
V_LINES_TXT TYPE I,
V_LINES_BIN TYPE I.
DATA:it_pdfdata TYPE TABLE OF tline.
DATA:it_pdf TYPE TABLE OF solisti1.
BREAK-POINT .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZCSF_MM_PO_ORIGINAL'
IMPORTING
FM_NAME = V_FORM_NAME
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
W_CTRLOP-GETOTF = 'X'.
W_CTRLOP-NO_DIALOG = 'X'.
W_COMPOP-TDNOPREV = 'X'.
CALL FUNCTION V_FORM_NAME
EXPORTING
CONTROL_PARAMETERS = W_CTRLOP
OUTPUT_OPTIONS = W_COMPOP
USER_SETTINGS = 'X'
P_EBELN = P_EBELN
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
I_OTF[] = W_RETURN-OTFDATA[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = V_LEN_IN
TABLES
OTF = I_OTF
LINES = I_TLINE
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
ENDIF.
LOOP AT I_TLINE.
TRANSLATE I_TLINE USING '~'.
CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.
ENDLOOP.
TRANSLATE WA_BUFFER USING '~'.
DO.
I_RECORD = WA_BUFFER.
APPEND I_RECORD.
SHIFT WA_BUFFER LEFT BY 255 PLACES.
IF WA_BUFFER IS INITIAL.
EXIT.
ENDIF.
ENDDO.
Attachment
REFRESH: I_RECLIST,
I_OBJTXT,
I_OBJBIN,
I_OBJPACK.
CLEAR WA_OBJHEAD.
I_OBJBIN[] = I_RECORD[].
Create Message Body Title and Description
I_OBJTXT = 'test with pdf-Attachment!'.
APPEND I_OBJTXT.
DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.
READ TABLE I_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 I_OBJPACK-TRANSF_BIN.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
I_OBJPACK-BODY_NUM = V_LINES_TXT.
I_OBJPACK-DOC_TYPE = 'RAW'.
APPEND I_OBJPACK.
Attachment (pdf-Attachment)
I_OBJPACK-TRANSF_BIN = 'X'.
I_OBJPACK-HEAD_START = 1.
I_OBJPACK-HEAD_NUM = 0.
I_OBJPACK-BODY_START = 1.
DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.
READ TABLE I_OBJBIN INDEX V_LINES_BIN.
I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .
I_OBJPACK-BODY_NUM = V_LINES_BIN.
I_OBJPACK-DOC_TYPE = 'PDF'.
I_OBJPACK-OBJ_NAME = 'smart'.
I_OBJPACK-OBJ_DESCR = 'test'.
APPEND I_OBJPACK.
CLEAR I_RECLIST.
I_RECLIST-RECEIVER = 'XYZ'.
I_RECLIST-REC_TYPE = 'U'.
APPEND I_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 = I_OBJPACK
OBJECT_HEADER = WA_OBJHEAD
CONTENTS_BIN = I_OBJBIN
CONTENTS_TXT = I_OBJTXT
RECEIVERS = I_RECLIST
EXCEPTIONS
TOO_MANY_RECEIVERS = 1
DOCUMENT_NOT_SENT = 2
DOCUMENT_TYPE_NOT_EXIST = 3
OPERATION_NO_AUTHORIZATION = 4
PARAMETER_ERROR = 5
X_ERROR = 6
ENQUEUE_ERROR = 7
OTHERS = 8.
IF SY-SUBRC <> 0.
WRITE:/ 'Error When Sending the File', SY-SUBRC.
ELSE.
WRITE:/ 'Mail sent'.
ENDIF. -
I have a problem in converting smartform output to pdf format.
Hi,
While converting the smartform output to pdf format.
It is showing this error.
otf end command // missing in otf data.
I have used this function.
Assigning the OTFDATA to OTF Structure table
CLEAR gt_otf.
gt_otf[] = gs_otfdata-otfdata[].
Convert the OTF DATA to SAP Script Text lines
CLEAR gt_pdf_tab.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
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.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Please help me in this regard. Thanks in advance.Hi ,
I am getting this exception "err_conv_not_possible"
CALL FUNCTION f_name " '/1BCDWB/SF00000092'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = st_control_parameters
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = st_output_options
USER_SETTINGS = 'X'
ZST_TEXTSYMBOLS = ZST_TEXTSYMBOLS
wa_kna1 = wa_kna1
wa_claim_header = wa_claim_header
IMPORTING
DOCUMENT_OUTPUT_INFO = st_document_output_info
JOB_OUTPUT_INFO = st_job_output_info
JOB_OUTPUT_OPTIONS = st_job_output_options
TABLES
IT_CLAIM_VERSION = IT_CLAIM_VERSION
IT_CLAIM_ITEM = IT_CLAIM_ITEM
IT_CLAIM_PARTNER = IT_CLAIM_PARTNER
IT_FINAL = IT_FINAL
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.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX =
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.
ENDIF.
HERE when i tried to debug it i got SY-SUBRC = 1.
Please help me in this regard. Thanks in advance. -
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 -
Logo in Smartform output to pdf format is coming as Junk Character
Hi All,
I have a requirement to generate the Smartform output in PDF file. But when i am doing that i am getting the LOGO as Junk character in the PDF file. Can any one help me to resolve this issue?.
Thanks,
Muruganand.KYes check the spool and the output displayed correctly in the spool it means there is a problem when you convert OTF to PDF. Check that part of the code and try different options.
-
Smartform Output to PDF conversion
Hi experts,
i want to convert the smartform output to PDF Format and stored it in system level.But i got the following information message "OTF end command // missing in OTF data".
I used "CONVERT_OTF" for conversion of smartform output and "WS_DOWNLOAD & GUI_DOWNLOAD".
wt it means,can i make any changes,if tl me why it shows the message.
points wl be rewarded.
Thank you
chandu
Edited by: Chandu Valluri on Jan 4, 2008 12:56 PMhi,
*& Report ZPDF_DNLD_TEST2 *
*& DEVK904540 *
REPORT ZPDF_DNLD_TEST2 .
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'.
CALL FUNCTION '/1BCDWB/SF00000005'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = op_option
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
itab1 = itab1
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO = job_output
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.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE =
BIN_FILE =
TABLES
otf = job_output-otfdata
lines = i_pdf
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 =
filename = 'c:\test_pdf_sf.pdf'
FILETYPE = 'BIN'
tables
data_tab = i_pdf
FIELDNAMES =
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.
Maybe you are looking for
-
No se encontró el costo de uno o varios artículos
Hola, al tratar de crear una Entrega a partir de una Orden de Vta. me da el error "No se encontró el costo de uno o varios artículos" y me indica el código del artículo. Si voy a los datos maestros de ese artículo y checo la Lista de registros contab
-
SharePoint 2013 multiple search boxes on a single page
How can I have multiple independent search boxes on a single SharePoint 2013 page? My scenario is this: 1. Search Box 1 is added to the master page 2. Search Box 2 is on a dedicated search page along with a search results web part. Search Box 1 is t
-
Screen wallpaper snapshot without desktop icons appearing in it?
Greetings: I wish to create a screen snapshot for wallpaper without the desktop icons appearing in the shot. You see, on Tiger I use VirtueDesktop with MenuShade to create a wallpaper that uses fonts and won't display the menubar. However, Leopard re
-
No WF event triggered from PR coming from MRP
Hi every one, I have some Purchase Requisitions coming from MRP process, those PR doesnu2019t trigger any Workflow event to start a Workflow to approve them up (client requirement). The regular PR (manually) does trigger the traditional event. My q
-
Transferring Music/Videos/Photos on Zen Vision: M prob
[color="#ff00ff"><font face="Verdana" color="#009999">I seriously need help soon. This has been happening to me ever since Sunday. Whenever i try to music/videos/photos on my mp3 player a message pops up saying Acess Denied. And whenever i try to do