0% found this document useful (0 votes)
380 views20 pages

How To Download Smart Forms To Local File in PDF Format - SAP Q&A

Uploaded by

phogat project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
380 views20 pages

How To Download Smart Forms To Local File in PDF Format - SAP Q&A

Uploaded by

phogat project
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

Community

(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

Search the SAP Community

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

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%3D2515764%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%3DreportQuestion%26s_data%3D2515764%26s_csrf%3D1607311453723.058)

Assigned Tags

NW ABAP Print and Output Management (/tags/334558737810127171897316045257708) | ABAP Development (/tags/833755570260738661924709785639136) |

Related questions

Smartform .OTF to PDF download. (https://answers.sap.com/questions/4651594/smartform-otf-to-pdf-download.html)


By Bhanu Prakash ( https://people.sap.com/prakash.pols) Aug 26, 2008

Graphic printing in smart forms (https://answers.sap.com/questions/2572724/graphic-printing-in-smart-forms.html)


By Former Member ( https://people.sap.com/former.member) Jun 27, 2007

5 Answers

Sort by: Votes | Newest | Oldest

Former Member

Jun 15, 2007 at 08:06 AM

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.

Here is a sample code of program to perform the function.

/
SAMPLE CODE

*&---------------------------------------------------------------------*
*& Report ZAMIT_SMART_FORM_PDF *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*

REPORT ZAMIT_SMART_FORM_PDF .

data: carr_id type sbook-carrid,


cparam type ssfctrlop,
outop type ssfcompop,
fm_name type rs38l_fnam.

DATA: tab_otf_data TYPE ssfcrescl,


pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE,
tab_otf_final TYPE itcoo OCCURS 0 WITH HEADER LINE,
file_size TYPE i,
bin_filesize TYPE i,
FILE_NAME type string,
File_path type string,
FULL_PATH type string.

parameter: p_custid type scustom-id default 1.


select-options: s_carrid for carr_id default 'LH' to 'LH'.
parameter: p_form type tdsfname default 'ZAMIT_SMART_FORM'.

data: customer type scustom,


bookings type ty_bookings,
connections type ty_connections.

start-of-selection.

***************** suppressing the dialog box for print preview****************************


outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = SPACE.
cparam-getotf = 'X'.

select single * from scustom into customer where id = p_custid.


check sy-subrc = 0.

select * from sbook into table bookings


where customid = p_custid
and carrid in s_carrid
order by primary key.

select * from spfli into table connections


for all entries in bookings
where carrid = bookings-carrid
and connid = bookings-connid
order by primary key.

call function 'SSF_FUNCTION_MODULE_NAME'


exporting formname = p_form
* variant = ' '
* direct_call = ' '
importing fm_name = 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.
exit.
endif.

* calling the generated function module


call function fm_name
exporting
* archive_index =
* archive_parameters =
control_parameters = cparam
* mail_appl_obj =
* mail_recipient =
* mail_sender =
output_options = outop
user_settings = SPACE
bookings = bookings
customer = customer
connections = connections
importing
* document_output_info =
job_output_info = tab_otf_data
* job_output_options =
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.

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[].

CALL FUNCTION 'CONVERT_OTF'


EXPORTING
format = 'PDF'
max_linewidth = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
* ASCII_BIDI_VIS2LOG = ' '
IMPORTING
bin_filesize = bin_filesize
* BIN_FILE =
TABLES
otf = tab_otf_final
lines = 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.

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 = FILE_NAME
path = FILE_PATH
fullpath = 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.

*************downloading the converted PDF data to your local PC********

CALL FUNCTION 'GUI_DOWNLOAD'


EXPORTING
bin_filesize = bin_filesize
filename = 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'
IMPORTING
filelength = file_size
TABLES
data_tab = 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.

ENDIF.

Thanks and Regards,


Vasanth

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%3D2515795%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%3D2515795%26s_csrf%3D1607311453723.058) |
Share

2 Comments

Former Member  Former Member

Oct 14, 2015 at 04:47 AM (/comments/12011371/view.html)


Hi,

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.

Like (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-f.html%3FchildToView%3D12011371%23comment-


12011371%26s_action%3Dlike_comment%26s_data%3D12011371%26s_csrf%3D1607311453723.058) 0 |
Share
|

Alert Moderator (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-


f.html%3Fs_action%3DreportComment%26s_data%3D12011371%26s_csrf%3D1607311453723.058)

Show all

Comment on This Answer (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-to-local- le-in-pdf-


f.html%3Fs_action%3Dcomment%26s_data%3D2515795%26s_csrf%3D1607311453723.058)

Former Member

Jun 15, 2007 at 08:05 AM

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

Jun 15, 2007 at 08:10 AM

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

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%3D2515780%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%3D2515780%26s_csrf%3D1607311453723.058) |
Share

Former Member

Jun 15, 2007 at 09:26 AM

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)

go through this code

Code: -

Textpool :

I001 CONVERT_OTFSPOOLJOB_2_PDF function successful

I002 Not an OTF or ABAP spool request

I003 Request does not exist I004 No authorization to read spool request

I005 Error in CONVERT_OTFSPOOLJOB_2_PDF function

I006 CONVERT_ABAPSPOOLJOB_2_PDF function successful

I007 Error in CONVERT_ABAPSPOOLJOB_2_PDF function

I009 CaractÈres dans

R export SPOOLS to local les after PDF convertion

S_CREDATE Date

S_RQ2NAME Spool Name

S_RQDEST Destination (printer)

S_RQIDENT Spool Number

S_RQOWNER Author

Abap :

*----

The program select spools


/
and export then under PDF format.

REPORT YYJPL14 "NO STANDARD PAGE HEADING

LINE-SIZE 170

LINE-COUNT 58

MESSAGE-ID Y_LOCAL_FR22.

*=----

=*

TABLES: TSP01, RSPOTYPE.

*----

DATA: DEFDIR(256) VALUE 'C:SAP'

,_TSP01 LIKE TSP01 OCCURS 0 WITH HEADER LINE,

AUTHORITY LIKE RSTSTYPE-AUTHCHECKD,

CLIENT LIKE RSTSTYPE-CLIENT,

NAME LIKE RSTSTYPE-NAME,

PART LIKE TST01-DPART,

CHARCO LIKE RSTSTYPE-CHARCO,

CREATER LIKE RSTSTYPE-CREATER,

CREDATE LIKE RSTSTYPE-CREDATE,

DELDATE LIKE RSTSTYPE-DELDATE,

MAX_CREDATE LIKE RSTSTYPE-CREDATE,

MAX_DELDATE LIKE RSTSTYPE-DELDATE,

NON_UNIQ LIKE RSTSTYPE-SEL_OK,

NOOF_PARTS LIKE TST01-DNOPARTS,

RECTYP LIKE RSTSTYPE-RECTYP,

SIZE LIKE TST01-DSIZE,

STOTYP LIKE TST01-DSTOTYP,

TYPE LIKE RSTSTYPE-TYPE,

OBJTYPE LIKE RSTSTYPE-TYPE,

NUMBYTES TYPE I,

PDFSPOOLID LIKE TSP01-RQIDENT,

jobname like tbtcjob-jobname,

JOBCOUNT LIKE TBTCJOB-JOBCOUNT,

PDF LIKE TLINE OCCURS 0 WITH HEADER LINE,

P_FILE LIKE RLGRAP-FILENAME VALUE 'C:temp le.pdf (http://temp le.pdf)'.

RANGES: S_RQFIN FOR TSP01-RQFINAL.

RANGES: _CRETIME FOR TSP01-RQCRETIME.

*----

/
*

SELECT-OPTIONS:

_RQIDENT FOR TSP01-RQIDENT,

_RQOWNER FOR TSP01-RQOWNER,

_CREDATE FOR RSPOTYPE-CREDATE,

"_cretime FOR tsp01-rqcretime,

_RQ2NAME FOR TSP01-RQ2NAME,

_RQDEST FOR TSP01-RQDEST .

PARAMETERS:

DIR LIKE RLGRAP-FILENAME DEFAULT DEFDIR.

*----

AT SELECTION-SCREEN ON VALUE-REQUEST FOR DIR.

*----

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

DEF_FILENAME = '.'

DEF_PATH = DEFDIR

MASK = ',All les,..'

MODE = 'O'

TITLE = 'Get lename for directory'

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)

