Skip to content

victorizbitskiy/zspool_pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

147 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT ABAP 7.40sp08+ Code Statistics

Translations:

SAP Spool PDF

Submitting a report to the spool and receiving PDF.


Don't forget to click ⭐ if you like it!


Table of contents

  1. What is it?
  2. What is this for?
  3. Why not just use cl_bp_abap_job?
  4. Installation
  5. Using
  6. Diagrams
  7. How to contribute
  8. Got questions
  9. Logo

What is it?

SAP Spool PDF is a lightweight ABAP utility that simplifies generating PDFs from SAP reports. It provides a clean, object-oriented interface to submit a report to the spool and retrieve the output as a PDF file without dealing with low-level conversion logic.

What is this for?

Often, you need a report’s output as a PDF in xstring or binary format. One clean and non-intrusive way to achieve this is by submitting the report to the SAP spool (typically in the background) and then converting the spool request into a PDF using its spool ID. This approach avoids modifying standard SAP code—making it safer, upgrade-friendly, and easier to maintain.

Why not just use cl_bp_abap_job?

SAP’s standard class cl_bp_abap_job can run reports in the background—but it only supports passing parameters via a variant. (Let me know if that’s changed!) While variants work, they’re not always convenient: you either have to predefine one or create it dynamically at runtime, which adds complexity and overhead.

SAP Spool PDF gives you more flexibility. It lets you run any report in the background and generate a PDF from its output passing parameters directly, via a variant, or even both.

Thanks to its minimal and intuitive API, you can get the resulting PDF as an xstring in a single line ready to save, display, email, or process further.

Installation

Install the package using abapGit. Just clone the repository into your SAP system, and you’re ready to go!

Using

Example
   TYPES ty_pernr TYPE n LENGTH 8.
    DATA lt_pernr TYPE RANGE OF ty_pernr.

   " This example demonstrates how to generate 2-NDFL certificates (HCM module).
   " All individual PDF documents are automatically merged into a single file.

    DATA(lv_year) = '2021'.
    lt_pernr = VALUE #( sign = 'I' option = 'EQ' ( low = 00000001 ) ).
    DATA(lv_filename) = `C:\TEMP\spdf_merged_test.pdf`.

    TRY.
        DATA(lo_report) = NEW zcl_spdf_report( iv_name    = 'HRULNDFL'
                                               iv_variant = 'T1' ).

        lo_report->add_param( iv_name = 'PNPPERNR'
                              ia_data = lt_pernr ).

        lo_report->add_param( iv_name = 'P_YEAR'
                              ia_data = lv_year ).

        " Cases:
        " 1) Getting xstring
        DATA(lv_pdf) = lo_report->submit_to_sap_spool( )->get_merged_pdf( )->to_xstring( ).
        
        " 2) Save and show PDF
        lo_report->get_merged_pdf( )->save_local( lv_filename )->show( ).
   
        " 3) Send email
        lo_report->get_merged_pdf( )->send( iv_email    = 'test@test.com'
                                            iv_filename = lv_filename
                                            iv_subject  = 'This is an email with a PDF attachment' ).
      CATCH zcx_spdf_exception
            cx_rspo_spoolid_to_pdf INTO DATA(lx_e).
        WRITE lx_e->get_text( ).
    ENDTRY.

Diagrams

UML Class Diagram

UML Class Diagram

How to contribute

will help you. Contributions are welcome! Please follow the official contribution guide from abapGit to get started.

Got questions?

If you have any questions, feature ideas, or just want to share feedback - feel free to open a new (GitHub issue).

Logo

Project logo designed by pixel-buddha

About

Submitting a report to the spool and receiving PDF

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages