cancel
Showing results for 
Search instead for 
Did you mean: 

Error while converting OTF into PDF in CONVERT_OTF FM

Former Member
0 Kudos

Hi All,

I want to convert an OTF Output into PDF Format. So I am using the FM "CONVERT_OTF". But in that function, the syste is going into dump with the error "CONVT_NO_NUMBER". The complete error is as follows:

Short text

Unable to interpret "*381" as a number.

What happened?

Error in the ABAP Application Program

The current ABAP program "SAPLSTXW" had to be terminated because it has

come across a statement that unfortunately cannot be executed.

Error analysis

An exception occurred that is explained in detail below.

This exception cannot be caught in the context of the current statement.

The reason for the exception is:

The program attempted to interpret the value "*381" as a number, but

since the value contravenes the rules for correct number formats,

this was not possible.

The Contents of BIN_FILESIZE table are:

*381

0000

0000

2333

A381

Regards,

Vishal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Dear All,

Please suggest some solution.

Regards,

Vishal

Former Member
0 Kudos

Hi Vishal,

Follow the steps to generate output in PDF form.

1. Get the smartform generated FM name.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = <smartformname>
  IMPORTING
    fm_name            = v_form_name
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2.

2. Call the generated FM


w_ctrlop-GETOTF = 'X'.
w_ctrlop-NO_DIALOG = 'X'.
w_compop-tdnoprev = 'X'.

CALL FUNCTION v_form_name
 EXPORTING
   CONTROL_PARAMETERS         = W_CTRLOP
   OUTPUT_OPTIONS             = w_compop
   USER_SETTINGS              = 'X'
 IMPORTING
   JOB_OUTPUT_INFO            = w_return
 EXCEPTIONS
   FORMATTING_ERROR           = 1
   INTERNAL_ERROR             = 2
   SEND_ERROR                 = 3
   USER_CANCELED              = 4.

3. call FM SSFCOMP_PDF_PREVIEW to get PDF view

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'
  EXPORTING
    i_otf                          = w_return-otfdata[]
 EXCEPTIONS
   CONVERT_OTF_TO_PDF_ERROR       = 1
   CNTL_ERROR                     = 2.

4. save the pdf file to local file and for sending mail, see above postings.

Regards,

Raju.

Former Member
0 Kudos

Hi Raju,

Thanks for the reply. The first problem has been resolved. It was because I was using ACROBAT Ver 6.0. But when I installed ACROBAT 7.0 every thing is fine.

But when I use the FM GUI_DOWNLOAD, the system saves the PDF File but when I open this file its format is not supported. Just check the code:

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = fullpath

CONFIRM_OVERWRITE = 'X'

IMPORTING

FILELENGTH = FILELENGTH

tables

data_tab = job_output_info-otfdata[]

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

.

IF sy-subrc <> 0.

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

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

ENDIF.

job_output_info-otfdata[] is the Raw OTF file which I got from Smartform FM - /1BCDWB/SF00000097

Regards,

Vishal

Former Member
0 Kudos

Hi Vishal,

For download:

1. convert the OTF data to PDF format.


call function 'CONVERT_OTF_2_PDF'
 importing
   bin_filesize                 = v_len_in
  tables
    otf                          = w_return-otfdata[]
    doctab_archive               = i_docs
    lines                        = i_tline
 exceptions
   err_conv_not_possible        = 1
   err_otf_mc_noendmarker       = 2.

2. Then download.


call method cl_gui_frontend_services=>gui_download
  exporting
    bin_filesize              = v_len_in
    filename                  = 'C:\Documents and Settings\....\test123.pdf'
    filetype                  = 'BIN'
  changing
    data_tab                  = i_tline
  exceptions
    file_write_error          = 1
    no_batch                  = 2
    gui_refuse_filetransfer   = 3
    invalid_type              = 4
    no_authority              = 5
    unknown_error             = 6
    header_not_allowed        = 7
    separator_not_allowed     = 8
    filesize_not_allowed      = 9
    header_too_long           = 10
    dp_error_create           = 11
    dp_error_send             = 12
    dp_error_write            = 13
    unknown_dp_error          = 14
    access_denied             = 15
    dp_out_of_memory          = 16
    disk_full                 = 17
    dp_timeout                = 18
    file_not_found            = 19
    dataprovider_exception    = 20
    control_flush_error       = 21
    not_supported_by_gui      = 22
    error_no_gui              = 23
    others                    = 24.
