Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

pdf problem

Hello Team,

Please copy paste the below code i am trying to generate the PDF for the generated report code is syntactically correct but when i am executing the program it is throwing the error saying "SPOOL Request 0 does not exist"

Please can any help me the changes in my code.

TABLES :

vbak,

vbap,

vbpa,

mara.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.

SELECT-OPTIONS:

s_vkorg FOR vbak-vkorg OBLIGATORY,

s_vtweg FOR vbak-vtweg OBLIGATORY,

s_spart FOR vbak-spart OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.

SELECT-OPTIONS:

s_vbeln FOR vbak-vbeln,

s_matnr FOR mara-matnr.

PARAMETERS:

p_kunnr TYPE vbak-kunnr.

SELECT-OPTIONS:

s_erdat FOR vbak-erdat OBLIGATORY.

SELECTION-SCREEN END OF BLOCK b2.

DATA : w_spono LIKE tsp01-rqident,

w_binsize TYPE i,

w_filelen TYPE i,

t_sale LIKE TABLE OF tline WITH HEADER LINE.

DATA:

BEGIN OF t_sales OCCURS 0,

vbeln TYPE vbak-vbeln,

vkorg TYPE vbak-vkorg,

vtweg TYPE vbak-vtweg,

spart TYPE vbak-spart,

erdat TYPE vbak-erdat,

kunnr TYPE vbak-kunnr,

posnr TYPE vbap-posnr,

matnr TYPE vbap-matnr,

arktx TYPE vbap-arktx,

parvw TYPE vbpa-parvw,

kwmeng TYPE vbap-kwmeng,

kunnr1 TYPE vbpa-kunnr ,

END OF t_sales.

START-OF-SELECTION.

SELECT vbak~vbeln

vkorg

vtweg

vbak~spart

vbak~erdat

vbak~kunnr

vbap~posnr

matnr

arktx

parvw

kwmeng

vbpa~kunnr

INTO CORRESPONDING FIELDS OF TABLE t_sales

FROM ( ( vbak JOIN vbap ON vbap~vbeln EQ vbak~vbeln )

JOIN vbpa ON vbpa~vbeln EQ vbak~vbeln

    • and vbpaposnr eq vbapposnr

AND vbpa~parvw EQ 'WE' )

WHERE vkorg IN s_vkorg

AND vtweg IN s_vtweg

AND vbak~spart IN s_spart

AND vbak~vbeln IN s_vbeln

AND matnr IN s_matnr

AND vbak~kunnr EQ p_kunnr

AND vbak~erdat IN s_erdat.

IF sy-subrc EQ 0.

  • NEW-PAGE PRINT ON.

PERFORM display_sales_data.

NEW-PAGE PRINT OFF.

ELSE.

MESSAGE 'No records found with the spcified criteria' TYPE 'E'.

ENDIF.

w_spono = sy-spono.

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = w_spono

  • NO_DIALOG =

  • DST_DEVICE =

  • PDF_DESTINATION =

IMPORTING

pdf_bytecount = w_binsize

  • PDF_SPOOLID =

  • LIST_PAGECOUNT =

  • BTC_JOBNAME =

  • BTC_JOBCOUNT =

TABLES

pdf = t_sale

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

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

OTHERS = 12

.

  • 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 FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = w_binsize

filename = 'C:\Documents and Settings\Desktop\SO.pdf'

filetype = 'BIN'

  • APPEND = ' '

  • WRITE_FIELD_SEPARATOR = 'X'

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • CONFIRM_OVERWRITE = ' '

  • NO_AUTH_CHECK = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • WRITE_BOM = ' '

  • IMPORTING

  • FILELENGTH = w_filelen

TABLES

data_tab = t_sale

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

OTHERS = 22

.

  • IF sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

  • ENDIF.

*&----


*

*& Form display_sales_data

*&----


*

  • This subroutine is used to display the sales report

*

*----


*

  • No interface parameters

*----


*

FORM display_sales_data .

LOOP AT t_sales.

AT NEW spart.

SKIP 3.

WRITE :/ 'Sales Organization : ', t_sales-vkorg,

/ 'Distribution Channel : ', t_sales-vtweg,

/ 'Division : ', t_sales-spart.

SKIP.

WRITE:/ 'Sales Order'(001),

15 'Order Date'(002),

30 'Sold-to-party'(003),

50 'Ship-to-party'(004),

65 'Item'(005),

75 'Material'(006),

90 'Quantity'(007).

SKIP.

ENDAT.

IF t_sales-kunnr1 IS INITIAL.

t_sales-kunnr1 = p_kunnr.

ENDIF.

WRITE :/ t_sales-vbeln UNDER text-001,

t_sales-erdat UNDER text-002,

t_sales-kunnr UNDER text-003,

t_sales-kunnr1 UNDER text-004,

t_sales-posnr UNDER text-005,

t_sales-matnr UNDER text-006,

t_sales-kwmeng UNDER text-007.

ENDLOOP.

ENDFORM.

Tags:

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question