Application Development and Automation 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: 
Read only

Smartform, PDF Error, Unrecognized Token

Former Member
0 Likes
1,441

Dear Group,

I have used smarform to send the output of Purchase Order in PDF format to vendor's external mail id. The program is working fine and sending mail to vendor's mail id. But the problem is when I am trying to open the PDF file, I am getting the error. The error says ''An unrecognized token 'xxx.xx' was found", where xxx.xx is some number.

I have searched the forum, got some link to resolve that but didnt get the success. To send the mail, I have used the program which is generally used to send the mail. Like me some more users are looking for the solution for this error.

My SAP system is SAP IS Retail, ECC 6.0.

awaitng for your reply.

with regards,

Siddharth Patel

I came across your test pdf program on sdn. I am trying to create a smartform and attach it to an email. I copied and ran your program but when I tried to open the attachment from the email I got the error "an unrecognized token 'BT28.35' was found." in Adobe. Any suggestions?

Thanks,

Scott

8 REPLIES 8
Read only

Former Member
0 Likes
1,268

Refer the following link for more details:

http://www.sapdevelopment.co.uk/reporting/rep_spooltopdf.htm

Read only

Former Member
0 Likes
1,268

Hi Siddharth,

See the sample code for converting to PDF and sending mail

----


  • INCLUDE ZINCUSMAIL *

----


include <symbol>.

data : i_doc_data like sodocchgi1.

data : begin of i_pack_list occurs 0.

include structure sopcklsti1.

data : end of i_pack_list.

data : begin of i_receivers occurs 0.

include structure somlreci1.

data : end of i_receivers.

data : begin of i_contents occurs 0.

include structure solisti1.

data : end of i_contents.

data : begin of i_header occurs 0.

include structure solisti1.

data : end of i_header.

data : begin of i_att occurs 0.

include structure solisti1.

data : end of i_att.

  • Internal Table for Internet address.

data: begin of it_inad occurs 0,

kunnr like kna1-kunnr, " Customer Code

name1 like kna1-name1, " Customer Name

ssobl like knkk-ssobl, " Security Deposit

klimk like knkk-klimk, " Credit Limit

opbal like bsid-wrbtr, " Opening Balance

clbal like bsid-wrbtr, " Closing Balance

smtp like adr6-smtp_addr, " Internet mail (SMTP) address

end of it_inad.

data : pdf_line(134),

asdf like pdf_line occurs 0 with header line.

data : pdf_table like tline occurs 0 with header line,

pdf_fsize type i.

data : stuff(65000),

len type i,

pos type i,

tab_lines like sy-tabix.

data: spoolid type tsp01-rqident,

spdel type tsp01sys.

data: v_gjahrt like bsid-gjahr,

fmondest(10),

tmondest(10),

kunnr1 like kna1-kunnr,

gjah(4),

fmon(10).

&----


*& Form hide_write

&----


form hide_write.

new-page print on

line-size 160

  • line-count 58

no-title

no-heading

destination 'LOCL'

immediately ' '

new list identification 'X'

no dialog.

set blank lines on.

endform. " hide_write

&----


*& Form end_write

&----


form end_write using kunnr1.

set blank lines off.

new-page print off.

***Using Spoolid we are getting PDF formated file

spoolid = spdel-rqident = sy-spono.

spdel-sys = sy-sysid.

call function 'CONVERT_ABAPSPOOLJOB_2_PDF'

exporting

src_spoolid = spoolid

no_dialog = 'X'

importing

pdf_bytecount = pdf_fsize

tables

pdf = pdf_table

exceptions

others = 0.

***Delleting Spool request

call function 'RSPO_IDELETE_SPOOLREQ'

exporting

spoolreq = spdel

exceptions

others = 2.

***Converting PDF table line size 134 into standard list size 255

loop at pdf_table into pdf_line.

if pos = 34170.

perform attach.

endif.

stuff+pos(134) = pdf_line.

add 134 to pos.

endloop.

if not ( stuff is initial ).

perform attach.

endif.

clear pdf_line.

clear pdf_table[].

describe table i_att lines tab_lines.

i_pack_list-transf_bin = 'X'.

i_pack_list-head_start = '1'.

i_pack_list-head_num = '1'.

i_pack_list-body_start = '1'.

i_pack_list-body_num = tab_lines.

i_pack_list-doc_type = 'PDF'.

i_pack_list-obj_name = 'LedgerMail'.