REFRESH S_RQFIN. " select all C & . required for index!!!

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.

* nd the spool list

SELECT * FROM TSP01

INTO CORRESPONDING FIELDS OF TABLE _TSP01

WHERE RQFINAL IN S_RQFIN AND

RQIDENT IN _RQIDENT AND

RQOWNER IN _RQOWNER AND

RQCRETIME IN _CRETIME AND

RQ2NAME IN _RQ2NAME AND

RQDEST IN _RQDEST .

LOOP AT _TSP01.

MOVE-CORRESPONDING _TSP01 TO TSP01.

*authority to work with spool

CALL FUNCTION 'RSPO_CHECK_JOB_PERMISSION'


/
EXPORTING

ACCESS = 'BASE'

SPOOLREQ = TSP01

EXCEPTIONS

NO_PERMISSION = 1

OTHERS = 2.

*check authority

CHECK SY-SUBRC = 0.

*here inspiration comes from RSTXPDFT4

*retrieve spool attributes

client = tsp01-rqclient.

name = tsp01-rqo1name.

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

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.

MESSAGE E020 WITH SY-SUBRC CLIENT NAME.


/
CONTINUE.

ENDIF.

*spool À traiter

WRITE:/

TSP01-RQIDENT ,

TSP01-RQ0NAME ,