if sy-subrc <> 0.
endif.

Regards,

Raju.

Answers (3)

Answers (3)

Former Member
0 Kudos

Just wanted to say that I had this same (original issue) and what worked for me was simply adding in the optional parameter

bin_filesize

If you don't specify this, the function takes the default type for the field and abends when it gets too large...

Former Member
0 Kudos

Hi,

Use the below FM to get the output in PDF..

call function 'SSFCOMP_PDF_PREVIEW'

exporting i_otf = otf[]

exceptions convert_otf_to_pdf_error = 1

cntl_error = 2

others = 3.

Pass the OTF data table to the above FM..

dont forget to make get_otf parameter as 'X' in output options of SF Function Module.

Hope it helps!!

Rgds,

Pavan

Former Member
0 Kudos

Dear Vishnu,

As soon as I am calling the FM "CONVERT_OTF", the system is going into DUMP. So I am not able to reach the PRVIEW FM.

Regards,

Vishal

former_member205763
Active Contributor
0 Kudos

can u show the code, how u hv used the fm, the code given above by raju would work fine so try tht code and call the pdf preview fm after it so tht u'll know if the output is correct or no.

Former Member
0 Kudos

Hi Kartik,

Here is the Code:

REPORT z_sd_sale_ord_conf.

TABLES: vbak.

DATA: i_formname TYPE tdsfname,

i_fm_name TYPE rs38l_fnam,

it_vbak TYPE TABLE OF vbak WITH HEADER LINE.

DATA: output_options TYPE ssfcompop,

control_parameters TYPE ssfctrlop,

e_devtype TYPE rspoptype,

job_output_info TYPE ssfcrescl,

bin_file TYPE xstring,

lines TYPE TABLE OF tline WITH HEADER LINE,

doctab_archive TYPE TABLE OF docs WITH HEADER LINE,

filelength TYPE i,

bin_filesize TYPE sood-objlen.

PARAMETERS: p_vbeln TYPE vbak-vbeln OBLIGATORY MEMORY ID aun.

SELECTION-SCREEN: SKIP.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.

PARAMETERS: p_hsr RADIOBUTTON GROUP grp1 DEFAULT 'X'. SELECTION-SCREEN COMMENT /5(60) text-001. "For Hisar Preprinted Stationary

PARAMETERS: p_a4 RADIOBUTTON GROUP grp1. SELECTION-SCREEN COMMENT /5(50) text-002. "For A4 Invoice, valid for all branches also.

SELECTION-SCREEN: SKIP.

PARAMETERS: p_pdf AS CHECKBOX.

SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN .

PERFORM vbeln_validation.

&----


*& Form vbeln_validation

&----


  • text

----


FORM vbeln_validation .

IF p_vbeln NE ' '.

SELECT SINGLE vbeln

FROM vbak

INTO vbak-vbeln

WHERE vbeln EQ p_vbeln.

IF sy-subrc NE 0.

MESSAGE: 'Inavlid Sales Document !' TYPE 'E'.

ENDIF.

  • CLEAR: vbak.

ENDIF.

ENDFORM. " vbeln_validation

INITIALIZATION.

t1 = 'Print Options'.

START-OF-SELECTION.

SELECT * FROM vbak INTO TABLE it_vbak WHERE vbeln = p_vbeln.

IF p_hsr = 'X'.

i_formname = 'Z_SD_SALE_ORD_CONF'.

output_options-tddest = 'LP02'.

output_options-tdimmed = 'X'.

output_options-tdnewid = 'X'.

ELSE.

i_formname = 'Z_SD_SALE_ORD_CONF_A4'.

output_options-tddest = 'LP01'.

output_options-tdimmed = 'X'.

output_options-tdnewid = 'X'.

ENDIF.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = i_formname

IMPORTING

fm_name = i_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

IF sy-subrc <> 0. "checking subrc

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

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

ENDIF. "IF sy-subrc <> 0

IF p_pdf NE 'X'.

CALL FUNCTION i_fm_name

EXPORTING

control_parameters = control_parameters

output_options = output_options

user_settings = space

vbeln = p_vbeln

TABLES

it_vbak = it_vbak

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc <> 0.

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

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

ENDIF.

ELSE.

CALL FUNCTION 'SSF_GET_DEVICE_TYPE'

