Application Development 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: 

"OTF end command // missing in OTF data" while converting smartform to pdf

Former Member
0 Kudos

Dear ALL,

I'm trying to convert a smartform to pdf format. All programming I've done and there is no activation error.

But In selection screen after putting document number and verndor number when I press F8 (execute), I'm getting print screen and then I put "Output Device" and when I click print preview, firstly it show me an information message "OTF end command // missing in OTF data" and when I click "OK" it shows me "SAVE AS" Dialog Box and after clicking "Save", it saves it but in the task bar it shows me "0 bytes transferred" and also shows print privew of smarform.

So guys, I'm unable to convert a smartform to pdf.

Please Help!

Thanks to all..

Devinder

1 ACCEPTED SOLUTION

tamas_hoznek
Product and Topic Expert
Product and Topic Expert

Please check if the function module belonging to the Smartform processes correctly. It is possible that the FM raises a FORMATTING_ERROR exception, in which case no OTF data is returned. As a consequence, the PDF conversion will fail with the error message you're getting.

22 REPLIES 22

tamas_hoznek
Product and Topic Expert
Product and Topic Expert

Please check if the function module belonging to the Smartform processes correctly. It is possible that the FM raises a FORMATTING_ERROR exception, in which case no OTF data is returned. As a consequence, the PDF conversion will fail with the error message you're getting.

0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi,

Are you using FM SSF_GET_DEVICE_TYPE to get the default printer?

Then pass the device name to job_output_options-tdprinter component and in the control paramenters component, have you checked the getotf field in it.

If no, please do the above and check.

Regards,

Raja.D

0 Kudos

Hi Guys,

Thanks for your responses.. I'm pasting the code below:

Hope this will help you more to understand.

Edited by: Rob Burbank on Feb 3, 2012 4:53 PM

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

Use the proper tags, otherwise nobody will be able (or bother) to read the garbled code.

0 Kudos

Hi,

When I pasted this code, it was on proper manner but after sending, it was in like this format.

Please tell me how to give tags in between.

Thanks

Devinder

0 Kudos

Edited by: DevinderP on Jan 25, 2012 5:49 PM

Edited by: Rob Burbank on Feb 3, 2012 4:53 PM

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

Try this:

Paste your code, then highlight it all and click on the <code> button above the window. Then use the 'Preview' tab to see if the code tags format the post correctly before posting.

0 Kudos

Edited by: Rob Burbank on Feb 3, 2012 4:54 PM

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

OK. I tried to reformat your code, hope the result reflects what you have. I have some doubts around the area where the wa_ssfctrlop field values are set because it's not easy to figure out what's commented and what is not. Don't know why you couldn't format the code, the code tags work fine for me.

Anyway... here are a few comments:

Make sure that wa_ssfctrlop-getotf is set to 'X'.

Do NOT populate wa_ssfctrlop-no_close with an 'X'. That will cause no OTF data being generated (due to the form not being closed) and the PDF conversion will result in the error message you're getting.

Check the return code after CALL FUNCTION fmname and make sure there is no error. An error will mean no proper OTF - > conversion will fail.

Generally speaking, you seem to do a lot of unnecessary things... as far as I know, if you just want to generate the form, convert it to PDF and download, there is no need to call SSF_OPEN and SSF_CLOSE, since calling the FM of your form will give you what you need (the OTF data).

Check the above points, hopefully this will fix the issue.

0 Kudos

Dear Tamas,

Thanks for your help. But after alteration, I'm getting this error:

"No output request open. Document processing not possible."

And there is only "Exit" Button Prompt, there is no other option available and after clicking EXIT it goes to SAP Easy Access.

If I put SSF_OPEN and SSF_CLOSE then it shows atleast the form but not saving in pdf format.

Regards

Devinder

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

All right. Here is a very simple test program that does exactly what you want:

- call a form

- convert the output to PDF

- download the PDF to a local file.

There is no dialog, the device is the LOCL printer but it could be any other of course.

I tested the result and the PDF opens just fine in Adobe Acrobat Viewer.

The form itself is very simple, with a single window containing some text and it requires no other input parameters than the standard ones generated by the Smartforms framework.

This is all you need, no SSF_OPEN or SSF_CLOSE is necessary.

Hope this helps.

REPORT test.