TSP01-RQ1NAME ,

TSP01-RQ2NAME ,

TSP01-RQOWNER ,

(19) TSP01-RQCRETIME USING EDIT MASK '____/__/__ __:__:__',

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'.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = TSP01-RQIDENT

NO_DIALOG = ' '

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.

WRITE: / 'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001)

COLOR COL_POSITIVE.

when 1.

WRITE: / 'Kein OTF- und kein ABAP-Spoolauftrag'(002)

COLOR COL_negative.

exit.

when 2.

WRITE: / 'Spoolauftrag existiert nicht'(003)

COLOR COL_negative.

exit.

when 3.

WRITE: / 'Keine Berechtigung zum Lesen Spoolauftrag'(004)

COLOR COL_negative.

exit.

when others.

WRITE: / 'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005)

COLOR COL_negative.

exit.

endcase.

else.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

SRC_SPOOLID = TSP01-RQIDENT

NO_DIALOG = ' '


/
DST_DEVICE =
PDF_DESTINATION =

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.

WRITE: / 'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006)

COLOR COL_POSITIVE.

when 1.

WRITE: / 'Kein OTF- und kein ABAP-Spoolauftrag'(002)

COLOR COL_negative.

exit.

when 2.

WRITE: / 'Spoolauftrag existiert nicht'(003)

COLOR COL_negative.

exit.

when 3.

WRITE: / 'Keine Berechtigung zum Lesen Spoolauftrag'(004)

COLOR COL_negative.

exit.

when others.

WRITE: / 'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007)

COLOR COL_negative. /
exit.

endcase.

endif.

download PDF le

TRANSLATE TSP01-RQ2NAME USING '/ : * < > | ? '' " '.

CONDENSE TSP01-RQ2NAME NO-GAPS.

CONCATENATE DIR '' TSP01-RQ2NAME '-' TSP01-RQCRETIME '.pdf'

INTO P_FILE.

CALL FUNCTION 'WS_DOWNLOAD'"or GUI_DOWNLOAD

EXPORTING

BIN_FILESIZE = NUMBYTES

FILENAME = P_FILE

FILETYPE = 'BIN'

