# CONVERT_ABAPSPOOLJOB_2_PDF — Convert ABAP Spool Request to PDF

> Converts an ABAP list spool request to PDF and returns the result as a TLINE table or as binary data (BIN_FILE). It is used to e-mail the report output of background jobs as PDF attachments or to archive it. It only handles ABAP list spools (use CONVERT_OTFSPOOLJOB_2_PDF for SmartForms/SAPscript output); for large spools the conversion may be moved to a background job, which NO_BACKGROUND prevents.

- Modules: BASIS
- Type: Function module
- Function group: STXW
- Remote-enabled (RFC): No
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/convert-abapspooljob-2-pdf/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| SRC_SPOOLID | TSP01-RQIDENT | Source spool request number | Yes |
| NO_DIALOG | C | No dialog | - |
| DST_DEVICE | TSP03-PADEST | Target output device | - |
| PDF_DESTINATION | C | PDF destination | - |
| NO_BACKGROUND | C | Do not move to background job | - |
| GET_SIZE_FROM_FORMAT | C | Get size from format | - |
| USE_CASCADING | C | Use cascading fonts | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| PDF_BYTECOUNT | I | PDF byte count |
| PDF_SPOOLID | TSP01-RQIDENT | PDF spool request number |
| LIST_PAGECOUNT | I | Page count |
| BTC_JOBNAME | TBTCJOB-JOBNAME | Background job name |
| BTC_JOBCOUNT | TBTCJOB-JOBCOUNT | Background job count |
| BIN_FILE | XSTRING | PDF binary data |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| PDF | TLINE | PDF lines | - |

## Exceptions

- ERR_NO_ABAP_SPOOLJOB: Not an ABAP spool request
- ERR_NO_SPOOLJOB: No spool request
- ERR_NO_PERMISSION: No permission
- ERR_CONV_NOT_POSSIBLE: Conversion not possible
- ERR_BAD_DESTDEVICE: Invalid target device
- USER_CANCELLED: Cancelled by user
- ERR_SPOOLERROR: Spool error
- ERR_TEMSEERROR: TemSe error
- ERR_BTCJOB_OPEN_FAILED: Background job open failed
- ERR_BTCJOB_SUBMIT_FAILED: Background job submit failed
- ERR_BTCJOB_CLOSE_FAILED: Background job close failed

## Call template (ABAP)

```abap
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
  EXPORTING
    src_spoolid = lv_src_spoolid
  IMPORTING
    pdf_bytecount = lv_pdf_bytecount
    pdf_spoolid = lv_pdf_spoolid
    list_pagecount = lv_list_pagecount
    btc_jobname = lv_btc_jobname
    btc_jobcount = lv_btc_jobcount
    bin_file = lv_bin_file
  TABLES
    pdf = lt_pdf
  EXCEPTIONS
    err_no_abap_spooljob = 1
    err_no_spooljob = 2
    err_no_permission = 3
    err_conv_not_possible = 4
    err_bad_destdevice = 5
    user_cancelled = 6
    err_spoolerror = 7
    err_temseerror = 8
    OTHERS = 9.
```

## Related tables

TSP01