DATA wa_control_parameters TYPE ssfctrlop.
DATA wa_output_options TYPE ssfcompop.
DATA wa_job_output_info TYPE ssfcrescl.
DATA fmname TYPE tdsfname.
DATA v_bin_filesize TYPE i.
DATA v_filename TYPE string VALUE 'formtest.pdf'.
DATA it_lines TYPE STANDARD TABLE OF tline.
DATA it_docs TYPE STANDARD TABLE OF docs.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
    formname           = 'ZZ_TEST'
  IMPORTING
    fm_name            = fmname
  EXCEPTIONS
    no_form            = 1
    no_function_module = 2
    OTHERS             = 3.

IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  STOP.
ENDIF.

wa_control_parameters-no_dialog = 'X'.
wa_control_parameters-preview = 'X'.
wa_control_parameters-getotf = 'X'.
wa_output_options-tddest = 'LOCL'.

CALL FUNCTION fmname
  EXPORTING
    control_parameters = wa_control_parameters
    output_options     = wa_output_options
  IMPORTING
    job_output_info    = wa_job_output_info
  EXCEPTIONS
    formatting_error   = 1
    internal_error     = 2
    send_error         = 3
    user_canceled      = 4
    OTHERS             = 5.
IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  STOP.
ENDIF.

CALL FUNCTION 'CONVERT_OTF_2_PDF'
  IMPORTING
    bin_filesize           = v_bin_filesize
  TABLES
    otf                    = wa_job_output_info-otfdata
    doctab_archive         = it_docs
    lines                  = it_lines
  EXCEPTIONS
    err_conv_not_possible  = 1
    err_otf_mc_noendmarker = 2
    OTHERS                 = 3.

IF sy-subrc NE 0.
  WRITE: / 'conversion error, RC:', sy-subrc.
  STOP.
ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    bin_filesize            = v_bin_filesize
    filename                = v_filename
    filetype                = 'BIN'
  TABLES
    data_tab                = it_lines
  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 NE 0.
  WRITE: / 'download error, RC:', sy-subrc.
ENDIF.

0 Kudos

Hi,

Your answer is very helpful for me.

Now, after executing the report, I'm getting an message in the status bar, "8,052 bytes transferred" but simultinuosly I want to open the "SMARTFORM" also, which is not opening right now.

Can you please tell me how can I open the form as well and save it as " .pdf" ?

Thanks

Devinder

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

After completing the GUI_DOWNLOAD, you could do this:

wa_control_parameters-getotf = ' '.

CALL FUNCTION fmname
  EXPORTING
    control_parameters = wa_control_parameters
    output_options     = wa_output_options
  IMPORTING
    job_output_info    = wa_job_output_info
  EXCEPTIONS
    formatting_error   = 1
    internal_error     = 2
    send_error         = 3
    user_canceled      = 4
    OTHERS             = 5.

This will call the Smartform in print preview mode if you need the form displayed on the screen in addition to the download.

This is just a 'quick and dirty' solution, I suppose there may be a way to do this together with generating the OTF data, but it's possible that requesting the OTF will prevent the print preview display... I didn't debug the code enough to confirmm this. But the above solution will work for sure.

0 Kudos

Getting a dump error... because I've already used "fmname" before convrting to pdf.

any other solution::

Thanks

Devinder

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos

What did you use that variable for?

I can only say that I tried the described solution in my test program and it works fine. Don't use or change the fmname variable value in any way and insert the above additional code at the end. It will work... if not, then you'll have to fix your code so that the second FM call works.

0 Kudos

Hi Tamas,

Thanks for solution.i have solved my issue with your solution.

Thanks,

Satya.

nabheetscn
Active Contributor
0 Kudos

First of all when you will set GET_OTF parameter you will not be able to see print preview. But if you are using spool to PDF concept then make sure its blank.

Can you please paste what are the control parameters you are passing.

Nabheet

Former Member
0 Kudos

Hi Devinder,

I suspect the issue is happening during conversion of smartform to OTF.

Please go through this link.

http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/62ae7fcd-0b01-0010-3e9d-a54f26944450

This will give you some inputs regarding handling OTF data.

Regards,

SP.

tamas_hoznek
Product and Topic Expert
Product and Topic Expert
0 Kudos
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
  EXPORTING
    i_language    = v_language
    i_application = 'SAPDEFAULT'
  IMPORTING
    e_devtype     = v_e_devtype.

st_output_options-tdprinter = v_e_devtype.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
PERFORM process_data.

*&---------------------------------------------------------------------*
*& Form PROCESS_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM process_data .
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
  EXPORTING
  formname = 'ZAR_RFQ'