concatenate fmon '-' gjah into i_pack_list-obj_descr.

*i_pack_list-obj_descr = '2092-Oct03'.

i_pack_list-obj_langu = 'E'.

i_pack_list-doc_size = tab_lines * 255.

append i_pack_list.

***Data for receivers list

loop at it_inad where kunnr eq kunnr1.

i_receivers-receiver = it_inad-smtp.

i_receivers-rec_type = 'U'.

i_receivers-rec_date = sy-datum.

i_receivers-express = 'X'.

i_receivers-com_type = 'INT'.

i_receivers-notif_del = 'X'.

append i_receivers.

endloop.

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = i_doc_data

  • PUT_IN_OUTBOX = ' '

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

packing_list = i_pack_list

object_header = i_header

contents_bin = i_att

contents_txt = i_contents

receivers = i_receivers

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8

.

refresh i_att. clear i_att.

refresh i_receivers. clear i_receivers.

delete i_pack_list where doc_type = 'PDF'.

*refresh i_header.

*refresh i_contents.

*clear i_doc_data.

endform. " end_write

&----


*& Form doc_data

&----


form doc_data using fmondest v_gjahrt.

gjah = v_gjahrt.

fmon = fmondest.

***Data for Document Data

i_doc_data-obj_name = 'LedgerMail'.

concatenate 'Customer Ledger for : ' fmondest gjah

into i_doc_data-obj_descr separated by space.

i_doc_data-obj_langu = 'E'.

i_doc_data-obj_prio = '1'.

i_doc_data-no_change = 'X'.

i_doc_data-doc_size = '5101'.

***Data for Packing list

i_pack_list-head_start = '1'.

i_pack_list-head_num = '1'.

i_pack_list-body_start = '1'.

i_pack_list-body_num = '20'.

i_pack_list-doc_type = 'RAW'.

i_pack_list-obj_langu = 'E'.

append i_pack_list.

***Data for Header

i_header-line = 'Header'. append i_header.

***Data for contents

i_contents-line = 'Dear Customer,'. append i_contents.

i_contents-line = ' '. append i_contents.

concatenate 'Please find your enclosed Ledger for the month of : '

fmondest gjah into i_contents-line separated by space.

append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = 'This is a computer generated document and does not

require a signature.'. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = 'Note : If you do not have Acrobat Reader please click

on the below link.'. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = 'http://www.adobe.com/products/acrobat/readstep2.html'

. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

i_contents-line = ' '. append i_contents.

endform. " doc_data

&----


*& Form attach

&----


form attach.

clear pos.

len = strlen( stuff ).

while len > 0.

subtract 255 from len.

i_att = stuff+pos(255).

append i_att.

add 255 to pos.

endwhile.

clear pos.

clear stuff.

endform. " attach

Reward points if helpful.

Regards,

Harini.S

Read only

Former Member
0 Likes
1,268

hi

i had the same problem, i used this fm SX_OBJECT_CONVERT_OTF_PDF for convert OTF to PDF and then send by email.

Look this:

regards

Gregory

Read only

0 Likes
1,268

Dear Gregory Gotera,

Thanks for your reply.

Can you let me know, how to use this FM - SX_OBJECT_CONVERT_OTF_PDF.

I will be very much thankful to you, if you can forward your program to me.

my mail id is sidpatel_mca@yahoo.com

with regards,

Siddharth Patel

Read only

Former Member
0 Likes
1,268

Hi Sidhharth,

Have you find the solution for error "token not found"?

If yes then just tell me..

hope for reply

thnaks

jigar patel

Read only

0 Likes
1,268

Hi Jigar,

I solved the problem using following code.

DATA: bin_filesize TYPE i,

ist_lines TYPE TABLE OF tline,

wa_buffer TYPE string,

wa_lines TYPE tline,

wa_record TYPE solisti1,

ist_packing TYPE TABLE OF sopcklsti1,

ist_contents_txt TYPE TABLE OF solisti1,

ist_contents_bin TYPE TABLE OF solisti1,

ist_record TYPE TABLE OF solisti1,

ist_receivers TYPE TABLE OF somlreci1,

wa_contents_txt TYPE solisti1,

wa_receivers TYPE somlreci1,

count TYPE i,

wa_document TYPE sodocchgi1,

wa_packing TYPE sopcklsti1,

tab_lines TYPE sy-index,

name1 TYPE lfa1-name1.

*---new

DATA: i_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

i_tline TYPE TABLE OF tline WITH HEADER LINE,

