Reporte que procesa otros y muestra la salida en PDF.
*&---------------------------------------------------------------------*
*& Report ZTEST9998
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ztest9998.
*datos reporte
DATA: p_repid LIKE sy-repid VALUE 'ZHR_1_PRNT',
spoolno LIKE tsp01-rqident,
p_linsz LIKE sy-linsz VALUE 132, " Line size
p_paart LIKE sy-paart VALUE 'X_65_132'. " Paper Format
TABLES: tsp01. "spools
*variables de conversion a pdf
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.
* variables de obtencion de spool y submit
DATA:
mstr_print_parms LIKE pri_params,
mc_valid(1) TYPE c,
mi_bytecount TYPE i,
mi_length TYPE i,
mi_rqident LIKE tsp01-rqident.
*-- Setup the Print Parmaters
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
authority = space
copies = '1'
cover_page = space
data_set = space
department = space
destination = space
expiration = '1'
immediately = space
layout = space
mode = space
new_list_id = 'X'
no_dialog = 'X'
user = sy-uname
IMPORTING
out_parameters = mstr_print_parms
valid = mc_valid
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
*-- Make sure that a printer destination has been set up
*-- If this is not done the PDF function module ABENDS
IF mstr_print_parms-pdest = space.
mstr_print_parms-pdest = 'LOCL'.
ENDIF.
*-- Explicitly set line width, and output format so that
*-- the PDF conversion comes out OK
mstr_print_parms-linsz = p_linsz.
mstr_print_parms-paart = p_paart.
* EJECUTAR REPORTE
SUBMIT (p_repid) TO SAP-SPOOL WITHOUT SPOOL DYNPRO
SPOOL PARAMETERS mstr_print_parms
VIA SELECTION-SCREEN
AND RETURN.
*-- Find out what the spool number is that was just created
PERFORM get_spool_number USING sy-repid
sy-uname
CHANGING mi_rqident
client
name.
spoolno = mi_rqident.
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 = ' '
* 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.
* PERFORM bd_textbox_msg(rstxpdft) USING 80
* 'Funktion CONVERT_OTFSPOOLJOB_2_PDF erfolgreich'(001).
WHEN 1.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Fehler bei Funktion CONVERT_OTFSPOOLJOB_2_PDF'(005).
EXIT.
ENDCASE.
ELSE.
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spoolno
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.
* PERFORM bd_textbox_msg(rstxpdft) USING 80
* 'Funktion CONVERT_ABAPSPOOLJOB_2_PDF erfolgreich'(006).
WHEN 1.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Kein OTF- und kein ABAP-Spoolauftrag'(002).
EXIT.
WHEN 2.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Spoolauftrag existiert nicht'(003).
EXIT.
WHEN 3.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Keine Berechtigung zum Lesen Spoolauftrag'(004).
EXIT.
WHEN OTHERS.
PERFORM bd_textbox_err(rstxpdft) USING 80
'Fehler bei Funktion CONVERT_ABAPSPOOLJOB_2_PDF'(007).
EXIT.
ENDCASE.
ENDIF.
*************** download PDF file ***********
data: P_FILE LIKE RLGRAP-FILENAME value 'C:\file.pdf'.
if not ( jobname is initial ).
perform bd_textbox_var2_msg(rstxpdft) using 80
'Konvertierung per Hintergrundjob'(008)
jobname
jobcount.
exit.
endif.
perform download_w_ext(RSTXPDFT) tables pdf
using p_file
'.pdf'
'BIN'
numbytes
cancel.
*if cancel = space.
* data: s(80).
* s = numbytes. condense s.
* concatenate s 'Bytes heruntergeladen in Datei'(009)
* into s separated by space.
* perform bd_textbox_var1_msg(RSTXPDFT) using 80
* s
* p_file.
*endif.
*---------------------------------------------------------------------*
* FORM get_spool_number *
*---------------------------------------------------------------------*
* Get the most recent spool created by user/report *
*---------------------------------------------------------------------*
FORM get_spool_number USING f_repid
f_uname
CHANGING f_rqident
client
name.
DATA:
lc_rq2name LIKE tsp01-rq2name.
CONCATENATE f_repid+0(9)
f_uname+0(3)
INTO lc_rq2name ."SEPARATED BY '_'.
SELECT * FROM tsp01 WHERE rq2name = lc_rq2name
ORDER BY rqcretime DESCENDING.
f_rqident = tsp01-rqident.
client = tsp01-rqclient.
name = tsp01-rqo1name.
EXIT.
ENDSELECT.
IF sy-subrc NE 0.
CLEAR f_rqident.
ENDIF.
ENDFORM." get_spool_number
No hay comentarios:
Publicar un comentario