* variant = ' '
* direct_call = ' '
IMPORTING
  fm_name = fmname
EXCEPTIONS
  no_form = 1
  no_function_module = 2
  OTHERS = 3 .

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  wa_ssfctrlop-no_dialog = 'X'.
  wa_ssfctrlop-no_open = 'X'.
** wa_ssfctrlop-preview = 'X'.
** wa_ssfctrlop-getotf = 'X'.
  wa_ssfctrlop-no_close = 'X'.

  CALL FUNCTION 'SSF_OPEN'
* EXPORTING
* archive_parameters =
* user_settings = 'X'
* mail_sender =
* mail_recipient =
* mail_appl_obj =
* output_options =
* control_parameters =
IMPORTING
  job_output_options = wa_sfcresop
* 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.

  wa_ssfcompop-tddest = wa_sfcresop-tddest.
  wa_ssfctrlop-preview = wa_sfcresop-tdpreview.
  MOVE-CORRESPONDING wa_sfcresop TO wa_ssfcompop.

  CALL FUNCTION fmname
  EXPORTING
* archive_index =
* archive_index_tab =
* archive_parameters =
    control_parameters = wa_ssfctrlop
* mail_appl_obj =
* mail_recipient =
* mail_sender =
    output_options = wa_ssfcompop
* user_settings = 'X'
    v_ebeln = v_ebeln
    v_lifnr = v_lifnr
    v_datefrom =
    so_aedat-low
    v_dateto = so_aedat-high
  IMPORTING
    document_output_info = st_document_output_info
    job_output_info = st_job_output_info
    job_output_options = st_job_output_options
  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_2_PDF'
    IMPORTING
      bin_filesize           = v_bin_filesize
    TABLES
      otf                    = st_job_output_info-otfdata
      doctab_archive         = it_docs
      lines                  = it_lines
    EXCEPTIONS
      err_conv_not_possible  = 1
      err_otf_mc_noendmarker = 2
      OTHERS                 = 3.

  CONCATENATE 'smrt' '.pdf' INTO v_name.

  CREATE OBJECT v_guiobj.
  CALL METHOD v_guiobj->file_save_dialog
    EXPORTING
      default_extension = 'pdf'
      default_file_name = v_name
      file_filter       = v_filter
    CHANGING
      filename          = v_name
      path              = v_path
      fullpath          = v_fullpath
      user_action       = v_uact.

  IF v_uact = v_guiobj->action_cancel.
    EXIT.
  ENDIF.
  MOVE v_fullpath TO v_filename.

  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      bin_filesize            = v_bin_filesize
      filename                = v_filename
      filetype                = 'BIN'
    TABLES
      data_tab                = it_lines
    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.

  CALL FUNCTION 'SSF_CLOSE'
* IMPORTING
* job_output_info =
* EXCEPTIONS
* formatting_error = 1
* internal_error = 2
* send_error = 3
* OTHERS = 4 .
  .
ENDFORM. " PROCESS_DATA

Former Member
0 Kudos

== read this code and modify your code according to it.=====

Edited by: Rob Burbank on Feb 3, 2012 4:52 PM

0 Kudos

Hi Guys,

Thanks to all for your help..

I've got the answer from give below code:

DATA  :  l_spoolno    LIKE tsp01-rqident,         " Spool request number
           l_time_low   LIKE tsp01-rqcretime,       " Time a spool request was created
           l_time_high  LIKE tsp01-rqcretime.       " Time a spool request was created
*           l_file       LIKE rlgrap-filename.       " Path File Name
*  .
*  l_file = 'C:\file.pdf'.
  sy-uzeit = sy-uzeit - 20.
  CONCATENATE sy-datum '00000000' INTO l_time_low.

  sy-uzeit = sy-uzeit + 20.
  CONCATENATE sy-datum '99999999' INTO l_time_high.
**********************************************************************************
  SELECT SINGLE MAX( rqident ) FROM tsp01 INTO l_spoolno WHERE
                               rqclient = sy-mandt AND
                                rq0name = 'SMART' AND
                                rqowner = sy-uname AND
                                rqcretime BETWEEN l_time_low AND
                                l_time_high.

     IF l_spoolno IS NOT INITIAL.
    SUBMIT rstxpdft4 WITH spoolno EQ l_spoolno
                     WITH p_file EQ 'C:\file.pdf'
                     AND RETURN.
   ENDIF.

Thanks a lot Tamas