zoukankan      html  css  js  c++  java
  • Download ABAP Spool to PDF(代码样例)

    *** This program receive spool id and destination file name ***
    DATA: it_pdf TYPE TABLE OF TLINE WITH HEADER LINE,
          gv_string TYPE string.


    PARAMETERS: p_spool LIKE TSP01-RQIDENT,
                p_file LIKE RLGRAP-FILENAME.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION ’KD_GET_FILENAME_ON_F4’
        EXPORTING
    *     PROGRAM_NAME        = SYST-REPID
    *     DYNPRO_NUMBER       = SYST-DYNNR
    *     FIELD_NAME          = ’ ’
          STATIC              = ’X’
          MASK                = ’,*.txt,*.*’
        CHANGING
          FILE_NAME           = p_file
        EXCEPTIONS
          MASK_TOO_LONG       = 1
          OTHERS              = 2
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.

    START-OF-SELECTION.
      CALL FUNCTION ’CONVERT_ABAPSPOOLJOB_2_PDF’
        EXPORTING
          SRC_SPOOLID                    = p_spool
    *     NO_DIALOG                      =
    *     DST_DEVICE                     =
    *     PDF_DESTINATION                =
    *   IMPORTING
    *     PDF_BYTECOUNT                  =
    *     PDF_SPOOLID                    =
    *     LIST_PAGECOUNT                 =
    *     BTC_JOBNAME                    =
    *     BTC_JOBCOUNT                   =
       TABLES
         PDF                            = it_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
         OTHERS                         = 12
                .
      IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ELSE.
        gv_string = p_file.
        CALL FUNCTION ’GUI_DOWNLOAD’
          EXPORTING
    *       BIN_FILESIZE                    =
            FILENAME                        = gv_string
            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’
    *       WK1_N_FORMAT                    = ’ ’
    *       WK1_N_SIZE                      = ’ ’
    *       WK1_T_FORMAT                    = ’ ’
    *       WK1_T_SIZE                      = ’ ’
    *     IMPORTING
    *       FILELENGTH                      =
          TABLES
            DATA_TAB                        = it_pdf
    *       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.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    ENDIF.
     
  • 相关阅读:
    弱省胡策 Magic
    CF917D Stranger Trees
    【弱省胡策】Round #5 Count
    【BZOJ2117】 [2010国家集训队]Crash的旅游计划
    「2017 山东一轮集训 Day5」苹果树
    【SDOI2017】天才黑客
    【JXOI2018】守卫
    小程序两种图片加载方式
    小程序之底部栏设计
    小程序之全局变量的设置及使用
  • 原文地址:https://www.cnblogs.com/xiaomaohai/p/6157479.html
Copyright © 2011-2022 走看看