ATTENTION: The project is still under development and subject to change.
Translations:
Submitting a report to the spool and receiving PDF.
SAP Spool PDF
is a few classes to help you submit a report to spool and get PDF file easily.
It is often necessary to get a PDF in xstring or binary format. To do this, you can send a report to the sap-spool (in the background), and then read PDF by the spool ID. This way of getting the file is more preferable, because there is no need to do the enhancement in standard code.
The cl_bp_abap_job class exists in ABAP to run reports in the background. But this class only supports passing report parameters via variant (let me know if I'm wrong). This is not always convenient, since a variant must either be created before the report is run, or it must be created at runtime.
SAP Spool PDF
allows you to run any report generating PDF in the background. Report parameters can be passed directly and/or via a variant.
The laconic API allows you to literally get a file in the form of xstring in one line, save, show, or send it.
Installation is done with abapGit.
Example
TYPES ty_pernr TYPE n LENGTH 8.
DATA lt_pernr TYPE RANGE OF ty_pernr.
" This is an example of generating a 2-NDFL certificate (HCM module).
" All PDF documents will be merged into one.
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 = '[email protected]'
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.
This instruction will help you.
If you have questions or general suggestions, don't hesitate to submit a new (GitHub issue).
Project logo designed by pixel-buddha