on 10-29-2007 7:20 AM
Hi All,
I am having a requirement of sending the smart form to mail as pdf attachment.
I am passing
<b> control_parameters-getotf = 'X'.
control_parameters-no_dialog = 'X'.
control_parameters-langu = sy-langu.</b>
But I am not getting any data from <b>job_output_info-otfdata. It is blank</b>.
I tested the form with print preview. Data is there.
<b>Is there anything to do inside the smartform?</b>
HI
I myself got the result.
Thanks to all for your replies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Naresh,
Sorry I didn't check after my doubt was cleared. Just now only I am seeing this.
That was the error because of some data declarations. And now i forgot what is that one.
Here I am sending the code which worked well.
<b>Note: create & use your own smartform if necessary</b>
Code follows.........
DATA: x_ctrl_p TYPE ssfctrlop,
x_output_data TYPE ssfcrescl.
DATA: it_docs LIKE docs OCCURS 0 WITH HEADER LINE,
it_lines LIKE tline OCCURS 0 WITH HEADER LINE,
W_OUTOPTIONS TYPE SSFCOMPOP,
it_packing LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE.
*-----Initialisation
x_ctrl_p-no_dialog = 'X'.
x_ctrl_p-getotf = 'X'.
*x_ctrl_p-langu = sy-langu.
*x_ctrl_P-PREVIEW = ' '.
*x_ctrl_p-STARTPAGE = 'FIRST'.
*x_ctrl_p-REPLANGU1 = sy-langu.
*x_ctrl_p-REPLANGU2 = sy-langu.
*x_ctrl_p-REPLANGU2 = sy-langu.
W_OUTOPTIONS-TDDEST = 'ZPC_'.
----
Internal Tables Declaration *
----
DATA: it_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_pcklist LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
it_mess LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,
it_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
it_table LIKE solix OCCURS 0 WITH HEADER LINE.
DATA: it_soli LIKE soli OCCURS 0 WITH HEADER LINE.
*-----Work area declaration
DATA: wa_doc_data TYPE sodocchgi1.
----
Variable Declaration *
----
DATA: v_lines_txt TYPE i,
v_lines_bin TYPE i,
v_lines TYPE i,
v_fname TYPE rs38l_fnam,
v_size TYPE i,
v_filename TYPE rlgrap-filename.
DATA: ikna1 LIKE kna1 OCCURS 0 WITH HEADER LINE,
ivbak LIKE vbak OCCURS 0 WITH HEADER LINE.
----
Start of selection event *
----
START-OF-SELECTION.
SELECT * FROM kna1 INTO TABLE ikna1 UP TO 1 ROWS.
SELECT * FROM vbak INTO TABLE ivbak FOR ALL ENTRIES IN ikna1
WHERE kunnr = ikna1-kunnr .
LOOP AT IVBAK.
IF SY-TABIX > 10.
DELETE TABLE IVBAK FROM IVBAK.
ENDIF.
ENDLOOP.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZSMART_TEST'
IMPORTING
fm_name = v_fname.
*CALL FUNCTION v_fname
*EXPORTING
*control_parameters = x_ctrl_p
*IMPORTING
*job_output_info = x_output_data.
*loop at ikna1.
READ TABLE ikna1 INDEX 1.
CALL FUNCTION v_fname "'/1BCDWB/SF00000086'
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = x_ctrl_p
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS = W_OUTOPTIONS
USER_SETTINGS = ' '
ikna1 = ikna1
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = x_output_data
JOB_OUTPUT_OPTIONS =
TABLES
ivbak = ivbak[]
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.
*endloop.
PERFORM process_mail.
----
FORM process_mail *
----
........ *
----
FORM process_mail.
*-----Calling fumction module to convert output to pdf.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_size
TABLES
otf = x_output_data-otfdata
doctab_archive = it_docs
lines = it_lines.
*
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 134
IMPORTING
bin_filesize = v_size
TABLES
otf = x_output_data-otfdata
lines = it_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
OTHERS = 4.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
line_width_dst = 255
TABLES
content_in = it_lines
content_out = it_soli
EXCEPTIONS
err_line_width_src_too_long = 1
err_line_width_dst_too_long = 2
err_conv_failed = 3
OTHERS = 4.
*****CALL FUNCTION 'ZFUNC_CONVERT_DATA_ODC01'
*****EXPORTING
*****iv_byte_mode = 'X'
*****TABLES
*****it_data = it_lines
*****et_data = it_table.
*-----To caluculate total number of lines of internal table
DESCRIBE TABLE it_table LINES v_lines.
DESCRIBE TABLE it_soli LINES v_lines.
*-----Function module to download the output file.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
bin_filesize = v_size
filename = ' '
filetype = 'BIN'
IMPORTING
act_filename = v_filename
TABLES
data_tab = it_lines.
*-----Create Message Body and Title and Description
it_mess =
'i have successfully converted smartform from otf format to pdf' .
" and i have attached that in mail'.
APPEND it_mess.
wa_doc_data-obj_name = 'smartform'.
wa_doc_data-expiry_dat = sy-datum + 10.
wa_doc_data-obj_descr = 'Smart form'.
wa_doc_data-sensitivty = 'F'.
wa_doc_data-doc_size = v_lines * 255.
*-----PDF Attachment
it_pcklist-transf_bin = 'X'.
it_pcklist-head_start = 1.
it_pcklist-head_num = 0.
it_pcklist-body_start = 1.
it_pcklist-body_num = v_lines.
it_pcklist-doc_type = 'PDF'.
it_pcklist-obj_name = 'smartform'.
it_pcklist-obj_descr = 'smart_desc'.
it_pcklist-obj_langu = 'E'.
it_pcklist-doc_size = v_lines * 255.
APPEND it_pcklist.
*-----Giving the receiver email-id
CLEAR it_receivers.
it_receivers-receiver = 'vvijaykumar@johndeere.com'.
"'VVIJAYKUMAR@JOHNDEERE.COM'.
it_receivers-rec_type = 'U'.
APPEND it_receivers.
*
*-----Calling the function module to sending email
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_data
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_pcklist
contents_txt = it_mess
CONTENTS_BIN = it_mess
contents_hex = it_soli "it_table
receivers = it_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.
SUBMIT rsconn01 WITH mode = 'INT'
WITH output = 'X'
WITH rfcgroup = 'iwdf7ytc_YD3_94'
AND RETURN.
REFRESH: it_receivers,
it_mess,
it_pcklist.
ENDIF.
ENDFORM.
Hi All,
Now I am getting data into the otf table.
This time I am getting error that
<b> Adobe reader could not open '----
.pdf' because it is neither not a
supported file type or because the file has been damaged (for example, it was
sent as an email attachment and wasn't correctly decoded)</b>
Anybody help to solve this problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello chakradhar
Once go through this link below.. I have explained every this in detaied in Wiki page.
<a href="https://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat">Convert Smatrt form to PDF</a>
<b>Please Colse the thred when ur problem is solved,Raward Helpful answers</b>
Regrads
Naresh Reddy
go through this <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/49e15474-0e01-0010-9cba-e62df8244556">tutorial</a>.
close the thread once your question is answered.
Regards,
SaiRam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi SaiRam,
Here I am not getting the data into the otf table. I can use otf_* function module only if i get the otf table data from the smartform.
I am not getting the data from the smartform. But while seeing print preview there i am getting the data available.
What i have to do to get the data into otf table. ( ie., job_output_info from smartform)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
this is a program which will give the smartform as pdf
DATA: GIT_BSIK LIKE BSIK OCCURS 0 WITH HEADER LINE.
Variable declarations
DATA:
W_FORM_NAME TYPE TDSFNAME VALUE 'ZFII_EDD001',
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 = 'ZPC_'.
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 =
TABLES
ITAB = GIT_BSIK
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
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
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
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
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'
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'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = T_pdf_tab
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.
after that use the fm
SO_NEW_DOCUMENT_ATT_SEND_API1
to send that attachment
regards,
Venkatesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.