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: 

Smartform problem

Former Member
0 Kudos

Hello All,

I have a smartform that will be printed severals times inside a loop, now I want to avoid the print dialog and print preview, and depending of user options, I want to define the device and if the user wants to print inmediatly or just generate a spool order. but for some reason I can't do that.

Here is the code:


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

    control-no_dialog = 'X'.
    control-no_open   = 'X'.
    control-no_close  = 'X'.

    output_options-tdnewid  = 'X'.
    output_options-tdimmed  = p_device.
    output_options-tddest   = p_printNow.

    CALL FUNCTION 'SSF_OPEN'
      EXPORTING
        control_parameters = control
        output_options     = output_options
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        OTHERS             = 5.

   LOOP AT it_table.
    CALL FUNCTION l_fm_name
      EXPORTING
        control_parameters = control
        swnes              = it_table-swnes
        laufd              = it_table-laufd
        vblnr              = it_table-vblnr
        lifnr              = it_table-lifnr
        word               = it_table-word
        waers              = it_table-waers
      EXCEPTIONS
        formatting_error   = 1
        internal_error     = 2
        send_error         = 3
        user_canceled      = 4
        OTHERS             = 5.
   ENDLOOP.

   CALL FUNCTION 'SSF_CLOSE'
     EXCEPTIONS
       formatting_error = 1
       internal_error   = 2
       send_error       = 3
       OTHERS           = 4.

    CALL FUNCTION 'SSF_READ_ERRORS'
      IMPORTING
        errortab = errtab[].

Every time I try to call the FM l_fm_name (the smartform FM) without the print preview option in the control structure I have a sy-subrc return of 3 (Send error) and don't know why...

Any ideas will be welcome and rewarded.

4 REPLIES 4

Former Member
0 Kudos

Hi,

Can you try removing the SSF_OPEN / SSF_CLOSE functions?

Directly pass the control parameters and output options to the SMART form function.

Regards,

Ravi

Note : Please mark the helpful answers

Former Member
0 Kudos

Hi Mauro,

You can avoid the Print dialog and Print Preview Window by modifying the control parameters .

Just check this code.

REPORT YSHAIL_SMARTFORM1 .

data: cparam type SSFCTRLOP.

data: outop type SSFCOMPOP.

data: fm_name type RS38L_FNAM.

data: itab type table of zshail_t1 with header line.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = 'YSHAIL_SFORM2'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = fm_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.

select * from zshail_t1 into table itab.

<b>CPARAM-PREVIEW = 'X'.

OUTOP-TDDEST = 'LP01'. "device name"

CPARAM-NO_DIALOG = 'X'.</b>

CALL FUNCTION fm_name

EXPORTING

  • ARCHIVE_INDEX =

  • ARCHIVE_INDEX_TAB =

  • ARCHIVE_PARAMETERS =

<b> CONTROL_PARAMETERS = cparam</b>

  • MAIL_APPL_OBJ =

  • MAIL_RECIPIENT =

  • MAIL_SENDER =

<b> OUTPUT_OPTIONS = OUTOP</b>

<b> USER_SETTINGS = SPACE</b>

  • IMPORTING

  • DOCUMENT_OUTPUT_INFO =

  • JOB_OUTPUT_INFO =

  • JOB_OUTPUT_OPTIONS =

TABLES

itab = itab[]

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.

This will work.

Regards,

SP.

venkat_o
Active Contributor
0 Kudos

Hello Mauro,

<b>1</b>.You need to remove SSF_OPEN and SSF_CLOSE.

<b>2</b>.Define 2 variables

DATA:

num_1 TYPE i,

num_2 TYPE sy-tabix.

DESCRIBE TABLE it_table LINES num_1.

LOOP AT it_table.

num_2 = sy-tabix.

CASE num_2.

WHEN 1.

control_parameters-no_open = ' '.

control_parameters-no_close = 'X'.

WHEN num_1.

control_parameters-no_open = 'X'.

control_parameters-no_close = space.

WHEN OTHERS.

control_parameters-no_open = 'X'.

control_parameters-no_close = 'X'.

ENDCASE.

IF num_1 = 1.

CLEAR: control_parameters.

ENDIF.

control_parameters-langu = sy-langu.

control_parameters-no_dialog = 'X'.

control_parameters-preview = 'X'.<b>with print priview</b>

<b>or</b>

control_parameters-preview = 'X'.<b>Without print priview.This is direct printing</b>

<b>CALL FUNCTION l_fm_name </b>

<b>EXPORTING</b>

control_parameters = control_parameters

swnes = it_table-swnes laufd = it_table-laufd vblnr = it_table-vblnr lifnr = it_table-lifnr word = it_table-word waers = it_table-waers

<b>EXCEPTIONS </b>

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

ENDLOOP.

It solves ur problem.

Let me know ,if u have any problem.

<b>Thanks.

Venkat.O</b>

Former Member
0 Kudos

Hi Mauro,

Use this

DATA : g_fm_name TYPE rs38l_fnam,

g_output TYPE ssfcompop,

g_control TYPE ssfctrlop,

g_form TYPE tdsfname VALUE 'ZPRINT'.

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

formname = g_form

IMPORTING

fm_name = g_fm_name

EXCEPTIONS

no_form = 1

no_function_module = 2

OTHERS = 3.

g_control-no_dialog = 'X'.

g_output-tddest = p_device.

g_output-tdnewid = 'X'.

CALL FUNCTION g_fm_name

EXPORTING

control_parameters = g_control

output_options = g_output

user_settings = ' '

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

CLEAR g_output-tdnewid .