Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Adobe form : How to combine multiple spool output into a single pdf document?

Former Member
0 Kudos

Hi Everyone,

My Requirement is to combine the spool data (which is a adobe form for different customers) into a single pdf document.

I am able to create single spool output into a single pdf but not the multiple output into the single pdf.

Has anyone worked on the similar requirement before ?

Appreciate your inputs !!!!

Thanks.

1 REPLY 1

Former Member
0 Kudos

Hello Aashi ,

I have created such a program where i get several spool numbers that are OTF and combine them into a single PDF.

The code below works .

*********************************************************************************

REPORT  z_combine_spool_requests.

TYPES: BEGIN OF blob,
         line(80) TYPE x,
         END OF blob.

*** PDF conversion Declaration .
DATA: pdf_size      TYPE so_obj_len,
        pdf_content   TYPE solix_tab,
        pdf_xstring   TYPE xstring,
        v_xstring     TYPE xstring,
        v_text        TYPE localfile,
        rq            TYPE tsp01,
        bin_size      TYPE i,
        temp_bin_size TYPE i,
        dummy         TYPE TABLE OF rspoattr,
        cancel,
        doctab LIKE docs OCCURS 1 WITH HEADER LINE,
        numbytes TYPE i,
        arc_idx LIKE toa_dara,
        pdfspoolid LIKE tsp01-rqident,
        jobname LIKE tbtcjob-jobname,
        jobcount LIKE tbtcjob-jobcount,
        is_otf,
        client LIKE tst01-dclient,
        name LIKE tst01-dname,
        objtype LIKE rststype-type,
        type LIKE rststype-type,
        get_size_from_format,
        bindata TYPE TABLE OF blob WITH HEADER LINE,
        temp_bindata TYPE TABLE OF blob WITH HEADER LINE,
        result TYPE TABLE OF text WITH HEADER LINE,
        filesize TYPE i,
        convcount TYPE i,
        textlines LIKE tline OCCURS 100 WITH HEADER LINE,
        tab1 TYPE TABLE OF soli,
        tab  TYPE TABLE OF soli WITH HEADER LINE,
        doc  LIKE TABLE OF docs,
        pdf  LIKE TABLE OF tline,
        file TYPE string ,
        otf  TYPE TABLE OF itcoo WITH HEADER LINE,
        eof TYPE soli ,
        lines TYPE i .


***Selection Screen
DATA :   spoolno TYPE tsp01-rqident,
           temp_spool TYPE tsp01-rqident.

SELECT-OPTIONS : range FOR spoolno NO INTERVALS.



LOOP AT range.

    temp_spool = range-low.

    CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
      EXPORTING
        rqident                    = temp_spool
*       FIRST_LINE                 = 1
*       LAST_LINE                  =
*       DESIRED_TYPE               =
*     IMPORTING
*       REAL_TYPE                  =
*       SP_LANG                    =
      TABLES
        buffer                     = tab1
*       BUFFER_PDF                 =
     EXCEPTIONS
       no_such_job                = 1
       job_contains_no_data       = 2
       selection_empty            = 3
       no_permission              = 4
       can_not_access             = 5
       read_error                 = 6
       type_no_match              = 7
       OTHERS                     = 8
              .
    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    DESCRIBE TABLE tab1 LINES lines.
    READ TABLE tab1 INDEX lines INTO eof.
    DELETE tab1 INDEX lines.

    APPEND LINES OF tab1 TO tab.


    LOOP AT tab.
      CLEAR otf.
      otf = tab.
      APPEND otf.
    ENDLOOP.

*append lines of tab1 to bindata.
    REFRESH tab1.
    REFRESH tab.

ENDLOOP.
APPEND eof TO otf.




CALL FUNCTION 'CONVERT_OTF_2_PDF'
   EXPORTING
     use_otf_mc_cmd               = 'X'
*   ARCHIVE_INDEX                =
   IMPORTING
     bin_filesize                 = bin_size
    TABLES
      otf                          = otf
      doctab_archive               = doc
      lines                        = pdf
* EXCEPTIONS
*   ERR_CONV_NOT_POSSIBLE        = 1
*   ERR_OTF_MC_NOENDMARKER       = 2
*   OTHERS                       = 3
            .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*
*



CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      filename                = 'C:\sample.pdf'   " Please put the full path where the file has to be created.
      filetype                = 'BIN'
    CHANGING
      data_tab                = pdf
    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
      not_supported_by_gui    = 22
      error_no_gui            = 23
      OTHERS                  = 24.
IF sy-subrc <> 0.
    WRITE sy-subrc.
ENDIF.


**********************************************************************************