IMPORTING

act_ lename = p_ le

FILELENGTH = NUMBYTES

TABLES

DATA_TAB = PDF.

WRITE: / NUMBYTES, 'Bytes heruntergeladen in Datei'(009),

(100) P_FILE.

ULINE.

ENDLOOP.

thanks

mrutyun^

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%3D2516301%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%3D2516301%26s_csrf%3D1607311453723.058) |
Share

Former Member

Oct 14, 2015 at 04:43 AM

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-----------------*

SELECT-OPTIONS : s_kunnr FOR kna1-kunnr.

*---------

*-----------------Declarations----------------------*

DATA: wa_control_parameters TYPE ssfctrlop. /


DATA: wa_output_options TYPE ssfcompop.

DATA: wa_job_output_info TYPE ssfcrescl.

DATA: fmname TYPE tdsfname.

DATA: v_bin_ lesize TYPE i.

DATA: v_ lename TYPE string. "VALUE 'formtest.pdf (http://formtest.pdf)'.

DATA: it_lines TYPE STANDARD TABLE OF tline.

DATA: it_docs TYPE STANDARD TABLE OF docs.

DATA: le_path TYPE string,

full_path TYPE string.

*---------

*-----------------Getting the Form name-------------------*

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZBM_DEMO_FORM'

* VARIANT = ' '

* DIRECT_CALL = ' '

IMPORTING

fm_name = fmname

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

*----------

*--------------Setting the output parameters for Form----------*

wa_control_parameters-no_dialog = 'X'.

wa_control_parameters-preview = 'X'.

wa_control_parameters-getotf = 'X'.

wa_output_options-tddest = 'LP01'.

*-----------

*--------------Calling the Form's FM----------------------------*

CALL FUNCTION fmname

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.

*-------------

*---------------Converting the OTF output into PDF---------------*

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_ lesize = v_bin_ lesize

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.

WRITE: / 'conversion error, RC:', sy-subrc.

STOP.

ENDIF.

*----------

/
*----------- THIS METHOD IS USED TO DISPLAY THE FILE SAVE DIALOG WINDOW-----------*

CALL METHOD cl_gui_frontend_services=> le_save_dialog

* 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.

* Implement suitable error handling here

ENDIF.

*------------

*--------------------Downloading the Form------------------*

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_ lesize = v_bin_ lesize

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.

WRITE: / 'download error, RC:', sy-subrc.

ENDIF.

*-------------------

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%3D12011277%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%3D12011277%26s_csrf%3D1607311453723.058) |
Share

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.

Rules of Engagement (https://www.sap.com/community/resources/rules-of-engagement.html)

Know someone who can answer? Share a link to this question.

You must be Logged in (/users/login.html?redirect_to=%2Fquestions%2F2515764%2Fhow-to-download-smart-forms-


/
to-local- le-in-pdf-f.html%3Fs action%3DanswerQuestion%26s csrf%3D1607311453723.058) to submit an answer.
to local le in pdf f.html%3Fs_action%3DanswerQuestion%26s_csrf%3D1607311453723.058) to submit an answer.

Please provide a distinct answer and use the comment option for clarifying purposes.

Submit your Answer

Find us on

(https://www.facebook.com/sapcommunity) (https://twitter.com/SAPCommunity) (https://www.youtube.com/c/SAPCommunities)

(https://www.linkedin.com/company/sap) (https://instagram.com/sap/) (http://www.slideshare.net/SAP) (mailto:?subject='SAP Community')

Privacy (http://sap.com/about/legal/privacy.html) Terms of Use (http://sap.com/corporate/en/legal/terms-of-use.html)

Legal Disclosure (http://sap.com/about/legal/impressum.html) Copyright (http://sap.com/about/legal/copyright.html)

Trademark (http://sap.com/about/legal/trademark.html) Cookie Preferences

Newsletter (https://www.sap.com/cmp/nl/sap-community-voice/index.html) Support (mailto:[email protected])

You might also like