Smartform as pdf
Hi experts..
how can we covert smartform output as pdf to on clinet request...
here i had tryed with some examples ... but in my form am passing the values
frrom interface parameters but if we r declaring this its showing error.....
how can we resolvw this prob ...........
tanx in advance.............
ls_control_param-getotf = c_x. " Chk this to get otf data
call smartform delivery note
call function lf_fm_name
exporting
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_appl_obj =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = c_space
is_dlv_delnote = ls_dlv_delnote
is_nast = nast
importing
job_output_info = it_job_output_info "Smart Forms: Return value at end of form printing
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
it_itcoo = it_job_output_info-otfdata[].
if it_itcoo[] is not initial.
call function 'CONVERT_OTF'
exporting
format = c_pdf
importing
bin_filesize = v_bin_filesize
tables
otf = it_itcoo
lines = it_tline
exceptions
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3.
concatenate <filename> '.PDF' into v_file.
*Write the PDF file to above specified path in application server
open dataset v_file for output in binary mode.
loop at it_tline.
transfer it_tline to v_file.
"clear wa_tline.
endloop.
close dataset v_file.
Similar Messages
-
Error while saving a smartform in pdf with action profile in service order
Hi experts,
I have a problem in saving a smartform which is converted in pdf.
WHat i m doing is.
The action profile is configured with new Z class and Z method. CL_DOC_PROCESSING_CRM_ORDER and CRM_SRVORDER_EXEC_SMART_FORM.
But when i click the button in the Order, i m able to save the pdf in local drive, but an error is coming in the Order page(at the bottom) "Action could not be executed successfully".
The action has been setup with "Printonly" and "Smartforms print" in customization.
I have a dount whether, this action Printonly is only to print the smartform ??? Or can we use just to save the smartform in pdf.
But when i remove the pdf conversion and save dialog and try to print it directly, Its printing the smartform. No errors are coming.
But guys, please help me on this. I have tried all the tricks i know.
I just want to save a smartform in pdf with action profile configured.
Thanks in advance.
<REMOVED BY MODERATOR>
KK
Edited by: Alvaro Tejada Galindo on Mar 19, 2008 4:26 PMHi;
Did you checked
Queries Error With FRM-92101 In Many NLS Forms [ID 443922.1] << seems similar error like yours
Forms FRM-92050, FRM-92100, FRM-92101, FRM-92102 Reference Guide [ID 444690.1]
If its not help please enable trace
How To Perform System Tracing For All Forms Runtime Processes? [ID 400144.1]
Regard
Helios -
Convert Smartform to PDF and send to SAP Workplace user
Hi to all.
I need help of somebody expert in SMARTFORM's.
I need to convert a smartform into PDF format and to send as attachement for SAP workplace
of the user.
I developed the next code.
IT is to function and to send the mail for SAP workplace, but it happens that smartform
contains images (logos) and tables, when the user tries to open the file pdf in inbox gives
to error - "An unrecognized token ' q0 ' was found".
I tried to call a smartform only with text and functioned well.
Somebody can help me?
My code:
Begin ***********************************************
REPORT zteste_nsa_send_pdf_sap_office.
DATA: t_print LIKE zeps_fm04 OCCURS 0 WITH HEADER LINE,
v_size TYPE i.
DATA: ls_bil_invoice TYPE lbbil_invoice.
TABLES: nast.
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.
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZFPS_FICHA_VALORIZACAO'
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'
is_bil_invoice = ls_bil_invoice
is_nast = nast
is_repeat = 'X'
IMPORTING
job_output_info = w_return
TABLES
t_list = t_print
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
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 EQ 0.
ENDIF.
Convert PDF from 132 to 255.
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.
SEND MAIL
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
Object with PDF.
i_objbin[] = i_record[].
Object with main text of the mail.
i_objtxt = 'Fichas de Valorização e Esquemas Tipo'.
APPEND i_objtxt.
Document information.
wa_doc_chng-obj_name = 'SMART'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = 'Ficha de Valorização'.
wa_doc_chng-sensitivty = 'F'. "Functional object
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
Pack to main body as RAW.
Obj. to be transported not in binary form
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
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.
Packing as PDF.
Obj. to be transported in binary form
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'SMART'.
CONCATENATE 'Ficha_Valorizacao' '.pdf' INTO i_objpack-obj_descr.
i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).
APPEND i_objpack.
e-mail receivers.
CLEAR i_reclist.
i_reclist-receiver = sy-uname.
i_reclist-rec_type = 'B'.
i_reclist-express = 'X'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = ' '
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 EQ 0.
ENDIF.
End *************************************************
Thanks very much to all and Happy New year...
NelsonHi
See this report as example:
http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm
I believe before converting the print to pdf, you should print your document, get the spool and convert it.
Max -
In R/3 display smartform as pdf in a custom container
Hello,
I want to display smartform as pdf in a custom contianer . I was able to find all the right code from sdn.
but my problem is that when executed my sap gui is closed without any error.
I am unable to understand what is going wrong.
CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL
IN_PLACE = 'X' ). does not show the pdf.
Can any one help me to find out if we need to do some setting for MIME type application/pdf. Because I tried to display a bar chart in the custom container of MIME type text/html , and this is working fine.
Is any setting missing in our R/3 because of which the code is not getting executed.
below code is the exact copy from a post in sdn:
report ztest_pdf.
DATA: LT_PDF TYPE TABLE OF TLINE,
LS_PDF LIKE LINE OF LT_PDF,
LV_URL TYPE CHAR255,
PDF_FSIZE TYPE I,
LV_CONTENT TYPE XSTRING,
LT_DATA TYPE STANDARD TABLE OF X255.
DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL.
DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP.
DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER.
* pdf_control type ref to cl_gui_pdfviewer.
DATA : P_VBELN TYPE VBELN_VL.
DATA : i_html TYPE w3htmltabtype.
", g_url TYPE w3url
FIELD-SYMBOLS <FS_X> TYPE X.
INITIALIZATION.
LS_CONTROL_PARAM-GETOTF = 'X'.
LS_CONTROL_PARAM-NO_DIALOG = 'X'.
START-OF-SELECTION.
CALL FUNCTION '/1BCDWB/SF00000298'
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = LS_CONTROL_PARAM
* P_VBELN = P_VBELN
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
* OUTPUT_OPTIONS =
* USER_SETTINGS = 'X'
IMPORTING
* DOCUMENT_OUTPUT_INFO = L_DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = L_JOB_OUTPUT_INFO
* JOB_OUTPUT_OPTIONS = L_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.
data pdfxstring type xstring.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = PDF_FSIZE
bin_file = pdfxstring
TABLES
OTF = L_JOB_OUTPUT_INFO-OTFDATA
LINES = LT_PDF
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
CALL SCREEN 100.
module STATUS_0100 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
CREATE OBJECT G_HTML_CONTAINER
EXPORTING
CONTAINER_NAME = 'PDF'.
CREATE OBJECT G_HTML_CONTROL
EXPORTING
PARENT = G_HTML_CONTAINER.
* Convert xstring to binary table to pass to the LOAD_DATA method
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = pdfxstring"LV_CONTENT
TABLES
BINARY_TAB = LT_DATA.
* PERFORM bar_chart .
* Load the HTML
CALL METHOD G_HTML_CONTROL->LOAD_DATA(
EXPORTING
TYPE = 'application' "'text' " 'application'
SUBTYPE = 'pdf' "'html' "'pdf'
IMPORTING
ASSIGNED_URL = lv_URL
CHANGING
DATA_TABLE = LT_DATA "i_html "LT_DATA
EXCEPTIONS
DP_INVALID_PARAMETER = 1
DP_ERROR_GENERAL = 2
CNTL_ERROR = 3
OTHERS = 4 ).
* Show it
CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL
IN_PLACE = 'X' ).
Thanks,
Jaya.
Edited by: kishan P on Jun 9, 2011 1:40 PMHello Sandra,
Thanks for your reply, but eventhen it fails to load the pdf. Is ADS required to be installed for this?
Can I just pass the pdf_fsize imported from CONVERT_OTF which is of type i.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
IMPORTING
BIN_FILESIZE = PDF_FSIZE
bin_file = pdfxstring
TABLES
OTF = L_JOB_OUTPUT_INFO-OTFDATA
LINES = LT_PDF
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
OTHERS = 4.
CALL METHOD G_HTML_CONTROL->LOAD_DATA(
EXPORTING
TYPE = 'application' "'text' " 'application'
SUBTYPE = 'pdf' "'html' "'pdf'
size = PDF_FSIZE
IMPORTING
ASSIGNED_URL = lv_URL
CHANGING
DATA_TABLE = LT_DATA "i_html "LT_DATA
EXCEPTIONS
DP_INVALID_PARAMETER = 1
DP_ERROR_GENERAL = 2
CNTL_ERROR = 3
OTHERS = 4 ).
Thanks,
Jaya. -
Error in SmartForm to PDF while Saving with Preview option.
Hi,
I have created a report to convert Smartform to PDF.
I want the user to Preview data, if user is interested, then they can save the file.
When user clicks the Back button in SmartForm Print Preview, user can select the path of PDF file to save the data.
My code works fine, if Preview is disabled.
In the sub-routine createpdffile, I am getting error while creating PDF file.
The program works fine, if I disable the preview option i.e. if I uncomment
cparam-getotf = 'X'.
How can I have the both options in my report?
1) Preview SmartForm.
2) Save the SmartForm as PDF.
Regards,
Vikas
DATA:
cparam TYPE ssfctrlop,
outop TYPE ssfcompop,
* fm_name TYPE rs38l_fnam,
* my_tabix TYPE sy-tabix,
file_size TYPE i,
bin_filesize TYPE i,
s_filename TYPE string.
DATA:
tab_otf_data TYPE ssfcrescl,
* tab_otf_data TYPE itcoo OCCURS 0 WITH HEADER LINE,
pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
it_ekpo TYPE STANDARD TABLE OF ekpo WITH HEADER LINE.
* it_docs TYPE STANDARD TABLE OF docs.
START-OF-SELECTION.
PERFORM fetchdata.
***************** suppressing the dialog box****************************
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = 'X'.
* cparam-getotf = 'X'.
END-OF-SELECTION.
PERFORM callsmartform.
tab_otf_final[] = tab_otf_data-otfdata[].
PERFORM createpdffile.
PERFORM getfilename.
PERFORM savepdffile.
*& Form FetchData
FORM fetchdata .
SELECT * FROM ekpo INTO CORRESPONDING FIELDS OF TABLE it_ekpo
WHERE ebeln > '4500009071' AND ebeln < '4500009073' .
ENDFORM. " FetchData
*& Form CallSmartForm
FORM callsmartform .
CALL FUNCTION '/1BCDWB/SF00000234'
EXPORTING
control_parameters = cparam
output_options = outop
user_settings = space
IMPORTING
job_output_info = tab_otf_data
TABLES
t_ekpo = it_ekpo
* EXCEPTIONS
IF sy-subrc <> 0.
MESSAGE 'Error in Calling Smart Form ' TYPE 'I'.
ENDIF.
ENDFORM. " CallSmartForm
*& Form CreatePDFFile
* text
FORM createpdffile .
****removing the initial and final markers from the OTF data**********
* DELETE tab_otf_data-otfdata WHERE tdprintcom = '//'.
* READ TABLE tab_otf_final WITH KEY tdprintcom = 'EP'.
* my_tabix = sy-tabix + 1.
******** appending the modified OTF table to the final OTF table****
* INSERT LINES OF tab_otf_data-otfdata INTO tab_otf_final INDEX my_tabix
************ converting OTF data into pdf data**************************
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
* BIN_FILE =
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE 'Error in Creating PDF File ' TYPE 'I'.
ENDIF.
ENDFORM. " CreatePDFFile
*& Form SavePDFFile
FORM savepdffile .
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = bin_filesize
filename = s_filename
filetype = 'BIN'
IMPORTING
filelength = file_size
TABLES
data_tab = pdf_tab
EXCEPTIONS
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE 'Error in Saving PDF File ' TYPE 'I'.
ENDIF.
ENDFORM. " SavePDFFile
*& Form GetFileName
FORM getfilename .
DATA:
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.
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.
MOVE v_fullpath TO s_filename.
ENDFORM. " GetFileNameI think the excerpt and link below is the why, but the page talks about server code and not javascript. I guessing that this is why blank pages work, but not wiki pages. Can anyone verify this?
The following are general rules for using server-side code on a site page.
If the page is uncustomized, server-side code is supported on the page.
If the page is customized, server-side code does not run, and the page does not render. This includes the code-behind for the page itself.
http://msdn.microsoft.com/en-us/library/office/aa979592(v=office.14).aspx -
Send smartform as pdf attachment through Email on ECC 5.0
I have been trying hard to do this, but am not able to send attachment. Below are the problems -
1. If sometimes the mail goes, the attachment is empty.
2. if i use COMMIT_WORK = 'X' in FM SO_NEW_DOCUMENT_ATT_SEND_API1 , it throws a dump - ' Invalid COMMIT WORK in an update function module.'
3. If i comment COMMIT_WORK = 'X', it gets executed successfully but, in the program i get a dump 'UC_OBJECTS_NOT_CHAR' exception.
Can someone suggest, what settings are required in SAP to send smartforms as PDF attachments. Also, please suggest how can i remove the dump. If anyone can give me a working program, it will be very very helpful.
here is the code,
REPORT zrsmfmail.
TYPE-POOLS: addi.
Tables defination.
TABLES : vbpa,vbak,nast, stxl, stxh.
Data Decleration .
DATA: lf_fm_name TYPE rs38l_fnam,
l_lines TYPE i.
DATA: output_options TYPE ssfcompop.
DATA: fcodem TYPE sy-ucomm.
DATA: i_id LIKE thead-tdid VALUE 'V002',
i_object LIKE thead-tdobject VALUE 'VBBK' ,
i_tdname LIKE thead-tdname ,
i_lang LIKE thead-tdspras VALUE 'E' .
Internal Table declration.
DATA: int_vbak LIKE vbak OCCURS 0 WITH HEADER LINE,
int_vbap LIKE vbap OCCURS 0 WITH HEADER LINE.
DATA : itline1 LIKE tline OCCURS 0 WITH HEADER LINE .
DATA: retcode LIKE sy-subrc. "Returncode
DATA: repeat(1) TYPE c.
DATA: xscreen(1) TYPE c. "Output on printer or screen
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,
lt_att_content_hex 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,
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: BEGIN OF zlines2 OCCURS 0,
tline TYPE char255,
END OF zlines2,
size TYPE i,
zdata TYPE sodocchgi1.
*& Form entry
FORM entry USING return_code TYPE i
us_screen TYPE c.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing.
IF retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
*& Form PROCESSING
text
FORM processing.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE int_vbak
FROM vbak
WHERE vbeln = nast-objky.
LOOP AT int_vbak .
i_tdname = int_vbak-vbeln .
SELECT SINGLE * FROM stxh WHERE tdobject = i_object
AND tdname = i_tdname
AND tdid = i_id
AND tdspras = i_lang.
IF sy-subrc = 0 .
CALL FUNCTION 'READ_TEXT'
EXPORTING
id = i_id
language = i_lang
name = i_tdname
object = i_object
TABLES
lines = itline1.
IF sy-subrc NE 0 .
APPEND itline1 .
ENDIF .
ENDIF .
DESCRIBE TABLE int_vbak LINES l_lines.
l_lines = l_lines .
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZORDER_QUOTE'
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
l_lines = l_lines
control_parameters = w_ctrlop
output_options = w_compop
user_settings = 'X'
IMPORTING
job_output_info = w_return
TABLES
int_vbak = int_vbak
int_vbap = int_vbap
itline1 = itline1
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 = size
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.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Change the PDF format from 132 to 255.
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
transfer_bin = 'X'
TABLES
content_in = i_tline
content_out = zlines2
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 ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Attachment
REFRESH:
i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objtxt = 'TEST 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-no_change = 'X'.
wa_doc_chng-obj_langu = sy-langu.
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.
(pdf-Attachment)
i_objbin[] = zlines2[].
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 1.
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 = 'SMARTFORM'.
i_objpack-obj_descr = 'TEST'.
APPEND i_objpack.
CLEAR i_reclist.
i_reclist-receiver = 'abc at aa.com'.
i_reclist-rec_type = 'F'.
i_reclist-express = 'X'.
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
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.
CASE sy-subrc.
WHEN 0.
WHEN 1. RAISE too_many_receivers.
WHEN 2. RAISE document_not_sent .
WHEN 3. RAISE document_type_not_exist.
WHEN 4. RAISE operation_no_authorization.
WHEN 5. RAISE parameter_error.
WHEN 7. RAISE enqueue_error .
WHEN OTHERS. RAISE x_error.
ENDCASE.
COMMIT WORK.
ENDLOOP.
ENDFORM. "entry
Please suggest ASAP, it has come to a critical stage now, a fruitful help will be a great saviour.
Thanks !Hi Guys,
You can even try this 'CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = bin_filesize
bin_file = xstring
TABLES
otf = it_otf_final
lines = it_pdfdata[]
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = xstring
APPEND_TO_TABLE = ' '
IMPORTING
OUTPUT_LENGTH =
TABLES
binary_tab = it_pdf
Use Cl_BSC Class for easy way to send mail.
Either u can Distribution list Tcode so23.
This is the way i have implemted .. ! -
Problem during output of smartform in PDF
Hi All,
I am using Function module for output of smartform in PDF Format.But it is giving following informatio -OTF end command // missing in OTF data.
and then no data in pdf format.
Could you please help me whar shoul I do for that?
MY code is like that :
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.Search the error in the first call to smartforms. ([Function documentation Checking and Testing a Smart Form|http://help.sap.com/saphelp_nw2004s/helpdata/en/4b/83fb5bdf8f11d3969700a0c930660b/frameset.htm])
Regards,
Raymond -
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 -
Unable to print directly from vf03 txn after converting smartform into PDF
Dear All,
I have converted ond smartform into pdf.now when i am trying to print one document using vf03 transaction whatever button i click(ex-print preview/print) it is asking to save the pdf as local file. but i want to print that document as pdf directly from vf03 without saving it into local file.
I am giving you the code below:-
(all modification done by me are in BOLD)
Print of a invoice by SAPscript SMART FORMS *
REPORT zrlb_invoice5.
declaration of data
INCLUDE zrlb_invoice_data_declare5.
*INCLUDE ZRLB_INVOICE_DATA_DECLARE.
*INCLUDE rlb_invoice_data_declare.
definition of forms
INCLUDE zrlb_invoice_form015.
*INCLUDE ZRLB_INVOICE_FORM01.
*INCLUDE rlb_invoice_form01.
INCLUDE zrlb_print_forms5.
*INCLUDE ZRLB_PRINT_FORMS.
*INCLUDE rlb_print_forms.
START-OF-SELECTION.
FORM ENTRY
FORM entry USING return_code us_screen.
DATA: lf_retcode TYPE sy-subrc.
CLEAR retcode.
xscreen = us_screen.
PERFORM processing USING us_screen
CHANGING lf_retcode.
IF lf_retcode NE 0.
return_code = 1.
ELSE.
return_code = 0.
ENDIF.
ENDFORM. "ENTRY
FORM PROCESSING *
FORM processing USING proc_screen
CHANGING cf_retcode.
DATA: lv_medium LIKE tnapr-nacha.
DATA: lwa_print_data_to_read TYPE lbbil_print_data_to_read.
DATA: lwa_bil_invoice TYPE lbbil_invoice.
DATA: lf_fm_name TYPE rs38l_fnam.
DATA: lwa_control_param TYPE ssfctrlop.
DATA: lwa_composer_param TYPE ssfcompop.
DATA: lwa_recipient TYPE swotobjid.
DATA: lwa_sender TYPE swotobjid.
DATA: lf_formname TYPE tdsfname.
DATA: lwa_addr_key LIKE addr_key.
DATA: ls_dlv-land LIKE vbrk-land1.
DATA:lv_job_output_info TYPE ssfcrescl,
lv_document_output_info TYPE ssfcrespd,
lv_job_output_options TYPE ssfcresop,
lv_bin_filesize TYPE i,
gt_docs TYPE STANDARD TABLE OF docs,
gt_lines TYPE STANDARD TABLE OF tline,
gt_otf TYPE TABLE OF itcoo, " OTF Structure
lv_name TYPE string VALUE 'INVOICE',
lv_guiobj TYPE REF TO cl_gui_frontend_services,
lv_path TYPE string VALUE 'D:\',
lv_fullpath TYPE string VALUE 'D:\INVOICE',
lv_filter TYPE string,
lv_uact TYPE i,
lv_filename TYPE string,
++lv_fm_name TYPE rs38l_fnam. +*****************************************
SmartForm from customizing table TNAPR
lf_formname = tnapr-sform.
lv_medium = tnapr-nacha.
determine print data
PERFORM set_print_data_to_read USING lf_formname
CHANGING lwa_print_data_to_read
cf_retcode.
IF cf_retcode EQ 0.
select print data
PERFORM get_data USING lwa_print_data_to_read
CHANGING lwa_addr_key
ls_dlv-land
lwa_bil_invoice
cf_retcode.
ENDIF.
IF cf_retcode EQ 0.
PERFORM set_print_param USING lwa_addr_key
ls_dlv-land
CHANGING lwa_control_param
lwa_composer_param
lwa_recipient
lwa_sender
cf_retcode.
ENDIF.
IF cf_retcode EQ 0.
determine smartform function module for invoice
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING formname = lf_formname
variant = ' '
direct_call = ' '
IMPORTING fm_name = lf_fm_name
EXCEPTIONS no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc NE 0.
error handling
cf_retcode = sy-subrc.
PERFORM protocol_update.
ENDIF.
ENDIF.
IF cf_retcode EQ 0.
PERFORM check_repeat.
IF lwa_composer_param-tdcopies EQ 0.
nast_anzal = 1.
ELSE.
nast_anzal = lwa_composer_param-tdcopies.
ENDIF.
lwa_composer_param-tdcopies = 1.
DO nast_anzal TIMES.
In case of repetition only one time archiving
IF sy-index GT 1 AND nast-tdarmod EQ 3.
nast_tdarmod = nast-tdarmod.
nast-tdarmod = 1.
lwa_composer_param-tdarmod = 1.
ENDIF.
IF sy-index NE 1 AND repeat IS INITIAL.
repeat = 'X'.
ENDIF.
call smartform invoice
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param
mail_appl_obj =
mail_recipient = ls_recipient
mail_sender = ls_sender
output_options = ls_composer_param
user_settings = space
is_bil_invoice = ls_bil_invoice
is_nast = nast
is_repeat = repeat
importing document_output_info =
job_output_info =
job_output_options =
EXCEPTIONS formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
lwa_control_param-getotf = 'X'.
lwa_control_param-no_dialog = 'X'.
lwa_control_param-device = 'PRINTER'.
CALL FUNCTION lf_fm_name
EXPORTING
archive_index = toa_dara
Begin of Changes 24/10/2007*
ARCHIVE_INDEX_TAB =*
ARCHIVE_PARAMETERS = arc_params*
control_parameters = lwa_control_param
MAIL_APPL_OBJ =*
MAIL_RECIPIENT = lwa_recipient*
MAIL_SENDER = lwa_sender*
*End of changes 04/12/2007
output_options = lwa_composer_param
user_settings = 'X'
is_bil_invoice = lwa_bil_invoice
is_nast = nast
is_repeat = repeat
iv_medium = lv_medium
Begin OF Changes 04/12/2007*
IMPORTING
document_output_info = lv_document_output_info
job_output_info = lv_job_output_info
*job_output_options = lv_job_output_options *
End Of Changes 04/12/2007*
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
CALL FUNCTION lf_fm_name
EXPORTING
ARCHIVE_INDEX = toa_dara
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS = arc_params
CONTROL_PARAMETERS = lWA_control_param
MAIL_APPL_OBJ =
MAIL_RECIPIENT = lwa_recipient
MAIL_SENDER = lwa_sender
OUTPUT_OPTIONS = lwa_composer_param
USER_SETTINGS = space
IS_BIL_INVOICE = LWA_BIL_INVOICE
IS_NAST = nast
IS_REPEAT = repeat
IV_MEDIUM = lv_medium
IMPORTING
DOCUMENT_OUTPUT_INFO =
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5
gt_otf[] = lv_job_output_info-otfdata[].
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '*
COPYNUMBER = 0*
ASCII_BIDI_VIS2LOG = ' '*
IMPORTING
BIN_FILESIZE = lv_bin_filesize
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.
*.......................GET THE FILE NAME TO STORE.........
CONCATENATE 'smrt' '.pdf' INTO lv_name.
CREATE OBJECT lv_guiobj.
CALL METHOD lv_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = lv_name
file_filter = lv_filter
CHANGING
filename = lv_name
path = lv_path
fullpath = lv_fullpath.
user_action = lv_uact.*
IF lv_uact = lv_guiobj->action_cancel.
EXIT.
ENDIF.*
MOVE lv_fullpath TO lv_filename.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
BIN_FILESIZE = lv_bin_filesize
filename = lv_fullpath
FILETYPE = 'BIN'
APPEND = SPACE
WRITE_FIELD_SEPARATOR = SPACE
HEADER = '00'
TRUNC_TRAILING_BLANKS = SPACE
WRITE_LF = 'X'
COL_SELECT = SPACE
COL_SELECT_MASK = SPACE
DAT_MODE = SPACE
CONFIRM_OVERWRITE = SPACE
NO_AUTH_CHECK = SPACE
CODEPAGE = SPACE
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = SPACE
TRUNC_TRAILING_BLANKS_EOL = 'X'
IMPORTING
FILELENGTH =
changing
data_tab = gt_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
NOT_SUPPORTED_BY_GUI = 22
ERROR_NO_GUI = 23
others = 24
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.*
ENDIF.
Else.
IF sy-subrc NE 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.
lwa_composer_param-tdcopies = nast_anzal.
IF NOT nast_tdarmod IS INITIAL.
nast-tdarmod = nast_tdarmod.
CLEAR nast_tdarmod.
ENDIF.
ENDIF.
get SmartForm protocoll and store it in the NAST protocoll
PERFORM ADD_SMFRM_PROT.
ENDFORM. "PROCESSING
kindly give me a sloution.Hi,
Check for the print mode in the print options and set it as 3- print and archive .
Regards,
Ram -
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. -
Convert Smartform in PDF format and send to SAP Workplace
Hi to all.
I need help of somebody expert in SMARTFORM's.
I need to convert a smartform into PDF format and to send as attachement for SAP workplace
of the user.
I developed the next code.
IT is to function and to send the mail for SAP workplace, but it happens that smartform
contains images (logos) and tables, when the user tries to open the file pdf in inbox gives
to error - "An unrecognized token ' q0 ' was found".
I tried to call a smartform only with text and functioned well.
Somebody can help me?
My code:
Begin ***********************************************
REPORT zteste_nsa_send_pdf_sap_office.
DATA: t_print LIKE zeps_fm04 OCCURS 0 WITH HEADER LINE,
v_size TYPE i.
DATA: ls_bil_invoice TYPE lbbil_invoice.
TABLES: nast.
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.
START-OF-SELECTION.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZFPS_FICHA_VALORIZACAO'
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'
is_bil_invoice = ls_bil_invoice
is_nast = nast
is_repeat = 'X'
IMPORTING
job_output_info = w_return
TABLES
t_list = t_print
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
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 EQ 0.
ENDIF.
Convert PDF from 132 to 255.
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.
SEND MAIL
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
Object with PDF.
i_objbin[] = i_record[].
Object with main text of the mail.
i_objtxt = 'Fichas de Valorização e Esquemas Tipo'.
APPEND i_objtxt.
Document information.
wa_doc_chng-obj_name = 'SMART'.
wa_doc_chng-expiry_dat = sy-datum + 10.
wa_doc_chng-obj_descr = 'Ficha de Valorização'.
wa_doc_chng-sensitivty = 'F'. "Functional object
wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).
Pack to main body as RAW.
Obj. to be transported not in binary form
DESCRIBE TABLE i_objtxt LINES v_lines_txt.
READ TABLE i_objtxt INDEX v_lines_txt.
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.
Packing as PDF.
Obj. to be transported in binary form
DESCRIBE TABLE i_objbin LINES v_lines_bin.
READ TABLE i_objbin INDEX v_lines_bin.
i_objpack-transf_bin = 'X'.
i_objpack-head_start = 1.
i_objpack-head_num = 0.
i_objpack-body_start = 1.
i_objpack-body_num = v_lines_bin.
i_objpack-doc_type = 'PDF'.
i_objpack-obj_name = 'SMART'.
CONCATENATE 'Ficha_Valorizacao' '.pdf' INTO i_objpack-obj_descr.
i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).
APPEND i_objpack.
e-mail receivers.
CLEAR i_reclist.
i_reclist-receiver = sy-uname.
i_reclist-rec_type = 'B'.
i_reclist-express = 'X'.
APPEND i_reclist.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = wa_doc_chng
put_in_outbox = 'X'
commit_work = ' '
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 EQ 0.
ENDIF.
End *************************************************
Thanks very much to all and Happy New year...
NelsonPlease check this link...
[http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/27/67443cc0063415e10000000a11405a/content.htm]
-Muktar -
How to send output of smartform in pdf format as an attachment to email
how to send output of smartform in pdf format as an attachment to email
search before posting further and follow Forum rules
Edited by: Vijay Babu Dudla on Jan 15, 2009 4:50 AMDid u check on sdn?
i dont think so or else there are many posts on this topic and good wikis too.
look at one of these code tutorial wiki
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/mail%2bsend%2bthrough%2boutput%2bcontrols
So next time do use the search functionality.
кu03B1ятu03B9к
Edited by: kartik tarla on Jan 15, 2009 12:33 PM -
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. -
Smartform as PDF On Button Click
Hello Everyone,
I need to display a smartform as PDF on click of a button.
I have done the conversion using CONVERT_OTF. And then,
CREATE OBJECT cached_response
EXPORTING add_c_msg = 1.
*Start display PDF
cached_response->set_header_field( name = 'content-type'
value = 'application/pdf' ).
some Browsers have caching problems when loading PDF format
cached_response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).
start PDF viewer either in the Browser or as a separate window
cached_response->set_header_field(
name = 'content-disposition'
value = 'attachment; filename=form.pdf' ).
finally display PDF format in Browser
l_pdf_len = xstrlen( l_pdf_xstring ).
cached_response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
DATA: OBJ1 TYPE REF TO CL_BSP_NAVIGATION,
lr_runtime type ref to cl_bsp_runtime.
CREATE OBJECT OBJ1
EXPORTING
RUNTIME = lr_runtime.
call method OBJ1->RESPONSE_COMPLETE .
Is this correct, did I miss anything?
I get a blank screen when I click on the button.
I know this was asked many times , checked those posts but no help.
Looking forward to your input.
Regards,
Mohit JoshiMohit,
did you check the smartform itself?
is it complete executed?
can you test it via the FM?
most of the times when the url shows an empty page is that or the SMARTFORM is not executed correctly or the pdf is not opened automatically.
KR,
Micha
have a look at my coding:
CALL FUNCTION 'SCMS_FTEXT_TO_BINARY'
EXPORTING
input_length = ls_len
append_to_table = 'X'
IMPORTING
output_length = ls_len
TABLES
ftext_tab = lt_objcont
binary_tab = lt_contents
EXCEPTIONS
failed = 1
OTHERS = 2.
lv_file_size = ls_len.
lv_contenttype = 'text/plain'. "#EC NOTEXT
ELSE.
lv_file_size = xwa_len.
lv_contenttype = 'application/pdf'. "#EC NOTEXT
CONCATENATE ls_guid_str '.pdf' INTO lv_filename.
lv_file_name = lv_filename.
server->response->append_data(
data = xwa
length = xwa_len ).
CLEAR lt_contents. REFRESH lt_contents.
ENDIF.
CONCATENATE 'inline; filename=' lv_filename
INTO lv_contentdisposition.
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-disposition'
value = lv_contentdisposition.
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-type'
value = lv_contenttype.
CALL METHOD server->response->set_header_field
EXPORTING
name = 'content-filename'
value = lv_filename.
Content Tabelle (Byte Arrays) rausschreiben
lv_chunksize = 1022.
LOOP AT lt_contents INTO ls_contents.
MOVE ls_contents-line TO xwa.
xwa_len = lv_file_size - ( lv_chunksize * ( sy-tabix - 1 ) ).
IF xwa_len >= lv_chunksize.
xwa_len = lv_chunksize.
ENDIF.
server->response->append_data( data = xwa
length = xwa_len ).
ENDLOOP.
Response beenden
server->response->delete_header_field(
name = 'Cache-Control' ). "#EC NOTEXT
server->response->delete_header_field(
name = 'Expires' ). "#EC NOTEXT
Edited by: Micha Van Nijen on May 3, 2011 12:39 PM -
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 -
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
Maybe you are looking for
-
Please have patient on my English. HELP! Since i upgraded my iphone 4s to iOS 6.0, i can no longer watch or view my Movies or Video's in my Music Playlist. I can still view them in my Videos which is not in orderly manner or arragement like i wanted
-
Cyrillic characters from MySQL not displaying correctly
I have a flash file that has a dynamic text link which is taking the data from a MySQL database. Everything is fine when it is receiving standard characters, but when I try to use Cyrillic characters I just get ???? instead. I've tried setting the c
-
All other fonts work and all Type 1s work on other programs. What do I do to make it work? They worked on XP 32.
-
All of a sudden all new items imported into Adobe Photoshop elements 9 Organizer have an hour glass that is not moving instead of a thumbnail photograph. Update thumbnail does not seem to work. My operating system is Windows Vista. The photos are Jp
-
Isight w/ skype during conversation goes mute
I just installed the beta version for skype, but i use to have this problem before. Sometimes during a conversation on skype suddenly the other person stop hearing me (i still can hear them). Even if i hang up and call again...still mute (the video w