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

PDF Conversion problem

Former Member
0 Likes
711

Hi ABAPers

While sending smartform as a mail attachment(PDF Format) i am facing problem.

While opening the PDF attachment in SOST (T-code), It shows a error pop up.(I.e., Conversion Problem in PDF). Some pages are getting opened as a blank page and some are not getting opened.

What may be the prolem.

Please help Me out ............

But it works properly in IDES version.

In IDES i have ADOBE 5.0 Version, In Live server it is ADOBE 6.0 ,7.0.

1 ACCEPTED SOLUTION
Read only

UmaArjunan
Active Participant
0 Likes
666

Please check your code while you are converting the data to the pdf format .

Did you check the email where the PDF is sent ?

Also please send you sample code used for converting from smartform to pdf inorder to analyse better

4 REPLIES 4
Read only

Former Member
0 Likes
666

Hi,

Refer to the following link.

Regards

Rajesh Kumar

Read only

UmaArjunan
Active Participant
0 Likes
667

Please check your code while you are converting the data to the pdf format .

Did you check the email where the PDF is sent ?

Also please send you sample code used for converting from smartform to pdf inorder to analyse better

Read only

0 Likes
666

Hi,

Thanks for your feedback

There is no problem in the coding , is there any thing we have to do in configuration level regarding PDF ?????

&----


*& Report ZVNPAML

&----


REPORT zvnpaml.

TABLES: somlrec90.

DATA: it_zvnpa TYPE TABLE OF zvnpa,

it_zvnpa1 TYPE TABLE OF zvnpa,

wa_zvnpa TYPE zvnpa,

it_head TYPE TABLE OF zvnpa,

it_head1 TYPE TABLE OF zvnpa,

wa_head TYPE zvnpa,

wa_head1 TYPE zvnpa,

fmname TYPE rs38l_fnam,

tot TYPE zvnpa-wrshb,

otfout TYPE ssfcrescl,

  • outopt type SSFCRESOP,

pdftab TYPE TABLE OF tline WITH HEADER LINE,

datab TYPE TABLE OF itcoo WITH HEADER LINE,

conpar TYPE ssfctrlop,

mailrec TYPE swotobjid,

outopt TYPE ssfcompop,

jobopt TYPE ssfcresop,

jobout TYPE ssfcrescl,

w_return TYPE ssfcrescl,

it_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,

binsz LIKE sood-objlen,

i_tline TYPE TABLE OF tline WITH HEADER LINE,

wa_buffer TYPE string,"To convert from 132 to 255

i_record LIKE solisti1 OCCURS 0 WITH HEADER LINE.

DATA: wa_doc_data TYPE sodocchgi1,

it_pack TYPE TABLE OF sopcklsti1,

wa_pack TYPE sopcklsti1,

it_mailhead TYPE TABLE OF solisti1, " OCCURS 1 WITH HEADER LINE,

wa_mailhead TYPE solisti1,

it_mailbody TYPE TABLE OF solisti1, " OCCURS 0 WITH HEADER LINE,

wa_mailbody TYPE solisti1,

it_receiverid TYPE TABLE OF somlrec90, " OCCURS 10 WITH HEADER LINE.

wa_receiverid TYPE somlrec90,

it_attach LIKE solisti1 OCCURS 0 WITH HEADER LINE,

  • wa_attach TYPE solisti1,

lncnt TYPE i.

DATA: lv_spool TYPE tsp01-rqident,

wa_line TYPE tsp01-rqident,

it_pdf_output TYPE TABLE OF tline.

SELECTION-SCREEN BEGIN OF BLOCK vendor WITH FRAME TITLE text-w03.

*PARAMETERS: pa_lifnr TYPE lfa1-lifnr,

  • pa_bukrs TYPE zvnpa-bukrs,

PARAMETERS: pa_augdt TYPE zvnpa-augdt.

SELECT-OPTIONS: pa_mail FOR somlrec90-receiver NO INTERVALS.

SELECTION-SCREEN END OF BLOCK vendor.

SELECT * FROM zvnpa INTO CORRESPONDING FIELDS OF TABLE it_zvnpa1

WHERE augdt = pa_augdt

AND bukrs = '2000'

AND flag <> 'X'.

  • konto = pa_lifnr AND

  • bukrs = pa_bukrs AND

