Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error while converting internal table into PDF

Former Member
0 Kudos

Hi Experts,

According to my requirement, i need to download the contents of the internal table into PDF file.

But when i create a spool of the internal table contents it shows zero pages even when there is content and it gets displayed when i double click on the TYPE column in Spool number.

Due to this when i use the FM 'CONVERT_ABAPSPOOLJOB_2_PDF' and then 'GUI_DOWNLOAD' to convert it into PDF and download on local machine, a PDF file gets generated but it showz error stating 'No Pages found'.

What might be the reason for this error?

1 ACCEPTED SOLUTION

keerthy_k
Active Participant
0 Kudos

Hi,

pls see the code below...it is working..

DATA :textlines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.

DATA it_lines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA options LIKE itcpo.

DATA header LIKE thead.

DATA result LIKE itcpp.

DATA: bin_filesize TYPE i,

fullpath type string.

DATA: filesize TYPE i,

convcount TYPE i,

cancel(1).

textlines-tdformat = '*'.

textlines-tdline = 'Hello Hao'.

APPEND textlines.

options-tdgetotf = 'X'.

options-tdnoprev = 'X'.

CALL FUNCTION 'PRINT_TEXT'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

  • DEVICE = 'PRINTER'

dialog = ' '

header = header

OPTIONS = options

IMPORTING

  • NEW_ARCHIVE_PARAMS =

RESULT = RESULT

tables

lines = textlines

otfdata = otf

  • EXCEPTIONS

  • CANCELED = 1

  • DEVICE = 2

  • FORM = 3

  • OPTIONS = 4

  • UNCLOSED = 5

  • UNKNOWN = 6

  • FORMAT = 7

  • TEXTFORMAT = 8

  • COMMUNICATION = 9

  • BAD_PAGEFORMAT_FOR_PRINT = 10

  • OTHERS = 11

.

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 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = filesize

TABLES

otf = otf

lines = it_lines

EXCEPTIONS

err_conv_not_possible = 1

err_bad_otf = 2.

fullpath = 'C:/foldename/test.pdf'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

filename = fullpath

filetype = 'BIN'

  • APPEND = ' '

  • CODEPAGE = ' '

  • NO_BYTEORDER_MARK = ' '

  • IMPORTING

  • FILELENGTH = c

TABLES

data_tab = it_lines

  • FORMAT_TAB =

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

Keerthi

Edited by: Keerthy K on Mar 10, 2009 7:42 AM

5 REPLIES 5

Former Member
0 Kudos

Hi

Firstly, How are you generating/triggering the spool?

Are you using any write statements to write the content of the internal table to the spool?

Do you see all the contents of the internal table in the spool when you select the spool and click 'Display' in trxn SP01?

Regards

Raj

0 Kudos

yes i am creating a spool, and i can see all the data in SP01, but the no. of pages is zero.

keerthy_k
Active Participant
0 Kudos

Hi,

pls see the code below...it is working..

DATA :textlines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA otf LIKE itcoo OCCURS 1000 WITH HEADER LINE.

DATA it_lines LIKE tline OCCURS 100 WITH HEADER LINE.

DATA options LIKE itcpo.

DATA header LIKE thead.

DATA result LIKE itcpp.

DATA: bin_filesize TYPE i,

fullpath type string.

DATA: filesize TYPE i,

convcount TYPE i,

cancel(1).

textlines-tdformat = '*'.

textlines-tdline = 'Hello Hao'.

APPEND textlines.

options-tdgetotf = 'X'.

options-tdnoprev = 'X'.

CALL FUNCTION 'PRINT_TEXT'

EXPORTING

  • APPLICATION = 'TX'

  • ARCHIVE_INDEX = ' '

  • ARCHIVE_PARAMS = ' '

  • DEVICE = 'PRINTER'

dialog = ' '

header = header

OPTIONS = options

IMPORTING

  • NEW_ARCHIVE_PARAMS =

RESULT = RESULT

tables

lines = textlines

otfdata = otf

  • EXCEPTIONS

  • CANCELED = 1

  • DEVICE = 2

  • FORM = 3

  • OPTIONS = 4

  • UNCLOSED = 5

  • UNKNOWN = 6

  • FORMAT = 7

  • TEXTFORMAT = 8

  • COMMUNICATION = 9

  • BAD_PAGEFORMAT_FOR_PRINT = 10

  • OTHERS = 11

.

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 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = filesize

TABLES

otf = otf

lines = it_lines

EXCEPTIONS

err_conv_not_possible = 1

err_bad_otf = 2.

fullpath = 'C:/foldename/test.pdf'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = bin_filesize

filename = fullpath

filetype = 'BIN'

  • APPEND = ' '

  • CODEPAGE = ' '

  • NO_BYTEORDER_MARK = ' '

  • IMPORTING

  • FILELENGTH = c

TABLES

data_tab = it_lines

  • FORMAT_TAB =

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6.

Keerthi

Edited by: Keerthy K on Mar 10, 2009 7:42 AM

sreeramkumar_madisetty
Active Contributor
0 Kudos

Hi

Check the Printer options how you were using whether Print Immediately/No Print/Print 0 pages etc.

One you got the spool correctly ,then you can use the FM: CONVERT_ABAPSPOOLJOB_2_PDF and do the necessary things.

Regards,

Sreeram Kumar.Madisetty

Former Member
0 Kudos

Hi ,

Go through this link below:

Hope it helps

Regrds

Mansi