Advertisement
rplantiko

Merge two ABAP lists into one PDF

Jul 4th, 2012
964
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 3.12 KB | None | 0 0
  1. * --------------------------------------------------------------------
  2. * Merge two ABAP lists given in spool jobs,
  3. * and convert the result to one pdf document
  4. * Works only for ABAP lists (not OTF or others)
  5. * Just to prove it's possible...
  6. * --------------------------------------------------------------------
  7. * Works on SAP_BASIS 702, but lower releases should do, too
  8. * --------------------------------------------------------------------
  9. report  zz_get_list line-size 1023.
  10.  
  11. parameters: p_list1  type rspoid obligatory,
  12.             p_list2  type rspoid obligatory,
  13.             p_submit type flag default 'X' no-display.
  14.  
  15.  
  16. start-of-selection.
  17.   perform start.
  18.  
  19. * ---
  20. form start.
  21.  
  22.   data: lv_spoolid    type rspoid,
  23.         lt_pdf        type tline_tab,
  24.         lv_pdf_length type i.
  25.  
  26.   if p_submit eq 'X'.
  27.  
  28.     perform conv_2_abap_spool_lists_to_pdf
  29.       using p_list1 p_list2
  30.       changing lt_pdf lv_pdf_length.
  31.  
  32.     perform download using lt_pdf lv_pdf_length.
  33.  
  34.   else.
  35.  
  36.     new-page print on. " line-size 1023.
  37.     perform write_to_current using :
  38.       p_list1,
  39.       p_list2.
  40.     lv_spoolid = sy-spono.
  41.     export spoolid from lv_spoolid to memory id 'SPOOLID'.
  42.     new-page print off.
  43.  
  44.   endif.
  45.  
  46. endform.                    "start
  47.  
  48. * ---
  49. form conv_2_abap_spool_lists_to_pdf
  50.   using iv_list1 type rspoid
  51.         iv_list2 type rspoid
  52.   changing et_pdf type tline_tab
  53.            ev_pdf_length type i.
  54.   data: lv_spoolid type rspoid.
  55.   submit zz_get_list
  56.     exporting list to memory and return
  57.     with p_list1 eq iv_list1
  58.     with p_list2 eq iv_list2
  59.     with p_submit eq space.
  60.   import spoolid to lv_spoolid from memory id 'SPOOLID'.
  61.   check lv_spoolid is not initial.
  62.   call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
  63.     exporting
  64.       src_spoolid   = lv_spoolid
  65.       no_dialog     = 'X'
  66.     importing
  67.       pdf_bytecount = ev_pdf_length
  68.     tables
  69.       pdf           = et_pdf
  70.     exceptions
  71.       others        = 1.
  72. endform.                    "conv_2_abapspoollists_to_pdf
  73.  
  74.  
  75. * ---
  76. form write_to_current using iv_id type rspoid.
  77.  
  78.   data: lt_list type table_abaplist.
  79.  
  80.   submit rspolist exporting list to memory and return
  81.                   with rqident = iv_id.
  82.  
  83.   call function 'LIST_FROM_MEMORY'
  84.     tables
  85.       listobject = lt_list
  86.     exceptions
  87.       not_found  = 1
  88.       others     = 2.
  89.  
  90.   check sy-subrc eq 0.
  91.  
  92.   call function 'WRITE_LIST'
  93.     tables
  94.       listobject = lt_list
  95.     exceptions
  96.       empty_list = 1
  97.       others     = 2.
  98.  
  99. endform.                    "write_to_current
  100.  
  101. * ---
  102. form download using it_pdf type tline_tab
  103.                     iv_pdf_length type i.
  104.  
  105.   data: lv_filename type string.
  106.  
  107.   call function 'GUI_FILE_SAVE_DIALOG'
  108.     exporting
  109.       window_title      = 'Save pdf'
  110.       default_file_name = 'test.pdf'
  111.     importing
  112.       fullpath          = lv_filename.
  113.  
  114.  
  115.   call function 'GUI_DOWNLOAD'
  116.     exporting
  117.       bin_filesize = iv_pdf_length
  118.       filename     = lv_filename
  119.       filetype     = 'BIN'
  120.     tables
  121.       data_tab     = it_pdf
  122.     exceptions
  123.       others       = 1.
  124.  
  125. endform.                    "download
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement