Downloading smartform as pdf (protecting)
Hi,
I have downloaded smartform contents into a pdf file.
Is there any way to protect the document like setting a password for the document.
That is,i have downloaded that pdf.while opening it must want to ask a password before opening.Is it possible via SAP.
Anybody plz help me
Hi Ramya
Refer this link
Re: Smartform in pdf format.
Thanks,
Syf
Similar Messages
-
While downloading smartform into PDF the character formatting such as "BOLD, UNERLINE,ITALIC" are not reflecting in the PDF document.
The following function modules are used for downloading:
1)'CONVERT_OTF'
2)'GUI_DOWNLOAD'
The printer used is 'LOCL' (Local Windows Printer).hi friend,
plz Check if the smartstyle for the respective smartform is transported or not.
Regards,
K.S.Kannan -
in script it is possible to download in pdf format without new spool
request.is it possible in smartforms if possible please help..Go through the link given below :
SMARTFORM to PDF File format
Smartform to PDF format -
Problem in downloading smartform as pdf file...
Hi SDNs.,
while downloading the invoice layout as .PDF file.. i am getting following error...
<b>OTF end command // missing in OTF data</b>
and the file is downloading as empty size... ( xyz.pdf with 0kb )
It is working fine in sandbox... i am getting this error in production...
what could be the probelm? when this type of error occurs?hi raghu.,
CALL FUNCTION LF_FM_NAME
EXPORTING
ARCHIVE_INDEX = TOA_DARA
ARCHIVE_PARAMETERS = ARC_PARAMS
CONTROL_PARAMETERS = W_CTRLOP
MAIL_RECIPIENT = LS_RECIPIENT
MAIL_SENDER = LS_SENDER
OUTPUT_OPTIONS = LS_COMPOSER_PARAM
USER_SETTINGS = 'X'
IS_BIL_INVOICE = LS_BIL_INVOICE
IS_NAST = NAST
IS_REPEAT = REPEAT
OUT_TYPE = V_OUTPUT
TEMP_LST = TEMP_LST
TEMP_CST = TEMP_CST
TEMP_TELF1 = TEMP_TELF1
TEMP_TELFX = TEMP_TELFX
TEMP_NAME1 = TEMP_NAME1
TEMP_STRAS = TEMP_STRAS
TEMP_ADRNR = TEMP_ADRNR
TMP_VAT = TMP_LST
TMP_CST = TMP_CST
TEMP_WERKS = TEMP_WERKS
VAT_DATE = VAT_DATE
CST_DATE = CST_DATE
VAT = VAT
I_ADDRESS = I_ADDRESS
FLAG_HDR = FLAG_HDR
I_ADDR = I_ADDR
TMP_CST_DATE = TMP_CST_DATE " mod-004
TMP_LST_DATE = TMP_LST_DATE " mod-004
IMPORTING
JOB_OUTPUT_INFO = W_RETURN
TABLES
IT_KONV = TEMP_KONV
IT_VBRP = IT_VBRP_FORM
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 protocoll and store it in the NAST protocoll
PERFORM ADD_SMFRM_PROT.
ENDIF.
ENDDO.
LS_COMPOSER_PARAM-TDCOPIES = NAST_ANZAL.
IF NOT NAST_TDARMOD IS INITIAL.
NAST-TDARMOD = NAST_TDARMOD.
CLEAR NAST_TDARMOD.
ENDIF.
ENDIF.
************************add for pdf**********************************
I_OTF[] = W_RETURN-OTFDATA[].
DATA : ITAB2 LIKE DOCS OCCURS 0,
SIZE TYPE I.
BIL_NUM = LS_BIL_INVOICE-HD_GEN-BIL_NUMBER.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
USE_OTF_MC_CMD = 'X'
ARCHIVE_INDEX =
IMPORTING
BIN_FILESIZE = SIZE
TABLES
OTF = I_OTF
DOCTAB_ARCHIVE = ITAB2
LINES = I_TLINE
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.
****************download************************
CONCATENATE 'C:\' BIL_NUM '.PDF' INTO FILENAME.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = FILENAME
FILETYPE = 'BIN'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = I_TLINE
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.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
IF SY-SUBRC = 0.
message i000.
ENDIF.
is this enough????
Thanking you.., -
Download smartform as PDF, suppress Print/Preview dialog
Hi Experts,
Facing some issues in downloading PDF converted from Smartform.
In the program I am trying directly download a smartform converted into PDF format and save it in local system.
When ever I am trying to execute the program it shows up the Print/Preview dialog before showing the Save As dialog.
I have passed control_parameters-getotf = 'X' to the smartform runtime FM, which ideally should have suppressed the Print/Preview dialog and return the otfdata.
Here the entire code is...
Moderator message - Please respect the 2,500 character maximum when posting. Post only the relevant portions of code
The program other wise works absolutly fine .
Please advise.
Thanks
Jahan
Edited by: Rob Burbank on Apr 8, 2010 11:10 AMHelloo Guyz...
I am exactly trying the same, but the Print Dialog is still coming ...
See here is my code ..
cont_param-getotf = 'X'.
cont_param-no_dialog = 'X'.
cont_param-preview = 'X' .
CALL FUNCTION fm_name
EXPORTING
control_parameters = cont_param
IMPORTING
job_output_info = otfdata
TABLES
s_bukrs = s_bukrs[]
s_gjahr = s_gjahr[]
s_rebzg = s_rebzg[]
s_kunnr = s_kunnr[]
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
even after this ..during execution the the Print Dialog is coming..
I have no idea what esle I am missing..
Thanks -
Download Smartform as PDF in background to App. Server
Hi experts,
we would like to create in background a smartform and convert its OTF stream to PDF. The challenge is now to
download the PDF file to the App. Server or to the BDS.
Our problem is, that the PDF data content doesn't fit to any known methods or function modules for downloading.
Short example what we have so far:
*create form
CALL FUNCTION l_function_module_name
EXPORTING
control_parameters = ls_output_control
output_options = ls_output_options
user_settings = ' '
IMPORTING
job_output_info = ls_output_info
TABLES
form_data = lt_sf_table
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
*convert to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = l_filesize
TABLES
otf = ls_output_info-otfdata
lines = lt_pdf_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
Problem: lt_pdf_lines does not have the right format e.g. using download to BDS:
CL_BDS_DOCUMENT_SET=>CREATE_WITH_TABLE requires a linetype RAW 1022
I am sure anybody of you has already downloaded a PDF in background to the BDS or application server and could give me a hint.
Please note, we are in backgroung and GUI_DOWNLOAD will not help.
Regards
TomPlease go through this link , hope you will get some useful stuff from this.
http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450
*& Form f9100_save_to_pdf
text
-->P_WS_FORMNAME text
FORM f9100_save_to_pdf using value(ws_formname).
data: i_lines TYPE tline OCCURS 0 WITH HEADER LINE.
data: ws_bin_size type i,
ws_filename type string.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = ws_bin_size
TABLES
otf = i_otf
lines = i_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
flg_exit = 'X'.
MESSAGE i050 WITH 'Error converting to PDF format'.
EXIT.
ENDIF.
Get the download path
PERFORM get_download_path CHANGING ws_filename.
if flg_exit = 'X'.
EXIT.
endif.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = ws_bin_size
filename = ws_filename
filetype = 'BIN'
TABLES
data_tab = i_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 i050 WITH 'Error while File download'.
flg_exit = 'X'.
EXIT.
ELSE.
MESSAGE i050 WITH 'File downloaded successfully '.
flg_exit = 'X'.
EXIT.
ENDIF.
Regards,
Prakash. -
Converting Smartform into pdf in encrypted format
Hi All,
I have a requirement to download smartform into pdf format. I have done this,but this pdf is editable with pdf editor tool.
is there any way to encrypt pdf data and downloading it? I find some FM's in forum but those are used to encrypt and decrypt the passwords etc....
Thanks in advance..
AnjiHi
SMART form to PDF
https://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat
smartform to MAIL
https://wiki.sdn.sap.com/wiki/display/Snippets/SmartformtoMailasPDF+attachment -
Hi All,
I created a smartform and got the PDF output of the same
using the function module FOPC_REPORT_SHOW_PDF.
I created a smartstyle using Arial Font (REgular, Size 12)
and I have used this smartstyle in the smartform.
When I displayed the smartform in OTF format I am able to see the exact font maintained in the smartstyle. But when the smartform is converted to PDF; the PDF o/p always displays the default font which is Courier/12.
Can anyone help me in resolving the issue.
<u>Additional Info</u>
I got the device type (PDF1) using the function module SSF_GET_DEVICE_TYPE and used the device type in the smartform display. When checked in Se73 this device type supports the Arial Font; but this font in SE73 is marked by a yellow line.
Regards,
MathiHi,
You can try this as alternative.
SmartForms Output to PDF
There is a way to download smartform in PDF format.
Please do the following:
1. Print the smartform to the spool.
2. Note the spool number.
3. Download a PDF file (Acrobat Reader) version of the spool by running Program RSTXPDFT4 and entering the
noted spool number.
feel free to revert back.
--Ragu -
DOWNLOAD SMARTFORM IN TXT FORMAT
NORMALLY WE DOWNLOAD SMARTFORM IN PDF FORMAT BUT I HAVE REQUIREMENT TO DOWNLOAD IN TEXT FORMAT.
PLEASE HELP.
<MOVED BY MODERATOR TO THE CORRECT FORUM>
Edited by: Alvaro Tejada Galindo on Jul 24, 2008 6:24 PMwhen you generate the spool you can down load that in txt format
Function is used RSPO_DOWNLOAD_SPOOLJOB when you want to do that programatically.
Using the spool number, and provide the path where you want to down load that time mention the name
C:\smart.txt
it will be downloaded . -
Convert SmartForm into PDF(PDF should be password protected)
Hi Friends,
This is my requirement.
Need to convert SmartForm into PDF and this PDF should be send as an email with attachment and PDF should be password protected.
Can anyone plz help me???Dear Jena,
This is my code.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZBIN_SMARTFORM'
IMPORTING
fm_name = v_fm.
*& ASSIGNING VALUES TO FORM CONTROL STRUCTURE AND FORM COMPOSER
gs_ctrlop-getotf = 'X'.
gs_ctrlop-device = 'PRINTER'.
gs_ctrlop-preview = ' '.
gs_ctrlop-no_dialog = 'X'.
gs_outopt-tddest = 'LOCL'.
* GETTING THE OTF DATA
CALL FUNCTION v_fm
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
control_parameters = gs_ctrlop
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
output_options = gs_outopt
user_settings = ' '
wa_lfa1 = wa_lfa1
wa_t001 = wa_t001
wa_ekko = wa_ekko
wa_adrc = wa_adrc
IMPORTING
* DOCUMENT_OUTPUT_INFO =
job_output_info = gs_otfdata
* JOB_OUTPUT_OPTIONS =
TABLES
it_ekpo = it_ekpo
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.
* ASSIGNING THE OTFDATA TO OTF STRUCTURE TABLE
CLEAR gt_otf.
gt_otf[] = gs_otfdata-otfdata[].
* CONVERTING THE OTFDATA
CLEAR gt_lines.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
* PDF_DELETE_OTFTAB = ' '
* PDF_USERNAME = ' '
* PDF_PREVIEW = ' '
* USE_CASCADING = ' '
IMPORTING
bin_filesize = bin_file
* bin_file = bin_file
TABLES
otf = gt_otf
lines = gt_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.
DATA l_file TYPE string .
CONCATENATE 'D:\usr\sap\CID\DVEBMGS00\work' '.PDF' INTO l_file.
OPEN DATASET l_file FOR OUTPUT IN BINARY MODE .
IF sy-subrc = 0 .
LOOP AT gt_lines INTO gs_lines .
TRANSFER gs_lines TO l_file .
ENDLOOP.
CLOSE DATASET l_file .
ELSE.
WRITE : / 'operating system could not open file' .
ENDIF.
* ASSIGNING THE DESCRIPTION OF THE OBJECT SENT IN MAIL
CLEAR gs_docdata.
gs_docdata-obj_name = gc_tst.
gs_docdata-obj_descr = gc_testing.
gs_docdata-obj_langu = sy-langu.
* ASSIGNING THE EMAIL-ID TO STRUCTURE OF API RECIPIENT LIST TABLE
CLEAR : gt_reclist,gs_reclist.
***IF INTERNAL MAIL-ID
* gs_reclist-receiver = sy-uname.
* gs_reclist-rec_type = 'B'.
***IF EXTERNAL MAIL-ID
gs_reclist-receiver = '[email protected]'.
gs_reclist-rec_type = 'U'.
APPEND gs_reclist TO gt_reclist.
* PASSING THE SAP SCRIPT LINES TO SAP OFFICE
CLEAR : gs_objbin,gs_lines.
LOOP AT gt_lines INTO gs_lines.
gv_pos = 255 - gv_len.
IF gv_pos > 134.
gv_pos = 134.
ENDIF.
gs_objbin+gv_len = gs_lines(gv_pos).
gv_len = gv_len + gv_pos.
IF gv_len = 255.
APPEND gs_objbin TO gt_objbin.
CLEAR : gs_objbin,gv_len.
IF gv_pos < 134.
gs_objbin = gs_lines+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 SAP OFFICE
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 = 'ATTACHMENT'.
gs_objpack-obj_descr = 'TEST'.
APPEND gs_objpack TO gt_objpack.
ENDIF.
DATA: BEGIN OF command_list OCCURS 0.
INCLUDE STRUCTURE sxpgcolist.
DATA: END OF command_list .
DATA: BEGIN OF exec_protocol OCCURS 0.
INCLUDE STRUCTURE btcxpm.
DATA: END OF exec_protocol.
DATA: status LIKE btcxp3-exitstat,
commandname LIKE sxpgcolist-name VALUE 'ZB_TEST',
sel_no LIKE sy-tabix.
* GET LIST OF EXTERNAL COMMANDS
CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
EXPORTING
commandname = commandname
operatingsystem = sy-opsys
TABLES
command_list = command_list
EXCEPTIONS
OTHERS = 1.
CALL FUNCTION 'SXPG_COMMAND_CHECK'
EXPORTING
commandname = command_list-name
operatingsystem = sy-opsys
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
x_error = 6
too_many_parameters = 7
parameter_expected = 8
illegal_command = 9
communication_failure = 10
system_failure = 11
OTHERS = 12.
CLEAR command_list.
REFRESH command_list.
DATA: v_dir_input TYPE sxpgcolist-parameters.
DATA: v_dir_input1 TYPE sxpgcolist-parameters.
command_list-name = 'ZB_TEST'.
command_list-opsystem = 'Windows NT'.
DATA : doc TYPE string.
DATA : pass TYPE string ,
name(40).
doc = 'invoice'.
pass = '123456'.
CONCATENATE 'cnd/c d:\pdf\encryptpdf.exe' doc'.PDF' INTO name.
CONCATENATE 'cmd /c d:\pdf\encryptpdf.exe' '-i' name '-o ' name '-u' pass INTO v_dir_input SEPARATED BY space .
READ TABLE command_list INDEX sel_no.
CONCATENATE command_list-opcommand v_dir_input INTO command_list-opcommand SEPARATED BY space.
* CHECK AUTHORIZATION
command_list-addpar = 'X'.
APPEND command_list.
CONSTANTS: c_extcom TYPE sxpgcolist-name VALUE 'ZB_TEST',
c_oper TYPE syopsys VALUE 'Windows NT'.
DATA: t_result TYPE STANDARD TABLE OF btcxpm.
v_dir_input = command_list-opcommand.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = c_extcom
additional_parameters = v_dir_input
operatingsystem = c_oper
TABLES
exec_protocol = t_result
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
OPEN DATASET l_file FOR INPUT IN BINARY MODE.
IF sy-subrc = 0.
READ DATASET l_file INTO itab_attach.
CLOSE DATASET l_file.
ENDIF.
CALL METHOD cl_bcs_convert=>xstring_to_solix
EXPORTING
iv_xstring = itab_attach
RECEIVING
et_solix = t_attachment.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = gs_docdata
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = gt_objpack
* OBJECT_HEADER =
CONTENTS_BIN = gt_objbin
* CONTENTS_TXT =
CONTENTS_HEX = t_attachment
* OBJECT_PARA =
* OBJECT_PARB =
receivers = gt_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 sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE 'SENT SUCCESSFULLY'.
ENDIF.
SUBMIT rsconn01 WITH mode EQ 'INT' AND RETURN.
The mail is sent to inbox successfully,but when am opening the attachment am getting the below error as,
---> There was an error while opening this file.The file is damaged and couldnt be repaired. -
Display Smartform in PDF.
Hi All,
I have gone through the forum threads to convert a smartform into a pdf document. All of them say to use function module CONVERT_OTF. This function module converts the output of the smartform which is in OTF into the PDF format and we can download the information which opens up with Adobe Reader.
The question is whether we can display the output of the smartform in Adobe at runtime within the SAP GUI because if it is in the portal then we can set the attribute in SAP Connect, to display the output of SAP Script and Smartforms in PDF.
I tried this code
REPORT ZACOSTA_FETCH_DATA_COPY.
DATA : IT_ZACOSTA TYPE ZACOSTA_TAB_DET.
DATA : V_FORM_NAME TYPE TDSFNAME VALUE 'ZACOSTA_FORMS_COPY1',
V_FUNC_NAME TYPE RS38L_FNAM.
DATA: LS_CONTROL_PARAMETERS TYPE SSFCTRLOP,
LS_OUTPUT_OPTIONS TYPE SSFCOMPOP,
LS_JOB_OUTPUT_INFO TYPE SSFCRESCL,
LT_LINES TYPE TABLE OF TLINE,
L_DEVTYPE TYPE RSPOPTYPE,
L_SAM_HAWKINS TYPE INT4,
L_DOC TYPE DOCS OCCURS 0 WITH HEADER LINE.
START-OF-SELECTION.
SELECT VBAKVBELN VBAKVKORG VBAK~VTWEG
VBAKSPART VBAKKUNNR VBAP~POSNR
VBAPMATNR VBAPARKTX VBAP~NETWR
VEDAVBEGDAT VEDAVENDDAT
INTO CORRESPONDING FIELDS OF TABLE IT_ZACOSTA
FROM VBAK INNER JOIN VBAP
ON VBAKVBELN = VBAPVBELN
INNER JOIN VEDA
ON VEDAVBELN = VBAPVBELN
WHERE VBAK~VBELN = '0040000264'. "Where Clause to be removed
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = V_FORM_NAME
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = V_FUNC_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.
Set language
LS_CONTROL_PARAMETERS-LANGU = SY-LANGU.
Set control parameters to get the output format (OTF) from Smart Forms
LS_CONTROL_PARAMETERS-NO_DIALOG = 'X'.
LS_CONTROL_PARAMETERS-GETOTF = 'X'.
LS_OUTPUT_OPTIONS-TDNOPREV = 'X'.
CALL FUNCTION V_FUNC_NAME
EXPORTING
OUTPUT_OPTIONS = LS_OUTPUT_OPTIONS
CONTROL_PARAMETERS = LS_CONTROL_PARAMETERS
USER_SETTINGS = SPACE
IT_ZACOSTA = IT_ZACOSTA
IMPORTING
JOB_OUTPUT_INFO = LS_JOB_OUTPUT_INFO.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
IMPORTING
BIN_FILESIZE = L_SAM_HAWKINS
bin_file = p_data " binary file
TABLES
OTF = LS_JOB_OUTPUT_INFO-OTFDATA
LINES = LT_LINES
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE =
FILENAME = 'C:\Test.pdf'
FILETYPE = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = LT_LINES
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.
The reson why I had to download is because this does not show the PDF at runtime. Am I missing some parameter here or is there some kind of configuration required to display the smartform in PDF at runtime within the SAP GUI.
Any hints on this would be greatly appreciated.
Best Regards,
SudhiHi,
Here is the sample code.This code will download the smartforms as PDF.Kindly reward points by clicking the star on the left of reply,if it helps.
REPORT zswar.
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME.
PARAMETER: p_date LIKE sy-datum.
PARAMETER: p_rea TYPE char255.
SELECTION-SCREEN: END OF BLOCK b1.
DATA: ws_ucomm LIKE sy-ucomm.
INITIALIZATION.
SET PF-STATUS 'STANDARD' OF PROGRAM 'ZSWAR'.
AT SELECTION-SCREEN.
ws_ucomm = sy-ucomm.
CASE ws_ucomm.
WHEN '&PDF'.
PERFORM f1000_download_form.
EXIT.
WHEN '&BACK'.
SET SCREEN 0.
EXIT.
WHEN '&EXIT'.
SET SCREEN 0.
EXIT.
WHEN '&canc'.
SET SCREEN 0.
LEAVE TO SCREEN 0.
ENDCASE.
*& Form F1000_DOWNLOAD_FORM
text
--> p1 text
<-- p2 text
FORM f1000_download_form.
DATA: form_name TYPE rs38l_fnam.
DATA: wa_ctrlop TYPE ssfctrlop,
wa_outopt TYPE ssfcompop.
DATA: t_otfdata TYPE ssfcrescl,
t_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
Tutorial on SMART FORMS
© 2005 SAP AG 7
DATA: t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE.
DATA: w_filesize TYPE i.
DATA: w_bin_filesize TYPE i.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMARTFORM_SWAR'
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-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'
Tutorial on SMART FORMS
© 2005 SAP AG 8
max_linewidth = 132
ARCHIVE_INDEX = ' '
IMPORTING
bin_filesize = w_bin_filesize
TABLES
otf = t_otf
lines = t_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.
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
bin_filesize = w_bin_filesize
CODEPAGE = ' '
filename = 'd: est.PDF'
filetype = 'BIN'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
filelength = w_filesize
TABLES
data_tab = t_pdf_tab
FIELDNAMES =
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
OTHERS = 10
IF sy-subrc <> 0.
MESSAGE i003(z00) WITH 'File not downloaded succesfully'.
ELSE.
MESSAGE i003(z00) WITH 'File Test.pdf downloaded succesfully '
'under D drive'.
ENDIF.
ENDFORM. " F1000_DOWNLOAD_FORM -
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 converting smartform to PDF
Hi Experts,
I am facing the issue while converting the smartform to pdf form with the help of FM convert_otf_2_pdf .
Problem is that
CH3OH4OD7 3 , 4 and 7 are the subscipts in SMARTFORM like in a chemical formula ,but after conveting to PDF # is replacing the subscripts like CH#OH#OD# .
Kindly help in this issue.
Thanks
Sachin
Edited by: Rob Burbank on Feb 6, 2012 10:13 AMTry this example it will be help full
REPORT YSAMPLE5.
DATA:
w_form_name TYPE tdsfname VALUE 'YSAMPLE2',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = w_cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = w_outoptions
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
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_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
IMPORTING
BIN_FILESIZE = W_bin_filesize
BIN_FILE =
TABLES
otf = T_OTF
lines = T_pdf_tab
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.
To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 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.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
tables
data_tab = T_pdf_tab
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Converting Smartform to PDF and send as email attachment
Hi
I want to send the Smartform to mail as PDF attachment.
I found the program in code gallery., it name was 'ZTEST_NREDDY_PDF_MAIL' .
I used this program and it send the Smartform to mail as PDF attachment but when open the pdf file it gave me error.
error : 'An unrecognized token Qq was found'.
Please help me out.
Thanks
AninaHi,
Following is the code logic:
Tables for OTF to PDF Conversion
DATA: g_t_docs TYPE STANDARD TABLE OF docs, " Table for Stored Document
g_t_lines TYPE STANDARD TABLE OF tline. " Table for Text lines
Objects to send mail.
DATA: g_t_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE, " SAPoffice: Description of Imported Object Components
g_t_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_contout LIKE solisti1 OCCURS 0 WITH HEADER LINE,
g_t_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE. " SAPoffice: Structure of the API Recipient List
Addresses (Business Address Services)
DATA: g_t_adrc LIKE adrc OCCURS 0,
g_t_adrc2 LIKE adrc OCCURS 0,
g_t_adrc3 LIKE adrc OCCURS 0,
g_t_adrc_wa TYPE adrc,
g_t_adrc2_wa TYPE adrc,
g_t_adrc3_wa TYPE adrc.
Sales Document: Partner
DATA: g_t_vbpa_wa TYPE vbpa.
E-Mail Addresses (Business Address Services)
DATA: g_t_adr6 LIKE adr6 OCCURS 0,
g_t_adr6_2 LIKE adr6 OCCURS 0,
g_t_adr6_wa TYPE adr6,
g_t_adr6_2_wa TYPE adr6.
DATA:
Work Area declarations
g_wa_objhead TYPE soli_tab, " Work Area for Objcont and Objhead as Table Type
g_wa_doc_chng TYPE sodocchgi1, " Work Area - Data of an object which can be changed
Variables declarations
g_lines_txt TYPE i,
g_lines_bin TYPE i,
g_email_id(40) VALUE '', " E-mail Address
PDF related data declarations
g_wa_job_output_info TYPE ssfcrescl, " Smart Forms: Return value at end of form printing
g_wa_control_parameters TYPE ssfctrlop,"#EC NEEDED " Smart Forms: Control structure
g_name TYPE string,
g_path TYPE string,
g_fullpath TYPE string,
g_filename TYPE string,
g_filter TYPE string,
g_bin_filesize TYPE i,
g_uact TYPE i,
g_guiobj TYPE REF TO cl_gui_frontend_services.
PERFORM f0100_download_pdf.
PERFORM f200_convert_to_pdf.
PERFORM f300_attach_and_mail_pdf.
*& Form f0100_download_pdf
To Download the PDF Format of SmartForm on
Presentation Server
FORM f0100_download_pdf. "#EC CALLED
Downloading PDF File
CREATE OBJECT g_guiobj.
CALL METHOD g_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = g_name
file_filter = g_filter
CHANGING
filename = g_name
path = g_path
fullpath = g_fullpath
user_action = g_uact.
IF g_uact = g_guiobj->action_cancel.
EXIT.
ENDIF.
MOVE g_fullpath TO g_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = g_bin_filesize
filename = g_filename
filetype = 'BIN'
TABLES
data_tab = g_t_lines.
ENDFORM. "f0100_download_pdf
*& Form f0200_convert_to_pdf
To convert the SmartForm to PDF format
FORM f0200_convert_to_pdf . "#EC CALLED
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = g_bin_filesize
TABLES
otf = g_wa_job_output_info-otfdata
doctab_archive = g_t_docs
lines = g_t_lines.
CONCATENATE text-001 g_sales_order_no '.pdf' INTO g_name.
ENDFORM. " f0200_convert_to_pdf
*& Form f0300_attach_and_mail_pdf
To E-Mail the PDF form as an Attachment
FORM f0300_attach_and_mail_pdf . "#EC CALLED
Attachment
REFRESH: g_t_reclist,
g_t_objtxt,
g_t_objbin,
g_t_objpack.
CLEAR g_wa_objhead.
Create Message Body Title and Description
g_t_objtxt = g_name.
APPEND g_t_objtxt.
DESCRIBE TABLE g_t_objtxt LINES g_lines_txt.
READ TABLE g_t_objtxt INDEX g_lines_txt.
g_wa_doc_chng-obj_name = g_name.
g_wa_doc_chng-expiry_dat = sy-datum + 10.
g_wa_doc_chng-obj_descr = g_name.
g_wa_doc_chng-sensitivty = 'F'.
g_wa_doc_chng-doc_size = g_lines_txt * 255.
Main Text
CLEAR g_t_objpack-transf_bin.
g_t_objpack-head_start = 1.
g_t_objpack-head_num = 0.
g_t_objpack-body_start = 1.
g_t_objpack-body_num = g_lines_txt.
g_t_objpack-doc_type = 'RAW'.
APPEND g_t_objpack.
Attachment (PDF-Attachment)
g_t_objpack-transf_bin = 'X'.
g_t_objpack-head_start = 1.
g_t_objpack-head_num = 0.
g_t_objpack-body_start = 1.
Convert TLINE to SOLISTI1
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_src = 134
line_width_dst = 255
TABLES
content_in = g_t_lines
content_out = g_t_contout
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE s000(0k) WITH text-002.
EXIT.
ENDIF.
Create Message Attachment
APPEND LINES OF g_t_contout[] TO g_t_objbin[].
DESCRIBE TABLE g_t_objbin LINES g_lines_bin.
READ TABLE g_t_objbin INDEX g_lines_bin.
g_t_objpack-doc_size = g_lines_bin * 255 .
g_t_objpack-body_num = g_lines_bin.
g_t_objpack-doc_type = 'PDF'.
g_t_objpack-obj_name = text-003.
g_t_objpack-obj_descr = text-004.
APPEND g_t_objpack.
CLEAR g_t_reclist.
g_t_reclist-receiver = g_email_id.
g_t_reclist-rec_type = 'U'.
APPEND g_t_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = g_wa_doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = g_t_objpack
object_header = g_wa_objhead
contents_bin = g_t_objbin
contents_txt = g_t_objtxt
receivers = g_t_reclist.
ENDFORM. " f0300_attach_and_mail_pdf -
Smartform to PDF and e_mail? Urgent
hi all,
i am able to convert smartform to pdf and download the pdf onto desktop but not able to send it as attachment thru email.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
EXPORTING
use_otf_mc_cmd = 'X'
IMPORTING
bin_filesize = v_len_in
TABLES
otf = i_otf[]
doctab_archive = lt_doctab
lines = <b>i_tline</b>
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
PERFORM doconv TABLES i_tline objbin.
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
how can i best deal with <b>i_tline</b> and send mail using <b>i_tline</b>.
thanks,
Subbahi,
* Internal Table declarations
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.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZZZ_TEST1'
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'
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.
* Fehlerhandling
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
* wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + strlen( i_objtxt )
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.
* Länge des Attachment ermitteln
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 = '[email protected]'.
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'
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.
rgds
Anver
Maybe you are looking for
-
I need to change my email to reflect my current provider, however when I try an error message comes up. It says I have to choose a different email as the one I'm trying to update to is my "rescue email." How do I fix this?
-
Edit button not working on a publishing site on sub-level pages only (SP 2010)
When I create a top level page, the Edit button/edit page works fine with checkout and checkin. However, once I create a sub-level page - that is I create a second page within the first page then the edit button does not work and there is a message
-
ALV display using dynamic field catalog and dynamic internal table
hi , please guide me for ALV display using dynamic field catalog and dynamic internal table. Thank you.
-
Coloring elements in array of clusters
Hi, I have an array of clusters. My goal is that each element(cluster) in the array will have a different background color. I tried to use the color property node but it changed the color of all the clusters(not only of the desired element). How It
-
Hello, I am facing post-clone error on 11i O.S aix 5.3 when i run post-clone script on db it got error.share any solution is highly appreciable $ perl adcfgclone.pl dbTier Enter the APPS password [APPS]: First Creating a new context file for the clon