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

Help with wrong output in PDF Creation

Former Member
0 Likes
1,692

Hello Everybody.

Perhaps someone could give me a hand with a problem I have:

I've make a program that generates a PDF from a smartform and send it through mail.

To make this possible I'm getting the OTF data from the Smartform function then converting it using the function CONVERT_OTF

and getting the bin file (xstring)

To send the mail I'm using the CL_BCS class. I'm converting the Xstring (bin file retrieved from the function convert_otf)  to Solix through the method XSTRING_TO_SOLIX of the class, then attaching it with the method ADD_ATTACHMENT:

     lo_document->add_attachment(

            EXPORTING

               i_attachment_type          = 'BIN'

               i_attachment_subject      = lv_filename

               I_att_conent_hex            = lt_pdf_data

               I_attachment_language  = p_langu ).

The pdf is generated succesfully and sent by mail, but the output of some symbols ( like the trademark, registered brand, etc.) is showing as #

This doesn't happen with the print version, and doesn't happen when I make a pdf and save it to the client pc (therefore is not a problem with the pdf printer).

I'm kind of lost here, and I'm trying to avoid using the SO_NEW_DOCUMENT_ATT_SEND_API1 Function.

Hello Everybody.

Perhaps someone could give me a hand with a problem I have:

I've make a program that generates a PDF from a smartform and send it through mail.

To make this possible I'm getting the OTF data from the Smartform function then converting it using the function CONVERT_OTF

and getting the bin file (xstring)

To send the mail I'm using the CL_BCS class. I'm converting the Xstring (bin file retrieved from the function convert_otf)  to Solix through the method XSTRING_TO_SOLIX of the class, then attaching it with the method ADD_ATTACHMENT:

     lo_document->add_attachment(

            EXPORTING

               i_attachment_type          = 'BIN'

               i_attachment_subject      = lv_filename

               I_att_conent_hex            = lt_pdf_data

               I_attachment_language  = p_langu ).

The pdf is generated succesfully and sent by mail, but the output of some symbols ( like the trademark, registered brand, etc.) is showing as #

This doesn't happen with the print version, and doesn't happen when I make a pdf and save it to the client pc (therefore is not a problem with the pdf printer).

I'm kind of lost here, and I'm trying to avoid using the SO_NEW_DOCUMENT_ATT_SEND_API1 Function.

9 REPLIES 9
Read only

michael_kozlowski
Active Contributor
0 Likes
1,621

Please check if note 1822639 apply for your system http://service.sap.com/sap/support/notes/1822639

Read only

0 Likes
1,621

Thanks Michael, I'll check it with the basis team of my company

Any other ideas?

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,621

Hi,

Just to verify....

Some code from here

The case of sending mail with graphs . | SCN

FORM mail_1_prep_5

  CHANGING

    ob_document_bcs TYPE REF TO cl_document_bcs .

  DATA: customer    TYPE  scustom .

  DATA: bookings    TYPE  ty_bookings .

  DATA: connections TYPE  ty_connections   .

  DATA: formname TYPE tdsfname .

  DATA: fm_name     TYPE rs38l_fnam .

  formname = p_fname .

  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

    EXPORTING

      formname           = p_fname

    IMPORTING

      fm_name            = fm_name

    EXCEPTIONS

      no_form            = 1

      no_function_module = 2

      OTHERS             = 3.

  IF sy-subrc NE 0 .

    RETURN .

  ENDIF .

  DATA: st_control_parameters TYPE ssfctrlop .

  DATA: st_output_options     TYPE ssfcompop .

  DATA: st_job_output_info    TYPE ssfcrescl .

  st_control_parameters-no_dialog = abap_true .

  st_control_parameters-getotf    = abap_true .

  CALL FUNCTION fm_name

    EXPORTING

      control_parameters = st_control_parameters

      output_options     = st_output_options

      customer           = customer

      bookings           = bookings

      connections        = connections

    IMPORTING

      job_output_info    = st_job_output_info

    EXCEPTIONS

      formatting_error   = 1

      internal_error     = 2

      send_error         = 3

      user_canceled      = 4

      OTHERS             = 5.

  IF sy-subrc EQ 4 .

    RETURN .

  ENDIF .

  IF sy-subrc NE 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

  DATA: bin_file TYPE xstring .

  DATA: it_lines_dummy TYPE tline_tab .

  DATA: bin_filesize TYPE i .

  CALL FUNCTION 'CONVERT_OTF'

    EXPORTING

      format                = 'PDF'

    IMPORTING

      bin_file              = bin_file

      bin_filesize          = bin_filesize

    TABLES

      otf                   = st_job_output_info-otfdata

      lines                 = it_lines_dummy

    EXCEPTIONS

      err_max_linewidth     = 1

      err_format            = 2

      err_conv_not_possible = 3

      err_bad_otf           = 4

      OTHERS                = 5.

  DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>xstring_to_solix

    EXPORTING

      iv_xstring = bin_file

    RECEIVING

      et_solix   = it_solix.

  DATA: attachment_subject TYPE so_obj_des .

  MESSAGE s000(oo) WITH 'attachment PDF hex' space INTO attachment_subject .

  TRY.

      CALL METHOD ob_document_bcs->add_attachment

        EXPORTING

          i_attachment_type    = 'pdf'

          i_attachment_subject = attachment_subject

          i_att_content_hex    = it_solix.

    CATCH cx_document_bcs .

  ENDTRY.

ENDFORM .                    "mail_1_prep_5

Read only

0 Likes
1,621

Thanks Eitan,

I was using 'BIN' in the ADD_ATTACHMENT method.

I've changed it to PDF but still have the same problem.

Read only

0 Likes
1,621

Hi,

Please call .

Phones are under my profile.

Regards.

Read only

Former Member
0 Likes
1,621

Check:

Read only

Chintu6august
Contributor
0 Likes
1,621

Hi,

please make the highlighted changes

  lo_document->add_attachment(

            EXPORTING

               i_attachment_type          = 'PDF'

               i_attachment_subject      = lv_filename

               I_att_conent_hex            = lt_pdf_data

               I_attachment_language  = p_langu ).

and follow the link provided by Elzkie La and change the current font to the font which support special characters for that particular text.

thanks!

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,621

If you are working with binary files always consider their size.

So use parameter I_ATTACHMENT_SIZE.

And do not use I_attachment_language if you are not attaching text.

That might solve problem 🙂

-- Tomas --
Read only

MariaJooRocha
Contributor
0 Likes
1,621

Hi,

data: l_bin_file type xstring

        it_pdf type standard tbale of tline

call function 'CONVERT_OTF'

...

  importing l_bin_file

...

call function 'SCMS_XSTRING_TO_BINARY'

  exporting

     buffer = l_bin_file

   tables

     binary_tab = it_pdf.

cal method wo_document->add_attachment    

     exporting

          i_attachment_type = 'PDF'

          i_attachment_subject = 'SUBJECT'

          i_att_content_hex = it_pdf.

Regards,

Maria João Rocha