Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

GUI_DOWNLOAD

Former Member
0 Kudos
1,075

Hi,

I am using the function module GUI_DOWNLOAD in the print program for the purchase order to dowload a smartform in pdf format. The problem is it is not dowloading the data in pdf file in my specified folder on my desktop. but i get success message saying that 16000 bytes transfered

1 ACCEPTED SOLUTION

Former Member
0 Kudos
231

HI,

This program will run in backgroud i think you cannot download into local directory , download it to application server or use the program RSTXPDFT5 and pass the spool number to this and it will download to ur local drive..

Thanks

Mahesh

3 REPLIES 3

Former Member
0 Kudos
232

HI,

This program will run in backgroud i think you cannot download into local directory , download it to application server or use the program RSTXPDFT5 and pass the spool number to this and it will download to ur local drive..

Thanks

Mahesh

Former Member
0 Kudos
231

I have done similar requirement ,but my version is 4.6C..

Check the below code and hope it may help you

  • Download PDF file with dialog for file path

IF NOT w_itcpp-tdspoolid IS INITIAL AND

sy-batch IS INITIAL AND

nast-kschl = 'ZPDF'.

w_download = 'X'.

w_file = 'C:\temp\file.pdf'.

  • This routine is a copy of SAP standard program RSTXPDFT4 with little

  • customization

PERFORM create_pdf_file USING w_itcpp-tdspoolid

w_download

w_file.

FORM create_pdf_file USING spoolno

download

p_file.

TABLES: tsp01.

DATA otf LIKE itcoo OCCURS 100 WITH HEADER LINE.

DATA cancel.

DATA pdf LIKE tline OCCURS 100 WITH HEADER LINE.

DATA doctab LIKE docs OCCURS 1 WITH HEADER LINE.

DATA: numbytes TYPE i,

arc_idx LIKE toa_dara,

pdfspoolid LIKE tsp01-rqident,

jobname LIKE tbtcjob-jobname,

jobcount LIKE tbtcjob-jobcount,

is_otf.

DATA: client LIKE tst01-dclient,

name LIKE tst01-dname,

objtype LIKE rststype-type,

type LIKE rststype-type.

  • Check if spool id exists

SELECT SINGLE * FROM tsp01 WHERE rqident = spoolno.

IF sy-subrc <> 0.

WRITE: / 'Spoolauftrag existiert nicht'(003)

COLOR COL_NEGATIVE.

EXIT.

ENDIF.

client = tsp01-rqclient.

name = tsp01-rqo1name.

CALL FUNCTION 'RSTS_GET_ATTRIBUTES'

EXPORTING

authority = 'SP01'

client = client

name = name

part = 1

IMPORTING

type = type

objtype = objtype

EXCEPTIONS

fb_error = 1

fb_rsts_other = 2

no_object = 3

no_permission = 4.

IF objtype(3) = 'OTF'.

is_otf = 'X'.

ELSE.

is_otf = space.

ENDIF.

IF is_otf = 'X'.

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = spoolno

no_dialog = ' '

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

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 = spoolno

no_dialog = ' '

IMPORTING

pdf_bytecount = numbytes

pdf_spoolid = pdfspoolid

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

CHECK download = 'X'.

IF NOT ( jobname IS INITIAL ).

WRITE: / 'Konvertierung per Hintergrundjob'(008)

COLOR COL_NORMAL,

jobname, jobcount.

EXIT.

ENDIF.

CALL FUNCTION 'DOWNLOAD'

EXPORTING

bin_filesize = numbytes

filename = p_file

filetype = 'BIN'

mode = ' '

silent = 'X'

IMPORTING

act_filename = p_file

filesize = numbytes

cancel = cancel

TABLES

data_tab = pdf.

ENDFORM. " create_pdf_file

Thanks

Seshu

Former Member
0 Kudos
231

Thank you all of the suggestions were helpfull