博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
导出到PDF例子
阅读量:2034 次
发布时间:2019-04-28

本文共 4086 字,大约阅读时间需要 13 分钟。

REPORT RSTXPDFT4 
line-
size 
80.
*
* Read spool job contents (OTF or ABAP list) and convert
* to PDF, download PDF
* B20K8A0IKH replace WS_DOWNLOAD with GUI_DOWNLOAD
*
PARAMETERS:
  SPOOLNO 
LIKE TSP01-RQIDENT,
  DOWNLOAD 
AS 
CHECKBOX 
DEFAULT 
'X',
  P_FILE 
LIKE RLGRAP-FILENAME 
DEFAULT 
'C:\temp\file.pdf'
"#EC NOTEXT
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.
tables: tsp01.
select 
single * 
from tsp01 
where rqident = spoolno.
if sy-subrc <> 
0.
  
perform bd_textbox_err(rstxpdft) 
using 
80
   
'Spoolauftrag existiert nicht'(
003).
  
exit.
endif.
client = tsp01-rqclient.
name   = tsp01-rqo1name.
CALL 
FUNCTION 
'RSTS_GET_ATTRIBUTES'
       
EXPORTING
            AUTHORITY     = 
'SP01'
            
CLIENT        = 
client
            NAME          = name
            PART          = 
1
       
IMPORTING
*           CHARCO        =
*           CREATER       =
*           CREDATE       =
*           DELDATE       =
*           MAX_CREDATE   =
*           MAX_DELDATE   =
*           NON_UNIQ      =
*           NOOF_PARTS    =
*           RECTYP        =
*           SIZE          =
*           STOTYP        =
            
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 ***********
check download = 
'X'.
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.

转载地址:http://cvhaf.baihongyu.com/

你可能感兴趣的文章
redis中与清空数据有关的命令
查看>>
redis cluster 一个问题:双master不能在一个虚拟机/物理机上
查看>>
Redis缓冲区设置
查看>>
RocketMQ初步应用架构理论(主从切换/异/同步刷盘)
查看>>
eclipse 修改 项目的git地址
查看>>
Spring gateway使用一个lambda例子的说明
查看>>
Bug: Return value of putIfAbsent is ignored, but list is reused
查看>>
理解WEB API网关
查看>>
maven-jar-plugin 排除不想打包的目录文件内容
查看>>
feign.FeignException: status 404 reading xxService#xxmethod(Integer)
查看>>
唯品会后端架构部分内容分享(一) ( 20180613 by flyer)
查看>>
Spring Cloud Zuul实现动态路由
查看>>
zuul动态路由支持的路径格式及扩展性测试
查看>>
linux服务器校对时间方法
查看>>
rocketMQ 消息查询(id,key) 运维命令以及java API的用法
查看>>
RocketMQ学习(五):Pull和Push (important)
查看>>
Linux下查看系统启动时间和运行时间
查看>>
数据处理过慢的问题分析(涉及插入查询)
查看>>
JVM线程状态,park, wait, sleep, interrupt, yeild 对比
查看>>
java.lang.Thread.State:WAITING(parking)
查看>>