SAP Spool PDF
An ABAP class that submits a report to the spool, typically in the background, and converts the resulting spool request into a PDF it can return as an xstring, save, show or email.
A report's output is often needed as a PDF in xstring or binary format. SAP Spool PDF submits any report to the SAP spool, typically in the background, and converts the resulting spool request into a PDF using its spool ID, which the README presents as a clean and non-intrusive way that avoids modifying standard SAP code. Unlike SAP's own cl_bp_abap_job, which only accepts parameters through a variant, it can pass them directly, via a variant, or both. The merged PDF comes back as an xstring from one chained call, and the same object saves it locally, shows it or sends it as an email attachment.
Facts
Where it sits
Who is behind it
In the atlas: maintains 2, contributes to 4@victorizbitskiymaintainer
What it declares
Every artifact
- Type
- Package
- Origin
- Independently maintained
As a package
- Where it runs
- Inside its host
- Distributed through
- abapGit
Connections
Producing printed forms, PDFs and filled templates for people
Download
README
quoted from victorizbitskiy/zspool_pdf under MIT, readTranslations:
SAP Spool PDF
Submitting a report to the spool and receiving PDF.
Don't forget to click ⭐ if you like it!
Table of contents
- What is it?
- What is this for?
- Why not just use cl_bp_abap_job?
- Installation
- Using
- Diagrams
- How to contribute
- Got questions
- 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
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
Others providing
Compare all 11 on the Document output page →- abap2xlsxabap2xlsxA library that reads and generates .xlsx Excel workbooks directly from ABAP data, without exporting through a list viewer, installed through abapGit and tested from SAP_ABA 731.independent, abapLibrary that reads and generates Excel spreadsheets from ABAPfrom ABAP
- zcl_docxzcl_docxAn ABAP class that fills a Word .docx template tagged with content controls, with a report, ZDOCX_GET_TYPES, that generates the ABAP types the template needs; the document opens in Word or returns as an xstring.independent, abapABAP class filling a tagged Word .docx template with datafrom ABAP
- zcl_pdfzcl_pdfA standalone ABAP class that draws simple PDFs without Adobe Document Server: text in built-in fonts, text fitted into a box and rectangles, returned as a raw string to store, send or display.independent, abapStandalone ABAP class drawing PDFs without Adobe Document Serverfrom ABAP
- XTTXTTAn ABAP template engine that merges data, including nested structures, tables and trees, into Excel, Word, HTML and PDF templates prepared in ordinary editors with markers in curly brackets.independent, abapABAP template engine for Excel, Word, HTML and PDFfrom ABAP
- SAP Forms Service by AdobeSAP Forms Service by AdobeAdobe Document Services on BTP: renders print and interactive PDF forms from stored templates, called over a REST API from a cloud application or connected to an ABAP system.sap official, btpAdobe Document Services on BTP for print and interactive PDFsfrom BTP/BAIP
- SAP Print serviceSAP Print servicePrint queues between cloud applications and a customer's local printers: an application queries queues and creates print queue items through public APIs, and the queues are managed in the service.sap official, btpPrint queues between cloud applications and local printersfrom BTP/BAIP
- @cap-js/print@cap-js/printA CDS plugin that prints a document held in a CAP entity, through SAP Print service and a @PDF.Printable annotation.sap official, capPrints documents held in CAP entities through SAP Print servicefrom CAP
- HandlebarsABAPHandlebarsABAPA single-file Handlebars templating implementation for ABAP 7.40 SP02 and up that fills a template from an ABAP structure or table, with block helpers, partials and custom helpers.independent, abapSingle-file Handlebars templating for ABAP 7.40 SP02 and upfrom ABAP
- open-abap-pdfopen-abap-pdfA standalone PDF generator written in ABAP that builds a multi-page document from text, lines, rectangles and circles placed at given coordinates and returns it as a string or an xstring.community org, abapStandalone PDF generator written in ABAPfrom ABAP
- @salvatorela/cap-plugin-adobe-forms@salvatorela/cap-plugin-adobe-formsA CAP plugin that wraps the SAP Forms service by Adobe on BTP as a CAP service, rendering a PDF from a form template with credentials from a destination or direct configuration.independent, capCAP plugin wrapping the SAP Forms service by Adobe on BTPfrom CAP
Details
Sources
Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.
Compatibility and provenance
abaplint
History in the atlas
- First seen.
For your agent
- Ref
artifact:victorizbitskiy-zspool-pdf- JSON
- /artifacts/victorizbitskiy-zspool-pdf.json
- MCP
- Connecting an agent