cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with SmartForms driver program

Former Member
0 Kudos

Hello,

I have the following problem:

I have created a Smarform that uses a standard text element. In my program, the text in this element is changed depending on the language the user has selected.

The form is then created and converted to PDF and displayed to the user. The problem I have is that the first time, the PDF is displayed in the correct language. However, when another language is selected the second time, the displayed PDF will still show the first language. After some testing, I found out that the problem most likely lies with the Smartforms function module. It seems that a certain variable is not being reset when it is called the second time, resulting in the same language being shown. Perhaps there's some variable in the control_parameters that I didn't set?

In any case, this is the code of the driver program:


DATA: fm_name TYPE rs38l_fnam.
  DATA: output_options TYPE ssfcompop,
        control_parameters TYPE ssfctrlop,
        job_output_info TYPE ssfcrescl.

* Get function module name for SmartForm
  CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
    EXPORTING
      formname = 'ZHR_ADVERTISEMENT'
    IMPORTING
      fm_name  = fm_name.

* SmartForm settings
  control_parameters-getotf = 'X'.
  control_parameters-no_dialog = 'X'.
  output_options-tdnoprev = 'X'.

* Execute SmartForm
  CALL FUNCTION fm_name
    EXPORTING
      control_parameters = control_parameters
      output_options     = output_options
    IMPORTING
      job_output_info    = job_output_info
    EXCEPTIONS
      formatting_error   = 1
      internal_error     = 2
      send_error         = 3
      user_canceled      = 4
      OTHERS             = 5.

* Display PDF
  CALL FUNCTION 'HR_EFI_SHOW_PDF_FORM'
    TABLES
      otf_table = job_output_info-otfdata.

Thanks in advance!

Dave

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

Have you checked language key in NAST...... I have seen cases where the nast table does not get updated..........

Former Member
0 Kudos

Well, I'm not sure if the language is really the problem. It's just that in my case, I call the smartforms multiple times in different languages. But if I were to just keep the language and change the text to something else, the first text would still be displayed.

I think you could try it out for yourself. Just create a smartform that uses an 'include text' type of text box. You call the FM of the smartforms the first time, then before the second time change the standard text that is used in the smartform and call the smartforms the second time (in the same program run, of course). The text will not be different.

Former Member
0 Kudos

Hi,

Check the below code and see if ur missing something

DATA: form_name TYPE rs38l_fnam, " Used to get the function module of Smartform

wa_ctrlop TYPE ssfctrlop, " Smart Forms: Control structure

wa_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options

t_otfdata TYPE ssfcrescl. " Smart Forms: Return value at end of form printing

Data: t_pdf_tab type table of tline, " SAPscript: Text Lines

t_otf TYPE table of itcoo. " OTF Structure

  • Variables used to pass to GUI_DOWNLOAD

DATA: w_filesize TYPE i,

w_bin_filesize TYPE i.

  • Variables used for Save Dialog Box

DATA : file_name TYPE string,

file_path TYPE string,

full_path TYPE string.

START-OF-SELECTION.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'ZPDF_G' "p_name

IMPORTING

fm_name = form_name

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_ctrlop-getotf = 'X'.

wa_ctrlop-no_dialog = 'X'.

wa_outopt-tdnoprev = 'X'.

CALL FUNCTION form_name

EXPORTING

control_parameters = wa_ctrlop

output_options = wa_outopt

user_settings = 'X'

IMPORTING

job_output_info = t_otfdata

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.

END-OF-SELECTION.

t_otf[] = t_otfdata-otfdata[].

CALL FUNCTION 'CONVERT_OTF'

EXPORTING

format = 'PDF'

max_linewidth = 132

IMPORTING

bin_filesize = w_bin_filesize

TABLES

otf = t_otf

lines = t_pdf_tab

EXCEPTIONS

err_max_linewidth = 1

err_format = 2

err_conv_not_possible = 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.

----


TAKING THE DOWNLOAD FILE PATH AS USER INPUT*

CALL METHOD cl_gui_frontend_services=>file_save_dialog

CHANGING

filename = file_name

path = file_path

fullpath = full_path

EXCEPTIONS

cntl_error = 1

error_no_gui = 2

not_supported_by_gui = 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.

  • Download the file to the selected path

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

bin_filesize = w_bin_filesize

filename = full_path "fname1

filetype = 'BIN'

IMPORTING

filelength = w_filesize

TABLES

data_tab = t_pdf_tab

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 i000(zpdf). "File not downloaded

ELSE.

MESSAGE i001(zpdf). "File downloaded

ENDIF.

Former Member
0 Kudos

The code is the same. I didn't include the user_settings variable in the FM because this is by default 'X'. That's the only difference.

The otfdata is always the same after the FM is called, even though the content of the smartform should be different.

The only way I can get the smartform to display the other language is when I close and re-open the program. So that's why I figure there's some sort of temporary variable not being reset.