EXPORTING

i_language = 'E'

  • I_APPLICATION = 'SAPDEFAULT'

IMPORTING

e_devtype = e_devtype

EXCEPTIONS

no_language = 1

language_not_installed = 2

no_devtype_found = 3

system_error = 4

OTHERS = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

  • WRITE: / e_devtype.

*

*control_parameters-DEVICE = e_devtype.

control_parameters-no_dialog = 'X'.

control_parameters-getotf = 'X'.

CALL FUNCTION i_fm_name "'/1BCDWB/SF00000097'

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

control_parameters = control_parameters

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

output_options = output_options

user_settings = space

vbeln = p_vbeln

IMPORTING

  • DOCUMENT_OUTPUT_INFO =

job_output_info = job_output_info

  • JOB_OUTPUT_OPTIONS =

TABLES

it_vbak = it_vbak

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

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'

  • MAX_LINEWIDTH = 132

  • ARCHIVE_INDEX = ' '

  • COPYNUMBER = 0

  • ASCII_BIDI_VIS2LOG = ' '

  • PDF_DELETE_OTFTAB = ' '

IMPORTING

  • BIN_FILESIZE = BIN_FILESIZE

bin_file = bin_file

TABLES

otf = job_output_info-otfdata[]

lines = lines[]

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 3

err_bad_otf = 4

OTHERS = 5

.

IF sy-subrc <> 0.

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

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

ENDIF.

Regards,

Vishal

Former Member
0 Kudos

Hi,

I am not able to set the proper format of the code. Can you tell how can I upload the code in proper format.

I have tried with Markup Possibilties also. But I am not getting the desired result.

Regards

Vishal

Former Member
0 Kudos

Hi Vishal,

See the following code.


data: v_len_in like sood-objlen.

call function 'CONVERT_OTF'
 exporting
   format                      = 'PDF'
   max_linewidth               = 132
*   ARCHIVE_INDEX               = ' '
*   COPYNUMBER                  = 0
*   ASCII_BIDI_VIS2LOG          = ' '
*   PDF_DELETE_OTFTAB           = ' '
 importing
   bin_filesize                = v_len_in
*   BIN_FILE                    =
  tables
    otf                         = i_otf
    lines                       = i_tline
 exceptions
   err_max_linewidth           = 1
   err_format                  = 2
   err_conv_not_possible       = 3
   err_bad_otf                 = 4.

Regards,

Raju.

Former Member
0 Kudos

Hi Raju,

I tried with your options, but now the report is not giving any output at all. After execution, it simply return back to the Selection Screen.

Regards,

Vishal

Former Member
0 Kudos

Hi,

Are you sending a mail attachment(PDF)?

see the following code.


i_otf[] = w_return-otfdata[].

CALL FUNCTION 'CONVERT_OTF'
 EXPORTING
   FORMAT                      = 'PDF'
   MAX_LINEWIDTH               = 132
*   ARCHIVE_INDEX               = ' '
*   COPYNUMBER                  = 0
*   ASCII_BIDI_VIS2LOG          = ' '
*   PDF_DELETE_OTFTAB           = ' '
 IMPORTING
   BIN_FILESIZE                = v_len_in
*   BIN_FILE                    =
  TABLES
    otf                         = i_otf
    lines                       = i_tline
 EXCEPTIONS
   ERR_MAX_LINEWIDTH           = 1
   ERR_FORMAT                  = 2
   ERR_CONV_NOT_POSSIBLE       = 3
   ERR_BAD_OTF                 = 4.

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.
* Attachment
REFRESH: i_reclist,
i_objtxt,
i_objbin,
i_objpack.
CLEAR wa_objhead.
i_objbin[] = i_record[].
* Create Message Body Title and Description
i_objtxt = 'Test with PDF attachemnet-Body Text'.
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.
IF sy-subrc ne 0.
  WRITE:/ 'error when sending the file', sy-subrc.
ELSE.
  WRITE:/ 'mail sent'.
ENDIF.

Regards,

Raju.

Former Member
0 Kudos

Hi Raju,

I am not Mailing the document right now. The mailing of Document will be my third step.

First Step is: To generate the Output in PDF Format.

Second Step: To Save the PDF File in local file.

Third Step: To Mail the PDF file.

So first we have to reslove first step. Now just tell whether for first step also, I need to do the changes told by you or not?

Regards,

Vishal