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

CONVERT_OTF

mansur_shaik
Explorer
0 Likes
17,144

Hello Gurus,

While using FM "Convert_OTF" I am facing problem. I can see the correct data in the print preview of the smartform but while converting to PDF this data is migrated/mismatched. Please help me to solve.

   call function 'CONVERT_OTF'
        exporting
          format                = 'PDF'
*         MAX_LINEWIDTH         = 132
*         ARCHIVE_INDEX         = ' '
*         COPYNUMBER            = 0
*         ASCII_BIDI_VIS2LOG    = ' '
*         PDF_DELETE_OTFTAB     = ' '
        importing
          bin_filesize          = lv_size
*         bin_file              =
        tables
          otf                   = ls_output-otfdata
          lines                 = lt_tline
        exceptions
          err_max_linewidth     = 1
          err_format            = 2
          err_conv_not_possible = 3
          err_bad_otf           = 4
          others                = 5.
      if sy-subrc = 0.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
9,396

Hi Mansur,

What are you trying to do after convert OTF data?

I mean, if you are trying to send an e-mail as PDF attachment, please, check the code below. It is working fine to me.

DATA : pdf_xstring     TYPE xstring,

          lv_bin_filesize TYPE i,

          lt_pdf_table    TYPE tlinetab.

DATA: lt_otf TYPE TABLE OF itcoo.

" First you convert the OTF data

CALL FUNCTION 'CONVERT_OTF'

     EXPORTING

       format                = 'PDF'

       max_linewidth         = 132

     IMPORTING

       bin_filesize          = lv_bin_filesize

       bin_file              = pdf_xstring

     TABLES

       otf                   = lt_otf

       lines                 = lt_pdf_table

     EXCEPTIONS

       err_max_linewidth     = 1

       err_format            = 2

       err_conv_not_possible = 3

       err_bad_otf           = 4

       OTHERS                = 5.

*Now for mailing...

   DATA: lt_attach_bin      TYPE TABLE OF solix,

         lt_text            TYPE bcsy_text,

         send_request       TYPE REF TO cl_bcs,

         document           TYPE REF TO cl_document_bcs,

         sender             TYPE REF TO cl_cam_address_bcs,

         recipient          TYPE REF TO cl_cam_address_bcs,

         bcs_exception      TYPE REF TO cx_bcs,

         sent_to_all        TYPE os_boolean.

   TRY.

       send_request = cl_bcs=>create_persistent( ).

       lt_attach_bin = cl_document_bcs=>xstring_to_solix( ip_xstring = pdf_xstring ).

       APPEND 'Test message' TO lt_text.

       document = cl_document_bcs=>create_document( i_type    = 'RAW'

                                                    i_text    = lt_text

                                                    i_subject = 'Script as pdf attachment' ).

       document->add_attachment( i_attachment_type    = 'PDF'

                                 i_attachment_subject = 'script.pdf'

                                 i_att_content_hex    = lt_attach_bin ).

       send_request->set_document( document ).

*      sender    = cl_cam_address_bcs=>create_internet_address( 'jonh@gmail.com' ).

       recipient = cl_cam_address_bcs=>create_internet_address( 'jonh@gmail.com' ).

*      send_request->set_sender( sender ).

       send_request->add_recipient( i_recipient = recipient

                                    i_express   = 'X' ).

       sent_to_all = send_request->send( i_with_error_screen = 'X' ).

       COMMIT WORK.

     CATCH cx_bcs INTO bcs_exception.

       MESSAGE 'eee' TYPE 'S'.

       EXIT.

   ENDTRY.


Regards

Vinicius Ostan

8 REPLIES 8
Read only

Former Member
0 Likes
9,396

Salaam Mansur,

The CONVERT_OTF call is fine the problem could be with the SMARTFORM Call.

When you are calling in foreground you are specifying the print parameters in pop-up which I don't guess are passed while in OTF case.

Provide appropriate print params it will show properly.

Regards

Read only

0 Likes
9,396

here is a sample

lwa_param  TYPE ssfctrlop,

lwa_output TYPE ssfcompop,

* Calling the SMARTFORM using the function module retrieved above

* GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF

* format of the output

lwa_param-no_dialog = 'X'.

lwa_param-preview = space.

lwa_param-getotf = 'X'.

lwa_output-TDPRINTER = 'SAPWIN'. "Set your printer here

lwa_output-tddest    = 'LP01'.   "Set your device here

pass these to

control_parameters = lwa_param

output_options       = lwa_output

Read only

gouravkumar64
Active Contributor
0 Likes
9,396

Hi,

If requirement is only for PDF conversion,you can use PDF! in print preview command bar Instead of this code.

It will works.

Thanks

Gourav.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
9,396

First perform some search at OSS, there are "some" notes (*) on what can be converted to pdf from Sap Script or Smart Forms and what cannot...

What is getting wrong with conversion : character fonts, barcodes, pictures ?

Regards,
Raymond

PS: Some notes

1180387   PDF convertrt: Languages BS, MK not treated as Latin-1

1151806   Arial Unicode MS TrueType fonts from Ascender Corp.

992915    PDF converter: Character Dstroke/Dcroat missing for Latin-2

941495    PDF converter: Font is not embedded for Latin-2

820106    CONVERT_OTF: PDF replacement fonts are not embedded

588724    PDF conversion: incorrect special characters with Latin-2

495892    PDF converter: Ohungarumlaut is not displayed

372666    PDF conversion: Supporting Greek font