IF it_zvnpa1 IS NOT INITIAL.

SORT it_zvnpa1 BY konto.

LOOP AT it_zvnpa1 INTO wa_zvnpa.

APPEND wa_zvnpa TO it_zvnpa.

CLEAR: wa_zvnpa.

AT END OF konto.

SORT it_zvnpa BY ttref augbl wrshb shkzg.

*it_head[] = it_zvnpa[].

LOOP AT it_zvnpa INTO wa_zvnpa WHERE shkzg = 'S'.

APPEND wa_zvnpa TO it_head1.

CLEAR: wa_zvnpa.

ENDLOOP.

*delete adjacent duplicates from it_head comparing ttref.

SORT it_head1 BY ttref augbl wrshb shkzg.

LOOP AT it_head1 INTO wa_head1.

tot = tot + wa_head1-wrshb.

wa_head = wa_head1.

AT END OF ttref.

wa_head-wrshb = tot.

APPEND wa_head TO it_head.

CLEAR: wa_head,tot.

ENDAT.

CLEAR: wa_head1.

ENDLOOP.

SORT it_head BY ttref augbl wrshb shkzg.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZVNPASF'

IMPORTING

fm_name = fmname.

conpar-no_dialog = 'X'.

conpar-getotf = 'X'.

outopt-tddest = 'LOCL'.

outopt-urlcall = fmname.

outopt-tdnoprev = 'X'.

  • outopt-tdnewid = 'X'.

CALL FUNCTION fmname

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = conpar

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = outopt

user_settings = ' '

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

job_output_info = w_return

  • JOB_OUTPUT_OPTIONS =

TABLES

it_zvnpa = it_zvnpa

it_head = it_head.

******************************************************************************************

  • READ TABLE w_return-spoolids INTO wa_line INDEX 1.

  • IF sy-subrc = 0.

  • lv_spool = wa_line.

*

  • CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

  • EXPORTING

  • src_spoolid = lv_spool

  • no_dialog = ' '

  • dst_device = 'LOCL'

  • TABLES

  • pdf = it_pdf_output

  • EXCEPTIONS

  • err_no_otf_spooljob = 1

  • err_no_spooljob = 2

  • err_no_permission = 3

  • err_conv_not_possible = 4

  • err_bad_dstdevice = 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.

********************************************************************************************************

it_otf[] = w_return-otfdata[].

IF it_otf[] IS NOT INITIAL.

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = binsz

TABLES

otf = it_otf

lines = i_tline.

*

LOOP AT i_tline.

TRANSLATE i_tline USING ' ~'.

CONCATENATE wa_buffer i_tline INTO wa_buffer.

ENDLOOP.

TRANSLATE wa_buffer USING '~ '.

DO.

i_record = wa_buffer.

APPEND i_record.

SHIFT wa_buffer LEFT BY 255 PLACES.

IF wa_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

ENDIF.

*

IF i_record[] IS NOT INITIAL.

it_attach[] = i_record[].

  • CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'

  • EXPORTING

  • LINE_WIDTH_SRC = '132'

  • LINE_WIDTH_DST = '255'

    • TRANSFER_BIN = ' '

  • TABLES

  • content_in = i_tline[]

  • content_out = IT_ATTACH[]

    • EXCEPTIONS

    • ERR_LINE_WIDTH_SRC_TOO_LONG = 1

    • ERR_LINE_WIDTH_DST_TOO_LONG = 2

    • ERR_CONV_FAILED = 3

    • OTHERS = 4

  • .

  • IF sy-subrc <> 0.

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

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

  • ENDIF.

  • it_attach[] = w_return-otfdata[].

*******************************************************************************************

  • IF it_pdf_output[] IS NOT INITIAL.

  • it_attach[] = it_pdf_output[].

wa_mailbody-line = 'Dear Sir / Madam,'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Please be informed that we have remitted the payment towards your outstanding bills as per the attachment:'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = ' '.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = ' '.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Best Regards,'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Mary. G '.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Finance department'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Intimate Fashions (I) Pvt Ltd'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = ' '.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'Please do not print this email unless it is absolutely necessary. Become environment friendly.'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'E-MAIL DISCLAIMER.'.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'If you are not the addressee of this mail, please delete this. Intimate Fashions does not accept any liability on the improper usage of this mail. It may also be legally '.

