How To Download Smart Forms To Local File in PDF Format - SAP Q&A
How To Download Smart Forms To Local File in PDF Format - SAP Q&A
(http://www.sap.com/)
(https://community.sap.com)
(/users/login.html?
redirect_to=%2Fquestions%2F2515764%2Fhow-to-
download-smart-forms-to-local-file-in-pdf-f.html)
Ask a Question (https://answers.sap.com/questions/ask.html) Write a Blog Post (https://blogs.sap.com/wp-admin/post-new.php) Login (/users
Former Member
how to download smart forms to local le in pdf format
Jun 15, 2007 at 08:03 AM | 3.9k Views
questions%2F2515764%2Fhow-to-download-smart-
o-local-
a%3D2515764%26s_csrf%3D1607311453723.058)
le-in-pdf-
0
questions%2F2515764%2Fhow-to-download-smart-
ata%3D2515764%26s_csrf%3D1607311453723.058)
o-local- le-in-pdf-
(/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-
Follow
f.html%3Fs_action%3Dfollow%26s_csrf%3D1607311453723.058) RSS Feed
Hi All,
Please help me, i want to download my smartform to my local machine(windows) in PDF format.
THANKS,
Gaurav Mittal
Assigned Tags
Related questions
5 Answers
Former Member
Hi,
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515795%23answer-
data%3D2515795%26s_csrf%3D1607311453723.058)
1
please go throuh the below procedure and sample Code, this might help you.
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515795%23answer-
_data%3D2515795%26s_csrf%3D1607311453723.058)
Procedure
When we activate the Smartform the system generates a Function Module. The function module name we can get from Smartfrom screen from menubar
Environment => Function Module_Name . In a report we can get this Function module name by calling a Function Module standard SSF_FUNCTION_MODULE_NAME. This
function module at runtime calls the FM generated by smartform, which in turn is then used to pass data from the report to Smartform. In the report given below the FM
generated is /1BCDWB/SF00000152 . In this FM we can see CONTROL_PARAMETERS in import tab. This is of type SSFCTRLOP. We need to set the GETOTF of this to be
X . Setting this eld will activate the OTF eld in smartform.
/
In export tab of the FM generated by smartform we can see a parameter JOB_OUTPUT_INFO which is of type SSFCRESCL. The SSFCRESCL is a structure of having one of
elds as OTFDATA. OTFDATA in turn is a table of type ITCOO. ITCOO has two elds TDPRINTCOM and TDPRINTPAR. TDPRINTCOM represents command line of OTF format
data and TDPRINTPAR contains command parameters of OTF format data.
In every Smartform output in OTF format, TDPRINTCOM begins and ends with // . EP represents the end-of-page value for TDPRINTCOM eld.
In addition we need to set few elds at the place where we call this FM(generated by smartform) in our program. While calling this FM we should set control_parameters,
output_options, user_settings and job_putput_info elds as shown in program.
Once these settings are done we can call Function Module CONVERT_OTF to convert the OTF data of smartfrom output to PDF data format. Once these are done we can call
method cl_gui_fronted_services=> le_save_dialog to specify the directory path where we want to save the output PDF le. After this we can call Function Module
GUI_DOWNLOAD to download the PDF le on our local system.
/
SAMPLE CODE
*&---------------------------------------------------------------------*
*& Report ZAMIT_SMART_FORM_PDF *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZAMIT_SMART_FORM_PDF .
start-of-selection.
if sy-subrc <> 0. /
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
exit.
endif.
if sy-subrc <> 0.
* error handling
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
tab_otf_final[] = tab_otf_data-otfdata[].
ENDIF.
2 Comments
As per my understanding we do not need to pass any value in program but it takes the value when we provide local desktop path at the output..
Regards.
Show all
Former Member
Hi,
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515769%23answer-
data%3D2515769%26s_csrf%3D1607311453723.058)
0
Goto SMARTFORMS, then give the Smartform name then Utilities --> Download to Download the Smartform
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515769%23answer-
_data%3D2515769%26s_csrf%3D1607311453723.058)
Regards
Sudheer
Add a Comment (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-
f.html%3Fs_action%3Dcomment%26s_data%3D2515769%26s_csrf%3D1607311453723.058) |
Alert Moderator (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-
f.html%3Fs_action%3Dreport%26s_data%3D2515769%26s_csrf%3D1607311453723.058) |
Share
Former Member
Hi,
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515780%23answer-
data%3D2515780%26s_csrf%3D1607311453723.058)
0
This link may help you.
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2515780%23answer-
_data%3D2515780%26s_csrf%3D1607311453723.058)
http://www.saptechnical.com/Tutorials/Smartforms/OTF2PDF.htm (http://www.saptechnical.com/Tutorials/Smartforms/OTF2PDF.htm) /
Thanks,
Anitha
Former Member
hi
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2516301%23answer-
data%3D2516301%26s_csrf%3D1607311453723.058)
0
good
2Fquestions%2F2515764%2Fhow-to-download-smart-
ml%3FchildToView%3D2516301%23answer-
_data%3D2516301%26s_csrf%3D1607311453723.058)
Code: -
Textpool :
I003 Request does not exist I004 No authorization to read spool request
S_CREDATE Date
S_RQOWNER Author
Abap :
*----
LINE-SIZE 170
LINE-COUNT 58
MESSAGE-ID Y_LOCAL_FR22.
*=----
=*
*----
NUMBYTES TYPE I,
*----
/
*
SELECT-OPTIONS:
PARAMETERS:
*----
*----
EXPORTING
DEF_FILENAME = '.'
DEF_PATH = DEFDIR
MODE = 'O'
IMPORTING
FILENAME = DIR
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC <> 0.
SY-SUBRC = SY-SUBRC + 0.
ENDIF.
DEFDIR = DIR.
*=----
=*
START-OF-SELECTION.
*=----
=* /
*here inspiration comes from RSPOSP01 (transaction SP01)
S_RQFIN-LOW = 'C'.
S_RQFIN-SIGN = 'I'.
S_RQFIN-OPTION = 'EQ'.
APPEND S_RQFIN.
S_RQFIN-LOW = '.'.
APPEND S_RQFIN.
CLEAR _CRETIME.
REFRESH _CRETIME.
LOOP AT _CREDATE.
_CRETIME-SIGN = _CREDATE-SIGN.
_CRETIME-OPTION = _CREDATE-OPTION.
IF _CREDATE-LOW IS INITIAL.
CLEAR _CRETIME-LOW.
ELSE.
_CRETIME-LOW(8) = _CREDATE-LOW.
_CRETIME-LOW+8(8) = '00000000'.
ENDIF.
IF _CREDATE-HIGH IS INITIAL.
CLEAR _CRETIME-HIGH.
ELSE.
_CRETIME-HIGH(8) = _CREDATE-HIGH.
_CRETIME-HIGH+8(8) = '23595900'.
ENDIF.
APPEND _CRETIME.
ENDLOOP.
RQDEST IN _RQDEST .
LOOP AT _TSP01.
ACCESS = 'BASE'
SPOOLREQ = TSP01
EXCEPTIONS
NO_PERMISSION = 1
OTHERS = 2.
*check authority
CHECK SY-SUBRC = 0.
client = tsp01-rqclient.
name = tsp01-rqo1name.
EXPORTING
AUTHORITY = 'SP01'
CLIENT = CLIENT
NAME = NAME
PART = 1
IMPORTING
CHARCO = CHARCO
CREATER = CREATER
CREDATE = CREDATE
DELDATE = DELDATE
MAX_CREDATE = MAX_CREDATE
MAX_DELDATE = MAX_DELDATE
NON_UNIQ = NON_UNIQ
NOOF_PARTS = NOOF_PARTS
RECTYP = RECTYP
SIZE = SIZE
STOTYP = STOTYP
TYPE = TYPE
OBJTYPE = OBJTYPE
EXCEPTIONS
FB_ERROR = 1
FB_RSTS_OTHER = 2
NO_OBJECT = 3
NO_PERMISSION = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
ENDIF.
*spool À traiter
WRITE:/
TSP01-RQIDENT ,
TSP01-RQ0NAME ,
TSP01-RQ1NAME ,
TSP01-RQ2NAME ,
TSP01-RQOWNER ,
TSP01-RQDEST ,
TSP01-RQPAPER.
" client ,
" name ,
" part ,
" charco ,
" creater ,
" credate ,
" deldate ,
" max_credate ,
" max_deldate ,
" non_uniq ,
" noof_parts ,
" rectyp ,
" size ,
" stotyp ,
" type ,
" objtype .
if objtype(3) = 'OTF'.
EXPORTING
SRC_SPOOLID = TSP01-RQIDENT
DST_DEVICE =
PDF_DESTINATION =
IMPORTING
PDF_BYTECOUNT = numbytes
PDF_SPOOLID = pdfspoolid
OTF_PAGECOUNT =
BTC_JOBNAME = jobname
BTC_JOBCOUNT = jobcount /
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_OTF_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DSTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
case sy-subrc.
when 0.
COLOR COL_POSITIVE.
when 1.
COLOR COL_negative.
exit.
when 2.
COLOR COL_negative.
exit.
when 3.
COLOR COL_negative.
exit.
when others.
COLOR COL_negative.
exit.
endcase.
else.
EXPORTING
SRC_SPOOLID = TSP01-RQIDENT
IMPORTING
PDF_BYTECOUNT = numbytes
PDF_SPOOLID = pdfspoolid
LIST_PAGECOUNT =
BTC_JOBNAME = jobname
BTC_JOBCOUNT = jobcount
TABLES
PDF = pdf
EXCEPTIONS
ERR_NO_ABAP_SPOOLJOB = 1
ERR_NO_SPOOLJOB = 2
ERR_NO_PERMISSION = 3
ERR_CONV_NOT_POSSIBLE = 4
ERR_BAD_DESTDEVICE = 5
USER_CANCELLED = 6
ERR_SPOOLERROR = 7
ERR_TEMSEERROR = 8
ERR_BTCJOB_OPEN_FAILED = 9
ERR_BTCJOB_SUBMIT_FAILED = 10
ERR_BTCJOB_CLOSE_FAILED = 11.
case sy-subrc.
when 0.
COLOR COL_POSITIVE.
when 1.
COLOR COL_negative.
exit.
when 2.
COLOR COL_negative.
exit.
when 3.
COLOR COL_negative.
exit.
when others.
COLOR COL_negative. /
exit.
endcase.
endif.
download PDF le
INTO P_FILE.
EXPORTING
BIN_FILESIZE = NUMBYTES
FILENAME = P_FILE
FILETYPE = 'BIN'
IMPORTING
act_ lename = p_ le
FILELENGTH = NUMBYTES
TABLES
DATA_TAB = PDF.
(100) P_FILE.
ULINE.
ENDLOOP.
thanks
mrutyun^
Former Member
Hi,
2Fquestions%2F2515764%2Fhow-to-download-smart-
data%3D12011277%26s_csrf%3D1607311453723.058)
l%3FchildToView%3D12011277%23answer-
0
Hope this Simple code would be useful to you.
2Fquestions%2F2515764%2Fhow-to-download-smart-
_data%3D12011277%26s_csrf%3D1607311453723.058)
l%3FchildToView%3D12011277%23answer-
TABLES: kna1.
*-----------------Interface options-----------------*
*---------
*-----------------Declarations----------------------*
*---------
EXPORTING
formname = 'ZBM_DEMO_FORM'
IMPORTING
fm_name = fmname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
ENDIF.
*----------
wa_control_parameters-no_dialog = 'X'.
wa_control_parameters-preview = 'X'.
wa_control_parameters-getotf = 'X'.
wa_output_options-tddest = 'LP01'.
*-----------
EXPORTING
control_parameters = wa_control_parameters
/
output_options = wa_output_options
kunnr_low = s_kunnr-low
kunnr_high = s_kunnr-high
IMPORTING
job_output_info = wa_job_output_info
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
STOP.
ENDIF.
*-------------
IMPORTING
TABLES
otf = wa_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 NE 0.
STOP.
ENDIF.
*----------
/
*----------- THIS METHOD IS USED TO DISPLAY THE FILE SAVE DIALOG WINDOW-----------*
* EXPORTING
* window_title =
* default_extension =
* default_ le_name =
* with_encoding =
* le_ lter =
* initial_directory =
* prompt_on_overwrite = 'X'
CHANGING
lename = v_ lename
path = le_path
fullpath = full_path
* user_action =
* le_encoding =
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4
IF sy-subrc <> 0.
ENDIF.
*------------
EXPORTING
lename = v_ lename
letype = 'BIN'
TABLES
data_tab = it_lines
EXCEPTIONS
le_write_error = 1
no_batch = 2
/
gui_refuse_ letransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
lesize_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
le_not_found = 19
dataprovider_exception = 20
control_ ush_error = 21
OTHERS = 22.
IF sy-subrc NE 0.
ENDIF.
*-------------------
Before answering
You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please
leave a comment instead, requesting additional details. When answering, please include speci cs, such as step-by-step instructions, context for the solution, and links to
useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
Please provide a distinct answer and use the comment option for clarifying purposes.
Find us on