339832    PDF conversion: Thai support

323736    Restrictions with "PDF print" through spooler

322998    PDF conversion: Cyrillic support

163266    PDF conversion: character set for softfonts

144718    PDF conversion: CJK support

141219    RSTXPDF2: Error during the upload of Adobe Typ 1 font's data

Read only

mansur_shaik
Explorer
0 Likes
9,396

Thank you for your inputs .

Mansur

Read only

Former Member
0 Likes
9,396

Hi Mansur,

You can try calling the function module CONVERT_OTF_2_PDF instead of CONVERT_OTF.

Please check the below link for sample code:

http://wiki.scn.sap.com/wiki/display/Snippets/Convert+Smartform+to+PDF+format

Thanks,

Ajay Bose

Read only

Former Member
0 Likes
9,397

Hi Mansur,

What are you trying to do after convert OTF data?

I mean, if you are trying to send an e-mail as PDF attachment, please, check the code below. It is working fine to me.

DATA : pdf_xstring     TYPE xstring,

          lv_bin_filesize TYPE i,

          lt_pdf_table    TYPE tlinetab.

DATA: lt_otf TYPE TABLE OF itcoo.

" First you convert the OTF data

CALL FUNCTION 'CONVERT_OTF'

     EXPORTING

       format                = 'PDF'

       max_linewidth         = 132

     IMPORTING

       bin_filesize          = lv_bin_filesize

       bin_file              = pdf_xstring

     TABLES

       otf                   = lt_otf

       lines                 = lt_pdf_table

     EXCEPTIONS

       err_max_linewidth     = 1

       err_format            = 2

       err_conv_not_possible = 3

       err_bad_otf           = 4

       OTHERS                = 5.

*Now for mailing...

   DATA: lt_attach_bin      TYPE TABLE OF solix,

         lt_text            TYPE bcsy_text,

         send_request       TYPE REF TO cl_bcs,

         document           TYPE REF TO cl_document_bcs,

         sender             TYPE REF TO cl_cam_address_bcs,

         recipient          TYPE REF TO cl_cam_address_bcs,

         bcs_exception      TYPE REF TO cx_bcs,

         sent_to_all        TYPE os_boolean.

   TRY.

       send_request = cl_bcs=>create_persistent( ).

       lt_attach_bin = cl_document_bcs=>xstring_to_solix( ip_xstring = pdf_xstring ).

       APPEND 'Test message' TO lt_text.

       document = cl_document_bcs=>create_document( i_type    = 'RAW'

                                                    i_text    = lt_text

                                                    i_subject = 'Script as pdf attachment' ).

       document->add_attachment( i_attachment_type    = 'PDF'

                                 i_attachment_subject = 'script.pdf'

                                 i_att_content_hex    = lt_attach_bin ).

       send_request->set_document( document ).

*      sender    = cl_cam_address_bcs=>create_internet_address( 'jonh@gmail.com' ).

       recipient = cl_cam_address_bcs=>create_internet_address( 'jonh@gmail.com' ).

*      send_request->set_sender( sender ).

       send_request->add_recipient( i_recipient = recipient

                                    i_express   = 'X' ).

       sent_to_all = send_request->send( i_with_error_screen = 'X' ).

       COMMIT WORK.

     CATCH cx_bcs INTO bcs_exception.

       MESSAGE 'eee' TYPE 'S'.

       EXIT.

   ENDTRY.


Regards

Vinicius Ostan

Read only

0 Likes
9,396

Hello,

One’s task done(Quality notification), system need to send mails to customer as PDF & user can see the same in Preview. Problem was solved using MPDF functionality(test data below). Thank for your inputs

F sy-ucomm = 'VIEW'.                                     "NK02*   Call FM to print smartformCALL FUNCTION lv_formname
     
EXPORTING
        control_parameters
= lv_ssfctrlop
        output_options    
= lv_ssfcompop
        i_wire            
= zqm_cust_comp
        i_textsymbols     
= zqm_cust_comp_textsym
        i_form            
= gv_rep_i               "NK01
        i_workpaper       
= wworkpaper-workpaper   "SPC02
        i_string          
= gv_string                      "JP75879
        i_langu           
= gv_spras                       "JP80603
     
TABLES
        it_desc           
= gt_tline
        it_text_name      
= gt_text_name                   "AS81726
        it_activity       
= gt_activity     "NK01
        it_activity_1     
= gt_activity_new                "HS116368
     
EXCEPTIONS
        formatting_error  
= 1
        internal_error    
= 2
        send_error        
= 3
        user_canceled     
= 4
       
OTHERS             = 5.
   
IF sy-subrc <> 0.* Implement suitable error handling here
   
ENDIF.*    REFRESH gt_text_name.              "AS81726 "AS83026* Commented since, it is not being used, so no need to refresh,* just a blank value is passed.
* Begin of insertion by XXXXX  BDVK966144 
 
ELSE.
   
if sy-uname = 'XXXXXX' or sy-uname = 'XXXXXX'.
lv_ssfcompop
-tdnoprev = 'X'.
lv_ssfcompop
-tddest = 'MPDF'.
lv_ssfcompop
-tdtitle = 'to=mansurali.shaik@XXXX.com'.
lv_ssfcompop
-TDCOVTITLE = 'to=mansurali.shaik@XXXXX.com'.
lv_ssfctrlop
-device = 'PRINTER'.
lv_ssfctrlop
-PREVIEW = ''.
     
else.
    lv_ssfctrlop
-getotf    = 'X'.               "