APPEND wa_mailbody TO it_mailbody.

wa_mailbody-line = 'privileged. Internet communications cannot be guaranteed to be timely, secure or virus free'.

APPEND wa_mailbody TO it_mailbody.

DESCRIBE TABLE it_mailbody LINES lncnt.

wa_doc_data-obj_descr = 'Remittance details - Brunet'.

wa_doc_data-expiry_dat = sy-datum + 10.

wa_doc_data-obj_name = 'TRIAL'.

wa_doc_data-sensitivty = 'F'.

wa_doc_data-doc_size = lncnt * 255.

CLEAR wa_pack.

CLEAR wa_pack-transf_bin.

wa_pack-doc_type = 'RAW'.

  • wa_pack-transf_bin = ' '.

wa_pack-head_start = 1.

wa_pack-head_num = 0.

wa_pack-body_start = 1.

wa_pack-body_num = lncnt.

  • wa_pack-doc_size = lncnt * 255.

APPEND wa_pack TO it_pack.

CLEAR: lncnt,wa_pack.

DESCRIBE TABLE it_attach LINES lncnt.

wa_pack-transf_bin = 'X'.

wa_pack-head_start = 1.

wa_pack-head_num = 1.

wa_pack-body_start = 1.

wa_pack-body_num = lncnt.

wa_pack-doc_type = 'PDF'.

wa_pack-obj_name = 'VNPA'.

CONCATENATE 'Vendor Payment Advice' '.PDF' INTO wa_pack-obj_descr.

  • wa_pack-obj_descr = 'Vendor Payment Advice'.

READ TABLE it_attach INDEX lncnt. "INTO WA_ATTACH

  • wa_pack-doc_size = ( lncnt - 1 ) * 255 + STRLEN( it_attach ).

wa_pack-doc_size = lncnt * 255.

APPEND wa_pack TO it_pack.

CLEAR: lncnt,wa_pack.

wa_mailhead = 'Vendor Payment Advice'.

APPEND wa_mailhead TO it_mailhead.

CLEAR: wa_mailhead.

LOOP AT pa_mail.

wa_receiverid-receiver = pa_mail-low.

wa_receiverid-rec_type = 'U'.

APPEND wa_receiverid TO it_receiverid.

CLEAR:wa_receiverid.

ENDLOOP.

  • wa_receiverid-receiver = 'xxxxx'. "(I have given mail id here )

  • wa_receiverid-rec_type = 'U'.

  • APPEND wa_receiverid TO it_receiverid.

*

  • wa_receiverid-receiver = 'xxxxx'. "(I have given mail id here )

  • wa_receiverid-rec_type = 'U'.

  • APPEND wa_receiverid TO it_receiverid.

*

  • wa_receiverid-receiver = 'xxxxx'. "(I have given mail id here )

  • wa_receiverid-rec_type = 'U'.

  • APPEND wa_receiverid TO it_receiverid.

  • CLEAR:wa_receiverid,lncnt.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_data

put_in_outbox = 'X'

commit_work = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = it_pack

object_header = it_mailhead

contents_bin = it_attach[]

contents_txt = it_mailbody

  • CONTENTS_HEX = it_attach

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = it_receiverid

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.

IF sy-subrc = 0.

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

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

LOOP AT it_zvnpa INTO wa_zvnpa.

wa_zvnpa-flag = 'X'.

MODIFY it_zvnpa FROM wa_zvnpa TRANSPORTING flag.

ENDLOOP.

MODIFY zvnpa FROM TABLE it_zvnpa.

ENDIF.

ENDIF.

CLEAR: wa_zvnpa,it_zvnpa,it_otf,it_otf[],w_return,lncnt,

wa_doc_data,

wa_head,it_head,it_head1,

i_record,i_record[],

i_tline,i_tline[],

it_pack,

wa_pack,

it_mailhead,

wa_mailhead,

it_mailbody,

wa_mailbody,

it_receiverid,

wa_receiverid,

it_attach.

ENDAT.

ENDLOOP.

ENDIF.

Read only

0 Likes
666

Prasad,

I checked this. the conversion part is correct only.

but plz check the below sdn link for the pdf.

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/mailsendthroughoutputcontrols

might it will be useful to cross check if something is missed out.