메뉴 건너뛰기

SAP 한국 커뮤니티

PDF 변환 소스

sapjoy 2006.12.20 14:46 조회 수 : 5441 추천:36

report zabap_2_pdf.
*-- Enhancements: only allow to be run with variant.  Then called
*-- program will be transparent to users
*-- TABLES
tables:
  tsp01.
*-- STRUCTURES
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.
*-- INTERNAL TABLES
data:
  mtab_pdf    like tline occurs 0 with header line,
  mc_filename like rlgrap-filename.
*-- SELECTION SCREEN
parameters:
  p_repid like sy-repid, " Report to execute
  p_linsz like sy-linsz default 132, " Line size
  p_paart like sy-paart default 'X_65_132'.  " Paper Format
start-of-selection.
concatenate 'c:'
            p_repid
            '.pdf'
  into mc_filename.
*-- 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
     in_archive_parameters        = space
     in_parameters                = 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.
  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.
*-- Convert Spool to PDF
  call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
    exporting
      src_spoolid= mi_rqident
      no_dialog  = space
      dst_device = mstr_print_parms-pdest
    importing
      pdf_bytecount                  = mi_bytecount
    tables
      pdf        = mtab_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.
call function 'DOWNLOAD'
     exporting
          bin_filesize            = mi_bytecount
          filename                = mc_filename
          filetype                = 'BIN'
     importing
          act_filename            = mc_filename
     tables
          data_tab                = mtab_pdf.
*---------------------------------------------------------------------*
*       FORM get_spool_number *
*---------------------------------------------------------------------*
*       Get the most recent spool created by user/report              *
*---------------------------------------------------------------------*
*  -->  F_REPID               *
*  -->  F_UNAME               *
*  -->  F_RQIDENT             *
*---------------------------------------------------------------------*
form get_spool_number using f_repid
     f_uname
                changing f_rqident.
  data:
    lc_rq2name like tsp01-rq2name.
  concatenate f_repid+0(8)
              f_uname+0(3)
    into lc_rq2name separated by '_'.
  select * from tsp01 where  rq2name = lc_rq2name
  order by rqcretime descending.
    f_rqident = tsp01-rqident.
    exit.
  endselect.
  if sy-subrc ne 0.
    clear f_rqident.
  endif.
endform." get_spool_number
번호 제목 글쓴이 날짜 조회 수
527 data [2] sapjoy 2006.12.03 16722
526 Abap Dump Top 10 [5] 양키 2013.01.14 15746
525 BAPI_GOODSMVT_CREATE 입고/출고/재고이동시에 사용하세요. [5] 노름마치 2007.12.10 15106
524 Dynamic Internal Table 생성 꿀꿀윤뚱67 2019.11.27 14857
523 <img src=b.gif>Windows 7 에서 SAP GUI ALV 반응느림 해결방법 공유 (GUI720 기준)[추천:e-abap][추천:유리선율][추천:보나] [17] 점점 2010.07.02 14783
522 텍스트파일 다운받을때 유니코드 문제 해결 [8] file 솔로몬 2007.06.28 13798
521 SAP GUI WINDOW TITLE BAR 정보 표시 설정 방법 / 색상 설정 [15] file 미소 2010.12.26 13452
520 SAP 데이터 EXCEL로 내리는 절차 [6] sapjoy 2007.06.04 13354
519 Useful SAP System Administration Transactions [2] 홍성현 2007.08.08 12752
518 사업장 변경 [J_1BBRANCH] [1] Alexhong 2012.03.07 12646
517 테이블 변경 이력 테이블 [5] sapjoy 2006.12.12 12636
516 SAP GUI 7.10 patch level 14 Download Link 입니다. [2] 방배 2009.10.13 12611
515 오라클 힌트 리스트 정리 [3] sapjoy 2012.03.08 12537
514 native sql 사용 [8] sapjoy 2006.12.28 12436
513 GUI 720에서 ALV Grid 느린 현상 [26] 벗님 2011.10.12 12368
512 SELECT 문의 종류 및 CONCATENATE의 사용 [24] file iceout 2010.08.20 11792
511 delete 인터널 테이블 [7] ecbase 2006.12.02 11558
510 Batch JOB이 수행중인지 여부체크 [5] deepbluesea 2011.04.05 11401
509 클라이언트간 CTS로 데이타이관 [15] file 노름마치 2008.07.11 11095
508 나름데로 User Exit 정리 [17] 한해동안 2008.06.03 11081