i_receivers TYPE TABLE OF somlreci1 WITH HEADER LINE,

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE,

  • Objects to send mail.

i_objpack LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,

i_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_objbin LIKE solisti1 OCCURS 0 WITH HEADER LINE,

i_reclist LIKE somlreci1 OCCURS 0 WITH HEADER LINE,

  • Work Area declarations

wa_objhead TYPE soli_tab,

w_ctrlop TYPE ssfctrlop,

w_compop TYPE ssfcompop,

w_return TYPE ssfcrescl,

wa_doc_chng TYPE sodocchgi1,

w_data TYPE sodocchgi1,

  • WA_BUFFER TYPE STRING,"To convert from 132 to 255

  • Variables declarations

v_form_name TYPE rs38l_fnam,

v_len_in LIKE sood-objlen,

v_len_out LIKE sood-objlen,

v_len_outn TYPE i,

v_lines_txt TYPE i,

v_lines_bin TYPE i.

DATA : l_text TYPE c LENGTH 60.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = v_len_in

TABLES

otf = p_itcoo

lines = i_tline

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

OTHERS = 4.

IF sy-subrc <> 0.

MESSAGE 'error' TYPE 'I'.

ENDIF.

DATA : pos TYPE i.

DATA : len TYPE i.

LOOP AT i_tline.

pos = 255 - len.

IF pos > 134. "length of pdf_table

pos = 134.

ENDIF.

i_record+len = i_tline(pos).

len = len + pos.

IF len = 255. "length of out (contents_bin)

APPEND i_record.

CLEAR: i_record, len.

IF pos < 134.

i_record = i_tline+pos.

len = 134 - pos.

ENDIF.

ENDIF.

ENDLOOP.

IF len > 0.

APPEND i_record.

ENDIF.

i_objbin[] = i_record[].

*----


              • Create Message Body

*----


        • Title and Description

  • l_text = 'PO obj txt'.

i_objtxt = l_text.

APPEND i_objtxt.

DESCRIBE TABLE i_objtxt LINES v_lines_txt.

READ TABLE i_objtxt INDEX v_lines_txt.

wa_doc_chng-obj_name = 'smartform'.

wa_doc_chng-expiry_dat = sy-datum + 10.

  • wa_doc_chng-obj_descr = l_text.

SELECT SINGLE name1 INTO name1

FROM lfa1

WHERE lifnr = p_ekko-lifnr.

CONCATENATE p_ekko-ebeln ' - ' name1 INTO wa_doc_chng-obj_descr.

wa_doc_chng-sensitivty = 'F'.

  • wa_doc_chng-doc_size = v_lines_txt * 255.

wa_doc_chng-doc_size = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).

CLEAR i_objpack-transf_bin.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

i_objpack-body_num = v_lines_txt.

i_objpack-doc_type = ( v_lines_txt - 1 ) * 255 + STRLEN( i_objtxt ).

i_objpack-doc_type = 'RAW'.

APPEND i_objpack.

        • Attachment

  • (pdf-Attachment)

i_objpack-transf_bin = 'X'.

i_objpack-head_start = 1.

i_objpack-head_num = 0.

i_objpack-body_start = 1.

DESCRIBE TABLE i_objbin LINES v_lines_bin.

READ TABLE i_objbin INDEX v_lines_bin.

  • i_objpack-doc_size = v_lines_bin * 255 .

i_objpack-doc_size = ( v_lines_bin - 1 ) * 255 + STRLEN( i_objbin ).

i_objpack-body_num = v_lines_bin.

i_objpack-doc_type = 'PDF'.

i_objpack-obj_name = 'ATTACHMENT'.

i_objpack-obj_descr = p_ekko-ebeln.

APPEND i_objpack.

CLEAR i_reclist[].

i_reclist-receiver = 'test@test.com'.

i_reclist-rec_type = 'U'.

i_reclist-express = 'X'.

APPEND i_reclist.

CLEAR i_reclist.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

put_in_outbox = 'X'

  • COMMIT_WORK = 'X'

TABLES

packing_list = i_objpack

object_header = wa_objhead

contents_bin = i_objbin

contents_txt = i_objtxt

receivers = i_reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

with regards,

Siddharth Patel

Read only

Former Member
0 Likes
1,268

solved by myself

Read only

0 Likes
1,268

Hi Sidhharth,

Thanks a lot.

You solved my problem.

Thanks and Regards,

Jigar